1
0

backup_iassign_stepslib.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 backup_activity_structure_step
  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. /**
  22. * Define the complete choice structure for backup, with file and id annotations
  23. * @see backup_activity_structure_step
  24. */
  25. class backup_iassign_activity_structure_step extends backup_activity_structure_step {
  26. /**
  27. * Define the structure for the iassign activity
  28. * @return void Return the root element (choice), wrapped into standard activity structure
  29. */
  30. protected function define_structure () {
  31. // To know if we are including userinfo
  32. $userinfo = $this->get_setting_value('userinfo');
  33. $iassign = new backup_nested_element('iassign', array('id'), array('name',
  34. 'course',
  35. 'intro',
  36. 'introformat',
  37. 'activity_group',
  38. 'grade',
  39. 'timeavailable',
  40. 'timedue',
  41. 'preventlate',
  42. 'test',
  43. 'max_experiment'));
  44. $statements = new backup_nested_element('statements');
  45. $statement = new backup_nested_element('statement', array('id'), array('name',
  46. 'iassignid',
  47. 'type_iassign',
  48. 'proposition',
  49. 'author_name',
  50. 'author_modified_name',
  51. 'iassign_ilmid',
  52. 'file',
  53. 'grade',
  54. 'timecreated',
  55. 'timemodified',
  56. 'timeavailable',
  57. 'timedue',
  58. 'preventlate',
  59. 'test',
  60. 'special_param1',
  61. 'position',
  62. 'visible',
  63. 'max_experiment',
  64. 'dependency',
  65. 'automatic_evaluate',
  66. 'show_answer',
  67. 'store_all_submissions',
  68. 'filesid'));
  69. $iassign_submissions = new backup_nested_element('iassign_submissions');
  70. $iassign_submission = new backup_nested_element('iassign_submission', array('id'), array('iassign_statementid',
  71. 'userid',
  72. 'timecreated',
  73. 'timemodified',
  74. 'grade',
  75. 'teacher',
  76. 'answer',
  77. 'experiment',
  78. 'status'));
  79. $iassign_submission_comments = new backup_nested_element('iassign_submission_comments');
  80. $iassign_submission_comment = new backup_nested_element('iassign_submission_comment', array('id'), array('iassign_submissionid',
  81. 'comment_authorid',
  82. 'timecreated',
  83. 'comment',
  84. 'return_status',
  85. 'receiver'));
  86. // Build the tree
  87. $iassign->add_child($statements);
  88. $statements->add_child($statement);
  89. $statement->add_child($iassign_submissions);
  90. $iassign_submissions->add_child($iassign_submission);
  91. $iassign_submission->add_child($iassign_submission_comments);
  92. $iassign_submission_comments->add_child($iassign_submission_comment);
  93. // Define sources
  94. $iassign->set_source_table('iassign', array('id' => backup::VAR_ACTIVITYID));
  95. $statement->set_source_sql('
  96. SELECT *
  97. FROM {iassign_statement}
  98. WHERE iassignid = ?', array(backup::VAR_PARENTID));
  99. if($userinfo) {
  100. $iassign_submission->set_source_table('iassign_submission', array('iassign_statementid' => backup::VAR_PARENTID));
  101. $iassign_submission_comment->set_source_table('iassign_submission_comment', array('iassign_submissionid' => backup::VAR_PARENTID));
  102. }
  103. // Define id annotations
  104. $iassign_submission->annotate_ids('user', 'userid');
  105. $iassign_submission->annotate_ids('user', 'teacher');
  106. $iassign_submission_comment->annotate_ids('user', 'comment_authorid');
  107. // Define file annotations
  108. $iassign->annotate_files('mod_iassign', 'exercise', null); // This file area hasn't itemid
  109. return $this->prepare_activity_structure($iassign);
  110. }
  111. }