mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 04:30:15 +01:00
add hotpot_encode_content_links() and hotpot_decode_content_links() to HotPot's backuplib.php and restorelib.php respectively
This commit is contained in:
parent
d4af02e252
commit
34adfa0f5c
@ -334,4 +334,14 @@
|
||||
}
|
||||
return $info;
|
||||
}
|
||||
|
||||
// Return content encoded to support interactivities linking.
|
||||
// Called by "backup_encode_absolute_links()" in backup/backuplib.php
|
||||
// Content will be decoded by "hotpot_decode_content_links()"
|
||||
function hotpot_encode_content_links ($content, $preferences) {
|
||||
global $CFG;
|
||||
$base = preg_quote("$CFG->wwwroot/mod/hotpot/", '/');
|
||||
$search = "/($base)([a-z]+).php\?([a-z]+)\=([0-9]+)/";
|
||||
return preg_replace($search, '$@HOTPOT*$2*$3*$4@$', $content);
|
||||
}
|
||||
?>
|
||||
|
@ -484,4 +484,46 @@ function hotpot_restore_logs($restore, $log) {
|
||||
} // end switch
|
||||
return $status ? $log : false;
|
||||
}
|
||||
|
||||
function hotpot_decode_content_links($content, $restore) {
|
||||
$search = '/\$@(HOTPOT)\*([a-z]+)\*([a-z]+)\*([0-9]+)@\$/ise';
|
||||
$replace = 'hotpot_decode_content_link("$2", "$3", "$4", $restore)';
|
||||
return preg_replace($search, $replace, $content);
|
||||
}
|
||||
|
||||
function hotpot_decode_content_link($scriptname, $paramname, $paramvalue, &$restore) {
|
||||
global $CFG;
|
||||
|
||||
$table = '';
|
||||
switch ($paramname) {
|
||||
case 'id':
|
||||
switch ($scriptname) {
|
||||
case 'index':
|
||||
$table = 'course';
|
||||
break;
|
||||
case 'report':
|
||||
case 'review':
|
||||
case 'view':
|
||||
$table = 'course_modules';
|
||||
break;
|
||||
case 'attempt':
|
||||
$table = 'hotpot_attempts';
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'hp':
|
||||
case 'hotpotid':
|
||||
$table = 'hotpot';
|
||||
break;
|
||||
}
|
||||
|
||||
$new_id = 0;
|
||||
if ($table) {
|
||||
if ($rec = backup_getid($restore->backup_unique_code, $table, $paramvalue)) {
|
||||
$new_id = $rec->new_id;
|
||||
}
|
||||
}
|
||||
|
||||
return "$CFG->wwwroot/mod/hotpot/$scriptname.php?$paramname=$new_id";
|
||||
}
|
||||
?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user