Skip to content

Commit

Permalink
more last fixes to question forms and removal of redundant files
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiesensei committed Jan 7, 2007
1 parent 111be76 commit c6fc998
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 62 deletions.
48 changes: 48 additions & 0 deletions question/type/multianswer/edit_multianswer_form.php
Expand Up @@ -15,6 +15,54 @@ class question_edit_multianswer_form extends question_edit_form {

// No question-type specific form fields.

function set_defaults($question) {
if ($question->questiontext and $question->id and $question->qtype) {

foreach ($question->options->questions as $key => $wrapped) {
// The old way of restoring the definitions is kept to gradually
// update all multianswer questions
if (empty($wrapped->questiontext)) {
$parsableanswerdef = '{' . $wrapped->defaultgrade . ':';
switch ($wrapped->qtype) {
case 'multichoice':
$parsableanswerdef .= 'MULTICHOICE:';
break;
case 'shortanswer':
$parsableanswerdef .= 'SHORTANSWER:';
break;
case 'numerical':
$parsableanswerdef .= 'NUMERICAL:';
break;
default:
error("questiontype $wrapped->qtype not recognized");
}
$separator= '';
foreach ($wrapped->options->answers as $subanswer) {
$parsableanswerdef .= $separator
. '%' . round(100*$subanswer->fraction) . '%';
$parsableanswerdef .= $subanswer->answer;
if (!empty($wrapped->options->tolerance)) {
// Special for numerical answers:
$parsableanswerdef .= ":{$wrapped->options->tolerance}";
// We only want tolerance for the first alternative, it will
// be applied to all of the alternatives.
unset($wrapped->options->tolerance);
}
if ($subanswer->feedback) {
$parsableanswerdef .= "#$subanswer->feedback";
}
$separator = '~';
}
$parsableanswerdef .= '}';
// Fix the questiontext fields of old questions
set_field('question', 'questiontext', addslashes($parsableanswerdef), 'id', $wrapped->id);
} else {
$parsableanswerdef = str_replace('&#', '&\#', $wrapped->questiontext);
}
$question->questiontext = str_replace("{#$key}", $parsableanswerdef, $question->questiontext);
}
}
}

function qtype() {
return 'multianswer';
Expand Down
7 changes: 0 additions & 7 deletions question/type/multianswer/editquestion.html

This file was deleted.

54 changes: 0 additions & 54 deletions question/type/multianswer/editquestion.php

This file was deleted.

4 changes: 3 additions & 1 deletion question/type/multichoice/edit_multichoice_form.php
Expand Up @@ -20,9 +20,11 @@ class question_edit_multichoice_form extends question_edit_form {
function definition_inner(&$mform) {
$menu = array(get_string('answersingleno', 'qtype_multichoice'), get_string('answersingleyes', 'qtype_multichoice'));
$mform->addElement('select', 'single', get_string('answerhowmany', 'qtype_multichoice'), $menu);
$mform->setDefault('single', 1);

$mform->addElement('selectyesno', 'shuffleanswers', get_string('shuffleanswers', 'qtype_multichoice'));
$mform->addElement('advcheckbox', 'shuffleanswers', get_string('shuffleanswers', 'qtype_multichoice'), null, null, array(0,1));
$mform->setHelpButton('shuffleanswers', array('multichoiceshuffle', get_string('shuffleanswers','qtype_multichoice'), 'quiz'));
$mform->setDefault('shuffleanswers', 1);

/* $mform->addElement('static', 'answersinstruct', get_string('choices', 'qtype_multichoice'), get_string('fillouttwochoices', 'qtype_multichoice'));
$mform->closeHeaderBefore('answersinstruct');
Expand Down

0 comments on commit c6fc998

Please sign in to comment.