Replaced some (not all) tabs to spaces.
I've leave unmodified formats and nusoap library
This commit is contained in:
@@ -247,9 +247,9 @@
|
||||
|
||||
$status = true;
|
||||
|
||||
// We'll fetch the questions sorted by parent so that questions with no parents
|
||||
// (these are the ones which could be parents themselves) are backed up first. This
|
||||
// is important for the recoding of the parent field during the restore process
|
||||
// We'll fetch the questions sorted by parent so that questions with no parents
|
||||
// (these are the ones which could be parents themselves) are backed up first. This
|
||||
// is important for the recoding of the parent field during the restore process
|
||||
$questions = get_records("quiz_questions","category",$category,"parent ASC, id");
|
||||
//If there are questions
|
||||
if ($questions) {
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
/// Header:
|
||||
print_header_simple(get_string('editcategories', 'quiz'), '',
|
||||
"<a href=\"index.php?id=$course->id\">".get_string('modulenameplural', 'quiz').'</a>'.
|
||||
'-> <a href="edit.php">'.get_string('editquestions', 'quiz').'</a>'.
|
||||
'-> <a href="edit.php">'.get_string('editquestions', 'quiz').'</a>'.
|
||||
' -> '.get_string('editcategories', 'quiz'));
|
||||
|
||||
if (isset($SESSION->modform->instance) and $quiz = get_record('quiz', 'id', $SESSION->modform->instance)) {
|
||||
@@ -735,7 +735,7 @@ class quiz_category_object {
|
||||
function add_category($newparent, $newcategory, $newinfo, $newpublish, $newcourse) {
|
||||
|
||||
if ($newparent) {
|
||||
// first check that the parent category is in the correct course
|
||||
// first check that the parent category is in the correct course
|
||||
if(!(get_field('quiz_categories', 'course', 'id', $newparent) == $newcourse)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
+5
-5
@@ -103,11 +103,11 @@
|
||||
$modform->grades = quiz_get_all_question_grades($modform);
|
||||
}
|
||||
|
||||
if ($page > -1) {
|
||||
$modform->page = $page;
|
||||
} else {
|
||||
$page = isset($modform->page) ? $modform->page : 0;
|
||||
}
|
||||
if ($page > -1) {
|
||||
$modform->page = $page;
|
||||
} else {
|
||||
$page = isset($modform->page) ? $modform->page : 0;
|
||||
}
|
||||
|
||||
/// Now, check for commands on this page and modify variables as necessary
|
||||
|
||||
|
||||
@@ -578,8 +578,8 @@ function quiz_print_cat_question_list($course, $categoryid, $quizselected=true,
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
}
|
||||
echo '<tr><td colspan="3">';
|
||||
print_paging_bar($totalnumber, $page, $perpage, "edit.php?perpage=$perpage&");
|
||||
echo '<tr><td colspan="3">';
|
||||
print_paging_bar($totalnumber, $page, $perpage, "edit.php?perpage=$perpage&");
|
||||
echo "</td></tr></table>\n";
|
||||
print_simple_box_end();
|
||||
|
||||
|
||||
@@ -842,7 +842,7 @@ class quiz_default_questiontype {
|
||||
most simple question types. */
|
||||
|
||||
$teststate = clone($state);
|
||||
$teststate->raw_grade = 0;
|
||||
$teststate->raw_grade = 0;
|
||||
foreach($question->options->answers as $answer) {
|
||||
$teststate->responses[''] = $answer->answer;
|
||||
|
||||
@@ -1466,9 +1466,9 @@ function quiz_extract_responses($questions, $responses, $defaultevent) {
|
||||
*/
|
||||
function quiz_regrade_question_in_quizzes($question, $quizlist) {
|
||||
|
||||
if (empty($quizlist)) {
|
||||
return;
|
||||
}
|
||||
if (empty($quizlist)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($quizlist == 'all') { // assume that all quizzes are affected
|
||||
if (! $instances = get_records('quiz_question_instances',
|
||||
@@ -1482,7 +1482,7 @@ function quiz_regrade_question_in_quizzes($question, $quizlist) {
|
||||
}
|
||||
|
||||
// Get all affected quizzes
|
||||
$quizlist = implode(',', $quizlist);
|
||||
$quizlist = implode(',', $quizlist);
|
||||
if (! $quizzes = get_records_list('quiz', 'id', $quizlist)) {
|
||||
error('Couldn\'t get quizzes for regrading!');
|
||||
}
|
||||
|
||||
+31
-31
@@ -29,8 +29,8 @@
|
||||
|
||||
// a qtype > 99 means a remote question
|
||||
if ($qtype > 99) {
|
||||
$typeid = $qtype - 100;
|
||||
$qtype = RQP;
|
||||
$typeid = $qtype - 100;
|
||||
$qtype = RQP;
|
||||
}
|
||||
|
||||
$contextquiz = optional_param('contextquiz'); // the quiz from which this question is being edited
|
||||
@@ -215,46 +215,46 @@
|
||||
/// now update the question references in the quizzes
|
||||
if (!empty($replaceinquiz) and $quizzes = get_records_list("quiz", "id", implode(',', $replaceinquiz))) {
|
||||
|
||||
foreach($quizzes as $quiz) {
|
||||
$questionlist = ",$quiz->questions,"; // a little hack with the commas here. not nice but effective
|
||||
$questionlist = str_replace(",$oldquestionid,", ",$question->id,", $questionlist);
|
||||
$questionlist = substr($questionlist, 1, -1); // and get rid of the surrounding commas again
|
||||
if (!set_field("quiz", 'questions', $questionlist, 'id', $quiz->id)) {
|
||||
error("Could not update questionlist in quiz $quiz->id!");
|
||||
}
|
||||
|
||||
// the quiz_question_instances table needs to be updated too (aah, the joys of duplication :)
|
||||
if (!set_field('quiz_question_instances', 'question', $question->id, 'quiz', $quiz->id, 'question', $oldquestionid)) {
|
||||
error("Could not update question instance!");
|
||||
}
|
||||
if (isset($SESSION->modform) && (int)$SESSION->modform->instance === (int)$quiz->id) {
|
||||
$SESSION->modform->questions = $questionlist;
|
||||
$SESSION->modform->grades[$question->id] = $SESSION->modform->grades[$oldquestionid];
|
||||
unset($SESSION->modform->grades[$oldquestionid]);
|
||||
}
|
||||
}
|
||||
|
||||
// set originalquestion in states
|
||||
if ($attempts = get_records_list('quiz_attempts', 'quiz', implode(',', $replaceinquiz))) {
|
||||
foreach ($attempts as $attempt) {
|
||||
set_field('quiz_states', 'originalquestion', $oldquestionid, 'attempt', $attempt->id, 'question', $question->id, 'originalquestion', '0');
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach($quizzes as $quiz) {
|
||||
$questionlist = ",$quiz->questions,"; // a little hack with the commas here. not nice but effective
|
||||
$questionlist = str_replace(",$oldquestionid,", ",$question->id,", $questionlist);
|
||||
$questionlist = substr($questionlist, 1, -1); // and get rid of the surrounding commas again
|
||||
if (!set_field("quiz", 'questions', $questionlist, 'id', $quiz->id)) {
|
||||
error("Could not update questionlist in quiz $quiz->id!");
|
||||
}
|
||||
|
||||
// the quiz_question_instances table needs to be updated too (aah, the joys of duplication :)
|
||||
if (!set_field('quiz_question_instances', 'question', $question->id, 'quiz', $quiz->id, 'question', $oldquestionid)) {
|
||||
error("Could not update question instance!");
|
||||
}
|
||||
if (isset($SESSION->modform) && (int)$SESSION->modform->instance === (int)$quiz->id) {
|
||||
$SESSION->modform->questions = $questionlist;
|
||||
$SESSION->modform->grades[$question->id] = $SESSION->modform->grades[$oldquestionid];
|
||||
unset($SESSION->modform->grades[$oldquestionid]);
|
||||
}
|
||||
}
|
||||
|
||||
// set originalquestion in states
|
||||
if ($attempts = get_records_list('quiz_attempts', 'quiz', implode(',', $replaceinquiz))) {
|
||||
foreach ($attempts as $attempt) {
|
||||
set_field('quiz_states', 'originalquestion', $oldquestionid, 'attempt', $attempt->id, 'question', $question->id, 'originalquestion', '0');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// use the old code which simply overwrites old versions
|
||||
// it is also used for creating new questions
|
||||
$question = $QUIZ_QTYPES[$qtype]->save_question($question, $form, $course);
|
||||
$replaceinquiz = 'all';
|
||||
$replaceinquiz = 'all';
|
||||
}
|
||||
|
||||
if (empty($question->errors) && $QUIZ_QTYPES[$qtype]->finished_edit_wizard($form)) {
|
||||
// Automagically regrade all attempts (and states) in the affected quizzes
|
||||
if (!empty($replaceinquiz)) {
|
||||
if (!empty($replaceinquiz)) {
|
||||
$QUIZ_QTYPES[$question->qtype]->get_question_options($question);
|
||||
quiz_regrade_question_in_quizzes($question, $replaceinquiz);
|
||||
}
|
||||
}
|
||||
redirect("edit.php");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,10 +52,10 @@ class quiz_rqp_qtype extends quiz_default_questiontype {
|
||||
|
||||
// Check source file
|
||||
if (!$item = remote_item_info($options)) {
|
||||
// We have not been able to obtain item information from any server
|
||||
$result->notice = get_string('noconnection', 'quiz', $options);
|
||||
return $result;
|
||||
}
|
||||
// We have not been able to obtain item information from any server
|
||||
$result->notice = get_string('noconnection', 'quiz', $options);
|
||||
return $result;
|
||||
}
|
||||
if (is_soap_fault($item)) {
|
||||
$result->notice = get_string('invalidsource', 'quiz', $item);
|
||||
quiz_rqp_debug_soap($item);
|
||||
|
||||
+16
-16
@@ -191,7 +191,7 @@
|
||||
|
||||
//Now, build the QUIZ_QUESTIONS record structure
|
||||
$question->category = $new_category_id;
|
||||
$question->parent = backup_todb($que_info['#']['PARENT']['0']['#']);
|
||||
$question->parent = backup_todb($que_info['#']['PARENT']['0']['#']);
|
||||
$question->name = backup_todb($que_info['#']['NAME']['0']['#']);
|
||||
$question->questiontext = backup_todb($que_info['#']['QUESTIONTEXT']['0']['#']);
|
||||
$question->questiontextformat = backup_todb($que_info['#']['QUESTIONTEXTFORMAT']['0']['#']);
|
||||
@@ -205,8 +205,8 @@
|
||||
$question->hidden = backup_todb($que_info['#']['HIDDEN']['0']['#']);
|
||||
|
||||
////We have to recode the parent field
|
||||
// This should work alright because we ordered the questions appropriately during backup so that
|
||||
// questions that can be parents are restored first
|
||||
// This should work alright because we ordered the questions appropriately during backup so that
|
||||
// questions that can be parents are restored first
|
||||
if ($question->parent and $parent = backup_getid($restore->backup_unique_code,"quiz_questions",$question->parent)) {
|
||||
$question->parent = $parent->new_id;
|
||||
}
|
||||
@@ -268,7 +268,7 @@
|
||||
$status = quiz_restore_calculated($oldid,$newid,$que_info,$restore);
|
||||
} else if ($question->qtype == "11") {
|
||||
$status = quiz_restore_rqp($oldid,$newid,$que_info,$restore);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
//We are NOT creating the question, but we need to know every quiz_answers
|
||||
@@ -1461,7 +1461,7 @@
|
||||
}
|
||||
|
||||
//We have to recode the layout field (a list of questions id and pagebreaks)
|
||||
$attempt->layout = quiz_recode_layout($attempt->layout, $restore);
|
||||
$attempt->layout = quiz_recode_layout($attempt->layout, $restore);
|
||||
|
||||
//The structure is equal to the db, so insert the quiz_attempts
|
||||
$newid = insert_record ("quiz_attempts",$attempt);
|
||||
@@ -1787,7 +1787,7 @@
|
||||
$newid = insert_record ("quiz_rqp_states",$state);
|
||||
}
|
||||
|
||||
return $status;
|
||||
return $status;
|
||||
}
|
||||
|
||||
//This function restores the quiz_grades
|
||||
@@ -2017,16 +2017,16 @@
|
||||
function quiz_recode_layout($layout, $restore) {
|
||||
//Recodes the quiz layout (a list of questions id and pagebreaks)
|
||||
|
||||
//Extracts question id from sequence
|
||||
if ($questionids = explode(',', $layout)) {
|
||||
foreach ($questionids as $id => $questionid) {
|
||||
if ($questionid) { // If it iss zero then this is a pagebreak, don't translate
|
||||
$newq = backup_getid($restore->backup_unique_code,"quiz_questions",$questionid);
|
||||
$questionids[$id] = $newq->new_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
return implode(',', $questionids);
|
||||
//Extracts question id from sequence
|
||||
if ($questionids = explode(',', $layout)) {
|
||||
foreach ($questionids as $id => $questionid) {
|
||||
if ($questionid) { // If it iss zero then this is a pagebreak, don't translate
|
||||
$newq = backup_getid($restore->backup_unique_code,"quiz_questions",$questionid);
|
||||
$questionids[$id] = $newq->new_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
return implode(',', $questionids);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -237,7 +237,7 @@
|
||||
$newid = insert_record ("quiz_questions",$question);
|
||||
//If it is a random question, parent = id
|
||||
if ($newid && $question->qtype == RANDOM) {
|
||||
set_field ('questions', 'parent', $newid, 'id', $newid);
|
||||
set_field ('quiz_questions', 'parent', $newid, 'id', $newid);
|
||||
}
|
||||
$creatingnewquestion = true;
|
||||
}
|
||||
@@ -1179,7 +1179,6 @@
|
||||
//STEP 2. Restore quizzes and associated structures
|
||||
// (course dependent)
|
||||
function quiz_restore_pre15_mods($mod,$restore) {
|
||||
echo "PRE15!!";
|
||||
|
||||
global $CFG;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user