1
0

backup_iassign_activity_task.class.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 Leônidas O. Brandão
  11. * @version v 1.1 2014/01/06
  12. * @package mod_iassign_backup
  13. * @since 2012
  14. * @copyright iMatica (<a href="http://www.matematica.br">iMath</a>) - 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. /**
  22. * Moodle core defines constant MOODLE_INTERNAL which shall be used to make sure that the script is included and not called directly.
  23. */
  24. defined('MOODLE_INTERNAL') || die();
  25. require_once($CFG->dirroot . '/mod/iassign/backup/moodle2/backup_iassign_stepslib.php');
  26. /**
  27. * Provides the steps to perform one complete backup of the iAssign instance
  28. * @see backup_activity_task
  29. */
  30. class backup_iassign_activity_task extends backup_activity_task {
  31. /**
  32. * No specific settings for this activity
  33. */
  34. protected function define_my_settings () {
  35. //TODO Retirar quando atualizar todo os iassigns que estão com a tag &lt;ia_uc&gt;
  36. $temp = explode("&lt;ia_uc&gt;", $this->name);
  37. $this->name = $temp[0];
  38. }
  39. /**
  40. * Defines a backup step to store the instance data in the iassign.xml file
  41. */
  42. protected function define_my_steps () {
  43. $this->add_step(new backup_iassign_activity_structure_step('iassign_structure', 'iassign.xml'));
  44. }
  45. /**
  46. * Encodes URLs to various iAssign scripts
  47. * @param string $content some HTML text that eventually contains URLs to the activity instance scripts
  48. * @return string The content with the URLs encoded
  49. */
  50. static public function encode_content_links ($content) {
  51. global $CFG;
  52. $base = preg_quote($CFG->wwwroot, "/");
  53. // $base = preg_quote($CFG->wwwroot.'/mod/iassign','#');
  54. // Link to the list of choices
  55. $search = "/(" . $base . "\/mod\/iassign\/index.php\?id\=)([0-9]+)/";
  56. $content = preg_replace($search, '$@IASSIGNINDEX*$2@$', $content);
  57. // Link to choice view by moduleid
  58. $search = "/(" . $base . "\/mod\/iassign\/view.php\?id\=)([0-9]+)/";
  59. $content = preg_replace($search, '$@IASSIGNVIEWBYID*$2@$', $content);
  60. return $content;
  61. }
  62. }