Skip to content

Commit

Permalink
Replaced some (not all) tabs to spaces.
Browse files Browse the repository at this point in the history
I've leave unmodified formats and nusoap library
  • Loading branch information
stronk7 committed May 16, 2005
1 parent 271fea9 commit 87dddc1
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 70 deletions.
6 changes: 3 additions & 3 deletions mod/quiz/backuplib.php
Expand Up @@ -247,9 +247,9 @@ function quiz_backup_question($bf,$preferences,$category) {

$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) {
Expand Down
4 changes: 2 additions & 2 deletions mod/quiz/category.php
Expand Up @@ -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)) {
Expand Down Expand Up @@ -735,7 +735,7 @@ function publish_category($publish, $categoryid) {
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;
}
Expand Down
10 changes: 5 additions & 5 deletions mod/quiz/edit.php
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions mod/quiz/editlib.php
Expand Up @@ -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&amp;");
echo '<tr><td colspan="3">';
print_paging_bar($totalnumber, $page, $perpage, "edit.php?perpage=$perpage&amp;");
echo "</td></tr></table>\n";
print_simple_box_end();

Expand Down
10 changes: 5 additions & 5 deletions mod/quiz/locallib.php
Expand Up @@ -842,7 +842,7 @@ function grade_responses(&$question, &$state, $quiz) {
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;

Expand Down Expand Up @@ -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',
Expand All @@ -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!');
}
Expand Down
62 changes: 31 additions & 31 deletions mod/quiz/question.php
Expand Up @@ -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
Expand Down Expand Up @@ -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");
}
}
Expand Down
8 changes: 4 additions & 4 deletions mod/quiz/questiontypes/rqp/questiontype.php
Expand Up @@ -52,10 +52,10 @@ function save_question_options($form) {

// 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);
Expand Down
32 changes: 16 additions & 16 deletions mod/quiz/restorelib.php
Expand Up @@ -191,7 +191,7 @@ function quiz_restore_questions ($old_category_id,$new_category_id,$info,$restor

//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']['#']);
Expand All @@ -205,8 +205,8 @@ function quiz_restore_questions ($old_category_id,$new_category_id,$info,$restor
$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;
}
Expand Down Expand Up @@ -268,7 +268,7 @@ function quiz_restore_questions ($old_category_id,$new_category_id,$info,$restor
$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
Expand Down Expand Up @@ -1461,7 +1461,7 @@ function quiz_attempts_restore_mods($quiz_id,$info,$restore) {
}

//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);
Expand Down Expand Up @@ -1787,7 +1787,7 @@ function quiz_rqp_states_restore_mods($state_id,$info,$restore) {
$newid = insert_record ("quiz_rqp_states",$state);
}

return $status;
return $status;
}

//This function restores the quiz_grades
Expand Down Expand Up @@ -2017,16 +2017,16 @@ function quiz_restore_logs($restore,$log) {
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);
}

?>
3 changes: 1 addition & 2 deletions mod/quiz/restorelibpre15.php
Expand Up @@ -237,7 +237,7 @@ function quiz_restore_pre15_questions ($old_category_id,$new_category_id,$info,$
$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;
}
Expand Down Expand Up @@ -1179,7 +1179,6 @@ function quiz_restore_pre15_dataset_items ($definitionid,$info,$restore) {
//STEP 2. Restore quizzes and associated structures
// (course dependent)
function quiz_restore_pre15_mods($mod,$restore) {
echo "PRE15!!";

global $CFG;

Expand Down

0 comments on commit 87dddc1

Please sign in to comment.