Moodle
  1. Moodle
  2. MDL-14763

Improving multichoice display in multinaswers (Cloze) question type

    Details

    • Type: New Feature New Feature
    • Status: Reopened
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.0
    • Fix Version/s: STABLE backlog
    • Component/s: Questions
    • Labels:
      None
    • Affected Branches:
      MOODLE_20_STABLE
    • Rank:
      1093

      Description

      Adding radio button display for multichoice sub questions.
      See http://moodle.org/mod/forum/discuss.php?d=96799

      1. multianswer_tjh.html
        8 kB
        Tim Hunt
      2. multianswer.html
        11 kB
        Pierre Pichet
      3. multianswerpatchjr.txt
        1 kB
        Joseph Rézeau
      1. first_example_with_feedback.jpg
        124 kB
      2. screenshot-1.jpg
        119 kB
      3. screenshot JR (1 and 2).jpg
        149 kB

        Issue Links

          Activity

          Hide
          Itamar Tzadok added a comment -

          An alternative and perhaps a simpler improvement may be to allow a Multiple Choice question to present the choices horizontally rather then vertically. The discussion that triggered this issue does not seem to suggest that more than that is needed.

          Show
          Itamar Tzadok added a comment - An alternative and perhaps a simpler improvement may be to allow a Multiple Choice question to present the choices horizontally rather then vertically. The discussion that triggered this issue does not seem to suggest that more than that is needed.
          Hide
          Pierre Pichet added a comment -

          It is effectively easier to change the display of Multiple Choice although horizontally is useful only for short sentence.
          Horizontal is te best choice on a screen as vertical scolling is easier.

          Show
          Pierre Pichet added a comment - It is effectively easier to change the display of Multiple Choice although horizontally is useful only for short sentence. Horizontal is te best choice on a screen as vertical scolling is easier.
          Hide
          Pierre Pichet added a comment -

          Sorry
          Horizontal is not in general the best choice on a screen as vertical scolling is easier.

          Show
          Pierre Pichet added a comment - Sorry Horizontal is not in general the best choice on a screen as vertical scolling is easier.
          Hide
          Itamar Tzadok added a comment -

          Yes, but if the options are short enough then you don't have horizontal scrolling and you can have more items in the view and thus less vertical scrolling.

          Show
          Itamar Tzadok added a comment - Yes, but if the options are short enough then you don't have horizontal scrolling and you can have more items in the view and thus less vertical scrolling.
          Hide
          Pierre Pichet added a comment -

          This illustrate the three possible layouts of the multichoice.
          The vertical and horizontal use a table following the code of the standard multichoice.

          Show
          Pierre Pichet added a comment - This illustrate the three possible layouts of the multichoice. The vertical and horizontal use a table following the code of the standard multichoice.
          Hide
          Pierre Pichet added a comment -

          Here is the HTML question code of the first example.
          <p>This question consists of some text with an answer embedded right here

          {1:MULTICHOICE:Wrong answer#Feedback for this wrong answer~Another wrong answer#Feedback for the other wrong answer~=Correct answer#Feedback for correct answer~%50%Answer that gives half the credit#Feedback for half credit answer}

          .</p>
          <p>VERTICALThe same multichoice in vertical mode
          <table width="50%">
          <tbody>
          <tr>
          <td>

          {2:MCV:Wrong answer#Feedback for this wrong answer~Another wrong answer#Feedback for the other wrong answer~=Correct answer#Feedback for correct answer~%50%Answer that gives half the credit#Feedback for half credit answer}

          .</td>
          </tr>
          <tr>
          </tr>
          </tbody>
          </table>
          <table>
          <tbody>
          <tr>
          <td>HORIZONTALThe same multichoice in horizontal mode</td>
          <td>

          {2:MCH:Wrong answer#Feedback for this wrong answer~Another wrong answer#Feedback for the other wrong answer~=Correct answer#Feedback for correct answer~%50%Answer that gives half the credit#Feedback for half credit answer}

          </td>
          </tr>
          </tbody>
          </table>
          </p>
          <p>.</p>
          <p> </p>
          Notice that the Horizontal has been put in a table so that the answers output (i.e. between the

          {2:MCH:...answer}

          is place in one cell so that his dimension is controlled by the cell width.

          The code is transparent to the ordinary cloze question as these vertical and horizontal dispaly are declared by using for
          horizontal :MULTICHOICE_H or MCH
          vertical : MULTICHOICE_V or MCV
          The mdl_question_multiplechoice layout field being used to store
          0 -> default select elelement
          1-> vertical
          2->horizontal.
          two lines of code need to be added to the multichoice/questiontype.php so that the layout parameter is updated .
          @@ -105,6 +105,9 @@
          }
          $options->answers = implode(",",$answers);
          $options->single = $question->single;
          + if(isset($question->layout))

          { + $options->layout = $question->layout; + }

          $options->answernumbering = $question->answernumbering;
          $options->shuffleanswers = $question->shuffleanswers;
          $options->correctfeedback = trim($question->correctfeedback);

          The multipleanswer/questiontype.php integrate the code of the multichoice/questiontype.php and multichoice/display.html using a table to contain the answers and the feedback.
          This let the user use available HTML code from the HTML editor create a display that encounters its needs.

          As the only changes to the cloze text are the new MCV and MCH terms this modification will be easily merged to 1.9 or older version if necessary.

          Show
          Pierre Pichet added a comment - Here is the HTML question code of the first example. <p>This question consists of some text with an answer embedded right here {1:MULTICHOICE:Wrong answer#Feedback for this wrong answer~Another wrong answer#Feedback for the other wrong answer~=Correct answer#Feedback for correct answer~%50%Answer that gives half the credit#Feedback for half credit answer} .</p> <p>VERTICALThe same multichoice in vertical mode <table width="50%"> <tbody> <tr> <td> {2:MCV:Wrong answer#Feedback for this wrong answer~Another wrong answer#Feedback for the other wrong answer~=Correct answer#Feedback for correct answer~%50%Answer that gives half the credit#Feedback for half credit answer} .</td> </tr> <tr> </tr> </tbody> </table> <table> <tbody> <tr> <td>HORIZONTALThe same multichoice in horizontal mode</td> <td> {2:MCH:Wrong answer#Feedback for this wrong answer~Another wrong answer#Feedback for the other wrong answer~=Correct answer#Feedback for correct answer~%50%Answer that gives half the credit#Feedback for half credit answer} </td> </tr> </tbody> </table> </p> <p>.</p> <p> </p> Notice that the Horizontal has been put in a table so that the answers output (i.e. between the {2:MCH:...answer} is place in one cell so that his dimension is controlled by the cell width. The code is transparent to the ordinary cloze question as these vertical and horizontal dispaly are declared by using for horizontal :MULTICHOICE_H or MCH vertical : MULTICHOICE_V or MCV The mdl_question_multiplechoice layout field being used to store 0 -> default select elelement 1-> vertical 2->horizontal. two lines of code need to be added to the multichoice/questiontype.php so that the layout parameter is updated . @@ -105,6 +105,9 @@ } $options->answers = implode(",",$answers); $options->single = $question->single; + if(isset($question->layout)) { + $options->layout = $question->layout; + } $options->answernumbering = $question->answernumbering; $options->shuffleanswers = $question->shuffleanswers; $options->correctfeedback = trim($question->correctfeedback); The multipleanswer/questiontype.php integrate the code of the multichoice/questiontype.php and multichoice/display.html using a table to contain the answers and the feedback. This let the user use available HTML code from the HTML editor create a display that encounters its needs. As the only changes to the cloze text are the new MCV and MCH terms this modification will be easily merged to 1.9 or older version if necessary.
          Hide
          Pierre Pichet added a comment -

          Further testing the XML import and export shows that everything is OK so I will CVS to HEAD.
          Backup and restore should work as this is the same questions and subquestion structure.

          Show
          Pierre Pichet added a comment - Further testing the XML import and export shows that everything is OK so I will CVS to HEAD. Backup and restore should work as this is the same questions and subquestion structure.
          Hide
          Pierre Pichet added a comment - - edited

          The various tests show that the code is OK.
          todo: help and doc with example and merging to older version.
          Tim
          the actual multianswer code decode the question text using regexp and for doing so define some constants outside the multianswer questions type.
          line 867 of multianswer/questiontype.php
          /////////////////////////////////////////////////////////////
          //// ADDITIONAL FUNCTIONS
          //// The functions below deal exclusivly with editing
          //// 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.
          /////////////////////////////////////////////////////////////

          // ANSWER_ALTERNATIVE regexes
          define("ANSWER_ALTERNATIVE_FRACTION_REGEX",
          '=|%(-?[0-9]+)%');
          // for the syntax '(?<!' see http://www.perl.com/doc/manual/html/pod/perlre.html#item_C
          define("ANSWER_ALTERNATIVE_ANSWER_REGEX",
          '.+?(?<!\\\\|&|&)(?=~#}|$)');
          define("ANSWER_ALTERNATIVE_FEEDBACK_REGEX",
          '.*?(?<!\\\\)(?=[~}]|$)');
          define("ANSWER_ALTERNATIVE_REGEX",
          '(' . ANSWER_ALTERNATIVE_FRACTION_REGEX .')?' .
          '(' . ANSWER_ALTERNATIVE_ANSWER_REGEX . ')' .
          '(#(' . ANSWER_ALTERNATIVE_FEEDBACK_REGEX .'))?');

          // Parenthesis positions for ANSWER_ALTERNATIVE_REGEX
          define("ANSWER_ALTERNATIVE_REGEX_PERCENTILE_FRACTION", 2);
          define("ANSWER_ALTERNATIVE_REGEX_FRACTION", 1);
          define("ANSWER_ALTERNATIVE_REGEX_ANSWER", 3);
          define("ANSWER_ALTERNATIVE_REGEX_FEEDBACK", 5);

          and also the function
          function qtype_multianswer_extract_question($text) {

          I think that this should be changed because of plug-ins.
          How can these constants be "define" inside a class ( in PHP5 and if different in PHP4)?
          PHP5 which is the only one in 2.0
          and PHP4 because 1.9 will be the Moodle for servers that are not migrating to PHP4...

          Show
          Pierre Pichet added a comment - - edited The various tests show that the code is OK. todo: help and doc with example and merging to older version. Tim the actual multianswer code decode the question text using regexp and for doing so define some constants outside the multianswer questions type. line 867 of multianswer/questiontype.php ///////////////////////////////////////////////////////////// //// ADDITIONAL FUNCTIONS //// The functions below deal exclusivly with editing //// 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. ///////////////////////////////////////////////////////////// // ANSWER_ALTERNATIVE regexes define("ANSWER_ALTERNATIVE_FRACTION_REGEX", '=|%(-? [0-9] +)%'); // for the syntax '(?<!' see http://www.perl.com/doc/manual/html/pod/perlre.html#item_C define("ANSWER_ALTERNATIVE_ANSWER_REGEX", '.+?(?<!\\\\|&|&)(?= ~#} |$)'); define("ANSWER_ALTERNATIVE_FEEDBACK_REGEX", '.*?(?<!\\\\)(?= [~}] |$)'); define("ANSWER_ALTERNATIVE_REGEX", '(' . ANSWER_ALTERNATIVE_FRACTION_REGEX .')?' . '(' . ANSWER_ALTERNATIVE_ANSWER_REGEX . ')' . '(#(' . ANSWER_ALTERNATIVE_FEEDBACK_REGEX .'))?'); // Parenthesis positions for ANSWER_ALTERNATIVE_REGEX define("ANSWER_ALTERNATIVE_REGEX_PERCENTILE_FRACTION", 2); define("ANSWER_ALTERNATIVE_REGEX_FRACTION", 1); define("ANSWER_ALTERNATIVE_REGEX_ANSWER", 3); define("ANSWER_ALTERNATIVE_REGEX_FEEDBACK", 5); and also the function function qtype_multianswer_extract_question($text) { I think that this should be changed because of plug-ins. How can these constants be "define" inside a class ( in PHP5 and if different in PHP4)? PHP5 which is the only one in 2.0 and PHP4 because 1.9 will be the Moodle for servers that are not migrating to PHP4...
          Hide
          Pierre Pichet added a comment - - edited

          Tim,
          Could you revise the help text before I put it on 1.9.3
          The code for the new display is already on 1.9.3.
          In 1.9.3 do I put this as help/quiz/multianswer.html or as help/qtype_multianswer/multianswer.html as in 2.0?
          The help/qtype_multianswer/multianswer.html does not seem to work on 1.9.3 although there is a similar help/qtype_multichoice/multichoice.html.

          Show
          Pierre Pichet added a comment - - edited Tim, Could you revise the help text before I put it on 1.9.3 The code for the new display is already on 1.9.3. In 1.9.3 do I put this as help/quiz/multianswer.html or as help/qtype_multianswer/multianswer.html as in 2.0? The help/qtype_multianswer/multianswer.html does not seem to work on 1.9.3 although there is a similar help/qtype_multichoice/multichoice.html.
          Hide
          Tim Hunt added a comment -

          multianswer_tjh.html is my attempt, with the language edited slightly, and the HTML cleaned up.

          Show
          Tim Hunt added a comment - multianswer_tjh.html is my attempt, with the language edited slightly, and the HTML cleaned up.
          Hide
          Pierre Pichet added a comment -

          From a suggestion of Tieku Bortei-Doku I will eliminate the numbering and let the user add it at its convenience
          see http://moodle.org/mod/forum/discuss.php?d=96799#p484226

          Show
          Pierre Pichet added a comment - From a suggestion of Tieku Bortei-Doku I will eliminate the numbering and let the user add it at its convenience see http://moodle.org/mod/forum/discuss.php?d=96799#p484226
          Hide
          Pierre Pichet added a comment -

          Everything seems to be set even the help file and comments are positive on forum.

          Show
          Pierre Pichet added a comment - Everything seems to be set even the help file and comments are positive on forum.
          Hide
          Tim Hunt added a comment -

          Reviewed code. Looks OK. Thanks.

          Show
          Tim Hunt added a comment - Reviewed code. Looks OK. Thanks.
          Hide
          Joseph Rézeau added a comment -

          Just tested latest version of multianswer questiontype.php,v 1.41.2.16 2009/01/26 01:27:16 pichetp with moodle 1.9.4.
          I have used the online Help example provided to create a multianswer/cloze question.
          I am using standard theme.

          The display is not correct, the questions following a vertical or horizontal multiple choice question are displayed to the right of the table instead of below ; see attached screenshot JR (1).

          The only way I have found to get a correct display of the online Help example is to style the paragraphs following those MCQ questions with a clear:both CSS style. It does work but the correct display should be provided by the multianswer/cloze question type itself, rather than resorting to this hack. see screenshot JR (2).

          Joseph

          Show
          Joseph Rézeau added a comment - Just tested latest version of multianswer questiontype.php,v 1.41.2.16 2009/01/26 01:27:16 pichetp with moodle 1.9.4. I have used the online Help example provided to create a multianswer/cloze question. I am using standard theme. The display is not correct , the questions following a vertical or horizontal multiple choice question are displayed to the right of the table instead of below ; see attached screenshot JR (1). The only way I have found to get a correct display of the online Help example is to style the paragraphs following those MCQ questions with a clear:both CSS style. It does work but the correct display should be provided by the multianswer/cloze question type itself, rather than resorting to this hack. see screenshot JR (2). Joseph
          Hide
          Pierre Pichet added a comment -

          Thanks Joseph for your continuous testing and suggestions.

          I have noticed that the following questions are not displayed correctly strictu sensu.
          However they are in-line. The problem being the way HTML rendering works with <table> element.
          I prefer to let this as a simple <table> element to give all the flexibility to the user.

          However it will be nice if you could put additional info in moodle docs on how to get different displays of these table elements using CSS.

          The actual help is already quite long but I can add a specific reference once you have set moodle docs.

          You could also suggest a totally new example to put in the help that will illustrate more clearly all these new options.

          I think that this is more an help problem than a question code one.
          Perhaps you could start a new bug about the help text so we can cloze this one?

          Show
          Pierre Pichet added a comment - Thanks Joseph for your continuous testing and suggestions. I have noticed that the following questions are not displayed correctly strictu sensu. However they are in-line. The problem being the way HTML rendering works with <table> element. I prefer to let this as a simple <table> element to give all the flexibility to the user. However it will be nice if you could put additional info in moodle docs on how to get different displays of these table elements using CSS. The actual help is already quite long but I can add a specific reference once you have set moodle docs. You could also suggest a totally new example to put in the help that will illustrate more clearly all these new options. I think that this is more an help problem than a question code one. Perhaps you could start a new bug about the help text so we can cloze this one?
          Hide
          Tim Hunt added a comment -

          Does it fix the problem if you add class="clearfix" to the tables in the HTML?

          Show
          Tim Hunt added a comment - Does it fix the problem if you add class="clearfix" to the tables in the HTML?
          Hide
          Joseph Rézeau added a comment -

          The attached patch multianswerpatchjr.txt (against current 1.9.4 version) works fine.
          Joseph

          Show
          Joseph Rézeau added a comment - The attached patch multianswerpatchjr.txt (against current 1.9.4 version) works fine. Joseph
          Hide
          Joseph Rézeau added a comment -

          patch by Joseph Rézeau to get correct display after feedback tables in MCQ horizontal and vertical display tables.

          Show
          Joseph Rézeau added a comment - patch by Joseph Rézeau to get correct display after feedback tables in MCQ horizontal and vertical display tables.
          Hide
          Pierre Pichet added a comment -

          The <table> are already <table class="answer"> as in multichoice so that they will be rendered like multichoice.
          The Joseph patch is to add <div class="clearfix"></div> after the table .
          I did not add any formatting to the question text as I want to give complete freedom to the users.
          If we look at the forum the horizontal or vertical displays will be mostly used for a complete list of similar questions and the resulting tables will be displayed correctly.
          The forum feedbacks were satisfied with the actual code.

          The <div class="clearfix"></div> trick could be inserted in the help text.

          If there is a sufficient feedback from the users, we could do fix following Joseph patch.

          Show
          Pierre Pichet added a comment - The <table> are already <table class="answer"> as in multichoice so that they will be rendered like multichoice. The Joseph patch is to add <div class="clearfix"></div> after the table . I did not add any formatting to the question text as I want to give complete freedom to the users. If we look at the forum the horizontal or vertical displays will be mostly used for a complete list of similar questions and the resulting tables will be displayed correctly. The forum feedbacks were satisfied with the actual code. The <div class="clearfix"></div> trick could be inserted in the help text. If there is a sufficient feedback from the users, we could do fix following Joseph patch.
          Hide
          Joseph Rézeau added a comment -

          Pierre, I leave it up to you to decide whether to apply my patch or not. I agree that my patch is only needed if a multianswer question is not made of a succession of MCQ questions of the same type...
          Joseph

          Show
          Joseph Rézeau added a comment - Pierre, I leave it up to you to decide whether to apply my patch or not. I agree that my patch is only needed if a multianswer question is not made of a succession of MCQ questions of the same type... Joseph
          Hide
          Pierre Pichet added a comment -

          Let do it by modifying the help file .
          Coul you suggest a new example for the help file.

          Show
          Pierre Pichet added a comment - Let do it by modifying the help file . Coul you suggest a new example for the help file.
          Hide
          Tim Hunt added a comment -

          I was actually suggesting changing <table class="answer"> to <table class="answer clearfix">.

          My feeling is that more people would prefer it with that there. I think it is the behaviour more people would expect. However, I am happy to leave it up to your judgement.

          Show
          Tim Hunt added a comment - I was actually suggesting changing <table class="answer"> to <table class="answer clearfix">. My feeling is that more people would prefer it with that there. I think it is the behaviour more people would expect. However, I am happy to leave it up to your judgement.
          Hide
          Pierre Pichet added a comment -

          This seems to vary following other variables like here a display in explorer from a preview.
          The text is put after the table element.
          So let the code as it is and practice a wait and see policy on the forum.
          These improvments were done because of forum posts.
          As usual http://132.208.141.198/moodle_19/
          user:moodle pw:moodle
          Josph if you agree, close it

          Show
          Pierre Pichet added a comment - This seems to vary following other variables like here a display in explorer from a preview. The text is put after the table element. So let the code as it is and practice a wait and see policy on the forum. These improvments were done because of forum posts. As usual http://132.208.141.198/moodle_19/ user:moodle pw:moodle Josph if you agree, close it
          Hide
          Joseph Rézeau added a comment -

          Tim Hunt added a comment - 03/Feb/09 02:15 PM
          > I was actually suggesting changing <table class="answer"> to <table class="answer clearfix">.

          No, Tim, that won't work. What we need is to clear AFTER the table, not BEFORE, as clearfix will do! My suggested hack does just that.
          Joseph

          Show
          Joseph Rézeau added a comment - Tim Hunt added a comment - 03/Feb/09 02:15 PM > I was actually suggesting changing <table class="answer"> to <table class="answer clearfix">. No, Tim, that won't work. What we need is to clear AFTER the table, not BEFORE, as clearfix will do! My suggested hack does just that. Joseph
          Hide
          Tim Hunt added a comment -

          Joseph, look at what the clearfix rule does. It clears at the end of the current div, not at the start.

          Oh, but that may not work if you put it on the floated element itself.

          Show
          Tim Hunt added a comment - Joseph, look at what the clearfix rule does. It clears at the end of the current div, not at the start. Oh, but that may not work if you put it on the floated element itself.
          Hide
          Joseph Rézeau added a comment -

          Tim > Oh, but that may not work if you put it on the floated element itself.
          I think it does not work because <table class="answer"> is already included in a clearfix div...
          Again, my fix seems the only working solution.
          Joseph

          Show
          Joseph Rézeau added a comment - Tim > Oh, but that may not work if you put it on the floated element itself. I think it does not work because <table class="answer"> is already included in a clearfix div... Again, my fix seems the only working solution. Joseph

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: