Improving the multianswer(cloze) question, a proposal

Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -
Number of replies: 56
Most questiontypes contains 1 question however the multianswer (cloze) questiontype can contain more than one question. So actually when you use a cloze question with more than one question you don't have access to a detailed grading of your different answers as a student and as a teacher you don't have access to the item analysis report.
Also the actual display of cloze questions does not correspond to the new accessibility standards set-up for user interface when filling a quiz.
I am working on a multiquestion calculated version of the actual calculated question and setting correctly the cloze question type appears to be a first step before implementing the calculated one.

So should we split cloze questions like the example in the docs
cloze
cloze.JPG
to something like this first example (the individual subgrades are not displayed already)

preview

Eventually the cloze subquestions could be numbered or considered as individual questions.

Pierre

P.S.
Technically:
$question->length parameter stored in the question table was originally defined as the number of questions contained in one question. It is mostly used to control the quiz display.
For most questiontypes it has the value of 1.
For the description type it has the value of 0 .

This type of question is not really a question.
All it does is print some text without requiring any answers.
It can be used to print a descriptive text to be used by a following group of questions.

In the actual (moodle head ) code the questiontype function to access this parameter is
2 definitions:
and one reference in type/questiotype.php in
function save_question($question, $form, $course)
 $question->length = $this->actual_number_of_questions($question);

The $question->length is accessed also directly in

moodle_head\mod\quiz\attempt.php(473): $number += $questions[$i]->length;
moodle_head\mod\quiz\editlib.php(260): echo '<td>'.($question->length ? $qno : '&nbsp;').'</td>';
moodle_head\mod\quiz\editlib.php(261): $qno += $question->length;
moodle_head\mod\quiz\review.php(270): $number += $questions[$i]->length;
essentially so that question number does not increase if a questiontype description is used in the quiz.






Average of ratings: -
In reply to Pierre Pichet

Re: Improving the multianswer(cloze) question, a proposal

by chhivhorng ly -
Now, I used quiz already but all the question in quiz we can create one by one.
but I want to create more questions support more answer by one time.
Today I use Moodle1.7.1+
I can't use

Embedded Answers (Cloze)

it show me like this
please tell me the solution to resolve it.

best regards,
chhivhorng

Attachment embed.JPG
In reply to chhivhorng ly

Re: Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -
Have you tried to create a cloze question using the example that can be found in the help of cloze question i.e.
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} and right after that you will have to deal with this short answer {1:SHORTANSWER:Wrong answer#Feedback for this wrong answer~=Correct answer#Feedback for correct answer~%50%Answer that gives half the credit#Feedback for half credit answer} and finally we have a floating point number {2:NUMERICAL:=23.8:0.1#Feedback for correct answer 23.8~%50%23.8:2#Feedback for half credit answer in the nearby region of the correct answer}.

Note that addresses like www.moodle.org and smileys smile all work as normal:
a) How good is this? {:MULTICHOICE:=Yes#Correct~No#We have a different opinion}
b) What grade would you give it? {3:NUMERICAL:=3:2}

Good luck!


Pierre
In reply to Pierre Pichet

Re: Improving the multianswer(cloze) question, a proposal

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hello Pierre,

The new layout of the cloze (multianswer) question type that you propose is quite different from what I consider to be the original philosophy of the cloze question. The original idea of a cloze text it to present the student with a running text with blanked out words to be restored.

What you are suggesting is in fact a new question type consisting of a set of sub-questions.

I quite agree with your statement that as it is in moodle the Cloze question poses the problem that "you don't have access to a detailed grading of your different answers as a student and as a teacher you don't have access to the item analysis report".

However, although there is no detailed grading of individual blanks in the Cloze question, there is both the feedback colors (green, orange and red) plus the individual feedback.

If you decide to go the way you are suggesting, may I suggest that you make this a new question type but leave alone the present layout of the Cloze question which is very useful for quizzes in language teaching, for instance. Maybe we have differing views in this matter because you teach science whereas I teach languages.wink

All the best,

Joseph

In reply to Pierre Pichet

Re: Improving the multianswer(cloze) question, a proposal

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I think I agree with Joseph. The existing Cloze question if very useful as it is, and a lot of people would be unhappy if it changed radically.

So a new question type for your new idea would probably be better, especially as some things in the Cloze question type are a bit of a mess, and starting from scratch you may be able to do better.

However, maybe I am missing something, but with your example, why can't you just put several separate questions on one page?
In reply to Tim Hunt

Re: Improving the multianswer(cloze) question, a proposal

by Stefan Eberhard -
I have several proposals for the new "Cloze"-questiontype
  • There should be a difference between the main-part of the question (which is really more like a quiz) and the sections (the questions themselves)
  • important: the sections should have negative scores, so that a negative score in one or more sections decreases the score of the main question.
  • less important: check-box questions instead of using "yes" or "no" in tables would be very comfortable
This new questiontype could solve the unresolved problem of the negative score without messing up everything.

This tread is quite long, but only a few people use it to discuss this very important problem. That´s a little disapointing.



In reply to Pierre Pichet

Re: Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -
Hi Tim and Joseph
Your remarks about the utility of a "user friendly (if you know what you are doing)" style of creating cloze question are what I was expecting.
However the actual cloze interface for the student i.e the answer as displayed does not respect the new norms for accessibility that Moodle at large want to respect.
This is why in my project for a multianswer calculated question I program the output for multichoice using the new question display.
So
  1. my first proposal is: Should we (Moodle) or not use the new accessibility interface to display the "cloze" question?
  2. my second proposal is: Should we use the same interface(that respect the accessibility) to create a new question that the one we use for all other question types.
