diff --git a/question/format.php b/question/format.php index af5e464b3854..663e9176baf1 100644 --- a/question/format.php +++ b/question/format.php @@ -54,8 +54,8 @@ class qformat_default { protected $importcontext = null; -// functions to indicate import/export functionality -// override to return true if implemented + // functions to indicate import/export functionality + // override to return true if implemented /** @return bool whether this plugin provides import functionality. */ public function provide_import() { @@ -80,7 +80,7 @@ public function export_file_extension() { return '.txt'; } -// Accessor methods + // Accessor methods /** * set the category @@ -196,9 +196,9 @@ public function set_can_access_backupdata($canaccess) { $this->canaccessbackupdata = $canaccess; } -/*********************** - * IMPORTING FUNCTIONS - ***********************/ + /*********************** + * IMPORTING FUNCTIONS + ***********************/ /** * Handle parsing error @@ -315,11 +315,11 @@ public function importprocess($category) { $fractions = $question->fraction; $answersvalid = true; // in case they are! foreach ($fractions as $key => $fraction) { - $newfraction = match_grade_options($gradeoptionsfull, $fraction, $this->matchgrades); - if ($newfraction===false) { + $newfraction = match_grade_options($gradeoptionsfull, $fraction, + $this->matchgrades); + if ($newfraction === false) { $answersvalid = false; - } - else { + } else { $fractions[$key] = $newfraction; } } @@ -327,8 +327,7 @@ public function importprocess($category) { echo $OUTPUT->notification(get_string('invalidgrade', 'question')); ++$gradeerrors; continue; - } - else { + } else { $question->fraction = $fractions; } } @@ -337,7 +336,7 @@ public function importprocess($category) { $questions = $goodquestions; // check for errors before we continue - if ($this->stoponerror and ($gradeerrors>0)) { + if ($this->stoponerror && $gradeerrors > 0) { return false; } @@ -409,7 +408,8 @@ public function importprocess($category) { } // Give the question a unique version stamp determined by question_hash() - $DB->set_field('question', 'version', question_hash($question), array('id'=>$question->id)); + $DB->set_field('question', 'version', question_hash($question), + array('id' => $question->id)); } return true; } @@ -427,7 +427,8 @@ protected function count_questions($questions) { return $count; } foreach ($questions as $question) { - if (!is_object($question) || !isset($question->qtype) || ($question->qtype == 'category')) { + if (!is_object($question) || !isset($question->qtype) || + ($question->qtype == 'category')) { continue; } $count++; @@ -470,7 +471,8 @@ protected function create_category_path($catpath) { // Now create any categories that need to be created. foreach ($catnames as $catname) { - if ($category = $DB->get_record('question_categories', array('name' => $catname, 'contextid' => $context->id, 'parent' => $parent))) { + if ($category = $DB->get_record('question_categories', + array('name' => $catname, 'contextid' => $context->id, 'parent' => $parent))) { $parent = $category->id; } else { require_capability('moodle/question:managecategory', $context); @@ -612,10 +614,9 @@ public function importpostprocess() { return true; } - -/******************* - * EXPORT FUNCTIONS - *******************/ + /******************* + * EXPORT FUNCTIONS + *******************/ /** * Provide export functionality for plugin questiontypes @@ -684,9 +685,10 @@ public function exportprocess() { $trackcategory = 0; // iterate through questions - foreach($questions as $question) { + foreach ($questions as $question) { // used by file api - $contextid = $DB->get_field('question_categories', 'contextid', array('id'=>$question->category)); + $contextid = $DB->get_field('question_categories', 'contextid', + array('id' => $question->category)); $question->contextid = $contextid; // do not export hidden questions @@ -747,7 +749,7 @@ public function exportprocess() { protected function get_category_path($id, $includecontext = true) { global $DB; - if (!$category = $DB->get_record('question_categories',array('id' =>$id))) { + if (!$category = $DB->get_record('question_categories', array('id' => $id))) { print_error('cannotfindcategory', 'error', '', $id); } $contextstring = $this->translator->context_to_string($category->contextid);