mirror of
https://github.com/moodle/moodle.git
synced 2025-02-13 12:34:28 +01:00
117 lines
4.2 KiB
PHP
117 lines
4.2 KiB
PHP
<?php
|
|
//This php script contains all the stuff to backup/restore
|
|
//assignment mods
|
|
|
|
//This is the "graphical" structure of the assignment mod:
|
|
//
|
|
// assignment
|
|
// (CL,pk->id)
|
|
// |
|
|
// |
|
|
// |
|
|
// assignment_submisions
|
|
// (UL,pk->id, fk->assignment,files)
|
|
//
|
|
// Meaning: pk->primary key field of the table
|
|
// fk->foreign key to link with parent
|
|
// nt->nested field (recursive data)
|
|
// CL->course level info
|
|
// UL->user level info
|
|
// files->table may have files)
|
|
//
|
|
//-----------------------------------------------------------
|
|
|
|
|
|
//This function returns a log record with all the necessary transformations
|
|
//done. It's used by restore_log_module() to restore modules log.
|
|
function assignment_restore_logs($restore,$log) {
|
|
|
|
$status = false;
|
|
|
|
//Depending of the action, we recode different things
|
|
switch ($log->action) {
|
|
case "add":
|
|
if ($log->cmid) {
|
|
//Get the new_id of the module (to recode the info field)
|
|
$mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
|
|
if ($mod) {
|
|
$log->url = "view.php?id=".$log->cmid;
|
|
$log->info = $mod->new_id;
|
|
$status = true;
|
|
}
|
|
}
|
|
break;
|
|
case "update":
|
|
if ($log->cmid) {
|
|
//Get the new_id of the module (to recode the info field)
|
|
$mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
|
|
if ($mod) {
|
|
$log->url = "view.php?id=".$log->cmid;
|
|
$log->info = $mod->new_id;
|
|
$status = true;
|
|
}
|
|
}
|
|
break;
|
|
case "view":
|
|
if ($log->cmid) {
|
|
//Get the new_id of the module (to recode the info field)
|
|
$mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
|
|
if ($mod) {
|
|
$log->url = "view.php?id=".$log->cmid;
|
|
$log->info = $mod->new_id;
|
|
$status = true;
|
|
}
|
|
}
|
|
break;
|
|
case "view all":
|
|
$log->url = "index.php?id=".$log->course;
|
|
$status = true;
|
|
break;
|
|
case "upload":
|
|
if ($log->cmid) {
|
|
//Get the new_id of the module (to recode the info field)
|
|
$mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
|
|
if ($mod) {
|
|
$log->url = "view.php?a=".$mod->new_id;
|
|
$log->info = $mod->new_id;
|
|
$status = true;
|
|
}
|
|
}
|
|
break;
|
|
case "view submission":
|
|
if ($log->cmid) {
|
|
//Get the new_id of the module (to recode the info field)
|
|
$mod = backup_getid($restore->backup_unique_code,$log->module,$log->info);
|
|
if ($mod) {
|
|
$log->url = "submissions.php?id=".$mod->new_id;
|
|
$log->info = $mod->new_id;
|
|
$status = true;
|
|
}
|
|
}
|
|
break;
|
|
case "update grades":
|
|
if ($log->cmid) {
|
|
//Extract the assignment id from the url field
|
|
$assid = substr(strrchr($log->url,"="),1);
|
|
//Get the new_id of the module (to recode the info field)
|
|
$mod = backup_getid($restore->backup_unique_code,$log->module,$assid);
|
|
if ($mod) {
|
|
$log->url = "submissions.php?id=".$mod->new_id;
|
|
$status = true;
|
|
}
|
|
}
|
|
break;
|
|
default:
|
|
if (!defined('RESTORE_SILENTLY')) {
|
|
echo "action (".$log->module."-".$log->action.") unknown. Not restored<br />"; //Debug
|
|
}
|
|
break;
|
|
}
|
|
|
|
if ($status) {
|
|
$status = $log;
|
|
}
|
|
return $status;
|
|
}
|
|
|