<?php // $Id$
// Get a handle to the question type we are dealing with here
-$qtypeobj = $QTYPES[CALCULATED];
+$qtypeobj = $QTYPES['calculated'];
if (empty($form)) {
/****************************************************************/
//////////////////////////////////////////////////////////////////////////
//// INITIATION - Without this line the question type is not in use... ///
//////////////////////////////////////////////////////////////////////////
-// define("CALCULATED", "10"); // already defined in questionlib.php
-$QTYPES[CALCULATED]= new question_calculated_qtype();
+$QTYPES['calculated']= new question_calculated_qtype();
// The following adds the questiontype to the menu of types shown to teachers
-$QTYPE_MENU[CALCULATED] = get_string("calculated", "quiz");
+$QTYPE_MENU['calculated'] = get_string("calculated", "quiz");
function quiz_qtype_calculated_calculate_answer($formula, $individualdata,
$tolerance, $tolerancetype, $answerlength, $answerformat='1', $unit='') {
/// Exchange formula variables with the correct values...
global $QTYPES;
- $answer = $QTYPES[CALCULATED]->substitute_variables($formula, $individualdata);
+ $answer = $QTYPES['calculated']->substitute_variables($formula, $individualdata);
if ('1' == $answerformat) { /* Answer is to have $answerlength decimals */
/*** Adjust to the correct number of decimals ***/
/// QUESTION TYPE CLASS //////////////////
//
-// The question type DESCRIPTION is not really a question type
+// The question type 'description' is not really a question type
// and it therefore often sticks to some kind of odd behaviour
//
//// INITIATION - Without this line the question type is not in use... ///
//////////////////////////////////////////////////////////////////////////
// define("DESCRIPTION", "7"); // already defined in questionlib.php
-$QTYPES[DESCRIPTION]= new quiz_description_qtype();
+$QTYPES['description']= new quiz_description_qtype();
// The following adds the questiontype to the menu of types shown to teachers
-$QTYPE_MENU[DESCRIPTION] = get_string("description", "quiz");
+$QTYPE_MENU['description'] = get_string("description", "quiz");
?>
" {$CFG->prefix}quiz_question_instances i".
" WHERE i.quiz = '$cmoptions->id' AND q.id = i.question".
" AND q.id IN ($questionlist)".
- " AND q.qtype = '".ESSAY."'".
+ " AND q.qtype = '".'essay'."'".
" ORDER BY q.name";
if (empty($attemptid)) {
//////////////////////////////////////////////////////////////////////////
//// INITIATION - Without this line the question type is not in use... ///
//////////////////////////////////////////////////////////////////////////
-// define("ESSAY", "12"); // already defined in questionlib.php
-$QTYPES[ESSAY] = new question_essay_qtype();
+$QTYPES['essay'] = new question_essay_qtype();
// The following adds the questiontype to the menu of types shown to teachers
-$QTYPE_MENU[ESSAY] = get_string("essay", "quiz");
+$QTYPE_MENU['essay'] = get_string("essay", "quiz");
?>
//////////////////////////////////////////////////////////////////////////
//// INITIATION - Without this line the question type is not in use... ///
//////////////////////////////////////////////////////////////////////////
-// define("MATCH", "5"); // already defined in questionlib.php
-$QTYPES[MATCH]= new question_match_qtype();
+$QTYPES['match']= new question_match_qtype();
// The following adds the questiontype to the menu of types shown to teachers
-$QTYPE_MENU[MATCH] = get_string("match", "quiz");
+$QTYPE_MENU['match'] = get_string("match", "quiz");
?>
if (empty($wrapped->questiontext)) {
$parsableanswerdef = '{' . $wrapped->defaultgrade . ':';
switch ($wrapped->qtype) {
- case MULTICHOICE:
+ case 'multichoice':
$parsableanswerdef .= 'MULTICHOICE:';
break;
- case SHORTANSWER:
+ case 'shortanswer':
$parsableanswerdef .= 'SHORTANSWER:';
break;
- case NUMERICAL:
+ case 'numerical':
$parsableanswerdef .= 'NUMERICAL:';
break;
default:
///
/// The multianswer question type is special in that it
/// depends on a few other question types, i.e.
-/// MULTICHOICE, SHORTANSWER and NUMERICAL.
+/// 'multichoice', 'shortanswer' and 'numerical'.
/// These question types have got a few special features that
-/// makes them useable by the MULTIANSWER question type
+/// makes them useable by the 'multianswer' question type
///
/// QUESTION TYPE CLASS //////////////////
if ($options->feedback) {
$chosenanswer = null;
switch ($wrapped->qtype) {
- case NUMERICAL:
+ case 'numerical':
$testedstate = clone($state);
$testedstate->responses[''] = $response;
$raw_grade = 0;
}
}
break;
- case SHORTANSWER:
+ case 'shortanswer':
$testedstate = clone($state);
$testedstate->responses[''] = $response;
$teststate = clone($state);
}
}
break;
- case MULTICHOICE:
+ case 'multichoice':
if (isset($answers[$response])) {
$chosenanswer = clone($answers[$response]);
}
// Print the input control
switch ($wrapped->qtype) {
- case SHORTANSWER:
- case NUMERICAL:
+ case 'shortanswer':
+ case 'numerical':
echo " <input $style $readonly $popup name=\"$inputname\"
type=\"text\" value=\"$response\" size=\"12\" /> ";
break;
- case MULTICHOICE:
+ case 'multichoice':
$outputoptions = '<option></option>'; // Default empty option
foreach ($answers as $mcanswer) {
$selected = $response == $mcanswer->id
error("Can't find the subquestion $wrappedquestionid that is used as part $seqnum in cloze question $state->question");
}
// For multichoice question we need to recode the answer
- if ($answer and $wrappedquestion->qtype == MULTICHOICE) {
+ if ($answer and $wrappedquestion->qtype == 'multichoice') {
//The answer is an answer_id, look for it in backup_ids
if (!$ans = backup_getid($restore->backup_unique_code,"question_answers",$answer)) {
echo 'Could not recode cloze multichoice answer '.$answer.'<br />';
//////////////////////////////////////////////////////////////////////////
//// INITIATION - Without this line the question type is not in use... ///
//////////////////////////////////////////////////////////////////////////
-// define("MULTIANSWER", "9"); // already defined in questionlib.php
-$QTYPES[MULTIANSWER]= new quiz_embedded_cloze_qtype();
+$QTYPES['multianswer']= new quiz_embedded_cloze_qtype();
// The following adds the questiontype to the menu of types shown to teachers
-$QTYPE_MENU[MULTIANSWER] = get_string("multianswer", "quiz");
+$QTYPE_MENU['multianswer'] = get_string("multianswer", "quiz");
/////////////////////////////////////////////////////////////
//// ADDITIONAL FUNCTIONS
//// The functions below deal exclusivly with editing
-//// of questions with question type MULTIANSWER.
+//// of questions with question type 'multianswer'.
//// Therefore they are kept in this file.
//// They are not in the class as they are not
//// likely to be subject for overriding.
////////////////////////////////////////
$question = new stdClass;
- $question->qtype = MULTIANSWER;
+ $question->qtype = 'multianswer';
$question->questiontext = $text;
$question->options->questions = array();
$question->defaultgrade = 0; // Will be increased for each answer norm
$wrapped->defaultgrade = $answerregs[ANSWER_REGEX_NORM]
or $wrapped->defaultgrade = '1';
if (!empty($answerregs[ANSWER_REGEX_ANSWER_TYPE_NUMERICAL])) {
- $wrapped->qtype = NUMERICAL;
+ $wrapped->qtype = 'numerical';
$wrapped->multiplier = array();
$wrapped->units = array();
} else if(!empty($answerregs[ANSWER_REGEX_ANSWER_TYPE_SHORTANSWER])) {
- $wrapped->qtype = SHORTANSWER;
+ $wrapped->qtype = 'shortanswer';
$wrapped->usecase = 0;
} else if(!empty($answerregs[ANSWER_REGEX_ANSWER_TYPE_MULTICHOICE])) {
- $wrapped->qtype = MULTICHOICE;
+ $wrapped->qtype = 'multichoice';
$wrapped->single = 1;
} else {
error("Cannot identify qtype $answerregs[2]");
//////////////////////////////////////////////////////////////////////////
//// INITIATION - Without this line the question type is not in use... ///
//////////////////////////////////////////////////////////////////////////
-// define("MULTICHOICE", "3"); // already defined in questionlib.php
-$QTYPES[MULTICHOICE]= new question_multichoice_qtype();
+$QTYPES['multichoice']= new question_multichoice_qtype();
// The following adds the questiontype to the menu of types shown to teachers
-$QTYPE_MENU[MULTICHOICE] = get_string("multichoice", "quiz");
+$QTYPE_MENU['multichoice'] = get_string("multichoice", "quiz");
?>
//////////////////////////////////////////////////////////////////////////
//// INITIATION - Without this line the question type is not in use... ///
//////////////////////////////////////////////////////////////////////////
-// define("NUMERICAL", "8"); // already defined in questionlib.php
-$QTYPES[NUMERICAL]= new question_numerical_qtype();
+$QTYPES['numerical']= new question_numerical_qtype();
// The following adds the questiontype to the menu of types shown to teachers
-$QTYPE_MENU[NUMERICAL] = get_string("numerical", "quiz");
+$QTYPE_MENU['numerical'] = get_string("numerical", "quiz");
?>
*
* This function returns the number of question numbers to be assigned
* to the question. Most question types will have length one; they will be
- * assigned one number. The DESCRIPTION type, however does not use up a
+ * assigned one number. The 'description' type, however does not use up a
* number and so has a length of zero. Other question types may wish to
* handle a bundle of questions and hence return a number greater than one.
* @return integer The number of question numbers which should be
/// QUESTION TYPE CLASS //////////////////
class quiz_random_qtype extends default_questiontype {
- var $excludedtypes = array(RANDOM, RANDOMSAMATCH, ESSAY, DESCRIPTION);
+ var $excludedtypes = array('random', 'randomsamatch', 'essay', 'description');
// Carries questions available as randoms sorted by category
// This array is used when needed only
}
$question->questiontext = '<span class="notifyproblem">'.
get_string('toomanyrandom', 'quiz'). '</span>';
- $question->qtype = DESCRIPTION;
+ $question->qtype = 'description';
$state->responses = array('' => '');
return true;
}
// This is the case if there weren't enough questions available in the category.
$question->questiontext = '<span class="notifyproblem">'.
get_string('toomanyrandom', 'quiz'). '</span>';
- $question->qtype = DESCRIPTION;
+ $question->qtype = 'description';
return true;
}
// this must be an old-style state which stores only the id for the wrapped question
$options->choose = "";
$options->shuffleanswers = 1;
}
- $saquestions = $QTYPES[RANDOMSAMATCH]->get_sa_candidates($category->id);
+ $saquestions = $QTYPES['randomsamatch']->get_sa_candidates($category->id);
$numberavailable = count($saquestions);
unset($saquestions);
/// QUESTION TYPE CLASS //////////////////
class question_randomsamatch_qtype extends question_match_qtype {
-/// Extends MATCH as there are quite a few simularities...
+/// Extends 'match' as there are quite a few simularities...
function name() {
return 'randomsamatch';
function get_sa_candidates($categorylist, $questionsinuse=0) {
return get_records_select('question',
- "qtype = '".SHORTANSWER."' " .
+ "qtype = '".'shortanswer'."' " .
"AND category IN ($categorylist) " .
"AND parent = '0' " .
"AND hidden = '0'" .
//////////////////////////////////////////////////////////////////////////
//// INITIATION - Without this line the question type is not in use... ///
//////////////////////////////////////////////////////////////////////////
-// define("RANDOMSAMATCH", "6"); // already defined in questionlib.php
-$QTYPES[RANDOMSAMATCH]= new question_randomsamatch_qtype();
+$QTYPES['randomsamatch']= new question_randomsamatch_qtype();
// The following adds the questiontype to the menu of types shown to teachers
-$QTYPE_MENU[RANDOMSAMATCH] = get_string("randomsamatch", "quiz");
+$QTYPE_MENU['randomsamatch'] = get_string("randomsamatch", "quiz");
?>
function print_question_formulation_and_controls(&$question, &$state, $cmoptions, $options) {
global $CFG;
- /// This implementation is also used by question type NUMERICAL
+ /// This implementation is also used by question type 'numerical'
$answers = &$question->options->answers;
$correctanswers = $this->get_correct_responses($question, $state);
$readonly = empty($options->readonly) ? '' : 'readonly="readonly"';
//////////////////////////////////////////////////////////////////////////
//// INITIATION - Without this line the question type is not in use... ///
//////////////////////////////////////////////////////////////////////////
-// define("SHORTANSWER", "1"); // already defined in questionlib.php
-$QTYPES[SHORTANSWER]= new question_shortanswer_qtype();
+$QTYPES['shortanswer']= new question_shortanswer_qtype();
// The following adds the questiontype to the menu of types shown to teachers
-$QTYPE_MENU[SHORTANSWER] = get_string("shortanswer", "quiz");
+$QTYPE_MENU['shortanswer'] = get_string("shortanswer", "quiz");
?>
//////////////////////////////////////////////////////////////////////////
//// INITIATION - Without this line the question type is not in use... ///
//////////////////////////////////////////////////////////////////////////
-// define("TRUEFALSE", "2"); // already defined in questionlib.php
-$QTYPES[TRUEFALSE]= new question_truefalse_qtype();
+$QTYPES['truefalse']= new question_truefalse_qtype();
// The following adds the questiontype to the menu of types shown to teachers
-$QTYPE_MENU[TRUEFALSE] = get_string("truefalse", "quiz");
+$QTYPE_MENU['truefalse'] = get_string("truefalse", "quiz");
?>