1
0

restore_iassign_activity_task.class.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. /**
  3. * Define all the backup steps that will be used by the backup_iassign_activity_task
  4. *
  5. * @author Patricia Alves Rodrigues
  6. * @author Leônidas O. Brandão
  7. * @version v 1.0 2012
  8. * @package mod_iassign_backup
  9. * @since 2012
  10. * @copyright iMatica (<a href="http://www.matematica.br">iMath</a>) - Computer Science Dep. of IME-USP (Brazil)
  11. *
  12. * <b>License</b>
  13. * - http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  14. *
  15. * @see restore_activity_task
  16. */
  17. /**
  18. * Moodle core defines constant MOODLE_INTERNAL which shall be used to make sure that the script is included and not called directly.
  19. */
  20. defined('MOODLE_INTERNAL') || die();
  21. require_once($CFG->dirroot . '/mod/iassign/backup/moodle2/restore_iassign_stepslib.php');
  22. /**
  23. * iassign restore task that provides all the settings and steps to perform one complete restore of the activity.
  24. */
  25. class restore_iassign_activity_task extends restore_activity_task {
  26. /**
  27. * Define (add) particular settings this activity can have.
  28. */
  29. protected function define_my_settings () {
  30. // No particular settings for this activity
  31. }
  32. /**
  33. * Define (add) particular steps this activity can have.
  34. */
  35. protected function define_my_steps () {
  36. // iAssign only has one structure step
  37. $this->add_step(new restore_iassign_activity_structure_step('iassign_structure', 'iassign.xml'));
  38. }
  39. /**
  40. * Define the contents in the activity that must be
  41. * processed by the link decoder.
  42. * @return array Return a content of activity
  43. */
  44. static public function define_decode_contents () {
  45. $contents = array();
  46. $contents[] = new restore_decode_content('iassign', array('name'), 'iassign');
  47. return $contents;
  48. }
  49. /**
  50. * Define the decoding rules for links belonging
  51. * to the activity to be executed by the link decoder.
  52. * @return array Return the restore decode rule.
  53. */
  54. static public function define_decode_rules () {
  55. $rules = array();
  56. $rules[] = new restore_decode_rule('IASSIGNVIEWBYID', '/mod/iassign/view.php?id=$1', 'course_module');
  57. $rules[] = new restore_decode_rule('IASSIGNINDEX', '/mod/iassign/index.php?id=$1', 'course_module');
  58. return $rules;
  59. }
  60. /**
  61. * Define the restore log rules that will be applied
  62. * by the {@link restore_logs_processor} when restoring
  63. * iassign logs. It must return one array
  64. * of {@link restore_log_rule} objects.
  65. * @return array Return the restore log rule.
  66. */
  67. static public function define_restore_log_rules () {
  68. $rules = array();
  69. $rules[] = new restore_log_rule('iassign', 'add', 'view.php?id={course_module}', '{iassign}');
  70. $rules[] = new restore_log_rule('iassign', 'update', 'view.php?id={course_module}', '{iassign}');
  71. $rules[] = new restore_log_rule('iassign', 'view', 'view.php?id={course_module}', '{iassign}');
  72. $rules[] = new restore_log_rule('iassign', 'view submission', 'view.php?id={course_module}', '{iassign}');
  73. $rules[] = new restore_log_rule('iassign', 'upload', 'view.php?id={course_module}', '{iassign}');
  74. $rules[] = new restore_log_rule('iassign', 'update comment', 'view.php?id={course_module}', '{iassign}');
  75. $rules[] = new restore_log_rule('iassign', 'update submission', 'view.php?id={course_module}', '{iassign}');
  76. $rules[] = new restore_log_rule('iassign', 'delete iassign', 'view.php?id={course_module}', '{iassign}');
  77. $rules[] = new restore_log_rule('iassign', 'add comment', 'view.php?id={course_module}', '{iassign}');
  78. $rules[] = new restore_log_rule('iassign', 'add submission', 'view.php?id={course_module}', '{iassign}');
  79. // more...
  80. return $rules;
  81. }
  82. /**
  83. * Define the restore log rules that will be applied
  84. * by the {@link restore_logs_processor} when restoring
  85. * course logs. It must return one array
  86. * of {@link restore_log_rule} objects
  87. *
  88. * Note this rules are applied when restoring course logs
  89. * by the restore final task, but are defined here at
  90. * activity level. All them are rules not linked to any module instance (cmid = 0)
  91. *
  92. * @return array Return the restore log rule of course.
  93. */
  94. static public function define_restore_log_rules_for_course () {
  95. $rules = array();
  96. return $rules;
  97. }
  98. }