New feature for Embedded Answers (Cloze) - Sub question builder

New feature for Embedded Answers (Cloze) - Sub question builder

mohamed alsharaf གིས-
Number of replies: 15

Hi Moodlers

My name is Mohamed Alsharaf. I am newbie moodler and here is my first attempt to contribute to Moodle.

I have created a simple builder to create sub questions in embedded answers question type. The builder is in a popup window with a form and preview screen. I have attached the source code in this post.

How to install this new feature?

  1. Unzip the attached file
  2. There is a patch file “patch_multianswer”. Apply it to your code and you are done.
  3. Or,
  4. There are several files and folder included in the zip file. They are all what you need to for this new feature; most of them are new files except for edit_multianswer_form.php
  5. Copy all of the files/folder except for edit_multianswer_form.php into question/type/multianswer/
  6. Open edit_multianswer_form.php
  7. Copy the code from line 20 to 127, then paste it into your copy of edit_multianswer_form.php
  8. In your copy of edit_multianswer_form.php go to method “definition_inner”. Paste this code inside it
    $this->add_subquestion_builder($mform);
  9. You are done

How to use it

  1. Create a new Embedded answers (Cloze)
  2. You will see a link under question text field “Show Sub-Question Builder “ click the link to open the builder.

Missing features :

How to use language function in JavaScript code?

Currently the insert button works when you don’t have html editor enabled or if you are using TinyMCE editor.

More validations to the builder form. For example, if the question type is numerical then the answer must be numeric.

Any feedbacks?

I Hope you like this new feature.

Cheers
Mohamed

དཔྱ་སྙོམས་ཀྱི་སྐུགས་ཚུ།: -
In reply to mohamed alsharaf

Re: New feature for Embedded Answers (Cloze) - Sub question builder

