Skip to content

Commit

Permalink
MDL-17264 Merged from HEAD
Browse files Browse the repository at this point in the history
Adding control of usecase for the shortanswer type using SHORTANSWER_C or
 SAC or MWC,
  • Loading branch information
pichetp committed Nov 24, 2008
1 parent cc89382 commit a208bff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
13 changes: 13 additions & 0 deletions question/type/multianswer/edit_multianswer_form.php
Expand Up @@ -66,6 +66,9 @@ function definition_inner(&$mform) {
$mform->addElement('static', 'sub_'.$sub."_".'defaultgrade', get_string('defaultgrade', 'quiz'));
$mform->setDefault('sub_'.$sub."_".'defaultgrade',$this->questiondisplay->options->questions[$sub]->defaultgrade);

if ($this->questiondisplay->options->questions[$sub]->qtype =='shortanswer' ) {
$mform->addElement('static', 'sub_'.$sub."_".'usecase', get_string('casesensitive', 'quiz'));
}
if ($this->questiondisplay->options->questions[$sub]->qtype =='multichoice' ) {
$mform->addElement('static', 'sub_'.$sub."_".'layout', get_string('layout', 'qtype_multianswer'),array('cols'=>60, 'rows'=>1)) ;//, $gradeoptions);
}
Expand Down Expand Up @@ -150,6 +153,16 @@ function set_data($question) {
$answercount = 0;
$maxgrade = false;
$maxfraction = -1;
if ($subquestion->qtype =='shortanswer' ) {
switch ($subquestion->usecase) {
case '1':
$default_values[$prefix.'usecase']= get_string('caseyes', 'quiz');
break;
case '0':
default :
$default_values[$prefix.'usecase']= get_string('caseno', 'quiz');
}
}
if ($subquestion->qtype == 'multichoice' ) {
$default_values[$prefix.'layout'] = $subquestion->layout ;
switch ($subquestion->layout) {
Expand Down
10 changes: 7 additions & 3 deletions question/type/multianswer/questiontype.php
Expand Up @@ -269,8 +269,8 @@ function print_question_formulation_and_controls(&$question, &$state, $cmoptions

while (ereg('\{#([^[:space:]}]*)}', $qtextremaining, $regs)) {
$qtextsplits = explode($regs[0], $qtextremaining, 2);
echo "<label>"; // MDL-7497
echo $qtextsplits[0];
echo "<label>"; // MDL-7497
$qtextremaining = $qtextsplits[1];

$positionkey = $regs[1];
Expand Down Expand Up @@ -887,7 +887,7 @@ function generate_test($name, $courseid = null) {

// Remaining ANSWER regexes
define("ANSWER_TYPE_DEF_REGEX",
'(NUMERICAL|NM)|(MULTICHOICE|MC)|(MULTICHOICE_V|MCV)|(MULTICHOICE_H|MCH)|(SHORTANSWER|SA|MW)');
'(NUMERICAL|NM)|(MULTICHOICE|MC)|(MULTICHOICE_V|MCV)|(MULTICHOICE_H|MCH)|(SHORTANSWER|SA|MW)|(SHORTANSWER_C|SAC|MWC)');
define("ANSWER_START_REGEX",
'\{([0-9]*):(' . ANSWER_TYPE_DEF_REGEX . '):');

Expand All @@ -905,7 +905,8 @@ function generate_test($name, $courseid = null) {
define("ANSWER_REGEX_ANSWER_TYPE_MULTICHOICE_REGULAR", 5);
define("ANSWER_REGEX_ANSWER_TYPE_MULTICHOICE_HORIZONTAL", 6);
define("ANSWER_REGEX_ANSWER_TYPE_SHORTANSWER", 7);
define("ANSWER_REGEX_ALTERNATIVES", 8);
define("ANSWER_REGEX_ANSWER_TYPE_SHORTANSWER_C", 8);
define("ANSWER_REGEX_ALTERNATIVES", 9);

function qtype_multianswer_extract_question($text) {
$question = new stdClass;
Expand All @@ -927,6 +928,9 @@ function qtype_multianswer_extract_question($text) {
} else if(!empty($answerregs[ANSWER_REGEX_ANSWER_TYPE_SHORTANSWER])) {
$wrapped->qtype = 'shortanswer';
$wrapped->usecase = 0;
} else if(!empty($answerregs[ANSWER_REGEX_ANSWER_TYPE_SHORTANSWER_C])) {
$wrapped->qtype = 'shortanswer';
$wrapped->usecase = 1;
} else if(!empty($answerregs[ANSWER_REGEX_ANSWER_TYPE_MULTICHOICE])) {
$wrapped->qtype = 'multichoice';
$wrapped->single = 1;
Expand Down

0 comments on commit a208bff

Please sign in to comment.