mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-12575 - Backup and restore problems with the new question bank. Merged from MOODLE_19_STABLE.
This commit is contained in:
parent
e5e7b2a8fe
commit
27cabbe626
@ -123,7 +123,6 @@ define('RESTORE_GROUPS_GROUPINGS', 3);
|
||||
}
|
||||
$config = unserialize(base64_decode($instance->configdata));
|
||||
if ($blocks[$instance->blockid]->blockobject->restore_decode_absolute_links_in_config($config)) {
|
||||
echo '<p>Updating config for block ', $instance->id, '.</p>';
|
||||
$instance->configdata = base64_encode(serialize($config));
|
||||
$status = $status && update_record('block_instance', $instance);
|
||||
}
|
||||
|
@ -103,7 +103,7 @@
|
||||
//put the ids of the used questions from all these categories into the db.
|
||||
$status = $status && execute_sql("INSERT INTO {$CFG->prefix}backup_ids
|
||||
(backup_code, table_name, old_id, info)
|
||||
SELECT '$backup_unique_code', 'question', q.id, ''
|
||||
SELECT DISTINCT $backup_unique_code, 'question', q.id, ''
|
||||
FROM {$CFG->prefix}question q,
|
||||
$from
|
||||
{$CFG->prefix}question_categories qc,
|
||||
@ -139,7 +139,8 @@
|
||||
// those subcategories also need to be backed up. (The categories themselves
|
||||
// and their parents will already have been included.)
|
||||
$categorieswithrandom = get_records_sql("
|
||||
SELECT question.category AS id, SUM(question.questiontext) as questiontext
|
||||
SELECT question.category AS id, SUM(" .
|
||||
sql_cast_char2int('questiontext', true) . ") AS numqsusingsubcategories
|
||||
FROM {$CFG->prefix}quiz_question_instances qqi,
|
||||
$from
|
||||
{$CFG->prefix}question question
|
||||
@ -151,7 +152,7 @@
|
||||
$randomselectedquestions = array();
|
||||
if ($categorieswithrandom) {
|
||||
foreach ($categorieswithrandom as $category) {
|
||||
if ($category->questiontext){
|
||||
if ($category->numqsusingsubcategories > 0) {
|
||||
$status = $status && quiz_backup_add_sub_categories($categories, $randomselectedquestions, $category->id);
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +106,7 @@
|
||||
//search COURSECATEGORYLEVEL steps up the course cat tree or
|
||||
//to the top of the tree if steps are exhausted.
|
||||
$catno = $contextinfo['COURSECATEGORYLEVEL'][0]['#'];
|
||||
$catid = get_field('course', 'parent', 'id', $restore->course_id);
|
||||
$catid = get_field('course', 'category', 'id', $restore->course_id);
|
||||
while ($catno > 1){
|
||||
$nextcatid = get_field('course_categories', 'parent', 'id', $catid);
|
||||
if ($nextcatid == 0){
|
||||
@ -235,7 +235,7 @@
|
||||
//recode all parents to point at their old parent cats no matter what context the parent is now in
|
||||
foreach ($categories as $category) {
|
||||
$restoredcategory = get_record('question_categories','id',$category->new_id);
|
||||
if ($restoredcategory->parent != 0) {
|
||||
if ($restoredcategory && $restoredcategory->parent != 0) {
|
||||
$updateobj = new object();
|
||||
$updateobj->id = $restoredcategory->id;
|
||||
$idcat = backup_getid($restore->backup_unique_code,'question_categories',$restoredcategory->parent);
|
||||
@ -253,7 +253,7 @@
|
||||
$toupdate = array();
|
||||
foreach ($categories as $category) {
|
||||
$restoredcategory = get_record('question_categories','id',$category->new_id);
|
||||
if ($restoredcategory->parent != 0) {
|
||||
if ($restoredcategory && $restoredcategory->parent != 0) {
|
||||
$nextparentid = $restoredcategory->parent;
|
||||
do {
|
||||
if (!$parent = get_record('question_categories', 'id', $nextparentid)){
|
||||
@ -262,7 +262,7 @@
|
||||
}
|
||||
break;//record fetch failed finish loop
|
||||
} else {
|
||||
$nextparentid = $nextparent->parent;
|
||||
$nextparentid = $parent->parent;
|
||||
}
|
||||
} while (($nextparentid != 0) && ($parent->contextid != $restoredcategory->contextid));
|
||||
if (!$parent || ($parent->id != $restoredcategory->parent)){
|
||||
@ -862,7 +862,7 @@
|
||||
$session->newgraded = backup_todb($res_info['#']['NEWGRADED']['0']['#']);
|
||||
$session->sumpenalty = backup_todb($res_info['#']['SUMPENALTY']['0']['#']);
|
||||
|
||||
if ($res_info['#']['MANUALCOMMENT']['0']['#']) {
|
||||
if (isset($res_info['#']['MANUALCOMMENT']['0']['#'])) {
|
||||
$session->manualcomment = backup_todb($res_info['#']['MANUALCOMMENT']['0']['#']);
|
||||
} else { // pre 1.7 backups
|
||||
$session->manualcomment = backup_todb($res_info['#']['COMMENT']['0']['#']);
|
||||
|
@ -437,7 +437,11 @@ class question_numerical_qtype extends question_shortanswer_qtype {
|
||||
$status = true;
|
||||
|
||||
//Get the numerical array
|
||||
$numericals = $info['#']['NUMERICAL'];
|
||||
if (isset($info['#']['NUMERICAL'])) {
|
||||
$numericals = $info['#']['NUMERICAL'];
|
||||
} else {
|
||||
$numericals = array();
|
||||
}
|
||||
|
||||
//Iterate over numericals
|
||||
for($i = 0; $i < sizeof($numericals); $i++) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user