Here an example of what I have done for the extended calculated question.
The text is entered with {#1}, {#2} that set the position of the answers in the text
texte
then the parameters are entered as usual if the {#2} is a regular calculated question
calculated

or as a multichoice if {#0} is a multichoice

multichoice.jpg

I understand that the teacher creation display is more complex or crowded than the usual cloze
However the parameters are clear and can be checked in the validation process.

Pierre
P.S. This is not a new cloze question type it is just a new interface.
P.S. as for the number of questions in a question this is just one of the aspect of quiz rendering and report analysis for these multianswer types.
In reply to Pierre Pichet

Re: Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -
As an example for the second proposal (the question editing interface) this could get you the following interface if you are editing a multichoice (and that we allow multiple responses which are not allowed actually to conserve a simple display with a select element).
proto1

Pierre


In reply to Pierre Pichet

Re: Improving the multianswer(cloze) question, a proposal

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Pierre, I don't think you have yet answered my question "However, maybe I am missing something, but with your example, why can't you just put several separate questions on one page?"

Anyway, I think the best way to manage a change of this magnitude is to implement it initially as a new question type plugin. Then people can try it and give feedback based on actual use, and we can defer the decision about whether to include it in the standard release until after there is a working version to try.
In reply to Tim Hunt

Re: Improving the multianswer(cloze) question, a proposal

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Tim,

I agree with all of your remarks. Actually, things would be more clear if we kept as separate matters the teacher (i.e. authoring) and the student interfaces for the Cloze question type.

May I point out that I have already proposed a workaround for a better authoring interface with my clozejr small hack. I have not revised it recently so can't guarantee it would work with moodle 1.8 or 1.9.

And also Adriane Boyd had planned to work on improving the authoring interface so it might be a good idea for Pierre to contact Adriane before embarking upon major work in this field.

I am not too much bothered with the accessibility issue or rather I do not think that we can ever be 100% accessible (if that means something).

Pierre, could you illustrate your proposed new interface with questions other than the calculated type? with running text? Otherwise I agree with Tim that I don't see the point of having a Cloze question which does not look very different from several separate questions displayed on one quiz page...

Joseph

In reply to Joseph Rézeau

Re: Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -
Joseph,
Thanks for your comments and if somebody else is doing it, I will not go further.
I will add today (tonight for you) a more complete view my interface proposal using the example in Moodle Help.
In the database the main question is stored as
 This question consists of some text with an answer embedded right here {#1} and right after that you will have to deal with this short answer {#2} and finally we have a floating point number {#3}.

Note that addresses like www.moodle.org and smileys :-) all work as normal:
 a) How good is this? {#4}
 b) What grade would you give it? {#5}

Good luck!
So you can see the analogy with the new calculated example
"See you later"wink

Pierre

In reply to Tim Hunt

Re: Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -
Tim,
Just forget about the splitting of the cloze question.
I was not clear in my proposal.
I want to use $question->length parameter in the reports code so that it can be used to identify multianswer question like cloze. I put my search result in a quiz question about the legitimity of using it.
However I realized that my new calculated code was build around the cloze question code so wrote this proposal but kept my search results in it.

Pierre

In reply to Pierre Pichet

Re: Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -
Here is an example of my proposal for the teacher editing interface using the example in help.
ex1

ex2

ex1
etc and
ex1

the complete image can be seen here with some code output that show the raw question data.
I have to remove all editors for the answers feedback because the page become too long.
Note that the main parameters have been extracted from the data.
This first model cannot save the datasmile .
I you approve, i can continue the work.

Pierre
In reply to Pierre Pichet

Re: Improving the multianswer(cloze) question, a proposal

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Pierre,
At first sight your proposed teacher interface looks ok to me. I have one reservation: it looks as if you only envisage that there can be 3 types of sub-questions within one Cloze question: multichoice, short answer and numerical. How about other types (e.g. calculated or my own regexp?). Instead of having 3 "pre-set" buttons, why not have a drop-down list of all acceptable existing types to be used?
Joseph
In reply to Joseph Rézeau

Re: Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -
Joseph,
In an ideal world of complete transparent plug-in code including other question types in the cloze questiontype would be an easy task like your hack when you include a complete quiz in a cloze question. However real world is not so simple.
Considering your remarks and those of Tim about the utility of the cloze questiontype as a tool to include mostly language questions in a text, I decide to maintain the actual output style of the cloze questiontype even if it does not adhere to all the accessibility standards. So in the final version the multiple answer for multichoice questiontype will not be offered because it does not output simply in a line of text but as a table. Also including it, the code need to be adapted to the fact that in this case you have more than one valid answer in one valid response. This is one of the reason why I cannot put an open list of questiontypes.
I have seen somewhere in the forum that Tim prefer to limit the "official" questiontype and because of the regexp function complexity maintain your regexp questiontype at the plug-in status. One of the advantage of my proposal is the addition of error analysis of the different question parameters and I don't think that regexp expression can be easily verified. I must admit that there complexity sometimes horified mewink.
I just download your regexp code and I will see if it can be include "easily" in the cloze question. In such a case, it could be a fourth option for the cloze question. At first look, perhaps your alternative answers function should be dropped?

Pierre
In reply to Pierre Pichet

Re: Improving the multianswer(cloze) question, a proposal

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
It is nothing to do with the complexity, or otherwise, of the regexp question type that determines whether it goes into the official Moodle release.

The issue is long term support. Once it is in the official distribution, ultimate responsibility for fixing bugs in it falls to the quiz/question bank maintainer. That is, me. As long as it is in contrib, Joseph is responsible for looking after it, which he does very well.

The problem with question type plugins not being able to plug into the Cloze question type is MDL-6371. It is probably the most significant issue left that is part of MDL-2727, now we have dealt with MDL-6367 (import and export) over the summer.

MDL-6371 is hard. If I was trying to solve it, I would use the fact that Cloze format is very similar to GIFT import format (although the two use different code for extracting the questions). If you could make the Cloze question type use the GIFT import and export class (which would need some modifications), then that would solve editing Cloze questions. You would also need to change Cloze so that it used methods from the other question type classes for rendering questions and grading responses, rather than the way it works now. Altogether a big job, and not one that is anywhere on my todo list.
In reply to Tim Hunt

Re: Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -
Hi Tim,
"You would also need to change Cloze so that it used methods from the other question type classes for rendering questions and grading responses, rather than the way it works now."
  1. rendering and grading :This is my first proposal and I have already solved it for the new calculated which renders the multichoice in the standard way.So I can put it on my to-do listsmile
  2. rather than the way it works now: in the same forum item you seem to agree to the actual rendering i.e. the answers are displayed linearly in the text. Can I conclude that you want me to render them as shown in the new calculated example showed on the beginning of this forum item?
  3. I already agree elsewhere on the forum about the problem of maintaining the "official" moodle questions to their actual number.
  4. I think also that maintaining the cloze question to its actual options (i.e short, numerical and multichoice) is also part of the game.
  5. Because of he complexity of calculated question, the new calculated multiquestion will be the way to have the cloze option for this question type. I have design it so that the subquestions could be simple numerical ones .
Pierre
P.S. I will look at the bugs and comment later.

In reply to Pierre Pichet

Re: Improving the multianswer(cloze) question, a proposal

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
2. No, you can't conclude that. The current rendering is what we want. The code architecture that produces it is what is wrong.

4. I disagree. The position that we should be very, very hesitant before introducing new question types is only defensible if other question types are in no way second-class citizens - that is, there are no serious restriction on what they can do.

5. I look forwards to seeing this new question type.
In reply to Tim Hunt

Re: Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -
5. I look forwards to seeing this new question type.
You have a look of the rendering in the upper part of this discussion.
The editing interface is just a little lower.
When you create a new question or edit an actual question the initial interface is almost identical except for the submit button to "change to multichoice question" and at the end a submit button to add a new question.
The multichoice option was created because often quizzes use this form to limit the amount of calculation but wnat to test the knowledge on how to calculate the response.
The subquestions are necessary if you want ask many questions with the same dataset. This synchronization cannot be done easily in the quizz code.
In reply to Tim Hunt

Re: Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -
"If you could make the Cloze question type use the GIFT import and export class then that would solve editing Cloze questions."

Reading this twice I realize that there is some misunderstanding or misconception on my part.
It seems that you want to maintain two ways to build problems in Moodle i.e. through
  1. Standard interface with complex form interface on which you have done a lot of work so that they are meaningfull and validate the prarmeters so that there is no problems when using them in the quiz.
  2. Literal interface that can created by a simple text editor and inputed in Moodle using the GIFT fomat.
From your comments the Cloze question appears to be a Literal interface questiontype so the actual Cloze editing interface is OK and my proposal is not necessary. Perhaps.
However as we are on the forum, I will argue that in 2007, peoples are quite at ease in filling computer forms for all aspects of their life even when buying on eBay.
Moodle should migrate as possible to a Standard interface creating and validation mode for the questions use in quizzes as they are part of the student grading process.
On the other end Cloze should remain limited to standard questiontypes so that we could offer a Standard interface creating and validation process that is easy to maintain.
New plug-ins should be of the Standard interface type to assure that they integrate correctly in the quizzes.

Pierre
In reply to Pierre Pichet

Re: Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -
Continuing the preceeding:
Suppose that we follow your objectives about Cloze question
  1. Pierre :"so that maintaining the cloze question to its actual options (i.e short, numerical and multichoice) is also part of the game."
    Tim :
    "I disagree. The position that we should be very, very hesitant before introducing new question types is only defensible if other question types are in no way second-class citizens - that is, there are no serious restriction on what they can do."
  2. Tim :No, you can't conclude that. The current rendering is what we want. The code architecture that produces it is what is wrong.
  3. Tim:If you could make the Cloze question type use the GIFT import and export class (which would need some modifications), then that would solve editing Cloze questions. You would also need to change Cloze so that it used methods from the other question type classes for rendering questions and grading responses, rather than the way it works now.
I think that we need to precise the role of future Cloze questiontype.
  • we build a new Cloze code that works transparently for any plug-ins using as possible the code of the plug-in to edit, render and grade the question.
    1. The Cloze question become an almost complete quiz in a quiz.
    2. The plugins need to have a new rendering function that can be used by the Cloze to render the question, edit, validate grade etc. in the Cloze way which is not the Standard way .
  • The plugins that want to use Cloze should be able to be imported and exported by Gift which restrict these mostly to litteral plugins.
Pierre
P.S. Actually either to code the Cloze edition interface or the actual Cloze display part of code are derived from the questiontypes that work in Cloze (short,numerical,multichoice) but not always by using qtype->functions but by cut and paste from the questiontypes which is why I propose to limit the Cloze. However we can create new questiontype functions to get all internal Cloze code transparent to the editing,rendering. etc. At least a large project.
In reply to Pierre Pichet

Re: Improving the multianswer(cloze) question, a proposal

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I think you are still misinterpiting me slightly. Probably because I have been quite busy and therefore typing brief, cryptic messages.


The real confusion is that there are two different sorts of changes required to Cloze, and we have been talking about different ones.

As a developer, I look at the Cloze question as it currently is, knowing that the way it works now is useful to a lot of teachers, but what I see is that the code behind it is a mess. I want to clean up the mess, improve the architecture, eliminate copied code, and enable other question type plugins to work with it.

You are more of a teacher. You look at the interface for teachers and students, and realise that the interface for editing is very hard to use for non-technical people, and the student interface is still not fully accessible, despite the changes in 1.8.

We are both right. I am hoping that the work you are currently doing is trying to solve the second problem, now in a new question type, and I look forwards to a working version that lots of people can try and give comments on.


The point about GIFT is that what you have to type into the editing form for a Cloze question, in the questiontext field, looks a lot like GIFT import format, but is actually processed completely differently. That means two different pieces of code to maintain that do very similar things. That is a bad situation.

Similarly, in your P.S., you talk about more copy-and-pasted code that currenly exists withing Cloze. That is also bad. When I said above "You would also need to change Cloze so that it used methods from the other question type classes for rendering questions and grading responses, rather than the way it works now" I exactly mean get rid of the copy-and-pasted code, and replace it with calls to qtype-> methods. Using existing methods as far as possible, and inventing new ones where absolutely necessary.

Copy-and-paste code is evil because (expecially on an open source project with lots of developers working on the code), the two copies inevitably end up out of sync. Someone fixes a bug, and does not realise that there is another copy of the same code that needs to be fixed elsewere. The Pragmatic Programmers call this the DRY principal - Don't Repeat Yourself. They are absolutely right.

Any by using question type methods, it becomes possible to support other question types like regext in Cloze. That would be a good thing.


P.S. Beer: excellent idea. If only it were possible.
In reply to Tim Hunt

Re: Improving the multianswer(cloze) question, a proposal

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Tim > And by using question type methods, it becomes possible to support other question types like regexp in Cloze. That would be a good thing.

Yes, that sure woud be a good thing (I've been waiting for it to happen for about 2 years now...).wink

Joseph

In reply to Tim Hunt

Re: Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -
"I am hoping that the work you are currently doing is trying to solve the second problem, now in a new question type, and I look forwards to a working version that lots of people can try and give comments on."
"realise that the interface for editing is very hard to use for non-technical people, and the student interface is still not fully accessible, despite the changes in 1.8."
  1. I conclude that you agree that my proposal for a new interface as shown on this discussion, for editing Cloze is OK (Joseph agree) and I should continue to work on it.
  2. I conclude that it is OK if I improve the Cloze interface for student following the actual interface for the question types but perhaps more compact so it will not interfere to much in text display. I can then create new qtype->functions like , cloze_useable(), print_cloze_question() so that qtype that want to be used in Cloze will fill their code(). I will create ones for the current questiontypes (short,numerical,multichoice).
  3. I am hoping that the work you are currently doing is trying to solve the second problem, now in a new question type:
    Calculated question type with the specific needs about the datasets should remain out of the Cloze and with its own structure.Even the multichoice option in the calculated has particular needs so its code remains in calculated. However being similar to Cloze with their multiple answers, they should use similar code for grading and quiz report. This is why I am waiting for CVS the new calculated code so that I develop a model for question types (plugins) that have multiple answers.
  4. that what you have to type into the editing form for a Cloze question, in the questiontext field,
    Have a closer look of the interface on my proposal up in this discussion and you will find that their syntax is quite different.
    You write a text and put {#1},
    {#2} where you want the question{#1},{#2} to be placed.
    I don't think that Cloze should use Gift because this is too limiting. The normal way to create a Cloze question will be the new qtype open code Cloze interface. The MoodleXML should be able to handle subquestions so that means also to modify the import, export main files so that it handle subquestions on input specially i.e. not saving directly the question in the database. I will propose a solution to Howard.
Pierre


In reply to Tim Hunt

Re: Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -
Having open Cloze main problem could be to have qtype->editingform.php completely open i.e the code to display and validate the specific part of the question edition display. Just look at the actual code for multichoice or numerical questions.
Pierre
In reply to Pierre Pichet

Re: Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -
If we take the edit_numerical_form to illustrate the problem, the inner function is defined as

  • display the answer
  • the grading details
    • tolerance
    • grade
    • feedback
    • add tolerance $creategrades = get_grade_options();
      $gradeoptions = $creategrades->gradeoptions;
  • display the units
There could be also functions to modify the upper part (question text general feedback etc.
so we will need at least 5 functions to separate the inner function
  1. modification to the question general display
  2. display specific parameters (like in multichoice)
  3. display the answer
  4. the grading details
  5. other components
and similarly for the default settings
another function will be need to extract them from the form as the subquestion specific elements will all be named with a prefix that identify them correctly in the common edit_Cloze_form.php
So at least 11 new questiontype functions...
Flexibility as a price.

Pierre
P.S. each element has to be renamed with a specific prefix like "sub_1" given to the new functions as a parameter so that
$repeated[] =& $mform->createElement('text', 'answer', get_string('answer', 'quiz'));
becomes
$repeated[] =& $mform->createElement('text', $prefix.'answer', get_string('answer', 'quiz'));


In reply to Pierre Pichet

Re: Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -
Preliminary tests using the display of the units interface that is specific to numerical question show that this is quite easy to create those functions.
The unit values entered in the numerical format has to be hidden when another questiontype is displayed so you can go back and forth and this was already done in initial proposal.
However if there is a list of 12 questiontypes that could use the cloze question,the code has to be writen well to handle this hidden state when the questiontype is not the active one.
How many of those functions we need, has to be correctly evaluated as they should correctly fill the need of the future plugins.
So back to the future, which is quite interesting at my agesmile..

Pierre

In reply to Pierre Pichet

Re: Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -

Globally the project will necessitate that questiontypes that want to be useable in Cloze will furnished specific functions for the edition and the rendering etc. following guidelines from Cloze.
We have to do it this way because the rendering of the $question->options is also the part that is not standardized (with the exception perhaps of the answer record i.e answer, fraction and feedback) by its own nature.
I am working on this and come back later (1-2-3..days) with a list of specs probably more in the docs, I will see.

Pierre
P.S. Building some prototypes before putting it in text...as a good chemist, lab first...

In reply to Pierre Pichet

Re: Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -
For the edition display the principal code of the function definition_inner(&$mform) of the edit_questiontype_form.php is put in the questiontype.php as a function having supplementary parameters that can be filled by the cloze question
function definition_inner_answer(&$mform,$prefix='',&$that,$question,$prehdr='') {
The
  • $prefix allow to identify the parameter on the edit_cloze_form for example "sub_1".
  • $prehdr typically "Question {#1}" allows to identify the elements on the display.
  • $that is the reference to the cloze_edit_form object i.e $this. There is perhaps another way to do this, but its works.
Similar functions should be created for the default setting and validation.
Finally the common answer, fraction and feedback as long as they have the same name in the different qtypes they are transfered from one questiontype to another so there is no hidden parameters to maintain.

The questiontype should use this function in its own edit_question_type_form.php.

For the rendering the case could be different as we want that it can be included in a text without breaking all the display. If the question do not fill this requirement, it should be used as regular question in a quiz.
So we need a questiontype function is_question_clozeable() .

Pierre


In reply to Pierre Pichet

Re: Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -
I have a Cloze editing form display identical to the one show up in this discussion build on the transfer of actual code of the edit_qtype(i.e numerical)_form.php-> definition_inner to the same code with a new function call put in the respective gtype/questiontype.php as explained in the last posting.
I have also change the edit_qtype(i.e numerical)_form.php-> definition_inner() so that it use also this new function.
Everything is OK.
I will apply this to the three initially useable questiontypes in Cloze i.e. short,numerical and multichoice and come back with the results.

Tim, do you agree with my proposal to put most of the code of the edit_qtype(i.e numerical)_form.php in the qtype/questiontype.php so that it can be used by Cloze unless you have another way to do the same code sharing?
My proposal does not necessitate the creation of a new common questiontype function although this could perhaps be good. On the other end these are not general function in the sense that they will be used after a call to is_cloze_useable() and some questiontypes are not cloze_useable.

You are the expert for the PHP class and I am the expert for the classroomsmile.

Pierre
P.S. I am using the forum although this should (or could) be done in the Tracker because UQAM is filtering again the email from the tracker and the watching is not working. When the code is ready ,I will use the tracker as usual.
In reply to Pierre Pichet

Re: Improving the multianswer(cloze) question, a proposal

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I don't think this should go in CVS yet. I would like to see a patch in the tracker to review once the code is relatively finished.

But more important would be a demonstration area where other teachers in this forum who use the Cloze question can try out the modifications, and comment on how well the new interface will work for them.
In reply to Tim Hunt

Re: Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -
Tim,
I understand that you approve the general plan and I agree with you that this is not ready for the CVS. There are a lot of work before the final product.
I will set a moodle site so that other teachers (Joseph...) can test it and comment.
Can you comment on these point
  1. Cloze should be "reserved" for questiontypes that insert themselves well in a text as it is use today. For example multichoice should be restricted to the single answer mode and display using a select element.
  2. We are not creating an universal quiz inside the quiz structure.
  3. To simplify the grading process, the question types using cloze should have only one answer.
  4. a is_Cloze_compatible() (or something else) function should be added to the questiontypes.I will document the specifications to be cloze compatible.
  5. transfering functions from the edit_questiontype_form code to questiontype is the way to do it.
  6. These function as they are use for the question type and Cloze but not necessary for the other questiontypes that do not use Cloze are not put in the general questiontype object.
Pierre


In reply to Pierre Pichet

Re: Improving the multianswer(cloze) question, a proposal

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
1. Yes. We can always make new question types to do different things.

2. I agree.

3. That is reasonable.

4. Something like that. We already have an is_usable_by_random, so is_usable_by_cloze would be more consistent.

5. This is the one that worries me. At the moment for the user-interface for editing questions is nicely incapsulated in the edit...form class. Can't is stay there? Why can't the edit_cloze_form call the methods from edit_shortanswer_form, and so on. That seems like a better design to me.

6. I agree.
In reply to Tim Hunt

Re: Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -
5."This is the one that worries me. At the moment for the user-interface for editing questions is nicely incapsulated in the edit...form class. Can't is stay there? Why can't the edit_cloze_form call the methods from edit_shortanswer_form, and so on. That seems like a better design to me."

When they are in the qtype/questiontype.php I can address them using QTYPES for example
$default_values = $QTYPES['shortanswer']->set_data($subquestion,'sub'."_$sub");

I don't know how to do this in edit...form.php unless I rewrite QTYPES.
I will not use the edit...form.php functions in their actual way because of the code flow (i.e. there are parent:function() references in them) so the functions I am creating in qtype/questiontype.php are different but I understand that if I can access them in an other way, they could be put in the edit...form.

Your suggestions

Pierre

In reply to Tim Hunt

Re: Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -
I had a closer look of the QTYPES which means the question objects has been included so if I include by a similar process the is_usable_by_cloze edit....form objects , this will do the work.
I try and come back with the results..

Pierre
In reply to Tim Hunt

Re: Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -
Tim.
I will need your help and or Jamie's one.
Actually if I understand it wellshy, the edit...form is not build to be called in multiple 'qtype' objects like questiontype.

Pierre

In reply to Pierre Pichet

Re: Improving the multianswer(cloze) question, a proposal

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Isn't there a method of the question type class to get the editing form.

I am thinking about the GRASP object oriented design patterns I learned from studying M885.
In reply to Tim Hunt

Re: Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -
Yes there is one
* Return an instance of the question editing form definition. This looks for a
* class called edit_{$this->name()}_question_form in the file
* {$CFG->docroot}/question/type/{$this->name()}/edit_{$this->name()}_question_form.php
* and if it exists returns an instance of it.
*
* @param string $submiturl passed on to the constructor call.
* @return object an instance of the form definition, or null if one could not be found.
*/

function create_editing_form($submiturl, $question, $category, $contexts, $formeditable) {
global $CFG;
require_once("{$CFG->dirroot}/question/type/edit_question_form.php");
$definition_file = $CFG->dirroot.'/question/type/'.$this->name().'/edit_'.$this->name().'_form.php';
if (!(is_readable($definition_file) && is_file($definition_file))) {
return null;
}
require_once($definition_file);
$classname = 'question_edit_'.$this->name().'_form';
if (!class_exists($classname)) {
return null;
}
return new $classname($submiturl, $question, $category, $contexts, $formeditable);
}
it is used by question.php
$mform = $QTYPES[$question->qtype]->create_editing_form('question.php', $question, $category, $contexts, $formeditable);
filled with some parameters
$toform = fullclone($question); // send the question object and a few more parameters to the form
$toform->category = "$category->id,$category->contextid";
if ($formeditable && $id){
$toform->categorymoveto = $toform->category;
}
$toform->returnurl = $returnurl;
$toform->movecontext = $movecontext;
if ($cm !== null){
$toform->cmid = $cm->id;
$toform->courseid = $cm->course;
} else {
$toform->courseid = $COURSE->id;
}
$toform->inpopup = $inpopup;

then a call
$mform->set_data($toform);

and the thing is launched

So before loosing myself in the HTML form labyrinth, I just ask if you know the Ariane's thread.

Pierre
In reply to Tim Hunt

Re: Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -
5. This is the one that worries me. At the moment for the user-interface for editing questions is nicely incapsulated in the edit...form class. Can't is stay there? Why can't the edit_cloze_form call the methods from edit_shortanswer_form, and so on. That seems like a better design to me.

I had Skype text exchange with Jamie and he confims that this will necessitate some core code changes and he will come back later with suggestions on how to do them
Pierre

In reply to Tim Hunt

Re: Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -
5. This is the one that worries me. At the moment for the user-interface for editing questions is nicely incapsulated in the edit...form class. Can't is stay there? Why can't the edit_cloze_form call the methods from edit_shortanswer_form, and so on. That seems like a better design to me.

I HAVE A QUITE SIMPLE SOLUTION FINALLY big grin
The objective was to put in each edit_question_qtype_form.php (so in the corresponding class) the functions created for displaying the options (answers, units etc.) either in the usual editing interface for the given qtype and in the multianswer display.
So we need in multianswer form to create the edit_question_qtype_form class and the corresponding object without creating its own display and parameters .

For short answer as an example
I fits add in the edit_shortanswer_form class the function

function question_edit_shortanswer_form($submiturl, $question, $category, $contexts, $formeditable = true,$go=true){
if( $go) parent::question_edit_form($submiturl, $question, $category, $contexts, $formeditable );
}
In the normal call from question.php the last parameter does not appears so the call proceed normally.

I add also the function definition_inner_answer(&$mform,$prefix='',&$that,$question,$prehdr) {
that was precedently created in the shortanswer/questiontype.php so then its stays where Tim want it.

In edit_multianswer_form I include the edit_shortanswer_form.php
require_once("{$CFG->dirroot}/question/type/shortanswer/edit_shortanswer_form.php");
then I do the following call
$QTYPES[shortanswerform]= new question_edit_shortanswer_form(1,2,3,4,5,false);
The last parameter being false,the question_edit_shortanswer_form object was created without any activation.
So the call to the definition_inner_answer() in edit_multianswer_form could be done in like this
$QTYPES['shortanswerform']->definition_inner_answer(&$mform,'sub'."_$sub",$this,$this->question->options->questions[$subsub[$sub]],get_string('questionno', 'quiz', '{#'.$sub.'}').'&nbsp;');

AND THE EDIT MULTIANSWER FORM DISPLAY CORRECTLY THE SHORTANSWER DATA


Pierre

P.S. The principle is there, the multianswer will use the is_usable_by_random() to select the usable edit_question_..._forms and create the respective objects.





In reply to Pierre Pichet

Re: Improving the multianswer(cloze) question, a proposal

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
That is about right, but I don't see the need for the $go parameter. It is quite dangerous to create an object without calling the parent class constructor unless you know exactly what is going on, and I don't know formslib that well.

You definitely don't want to be adding the editing forms to the global $QTYPES array! Instead, create a new array (which does not need or want to be global) $editingforms. So

$editingforms['shortanswer']= new question_edit_shortanswer_form(1,2,3,4,5,false);

Don't use is_usable_by_random(). Create a new is_usable_by_multianswer() for this. (Add it to the base class returning false, and then override it in the question types that do support Cloze.)
In reply to Tim Hunt

Re: Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -
"That is about right"
The post itself was about rigthwink , It was midnigth and I was quite excited to have found the solution so there where imprecisions in the post itselfshy.

"but I don't see the need for the $go parameter. It is quite dangerous to create an object without calling the parent class constructor unless you know exactly what is going on,"
When you call a specific question_edit_..._form() like the call done in the qtype/questiontype.php
$classname = 'question_edit_'.$this->name().'_form';
if (!class_exists($classname)) {
return null;
}
return new $classname($submiturl, $question, $category, $contexts, $formeditable);

If there in no function question_edit_'.$this->name().'_form' (i.e.question_edit_shortanswer_form()) the call is "transfered" to the parent question_edit_form which has a function question_edit_form()
function question_edit_form($submiturl, $question, $category, $contexts, $formeditable = true){
$this->question = $question;
$this->contexts = $contexts;
$this->category = $category;
$this->categorycontext = get_context_instance_by_id($category->contextid);
//course id or site id depending on question cat context
$this->coursefilesid = get_filesdir_from_context(get_context_instance_by_id($category->contextid));
parent::moodleform($submiturl, null, 'post', '', null, $formeditable);
}
The call is then transfered to moodleform() which call MoodleQuickForm();
function moodleform($action=null, $customdata=null, $method='post', $target='', $attributes=null, $editable=true) {
if (empty($action)){
$action = strip_querystring(qualified_me());
}
$this->_formname = get_class($this); // '_form' suffix kept in order to prevent collisions of form id and other element
$this->_customdata = $customdata;
$this->_form =& new MoodleQuickForm($this->_formname, $method, $action, $target, $attributes);

So when I create a question_edit_shortanswer_form() I can the stop the initialization using the $go parameter and I obtain an empty question_edit_shortanswer_form (no parameters are set ) from which I can use the functions like the new ones

function definition_inner_answer(&$mform,$prefix='',&$that,$question,$prehdr) {
Note that in the actual version the call parameters renders this function completely independent, even the $this parameter of the object calling it, is included as the $that parameter. In the final version I will see what parameters are absolutely necessary.

"You definitely don't want to be adding the editing forms to the global $QTYPES array! Instead, create a new array (which does not need or want to be global) $editingforms. So
$editingforms['shortanswer']= new question_edit_shortanswer_form(1,2,3,4,5,false);"

You're rigth ("this is the midnigth effect").
I will probably create $cloze_usable_editingforms as a class parameter that will be filled in the function question_edit_multianswer_form()
to be created.
The $this->cloze_usable_editingforms will be filled using a code that use effectively is_usable_by_multianswer() and checked the presence of the necessary files

$definition_file = $CFG->dirroot.'/question/type/'.$this->name().'/edit_'.$this->name().'_form.php';
if (!(is_readable($definition_file) && is_file($definition_file))) {
// display a warning and do not inscribe this qtype in $this->cloze_usable_editingforms
}

By the way to be PHP4 compatible, should I use & ?
function question_edit_shortanswer_form(&$submiturl, &$question,&$category, &$contexts, &$formeditable true,$go=true){
if( $go) {
parent::question_edit_form($submiturl, $question, $category, $contexts, $formeditable );
} else {
//initialize $this->editingforms
}


Pierre

In reply to Pierre Pichet

Re: Improving the multianswer(cloze) question, a proposal

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Pierre > 3- To simplify the grading process, the question types using cloze should have only one answer.

I do not understand this one. Do you mean should have only one correct answer? That is not the case of SHORTANSWER nor REGEXP.

Joseph

PS.- Please set up a test site so we can test it live and let us know.

In reply to Joseph Rézeau

Re: Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -
Sorry for the imprecision. I mean questions that ask you only one response but for which there can be as many answers bad or good as SHORTANSWER, REGEXP,NUMERICAL
The MULTICHOICE can be either
  • a single response type when display with a select in Cloze or multiple radio buttons in the usual way.
  • a multiresponse type when display with select buttons.
The single response restriction already exists in CLOZE so the select element for display the MULTICHOICE. The standard MULTICHOICE single response radio button display interfere with the text linear display.
By the way, I think that the edition display can become quite crowdy if the feebacks are displayed each in a HTML editor so I want to have ordinary text input as default but switching to HTML editor is necessary. Do you agree?

Pierre
P.S. as soon as possible and I will include your regexp(I will make the necessary code modifications as an example for plugins). Actually I can display but not already save because code changes are necessary in the saving process.


In reply to Pierre Pichet

Re: Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -
A similar transfer of setdata() code from shortanswer/edit_shortanswer_from.php to shortanswer/questiontype.pph works well either in the editing a short answer question than when editing a Cloze question.
Next testing is function validate() which should be also OK.wink

Pierre


In reply to Pierre Pichet

Re: Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -
Internet is great, but it is a pain that this discussion cannot be done in a pub with some beerssmile
Pierre
In reply to Joseph Rézeau

Re: Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -
Hi Joseph,
In the actual state of the project, the multianswer will be able to include all questiontypes that are_useable_by_multianswer() as long as they fullfill some properties and internal functions (to be described) that can be used by the multianswer code.
These properties and internal functions will be defined by using first the standard shortanswer, numerical and multichoice as examples.

I have already set a control of the HTML editor for the answers feedback if the user want a less crowdy display.

  1. For numerical questions should the units editing included as this was not possible in the actual Cloze ? Or available with a submit button ?
  2. Should the question display stays as the actual
    question 1 your name
    ...
    and your age
    ...

    or can we think of compromise as a this when grading is on
    question 1 your name
    response
    feedback
    0.6/2
    and you age
    response
    feedback
    0.6/2




Pierre
P.S. Sorry for the display, just imagine that the response field is replace by a table really inline...
In reply to Joseph Rézeau

Re: Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -
Here is a first screen shot of the regexp display in the new interface.regexp

Pierre

P.S. I have to fix the default setting and validate function as well as the question saving process.
In reply to Pierre Pichet

Re: Improving the multianswer(cloze) question, a proposal

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Hello Pierre,
Thank you for your proposal to integrate the regexp plugin question type into your new Cloze question type. Actually, when a regexp question is part of a Cloze question, the Display Hint button cannot be used, so it should be set to its default "No" value (and should not be displayed). And the Grade for Answer 1 should be set to its default value of 100%.
Thanks,
Joseph
In reply to Joseph Rézeau

Re: Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -
Hello Joseph,
The regexp plugin question type is used as an example of how to integrate in the new Cloze questiontype other questiontypes than the actual officially supported question types.
Your comments illustrate well how other questiontypes can be integrated in the Cloze questiontype.
The questiontype and the multianswer questiontype will use a new version of the specific various functions of their edit_questiontype_form class and as these functions will know by some parameters that they are used either by their natural class or by the multianswer class they could switch on or off their parameters.
For example the function definition_inner is splitted with the creation of a new function definition_inner_answer() that will be used also by edit_multianswer_form class
function definition_inner(&$mform) {
$mform->removeElement('generalfeedback'); //JR

$this->definition_inner_answer($mform,'',$this,$this->question,'') ;
}
with a call like
$QTYPES_USEABLE_BY_MULTIANSWER[$this->editas[$sub]]->definition_inner_answer(&$mform,'sub'."_$sub",$this,$qq,get_string('questionno', 'quiz', '{#'.$sub.'}').'&nbsp;', $displayoptions);

The $QTYPES_USEABLE_BY_MULTIANSWER is built on-the-fly with all questiontypes that return true to $qtype->is_usable_by_multianswer()

Mode code details to follow .

Pierre

P.S. When everything will be finished, I will send you the modifed regexp files so regexp can return true to $qtype->is_usable_by_multianswer().

In reply to Joseph Rézeau

Re: Improving the multianswer(cloze) question,import export limits

by Pierre Pichet -
Hi Joseph,
Actually the XML import and export functions for Cloze questiontype use the questiontext to store all the question parameters using the specific Cloze convention text format.
The new interface offers the possibility to include various questiontypes that can not necessarily used the specific Cloze convention text format.
So I will need to write a new XML format code to import and export the questions->options->questions that are used by Cloze to store the question data in the database. The new code will actually also be compatible on input with the old one. Given the format differences it will not be difficult to identify the new one.

Pierre

P.S. However the plugins used on export should be available on import...
In reply to Joseph Rézeau

Re: Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -
Hi Joseph,
As the submit buttons that allow to change the question type will be repeated for each questions, I change to a select element.
select.jpg

Pierre

In reply to Joseph Rézeau

Re: Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -
Hi Joseph,
The first Cloze question created WITHOUT knowing anything about the Cloze question format...
first.jpg

Pierre
In reply to Joseph Rézeau

Re: Improving the multianswer(cloze) question, a proposal

by Pierre Pichet -
A simple example with the 4 questiontypes
second.jpg

Pierre
In reply to Pierre Pichet

Re: Testing the new multianswer(cloze) question,

by Pierre Pichet -
The new interface is available for testing at
http://132.208.141.198/moodle_head_exp/

login as moodle pw:moodle

As this is a testing site all the debugs options are on and even if the actual version is working "almost" correctly, so work remains...
You will not be able to export_xml or import_xml as this is on my to-do list...

I will put more infos on the docs although the interface is moodle standard with on important exception: you can control the display so that you can hide elements like feedback or units so that the display is cleaner.

You put the questions text and the corresponding {#1},{#2},{#3}.
Actually you have to put them in the right order but this will change soon.
The validation code is not done on this part but is working for the other parameters of the different questiontypes.

Pierre

In reply to Pierre Pichet

Re: Testing the new multianswer(cloze) question,

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hi Pierre,

Just tested the new Cloze question type authoring interface on your test site. Very nice job!approve

I will do some further testing and let you know of any remarks or suggestions for improvement. Of course it would be nice to be able to put the questions in the text text in any order : blabla {#1} blabla {#4} blabla {#3} blabla {#2} etc. Also, you might add some separators (lines, or a color scheme, etc.) to clearly separate each question from the next. When one has a fairly large number of questions, each with its own number of answers, the screen gets really cluttered and it is hard to know where one is, despite of the questions and anwers being numbered. I will try to think of something to suggest to you.

Again a big thanks for your hard work on this long-needed Cloze authoring interface.

Joseph

PS.- This thread has grown quite long and, with the many screen shots in it, it takes quite some time to load. May I suggest opening a new thread to continue the discussion?

In reply to Joseph Rézeau

Re: Testing the new multianswer(cloze) question,

by Pierre Pichet -
I just test it effectively you can put the questions in any order.
However actuallay there is no validation that the {#x} exists but this will be corrected.
Ok for the new thread.

Also, you might add some separators (lines, or a color scheme, etc.) to clearly separate each question from the next.
This is difficult as the headers are closed each time you begin one but I will try with double headers.
This is why also you can just display the answers . I could go further and put aside the answers and the fraction.

Pierre