Pierre Pichet གིས-
This sound interesting and you could submit your builder in the Modules and plugins section (http://moodle.org/mod/data/view.php?id=6009).

However the Multianswer (Cloze) question type was designed to add questions in a text with as simple text as possible.
The other initial requirements where that the input element should be in-line with the question text.
Many teachers use cloze to text analysis or syntax i.e. ( plural, punctuation marks etc.)

In november 2008 (MDL-14763) we introduce vertical and horizontal display of mutichoice element.
For the new engine we are extending multichoice to multi answers and shuffling.
http://docs.moodle.org/en/Development:Question_Engine_2:Developing_the_Multianswer_%28Cloze%29_Question_Type
Joseph Rézeau REGEXP question type is also part of future extensions.

The Cloze syntax is one the easisest way to add a question in a text and the Decode and Verify button will pinpoint problems.

Do you like my response? {1:MCH:=Very good;~%50%good;~%25%fair}

will generate the three horizontal buttons is a very simple way.wink

Pierre



In reply to mohamed alsharaf

Re: New feature for Embedded Answers (Cloze) - Sub question builder

Pierre Pichet གིས-
There is also a much simpler project of a cloze question generator that generates the text that the user could copy and paste.
See "I made a grafical CLOZE generator" on this forum
http://moodle.org/mod/forum/discuss.php?d=103681
and MDL-16154
The project was put aside until new question engine is completed.

Pierre



In reply to Pierre Pichet

Re: New feature for Embedded Answers (Cloze) - Sub question builder

mohamed alsharaf གིས-
Hi

Thanks for your reply.

I have looked at the other code. Its similar idea of having a link that will open a popup window with the generator.

But I could not download the zip file to try it or view the demo page. This page is broken http://root.goltergaul.de/moodle/cloze_generator.html

Could you please explain what is the complex in my code?

Thanks for your feedback

Mohamed
In reply to mohamed alsharaf

Re: New feature for Embedded Answers (Cloze) - Sub question builder

Pierre Pichet གིས-
"what is the complex in my code?"

I just figure its complexity once finished.

If we add a Cloze question generator to help people who don't want to learn the Cloze convention, we need to add a versatile question editor that can simulate all the question types allowed in Cloze i.e. at least shortanswer, numerical, and the various multiplechoices.
We need also to add all the validation process so that the question text is OK.

And if the user want to modify its subquestion, he will have to either simply modify the question (between the {...}) or to erase and recompose the question using you tool.

An independent Cloze question generator which propose a subquestion text {...} that the user could copy and paste in the question text appears a more general solution and easier to maintain giving the evolution of Cloze question in future Moodle versions.
It is more as an advanced Help function.

You code which apppears well done wink , could be a good base to start to build an somewhat independent cloze question generator like the one proposed in MDL-16154.

Add your code to MDL-16154 and we should work on this once the question engine code is OK.


Pierre

P.S. I attach a zip file containing the cloze generator code (root.goltergaul.de) and the edit_multianswer_form.php from actual moodle HEAD which only include a link to the cloze_generator.html so you can test it on 1.9.

In reply to Pierre Pichet

Re: New feature for Embedded Answers (Cloze) - Sub question builder

Nadav Kavalerchik གིས-
Core developers གི་པར Plugin developers གི་པར Testers གི་པར Translators གི་པར
thanks !

i have added a link to this Cloze Generator inside the question form, so teachers can open it up in a new window, which will help them generate the correct code.

super cool !
དགའ་འཛུམ་
In reply to Nadav Kavalerchik

Re: New feature for Embedded Answers (Cloze) - Sub question builder

Pierre Pichet གིས-
Just take care that this version needs improvments in the validation process.

i.e. the max grade is not include {??:MULTICHOICE:%100%good#~%50%half grade#}

However the Decode and verify button will do the validation.

Pierre

P.S. just by your reaction I understand that you vote for such an improvment. So put your vote on MDL-16154.


In reply to Pierre Pichet

Re: New feature for Embedded Answers (Cloze) - Sub question builder

Nadav Kavalerchik གིས-
Core developers གི་པར Plugin developers གི་པར Testers གི་པར Translators གི་པར
thanks for the warring !

i definitely voted for it (http://tracker.moodle.org/browse/MDL-16154)

and, attached, is a Hebrew translation too དགའ་འཛུམ་
In reply to mohamed alsharaf

Re: New feature for Embedded Answers (Cloze) - Sub question builder

Pierre Pichet གིས-
I play around with your code and I find a solution that could be more flexible for the user.

You display your generator but remove the
document.getElementById('subquestionbuilderbg').style.display = 'block';
so that the main question text remains visible.


Then the user can generate his subquestion using the tool and simply copy and paste the resulting subquestion text where he want in the question text.

Using cut and paste allows to remove the insert procedure (no editor problems).

Pierre

P.S We could examine if we can use the advanced feature to display or not the generator.



In reply to mohamed alsharaf

Re: New feature for Embedded Answers (Cloze) - Sub question builder

Pierre Pichet གིས-
The idea of a tool that could help user to generate the subquestion code i.e.
{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} is tempting.

However to do it at the Moodle interface standards ( Moodle Form) is a complex task.

It could be done using the Advance settings but this will mean replicating all the code of the three actually allowed question types (shortanswer, numerical and multichoice) in the Moodle form standards (i.e. only one parameter on a single line, editor for feedback etc.).
The generated text should also be validated.

No previewing of the resulting subquestion can be done in the editing form under Moodle standards.

With the new question engine, other question types could be allowed which will add more complexity.

The historical choice has been to give in the immediate help text at least one example of each variants as the numerical one shown in the reply.
It is then easy for the user to complete the subquestion text with his own needs.

Moodle docs could give more examples and you are encouraged to complete them as we encourage you to develop an independent tool that could fulfil many users needs without the strict Moodle standards constraints.

Pierre








In reply to Pierre Pichet

Re: New feature for Embedded Answers (Cloze) - Sub question builder

mohamed alsharaf གིས-

I see what you mean. Creating a cloze generator would create a complex code that has dependencies on other question types.

Before I developed the tool I was thinking of a way to build it without having to duplicate code required for each question type. In the end I decided to start with a simple tool (that I have posted here) then move towards a solution that is better དགའ་འཛུམ་

I have an idea, but i’m not sure if it’s possible. The cloze generator tool could proxy most of the functionalities to the other question types.

A use case:

System = Cloze generator tool

  1. In multi-answer question type, a link that will open an new popup window for the generator.
  2. User selects question type.
  3. System sends an ajax request to retrieve the question type form.
  4. User fills in the question type fields and clicks submit.
  5. System captures the submit/save click.
  6. System processes the validations from the question type code.
  7. System generates the cloze question code in a textarea, so the user can copy and paste.

Other functionality that can be added to the cloze generator:

Read and decode the question text, then provide a list of all the sub questions with an edit link next to each question.

ps. I have added my code to MDL-16154.

In reply to mohamed alsharaf

Re: New feature for Embedded Answers (Cloze) - Sub question builder

Pierre Pichet གིས-
"In multi-answer question type, a link that will open an new popup window for the generator. "

Such a link in a Moodle supported question type means that Moodle supported the generator for actual and future Moodle versions of multianswer question type and this we cannot afford at the present time or near future.

However such a generator can be either offer as a plug-in that the local moodle administrator could install or as an independent tool that the user could install on its computer.
The independent tool appears to me a better way but it is your decision.

Pierre

P.S. In autumn 2007 , I work on a modified cloze question project where I explore how to integrate code from the other question types edit_...forms.

See Improving the multianswer(cloze) question, a proposal


In reply to Pierre Pichet

Re: New feature for Embedded Answers (Cloze) - Sub question builder

Joseph Rézeau གིས-
Core developers གི་པར Particularly helpful Moodlers གི་པར Plugin developers གི་པར Testers གི་པར Translators གི་པར
There is also my Small Hack: clozejr to build a cloze question by using existing short answer, multichoice, etc. questions. I have not used it recently so have no idea if it's still working in Moodle 1.9.
Joseph
In reply to Joseph Rézeau

תשובה ל: Re: New feature for Embedded Answers (Cloze) - Sub question builder

Lior A གིས-

Hello guys,

I'm trying to find a cloze question type that supports as many question type as I can find.

I couldn't find a one suppoting mulichoice question with several correct answer (or just that I don't know how to create one).

Mohamed, do you support this type of question?

Pierre, does you proposal support it? (Improving the multianswer(cloze) question, a proposal) - where can I find the source files for this one?

Thanks a lot !

Lior


In reply to Lior A

Re: תשובה ל: Re: New feature for Embedded Answers (Cloze) - Sub question builder

Joseph Rézeau གིས-
Core developers གི་པར Particularly helpful Moodlers གི་པར Plugin developers གི་པར Testers གི་པར Translators གི་པར
Hi Lior,
What you want is not possible. The cloze question type in Moodle only supports the multi-choice, single answer sub-question type.
Joseph
In reply to Lior A

Re: תשובה ל: Re: New feature for Embedded Answers (Cloze) - Sub question builder

Pierre Pichet གིས-
The multianswer multichoice multiple answers will be supported with the new question engine hopely in 2.0

See MDL-20636 and
http://docs.moodle.org/en/Development:Question_Engine_2:Developing_the_Multianswer_(Cloze)_Question_Type


Pierre