? lang/en_utf8/help/qtype_multichoice/allornothing.html Index: lang/en_utf8/qtype_multichoice.php =================================================================== RCS file: /cvsroot/moodle/moodle/lang/en_utf8/qtype_multichoice.php,v retrieving revision 1.9.2.1 diff -u -a -w -b -B -r1.9.2.1 qtype_multichoice.php --- lang/en_utf8/qtype_multichoice.php 21 Nov 2008 23:04:06 -0000 1.9.2.1 +++ lang/en_utf8/qtype_multichoice.php 6 Apr 2009 15:46:49 -0000 @@ -11,6 +11,7 @@ $string['answernumberingnone'] = 'No numbering'; $string['answersingleno'] = 'Multiple answers allowed'; $string['answersingleyes'] = 'One answer only'; +$string['allornothing'] = 'All or nothing'; $string['choiceno'] = 'Choice $a'; $string['choices'] = 'Available choices'; $string['clozeaid'] = 'Enter missing word'; Index: lang/en_utf8/quiz.php =================================================================== RCS file: /cvsroot/moodle/moodle/lang/en_utf8/quiz.php,v retrieving revision 1.83.2.13 diff -u -a -w -b -B -r1.83.2.13 quiz.php --- lang/en_utf8/quiz.php 18 Mar 2009 11:14:17 -0000 1.83.2.13 +++ lang/en_utf8/quiz.php 6 Apr 2009 15:46:50 -0000 @@ -254,6 +254,8 @@ $string['generalfeedback'] = 'General feedback'; $string['generatevalue'] = 'Generate a new value between'; $string['geometric'] = 'Geometric'; +$string['getfromfileorno'] = 'Get from file or default (no)'; +$string['getfromfileoryes'] = 'Get from file or default (yes)'; $string['gift'] = 'GIFT format'; $string['giftleftbraceerror'] = 'Could not find a {'; $string['giftmatchingformat'] = 'Matching question answers are improperly formatted'; Index: question/format.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/format.php,v retrieving revision 1.35.2.12 diff -u -a -w -b -B -r1.35.2.12 format.php --- question/format.php 18 Mar 2009 11:16:59 -0000 1.35.2.12 +++ question/format.php 6 Apr 2009 15:46:54 -0000 @@ -107,6 +107,42 @@ } /** + * set shuffleanswers + * @param string shuffleanswers + */ + function setShuffleanswers( $shuffleanswers ) { + if ($shuffleanswers == 'true') { + $this->shuffleanswers = true; + } else if ($shuffleanswers == 'false') { + $this->shuffleanswers = false; + } + } + + /** + * set allornothing + * @param string allornothing + */ + function setAllornothing( $allornothing ) { + if ($allornothing == 'true') { + $this->allornothing = true; + } else if ($allornothing == 'false') { + $this->allornothing = false; + } + } + + /** + * set usecase + * @param string usecase + */ + function setUsecase( $usecase ) { + if ($usecase == 'true') { + $this->usecase = true; + } else if ($usecase == 'false') { + $this->usecase = false; + } + } + + /** * set catfromfile * @param bool catfromfile allow categories embedded in import file */ @@ -290,6 +326,17 @@ // reset the php timeout @set_time_limit(); + // overrule shufflanswers, all or nothing and usecase if set in import form + if (isset($this->shuffleanswers)) { + $question->shuffleanswers = $this->shuffleanswers; + } + if (isset($this->allornothing)) { + $question->allornothing = $this->allornothing; + } + if (isset($this->usecase)) { + $question->usecase = $this->usecase; + } + // check for category modifiers if ($question->qtype=='category') { if ($this->catfromfile) { Index: question/import.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/import.php,v retrieving revision 1.46.2.4 diff -u -a -w -b -B -r1.46.2.4 import.php --- question/import.php 15 Sep 2008 14:21:02 -0000 1.46.2.4 +++ question/import.php 6 Apr 2009 15:46:54 -0000 @@ -127,6 +127,9 @@ $qformat->setFilename($importfile); $qformat->setRealfilename($realfilename); $qformat->setMatchgrades($form->matchgrades); + $qformat->setShuffleanswers($form->shuffleanswers); + $qformat->setAllornothing($form->allornothing); + $qformat->setUsecase($form->usecase); $qformat->setCatfromfile(!empty($form->catfromfile)); $qformat->setContextfromfile(!empty($form->contextfromfile)); $qformat->setStoponerror($form->stoponerror); Index: question/import_form.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/import_form.php,v retrieving revision 1.5.2.3 diff -u -a -w -b -B -r1.5.2.3 import_form.php --- question/import_form.php 28 Aug 2008 13:43:25 -0000 1.5.2.3 +++ question/import_form.php 6 Apr 2009 15:46:54 -0000 @@ -37,6 +37,25 @@ $mform->setDefault('catfromfile', 1); $mform->setDefault('contextfromfile', 1); + $shuffleanswers = array(); + $shuffleanswers['default'] = get_string('getfromfileoryes', 'quiz'); + $shuffleanswers['true'] = get_string('yes'); + $shuffleanswers['false'] = get_string('no'); + $mform->addElement('select', 'shuffleanswers', get_string('shuffleanswers','qtype_multichoice'), $shuffleanswers); + $mform->setHelpButton('shuffleanswers', array('shuffleanswers', get_string('shuffleanswers','qtype_multichoice'), 'qtype_multichoice')); + + $allornothing = array(); + $allornothing['default'] = get_string('getfromfileorno', 'quiz'); + $allornothing['true'] = get_string('yes'); + $allornothing['false'] = get_string('no'); + $mform->addElement('select', 'allornothing', get_string('allornothing','qtype_multichoice'), $allornothing); + $mform->setHelpButton('allornothing', array('allornothing', get_string('allornothing','qtype_multichoice'), 'qtype_multichoice')); + + $usecase = array(); + $usecase['default'] = get_string('getfromfileorno', 'quiz'); + $usecase['true'] = get_string('caseyes', 'quiz'); + $usecase['false'] = get_string('caseno', 'quiz'); + $mform->addElement('select', 'usecase', get_string('casesensitive', 'quiz'), $usecase); $matchgrades = array(); $matchgrades['error'] = get_string('matchgradeserror','quiz'); Index: question/format/gift/format.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/format/gift/format.php,v retrieving revision 1.24.2.8 diff -u -a -w -b -B -r1.24.2.8 format.php --- question/format/gift/format.php 16 Mar 2009 13:43:19 -0000 1.24.2.8 +++ question/format/gift/format.php 6 Apr 2009 15:46:55 -0000 @@ -124,6 +124,28 @@ // REMOVED COMMENTED LINES and IMPLODE foreach ($lines as $key => $line) { $line = trim($line); + if (substr($line, 0, 17) == "//shuffleanswers:") { + if (substr($line, 17, 2) == "no") { + $question->shuffleanswers = 0; + } else if (substr($line, 17, 3) == "yes") { + $question->shuffleanswers = 1; + } + } + if (substr($line, 0, 15) == "//allornothing:") { + if (substr($line, 15, 2) == "no") { + $question->allornothing = 0; + } else if (substr($line, 15, 3) == "yes") { + $question->allornothing = 1; + } + } + if (substr($line, 0, 10) == "//usecase:") { + if (substr($line, 10, 2) == "no") { + $question->usecase = 0; + } else if (substr($line, 10, 3) == "yes") { + $question->usecase = 1; + } + } + if (substr($line, 0, 2) == "//") { $lines[$key] = " "; } @@ -609,6 +631,16 @@ } $expout .= "\n"; } + if (!empty($question->options->shuffleanswers) and $question->options->shuffleanswers) { + $expout .= "//shuffleanswers:yes\n"; + } else { + $expout .= "//shuffleanswers:no\n"; + } + if (!empty($question->options->allornothing) and $question->options->allornothing) { + $expout .= "//allornothing:yes\n"; + } else { + $expout .= "//allornothing:no\n"; + } $expout .= "}\n"; break; case SHORTANSWER: @@ -617,6 +649,11 @@ $weight = 100 * $answer->fraction; $expout .= "\t=%".$weight."%".$this->repchar( $answer->answer )."#".$this->repchar( $answer->feedback )."\n"; } + if (!empty($question->options->usecase) and $question->options->usecase) { + $expout .= "//usecase:yes\n"; + } else { + $expout .= "//usecase:no\n"; + } $expout .= "}\n"; break; case NUMERICAL: Index: question/format/xml/format.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/format/xml/format.php,v retrieving revision 1.41.2.9 diff -u -a -w -b -B -r1.41.2.9 format.php --- question/format/xml/format.php 16 Mar 2009 14:20:24 -0000 1.41.2.9 +++ question/format/xml/format.php 6 Apr 2009 15:46:55 -0000 @@ -177,6 +177,8 @@ $shuffleanswers = $this->getpath( $question, array('#','shuffleanswers',0,'#'), 'false' ); $qo->answernumbering = $this->getpath( $question, array('#','answernumbering',0,'#'), 'abc' ); $qo->shuffleanswers = $this->trans_single($shuffleanswers); + $allornothing = $this->getpath( $question, array('#','allornothing',0,'#'), 'false' ); + $qo->allornothing = $this->trans_single($allornothing); $qo->correctfeedback = $this->getpath( $question, array('#','correctfeedback',0,'#','text',0,'#'), '', true ); $qo->partiallycorrectfeedback = $this->getpath( $question, array('#','partiallycorrectfeedback',0,'#','text',0,'#'), '', true ); $qo->incorrectfeedback = $this->getpath( $question, array('#','incorrectfeedback',0,'#','text',0,'#'), '', true ); @@ -855,6 +857,7 @@ case MULTICHOICE: $expout .= " ".$this->get_single($question->options->single)."\n"; $expout .= " ".$this->get_single($question->options->shuffleanswers)."\n"; + $expout .= " ".$this->get_single($question->options->allornothing)."\n"; $expout .= " ".$this->writetext($question->options->correctfeedback, 3)."\n"; $expout .= " ".$this->writetext($question->options->partiallycorrectfeedback, 3)."\n"; $expout .= " ".$this->writetext($question->options->incorrectfeedback, 3)."\n"; Index: question/type/multichoice/edit_multichoice_form.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/type/multichoice/edit_multichoice_form.php,v retrieving revision 1.12.2.4 diff -u -a -w -b -B -r1.12.2.4 edit_multichoice_form.php --- question/type/multichoice/edit_multichoice_form.php 19 Feb 2009 01:09:34 -0000 1.12.2.4 +++ question/type/multichoice/edit_multichoice_form.php 6 Apr 2009 15:46:55 -0000 @@ -29,6 +29,12 @@ $mform->setHelpButton('shuffleanswers', array('multichoiceshuffle', get_string('shuffleanswers','qtype_multichoice'), 'quiz')); $mform->setDefault('shuffleanswers', 1); + $mform->addElement('advcheckbox', 'allornothing', get_string('allornothing', 'qtype_multichoice'), null, null, array(0,1)); + $mform->setHelpButton('allornothing', array('allornothing', get_string('allornothing','qtype_multichoice'), 'qtype_multichoice')); + $mform->setDefault('allornothing', 0); +# $mform->disabledIf('allornothing','single','eq', 1); // works only if you remove the deprecated function getPrivateName() from: + // lib/pear/HTML/QuickForm/advcheckbox.php. + $numberingoptions = $QTYPES[$this->qtype()]->get_numbering_styles(); $menu = array(); foreach ($numberingoptions as $numberingoption) { @@ -67,6 +73,7 @@ } } $default_values['single'] = $question->options->single; + $default_values['allornothing'] = $question->options->allornothing; $default_values['answernumbering'] = $question->options->answernumbering; $default_values['shuffleanswers'] = $question->options->shuffleanswers; $default_values['correctfeedback'] = $question->options->correctfeedback; Index: question/type/multichoice/questiontype.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/type/multichoice/questiontype.php,v retrieving revision 1.29.2.9 diff -u -a -w -b -B -r1.29.2.9 questiontype.php --- question/type/multichoice/questiontype.php 27 Nov 2008 05:13:41 -0000 1.29.2.9 +++ question/type/multichoice/questiontype.php 6 Apr 2009 15:46:55 -0000 @@ -109,6 +109,9 @@ } $options->answernumbering = $question->answernumbering; $options->shuffleanswers = $question->shuffleanswers; + if (isset($question->allornothing)) { + $options->allornothing = $question->allornothing; + } $options->correctfeedback = trim($question->correctfeedback); $options->partiallycorrectfeedback = trim($question->partiallycorrectfeedback); $options->incorrectfeedback = trim($question->incorrectfeedback); @@ -363,6 +366,9 @@ $state->raw_grade += $question->options->answers[$response]->fraction; } } + if ($question->options->allornothing && $state->raw_grade < 0.9999) { + $state->raw_grade = 0; + } } // Make sure we don't assign negative or too high marks @@ -420,6 +426,7 @@ fwrite ($bf,full_tag("ANSWERS",$level+1,false,$multichoice->answers)); fwrite ($bf,full_tag("SINGLE",$level+1,false,$multichoice->single)); fwrite ($bf,full_tag("SHUFFLEANSWERS",$level+1,false,$multichoice->shuffleanswers)); + fwrite ($bf,full_tag("ALLORNOTHING",$level+1,false,$multichoice->allornothing)); fwrite ($bf,full_tag("CORRECTFEEDBACK",$level+1,false,$multichoice->correctfeedback)); fwrite ($bf,full_tag("PARTIALLYCORRECTFEEDBACK",$level+1,false,$multichoice->partiallycorrectfeedback)); fwrite ($bf,full_tag("INCORRECTFEEDBACK",$level+1,false,$multichoice->incorrectfeedback)); @@ -457,6 +464,7 @@ $multichoice->layout = backup_todb($mul_info['#']['LAYOUT']['0']['#']); $multichoice->answers = backup_todb($mul_info['#']['ANSWERS']['0']['#']); $multichoice->single = backup_todb($mul_info['#']['SINGLE']['0']['#']); + $multichoice->allornothing = backup_todb($mul_info['#']['ALLORNOTHING']['0']['#']); $multichoice->shuffleanswers = isset($mul_info['#']['SHUFFLEANSWERS']['0']['#'])?backup_todb($mul_info['#']['SHUFFLEANSWERS']['0']['#']):''; if (array_key_exists("CORRECTFEEDBACK", $mul_info['#'])) { $multichoice->correctfeedback = backup_todb($mul_info['#']['CORRECTFEEDBACK']['0']['#']); Index: question/type/multichoice/version.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/type/multichoice/version.php,v retrieving revision 1.7.2.1 diff -u -a -w -b -B -r1.7.2.1 version.php --- question/type/multichoice/version.php 2 Nov 2007 16:20:34 -0000 1.7.2.1 +++ question/type/multichoice/version.php 6 Apr 2009 15:46:55 -0000 @@ -1,6 +1,6 @@ version = 2007081700; +$plugin->version = 2009040500; $plugin->requires = 2007101000; ?> Index: question/type/multichoice/db/install.xml =================================================================== RCS file: /cvsroot/moodle/moodle/question/type/multichoice/db/install.xml,v retrieving revision 1.5 diff -u -a -w -b -B -r1.5 install.xml --- question/type/multichoice/db/install.xml 24 Sep 2007 22:20:38 -0000 1.5 +++ question/type/multichoice/db/install.xml 6 Apr 2009 15:46:55 -0000 @@ -11,8 +11,9 @@ - - + + + Index: question/type/multichoice/db/upgrade.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/type/multichoice/db/upgrade.php,v retrieving revision 1.5.2.2 diff -u -a -w -b -B -r1.5.2.2 upgrade.php --- question/type/multichoice/db/upgrade.php 12 Dec 2008 13:12:59 -0000 1.5.2.2 +++ question/type/multichoice/db/upgrade.php 6 Apr 2009 15:46:55 -0000 @@ -68,6 +68,17 @@ $result = $result && set_field('question_multichoice', 'answernumbering', 'ABCD', 'answernumbering', 'ABC'); } + // Add field for allornothing. + if ($result && $oldversion < 2009040500) { + /// Define field allornothing to be added to question_multichoice + $table = new XMLDBTable('question_multichoice'); + $field = new XMLDBField('allornothing'); + $field->setAttributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'shuffleanswers'); + + /// Launch add field allornothing + $result = $result && add_field($table, $field); + + } return $result; }