backup_iassign_activity_task.class.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * This file contains the backup task for the iAssign module
  4. *
  5. * Release Notes:
  6. * - v 1.1 2014/01/06
  7. * + Fix bug in activity name, remove tag filter (backup_iassign_activity_task::define_my_settings).
  8. *
  9. * @author Patricia Alves Rodrigues
  10. * @author Leo^nidas de Oliveira Branda~o
  11. * @version v 1.1 2014/01/06
  12. * @package mod_iassign_backup
  13. * @since 2012
  14. * @cite iMath (http://www.matematica.br) - LInE (www.usp.br/line) - Computer Science Dep. of IME-USP (Brazil)
  15. *
  16. * <b>License</b>
  17. * - http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  18. *
  19. * @see backup_activity_task
  20. */
  21. defined('MOODLE_INTERNAL') || die(); // Moodle core defines constant MOODLE_INTERNAL which shall be used to make sure that the script is included and not called directly.
  22. require_once($CFG->dirroot . '/mod/iassign/backup/moodle2/backup_iassign_stepslib.php');
  23. // Provides the steps to perform one complete backup of the iAssign instance
  24. // @see backup_activity_task
  25. class backup_iassign_activity_task extends backup_activity_task {
  26. // No specific settings for this activity
  27. protected function define_my_settings () {
  28. //TODO Retirar quando atualizar todo os iAssign que estao com a tag &lt;ia_uc&gt;
  29. $temp = explode("&lt;ia_uc&gt;", $this->name);
  30. $this->name = $temp[0];
  31. }
  32. // Defines a backup step to store the instance data in the 'iassign.xml' file (and 'iassign_ilm.xml')
  33. protected function define_my_steps () {
  34. $this->add_step(new backup_iassign_activity_structure_step('iassign_structure', 'iassign.xml'));
  35. // $this->add_step(new backup_iassign_activity_structure_step('iassign_ilm_structure', 'iassign_ilm.xml')); //2023 To register all iLM
  36. }
  37. // Transform encoded links (URL) of iAssign, from this Moodle to generic
  38. // mark ("@IASSIGNINDEX" or "@IASSIGNVIEWBYID") to be decoded by restoring process.
  39. // Change anything like "http://...backupmoodle/mod/iassign/view.php?id=X" (or "iassign/index.php"), to the
  40. // "http://...restoremoodle/mod/iassign/view.php?id=X".
  41. // It is used in 'restore_iassign_activity_task.class.php!define_decode_rules()' to restore with correct ID
  42. // @param string $content some HTML text that eventually contains URL to the activity instance scripts
  43. // @return string The content with the URL encoded
  44. static public function encode_content_links ($content) {
  45. global $CFG;
  46. $base = preg_quote($CFG->wwwroot, "/");
  47. // $base = preg_quote($CFG->wwwroot.'/mod/iassign','#');
  48. // Link to the list of choices
  49. $search = "/(" . $base . "\/mod\/iassign\/index.php\?id\=)([0-9]+)/";
  50. $content = preg_replace($search, '$@IASSIGNINDEX*$2@$', $content);
  51. // Link to choice view by moduleid
  52. $search = "/(" . $base . "\/mod\/iassign\/view.php\?id\=)([0-9]+)/";
  53. $content = preg_replace($search, '$@IASSIGNVIEWBYID*$2@$', $content);
  54. return $content;
  55. }
  56. } // class backup_iassign_activity_task extends backup_activity_task