public function get_question_options($question) { global $CFG, $DB, $OUTPUT; parent::get_question_options($question); // Get the question answers and their respective tolerances // Note: question_numerical is an extension of the answer table rather than // the question table as is usually the case for qtype // specific tables. if (!($question->options->answers = $DB->get_records_sql("SELECT a.*, n.tolerance " . "FROM {question_answers} a, " . " {question_numerical} n " . "WHERE a.question = ? " . " AND a.id = n.answer " . "ORDER BY a.id ASC", array($question->id)))) { echo $OUTPUT->notification('Error: Missing question answer for numerical question ' . $question->id . '!'); return false; } $question->hints = $DB->get_records('question_hints', array('questionid' => $question->id), 'id ASC'); $this->get_numerical_units($question); // Get_numerical_options() need to know if there are units // to set correctly default values. $this->get_numerical_options($question); // If units are defined we strip off the default unit from the answer, if // it is present. (Required for compatibility with the old code and DB). if ($defaultunit = $this->get_default_numerical_unit($question)) { foreach ($question->options->answers as $key => $val) { $answer = trim($val->answer); $length = strlen($defaultunit->unit); if ($length && substr($answer, -$length) == $defaultunit->unit) { $question->options->answers[$key]->answer = substr($answer, 0, strlen($answer) - $length); } } } return true; }
public function get_question_options($question) { global $DB; parent::get_question_options($question); $question->options = $DB->get_record('qtype_randomsamatch_options', array('questionid' => $question->id)); return true; }
public function get_question_options($question) { global $DB; parent::get_question_options($question); $question->options = $DB->get_record('question_match', array('question' => $question->id)); $question->options->subquestions = $DB->get_records('question_match_sub', array('question' => $question->id), 'id ASC'); return true; }
public function get_question_options($question) { global $DB; $dbprefix = 'qtype_' . $this->name(); $question->options = $DB->get_record($dbprefix, array('questionid' => $question->id), '*', MUST_EXIST); $question->options->drags = $DB->get_records($dbprefix . '_drags', array('questionid' => $question->id), 'no ASC', '*'); $question->options->drops = $DB->get_records($dbprefix . '_drops', array('questionid' => $question->id), 'no ASC', '*'); parent::get_question_options($question); }
public function get_question_options($question) { global $DB; $question->options = $DB->get_record('qtype_poodllrecording_opts', array('questionid' => $question->id), '*', MUST_EXIST); parent::get_question_options($question); }
function get_question_options($question) { parent::get_question_options($question); $matrix = self::retrieve_matrix($question->id); if ($matrix) { $question->options->rows = $matrix->rows; $question->options->cols = $matrix->cols; $question->options->weights = $matrix->weights; $question->options->grademethod = $matrix->grademethod; $question->options->multiple = $matrix->multiple; $question->options->renderer = $matrix->renderer; } else { $question->options->rows = array(); $question->options->cols = array(); $question->options->weights = array(array()); $question->options->grademethod = self::defaut_grading()->get_name(); $question->options->multiple = true; } return true; }
public function get_question_options($question) { global $DB, $OUTPUT; $question->options = $DB->get_record('qtype_multichoiceset_options', array('questionid' => $question->id), '*', MUST_EXIST); parent::get_question_options($question); }
public function get_question_options($question) { global $DB; parent::get_question_options($question); $question->options = $DB->get_record('qtype_stack_options', array('questionid' => $question->id), '*', MUST_EXIST); $question->inputs = $DB->get_records('qtype_stack_inputs', array('questionid' => $question->id), 'name', 'name, id, questionid, type, tans, boxsize, strictsyntax, insertstars, ' . 'syntaxhint, forbidwords, allowwords, forbidfloat, requirelowestterms, ' . 'checkanswertype, mustverify, showvalidation, options'); $question->prts = $DB->get_records('qtype_stack_prts', array('questionid' => $question->id), 'name', 'name, id, questionid, value, autosimplify, feedbackvariables, firstnodename'); $noders = $DB->get_recordset('qtype_stack_prt_nodes', array('questionid' => $question->id), 'prtname, ' . $DB->sql_cast_char2int('nodename')); foreach ($noders as $node) { $question->prts[$node->prtname]->nodes[$node->nodename] = $node; } $noders->close(); $question->deployedseeds = $DB->get_fieldset_sql(' SELECT seed FROM {qtype_stack_deployed_seeds} WHERE questionid = ? ORDER BY id', array($question->id)); return true; }
public function get_question_options($question) { global $DB; $question->options = $DB->get_record('question_gapfill', array('question' => $question->id), '*', MUST_EXIST); parent::get_question_options($question); }
public function get_question_options($question) { global $DB; $question->options = $DB->get_record('question_' . $this->name(), array('questionid' => $question->id), '*', MUST_EXIST); parent::get_question_options($question); }
public function get_question_options($question) { global $CFG, $DB, $OUTPUT; parent::get_question_options($question); if ($question->options->prototypetype != 0) { // Question prototype? // Yes. It's 100% customised with nothing to inherit. $question->options->customise = True; } else { // Add to the question all the inherited fields from the question's prototype // record that have not been overridden (i.e. that are null) by this // instance. If any of the inherited fields are modified (i.e. any // (extra field not in the noninheritedFields list), the 'customise' // field is set. This is used only to display the customisation panel. $qtype = $question->options->coderunnertype; $context = $this->question_context($question); $row = $this->get_prototype($qtype, $context); $question->options->customise = False; // Starting assumption $noninheritedfields = $this->noninherited_fields(); foreach ($row as $field => $value) { $isinheritedfield = !in_array($field, $noninheritedfields); if ($isinheritedfield) { if (isset($question->options->{$field}) && $question->options->{$field} !== null && $question->options->{$field} !== '' && $question->options->{$field} != $value) { $question->options->customise = True; // An inherited field has been changed } else { $question->options->{$field} = $value; } } } if (!isset($question->options->sandbox)) { $question->options->sandbox = null; } if (!isset($question->options->grader)) { $question->options->grader = null; } if (!isset($question->options->sandboxparams) || trim($question->options->sandboxparams) === '') { $question->options->sandboxparams = null; } } // Add in any testcases (expect none for built-in prototypes) if (!($question->options->testcases = $DB->get_records('question_coderunner_tests', array('questionid' => $question->id), 'id ASC'))) { if ($question->options->prototypetype == 0 && $question->options->grader !== 'qtype_coderunner_combinator_template_grader') { throw new coderunner_exception("Failed to load testcases for question id {$question->id}"); } else { // Question prototypes may not have testcases $question->options->testcases = array(); } } return true; }
public function get_question_options($question) { global $DB, $OUTPUT; $question->options = $DB->get_record('question_turmultiplechoice', array('question' => $question->id), '*', MUST_EXIST); parent::get_question_options($question); }
public function get_question_options($question) { global $DB; $question->options = $DB->get_record($this->get_table_name(), array('questionid' => $question->id), '*', MUST_EXIST); return question_type::get_question_options($question); }