Skip to content

Commit

Permalink
MDL-27747 Fix a lot of coding style issues in question/format.php
Browse files Browse the repository at this point in the history
  • Loading branch information
timhunt committed Jun 7, 2011
1 parent 92111e8 commit e198992
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions question/format.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -80,7 +80,7 @@ public function export_file_extension() {
return '.txt';
}

// Accessor methods
// Accessor methods

/**
* set the category
Expand Down Expand Up @@ -196,9 +196,9 @@ public function set_can_access_backupdata($canaccess) {
$this->canaccessbackupdata = $canaccess;
}

/***********************
* IMPORTING FUNCTIONS
***********************/
/***********************
* IMPORTING FUNCTIONS
***********************/

/**
* Handle parsing error
Expand Down Expand Up @@ -315,20 +315,19 @@ 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;
}
}
if (!$answersvalid) {
echo $OUTPUT->notification(get_string('invalidgrade', 'question'));
++$gradeerrors;
continue;
}
else {
} else {
$question->fraction = $fractions;
}
}
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand All @@ -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++;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -612,10 +614,9 @@ public function importpostprocess() {
return true;
}


/*******************
* EXPORT FUNCTIONS
*******************/
/*******************
* EXPORT FUNCTIONS
*******************/

/**
* Provide export functionality for plugin questiontypes
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit e198992

Please sign in to comment.