Formulas question type fro Moodle 2.0

Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -
Number of replies: 173

Hello,

Here is  my first try at a version of the formulas question type for moodle 2.0.x

(the version for moodle 2.1 will be done later  when this one is complete).

Please don't use yet on a production server. You have been warned !!

I just post this here so that :

  • users more familiar than me with this question type can test it and report bugs
  • users needing this to test upgrade of their server to Moodle 2.0 during summer can see if their formulas questions are correctly upgraded
  • you know that somebody is actively working on this big grin (consequence of my university don't wanting to run a STACK server sad)

Things yet to do :

  • backup and restore
  • help buttons in question creation page with the associated lang strings

None of this is really hard but I didn't had time to do it. And I wanted a feedback first to see if i didn't broke anything in the question.

The most difficult part was to get the images working in the subquestions texts parts. The file manager is at first very difficult to understand !!

XML Import/export work with old and new xml files I think (new ones can have images in subquestions texts)

Please test and report.

 

Average of ratings: -
In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by hon wai lau -

Hello, Many thanks to your effort to port the formulas qtype to the moodle 2.0. I am the one who made the initial release of the formulas question type. Glad to know that you have read and modify my messy codes for the community. It is too time consuming for me to read the changes in the moodle 2.0. I have already leave my previous job when I develop the question type, so I currently only work slowly to the question type in my leisure time. I want to merge the change made after the first series of this qtype so that I have not yet ported it to moodle 2.0 yet. People is waiting for a long time so that I think your effort will let them know that someone is still developing this qtype. Thanks

I have not tested it yet and I will try your modification later. I have briefly looked through your code and I think it is most likely to work without any problem. Your modification does not touch the core code so the grading works exactly the same way. Also, the qtype API have only changed a little bit in moodle 2.0 and it should be ok. After a brief look, I have questions and comments:

  • If my understanding is correct, you are using a lower version number in the version.php. Why? It does not trigger the upgrade progress on my computer. After I changed the version number and preform the upgrade, it does not add the 'subqtextformat' to my database table. I dont know whether it is my setting problem
  • You have added an additional db field 'subqtextformat', is it neccessary for the use of image in the question text?
  • It seems that you have added the support of the image in the subquestion. Are you using this question type yourself? I do not know whether the image is useful or not, but it is a nice addition.
  • What is the use of the quiz_rewrite_question_urls() in the print_question_formulation_and_controls()? 
  • What is the use of the file_get_submitted_draft_itemid() in the set_data()?
  • Why are you adding the file handling in the class question_formulas_qtype? It should not use any files.
  • Is there a way to embed the documentation together with the plugin qtype. The moodle online help does not mention it.

There are some problems in the original formulas qtype put on the google code, particularly, related to the backup/restore and import/export. The backup/restore in the moodle 1.9 is plainly does not work and I have not fixed it yet. The import/export basically works. However, it fails to import question when the exported question contains the character "'" in the subquestion text. The import error message signify that it may result in some type of db injection. I have assumed that the moodle will backquote these characters, but am I wrong?

Have you tried to export questions from the moodle 1.9 and then reimport into moodle 2.0 of your modification code? I want to ensure that the import/export work correctly so that the user can move their question without the database upgarde to moodle-2.0.

In reply to hon wai lau

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Hello,

Sorry for the late answer but I was busy working on the version of formulas for Moodle 2.0 that is a lot more complex than I had expected.

  • I surely made a mistake in the version.php file with the version number. Sorry for the inconvenience. I will look at it and at the upgrade procedure. The subqtextformat should be created during the upgrade, and it should work with all settings and all previous versions. So there is surely a bug here
  • The problem with the subqtext field is that we have only 2 choices : either we make it a simple text field (textarea) with no editor, no images (in Moodle 2.0/2.1 it is NO MORE possible to copy and paste an internal image url as we were used in Moodle 1.9, so if people want to be able to display an image we MUST use an editor), or we use an HTML editor and we need the subqtextformat field. My thinking is that users will not be satisfied with a simple textarea so this is why I took the option to use an editor and add the subqtextformat field. Maybe I was wrong and that is not really usefull ?
  • the quiz_rewrite_question_urls is used because images tag are saved as $ $PLUGINFILE$ $ (without the spaces but I don't want the TeX filter to format my texte) in the database and converted to real urls when the question is edited or used. In the editor all images urls are begining with draftfile.php and are temporary ones. When the question is in use in a quiz images urls are begining with pluginfile.php.
  • the editor in the form has an itemid and files (images) relatives to that editor are tied to that itemid so the file_get_submitted_draft_itemid() function manage this
  • the files in the question_formulas_qtype are all the images (both the question text images, but also the subqtext images) in Moodle 1.9 you had nothing to do for the images but now they are linked to your question so you must write code to manage them.
  • I will look at the backup/restore code again, but I seem to remember having tested it and it worked. One thing that is not possible is to restore in Moodle 2.0 a backup made in Moodle 1.9, but that is not my fault, this feature is not part of Moodle 2.0, it is only available in Moodle 2.1 (but I have not finished that feature yet)
  • I tried to import some of my own questions exported from Moodle 1.9 and also I tried the examples you have on googledocs. It worked with no problem. So yes the Moodle 2.0 formulas accept XML files made by previous versions.
  • I just saw yesterday that the javascript on the question editing page is broken sad in the version I posted. This is because the body id of the page is no more "question-type-formulas" it is now "page-question-type-formulas" so I need to modify the script.js file (there are also other changes needed because the subqtext filed has changed). Sorry for that. This doesn't prevent the question editing from working, but the form is not similar to the 1.9 one (no more checkboxes for rarely used fields). I will release a corrected version.
  • As I said I have some trouble writing the 2.1 version. The question installation and the question editing part are done and (I think) working, I think XML import/export are also working but needs some testing. But I need to redo all the others parts because the question engine has completely changed. This is very complex because the question is complex !!
In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Sorry, there is a typo in my previous message :

but I was busy working on the version of formulas for Moodle 2.1 that is a lot more complex

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

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

Hello Jean-Michel,

Yes, upgrading questions from 1.9 or 2.0 to moodle 2.1 is a huge task, but thanks to Tim's work the new question engine offers more possibilities and is nicely programed, so it is worth it.approve

Joseph

Bon courage !

In reply to Joseph Rézeau

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Hello,

Thanks Joseph and Pierre,

I think we can be very gratefull to Tim for the work he has done. The question engine 2 is a lot better than the previous one. I think also the interactive behaviour is very interesting both for teachers and for students. QE2 is full of interesting features and I like it a lot.

I had nearly no problem to make versions for Moodle 2.1 of the Java molecule Editor, DragMath and Algebra question types. I think I now understand correctly the editor and the way files management work. I still need to learn more about hints and behaviors.

But upgrading Formulas is quite another story !

  • because it has more javascript and I am not good at javascript so I am very slow in understanding how the scripts work and how to find a way to upgrade them
  • because, and this is the main problem, because formulas has its own management of 1.9 adaptative mode with the ability to have a submit button for each answer box and the ability for the student to only check one part of the response. Currently I see no way to make this work with QE2 behaviors, and I don't understand behaviors enought to make the code working !!sad But i don't give up, simply I will need more time than I expected.
In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Wow! How on earth did they implement that? (formulas has its own management of 1.9 adaptative mode with the ability to have a submit button for each answer)

The only way you could do the same thing in Moodle 2.1 is to create a new behaviour, say question/behaviour/adaptivewithmultisubmit that provides the necessary extra functionality. Then override the make_behaviour method - like match does to use the interactivecountback behaviour instead of interactive.

In reply to Tim Hunt

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Hello Tim,

I don't really know if you have time with so many things to do,  but looking at the code of the formulas question type is interesting. We both know that question engine before 2.1 was rather "unfriendly" for people wanting to create a question type but what Mr Hon wai Lau has done is rather amazing because he managed to find workarounds to many question engine 1 limitations.

Unfortunately this make my task to port this question type to 2.1 very difficult.

Since I began this work, I though several times that it was not a task for me but rather for you or for Jamie Pratt.

But in life I don't give up easily so I am still working on it and progressing slowly.

This is how I spotted yesterday that if a question type has get_html_head_contributions or get_editing_head_contributions functions, they don't work anymore in 2.1. This is solved now and my javascript is working again.

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by hon wai lau -

Actually, many part of the question type is the improvements over the calculated/numerical question type. However, all these improvements together make it possible to create more complex questions that cannot be done by the internal question type.

Though the usage may need a little programming background but it gives much more flexibility for the teachers. It may seems that this question type has exposed many details of the internal implementation of a question type, but in fact, teachers only need to type a formula at an appropriate to get the functionality which make life easier. Maybe somedays, someone will create a easier interface for this question type.

You may think that many functionalities should be implemented in the question engine. However, it will take years for them to be included in the question engine and I cannot wait that long (my project has already ended). And a more important points is that the question is much harder for me to work with and I will look silly to make change while the question engine is being upgraded to version 2.

Though it seems that there is no contribution to the question engine, but you may consider the details of my question type as a preliminary implementation for a better question engine. Hope that Tim Hunt and Pierre Pichet and other future developer may find some functionalities useful and make the quiz engine more powerful.

In reply to Tim Hunt

Re: Formulas question type fro Moodle 2.0

by hon wai lau -

Hi Tim,

It is done by override the grading function. The reason to do that is to allow the submission of the subquestion one by one. The internal penalty handling (before QE1) is to deduce a constant fraction each time which is made the wrong marking.

It is the most dirty part of the question type because it should be handled by the question engine but it makes no such functionality at that time. I find no other way to circumvent this so I can only do it in this way.

In reply to Tim Hunt

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Hello Tim,

If I understand well

the adaptivewithmultisubmit will extends adaptative behavior and wil have

const IS_ARCHETYPAL = false;

and in my question definition I would have something like

    public function make_behaviour(question_attempt $qa, $preferredbehaviour) {
        if ($preferredbehaviour == 'adaptative' && this->peranswersubmit) {
            return question_engine::make_behaviour(
                    'adaptivewithmultisubmit', $qa, $preferredbehaviour);
        }
        return question_engine::make_archetypal_behaviour($preferredbehaviour, $qa);
    }

peranswersubmit is a booelan that tell if this question definition instance must have multisubmit or not.

Would it work ?

Why must I pass $preferredbehaviour as third parameter in question_engine::make_behaviour(
                    'adaptivewithmultisubmit', $qa, $preferredbehaviour);

I am quite tempted to try to do it even if I forsee many problems. Doing a behavior seems like a fun adventure cool

For instance I don't see how the submit buttons could be managed by the behavior as they are scattered among the subquestions text ?

Currently in the 1.9 version there is a hidden field subanum (set by javascript when student press one of the submit buttons that tell the code what submit button has been pressed so what subquestion was submitted. Would this work ? I don't so why it wouln't but better to ask.

Last thing : maybe it would be better that I ask the next questions (I am quite sure I will have some more !) in the general development forum ?

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Well, I have a missing $ in my previous code (before this), but beside that, it doesn't seems to work. If I preview (the preview is nor yet really working but I do have a preview for testing purposes) a formula with peranswersubmit set and I choose adaptative behavior, my 'adaptativeperanswersubmit' (that the name I gave to it) behavior is not selected as I had hoped. I am surely missing something.

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Hum,

As surprising as it may be:

if ($this->peranswersubmit) {

is working but :

if ($preferredbehaviour =='adaptative' && $this->peranswersubmit) {

and looking at the $preferredbehaviour value, I see adaptative wide eyes  I am surely not seeing an obvious mistake that's just under my nose blush

The good news is that when the if condition works my behavour is selected and I see it in the preview

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

There are some words missing in my previous post :

if ($this->peranswersubmit) {

is working but :

if ($preferredbehaviour =='adaptative' && $this->peranswersubmit) {

is not working.

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Stupid me, adaptive not adaptative ! of course that must be evident for somebody speaking english natively !

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

'adaptative' != 'adaptive'

Oh, you spotted that at the same time as me.

Rest assured that it is perfectly possible to do this sort of thing in your own lanaguage, and it is really hard to see wink Probably worse in a foreign language thought

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Yes. This will work.

To answer why you need to pass $preferredbehaviour to make_behaviour: Suppose you would like adaptivewithmultisubmit behaviour to handle both adaptive and adaptivenopenalty behviours?

(One answer would be to make new adaptivewithmultisubmit and adaptivewithmultisubmitnopenalty classes. The alternative would be to make one class which looks at the preferredbehaviour setting.)

In reply to Tim Hunt

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Hello Tim,

I decided it would be wise to define 3 questions definition classes :

class qtype_formulas_base extends question_graded_automatically

class qtype_formulas_singlesubmit extends qtype_formulas_base
class qtype_formulas_peranswersubmit extends qtype_formulas_base

Then in my qtype I do

    protected function make_question_instance($questiondata) {
        question_bank::load_question_definition_classes($this->name());
        if ($questiondata->options->peranswersubmit) {
            $class = 'qtype_formulas_peranswersubmit';
        } else {
            $class = 'qtype_formulas_singlesubmit';
        }
        return new $class();
    }

I have also defined 3 renderer classes :

class qtype_formulas_base_renderer extends qtype_renderer

class qtype_formulas_singlesubmit_renderer extends qtype_formulas_base_renderer

class qtype_formulas_peranswersubmit_renderer extends qtype_formulas_base_renderer

each question defintion class return the appropriate renderer in it's get_renderer method

and the last one has also

    public function make_behaviour(question_attempt $qa, $preferredbehaviour) {
        if ($preferredbehaviour == 'adaptive') {
            return question_engine::make_behaviour(
                    'adaptiveperanswersubmit', $qa, $preferredbehaviour);
        }
        return question_engine::make_archetypal_behaviour($preferredbehaviour, $qa);
    }

Am I on the right way ? I am really not sure I fully understand QE2 !

For the moment I concentrate my efforts on the singlesubmit question definition and rendered (the easier !). So doing I don't have to look at writting the adaptiveperanswersubmit behaviour now. Will see later !

Things progress nicely, the question are displaying OK and I think grading is OK too. I have a lot of trouble with javascript (I am not good at it, and there is quite a lot in formulas qtype !)

I need also to redo bell and whistle (understand colors, feedback, feedback images, ...)

As you may guess I have some questions (of course i would probaly find the answers myself looking at the code and comments but as my students say "it's easier to ask you")

in clear_wrong_from_response method, do I need to unset wrong responses or set them to an empty string ? Looking at various existing question types don't provide a clear answer.

I am puzzled by classify_response and get_possible_responses. I don't think I can return anything meaningfull.

formulas questions have variables including random variables wich value may change for each attempt.

Of course the number of variants is not infinite (nothing really is in real life !) but it can be very big (a variable can be specified as been drawn in an interval range given by the form 'start:stop:step' and it will have a value equal to start + n * step for a random integer n such as  start + n * step  < stop. I think this prevent all analysis.

If I understand well this will prevent some reports for formulas questions ?

It is clear that radom guess score is 0 wink for formulas questions.

 

 

 

 

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Sorry, another one (I was thinking it was clear in my mind but i suddently realise I have mixed things)

in the comment to start_attempt I read

     * @param question_attempt_step The first step of the {@link question_attempt}
     *      being started. Can be used to store state.

can you elaborate ? In QE1 we only had $state to store data now we have the question_attempt_step and our question definition instance .

I am now somewhat confused and thinking some of my code is bad, reflect of my bad understanding of OOP. Help.

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Look at match (for example) and see how start_attemtp uses the step to store the state like the what order the choices and stems are shuffled into; and then how apply_attempt_state uses that stored state. For a more complex example, look at the calculated qtype.

In reply to Tim Hunt

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Ah ah ! so when you said "can be used to store data" you were simply referring to the question_attempt_step_data table and the set_qt_var / get_qt_var functions ? If yes, of course I am already using it (if not, I could not retreive values of the variables as instancied at attempt_start) : I set and get 2 strings _random_var_text and _global_var_text. In apply_attempt_step I rebuild the data structure from these 2 strings.

But re-reading my message from yesterday it was very unclear : I need to store 3 arrays : unitcorr, anscorr, fraction who have each one element for each subquestion (anscorr is if the answer is right or wrong, unitcorr if the unit is right or wrong, and fraction is the fraction for this subquestion fraction can be recalculated from the 2 others if necassary) the calculation of the anscorr and unitcorr elements is costly so I want to do it only once. They change only if the user input change. I calculate them in a method of the question definition class (grade_responses_individually) what is the best way to store this results ? I don't think they need to be stored in the database (but maybe I am wrong) because these values don't need to be persistents for all the life of the question attempt so I was thinking I don't need set_qt_var / get_qt_var. in Moodle 1.9 they were stored in $state. until yesterday, I was storing them in my question definition class but your comment made me thinking that maybe I was wrong.

What is my best strategy ?

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

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'm afraid you have hit a flaw in the design of the question engine.

One the one hand, the idea was that you could always use $step->set_qt_var() to store some complex result that was expensive to calculate, not just during start_attempt, but at any later step too.

On the other hand, because I was converting from the old code; and because I wanted to avoid various types of possible abuses of the API in methods like grade_response, then those methods just take a plain array as $response, not a full $step object.

And, none of the core question types, nor any of the ou-specific ones we have, yet do anything computationally expensive during grading, so I have not run up hard against this problem yet, and had to solve it.

I can think of two feasible solutions:

1. Pass $pendingstep as an extra argument to methods like grade_responses, is_same_response, etc. This is simple, and will work.

2. Do some scary PHP magic, to make an object that behaves both like an array, but also like a $step, and then pass that to the methods instead of the $response array.

Option 2. is more backwards-compatible, but I think it would be too complex, and so should be avoided.

In reply to Tim Hunt

Re: Formulas question type fro Moodle 2.0

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Actually, I forgot some things in that previous post.

The most important reason why methods like grade_responses, is_same_response just get passed an array is that it guarantees that they don't have significant side-effect.

If they don't have side-effects, then it gives behaviours much more freedom. The behaviour does not have to worry which order it calls question type methods. Also, because you just need an array to call these methods, it is easy to call them with speculative data.

For example, imagine wanting to create a variant of adaptive mode that will not penalise the student for trying any previous response. So, suppose a student submits responses X, Y, X, Z, where Z is right, then you want them only to have 2 * penalty subtracted becuase they only gave two different wrong responses.

 

In terms of how to get round this problem, I thought of a third-option:

3. Add new API methods like pre_analyse_pending_step that give the question type a chance to perform expensive calculations and cache the results in $step, or in the qestion type class, before doing the usual grading code. No, that does not work either, because of what I said about giving behaviours freedom. sad

However, I do want to solve this. When I was designing the system, I had in mind something like Süreç Özcan's JUnit question type. That has to compile Java code during grading, which is very slow, and so the results of that really should be cached. Sadly, as I said, I only got part-way there with the design. The $step object is designed to be a place to store information like that, but there is currently no way for the question type to access it at the vital moments.

In reply to Tim Hunt

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Hello,

Well this is rather sad news. The only positive point is that yesterday when I was banging my head reading your comment about saving data and not understanding how my question definition could cache results, I was not so dumb I had thought smile.

For the moment I am recalling the grade_responses_individually method each time I need the results and for the rather small examples I use for testing response times are not so long I was fearing.

But I am now on finishing my renderer (What an idiot I have been not to have done a sub renderer class for each subquestion !!!! i think I will throw my code and refactor it entirely) and of course to give each answer the right feedback style and the right feedback image, I need the corresponding  element in fractions, unitcorrs and answercorrs and I only have the global fraction ! Arrg ! The only (atrocious ) way I have found is to reconstruct the response array with $qa->get_last_qt_var to be able to call my question definition methods (and one more time relaunch the entire calculation) just for a color and an image ! That seems silly. There must be another way.

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

So what i do now is :

$response = $qa->get_last_qt_data();

wantedresult = $qa->get_question()->whatevermethod($response);

Of course no caching but I can set my feedback style and image for each subquestion.

 

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Yes. That is probably the best option for now.

In reply to Tim Hunt

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Hello Tim,

I feel very bad for asking so much of your time ! But one more time I need your help.

I have some trouble writting my question_qtype_attempt_updater because documentation is light (I am  not at all complaining,  I understand not a lot of people on earth will need it, so that's a vey good  explanation)

Am I right in thinking the general idea is that these code should produce the same result that my 2.1 code but must not rely on it ?

The methods I "think" I understand :
   public function question_summary() {
   public function right_answer() {
   protected function make_summary($pairs) {   
   public function response_summary($state) {
   public function compare_answers($answer1, $answer2) {
   public abstract function set_first_step_data_elements($state, &$data);   -> should produce a result similar to start_attempt in $data
   public abstract function set_data_elements_for_step($state, &$data);   -> should use $state->answer to set $data so that question_attempt_step data can be populated

I am not sure to fully understand what I should do and return :
   public function was_answered($state) {
   public function supply_missing_first_step_data(&$data) {

Any other method to write ?

Anything special to care ?

Again thanks a lot


In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

First, can I say that I feel cery good that several people are trying so hard to engage with and build upon the work I did. I am more than happy to help.

Of course, what I really should be doing is taking all the quesions and answers from these threads, and distilling them into documentation!

 

This upgrade code is used in two places. When upgrading from 2.0 to 2.1, and when restoring a 2.0 backup into 2.1. And yes, becuase this is used during upgrade, it should not use any other code. It should be self-contained.

When writing these upgrade classes, I strongly recommend taking a test-driven approach. You can use the question engine upgrade helper plugin to extract the data abotu some attempts from your 2.0 database, and then you can work out by hand what the transformed data should look like, and then you can write the code to do the work.

(Look in some of the other question types for examples.)

was_answered looks at question_states.answer and has to decide whether there is a student response there. You need that, for example, because for a multichoice question, a blank answer looke like 123,234,456: That is, it is not blank, it includes the shuffled order of the choices, so you need code to check what comes after the :.

supply_missing_first_step_data - This, and various other parts of the upgrade system, are there because the site being upgraded may have all sorts of random junk in its database (probably the outcome of old bugs). The upgrade system has to do its best to cope with that garbage, and repair it.

supply_missing_first_step_data has to make a plausble first step for a question attempt, when there was not one present before the ugprade. So, for multiple choice, it has to make up a random order of the choices, for example.

In reply to Tim Hunt

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Tim,

I began studying behaviours to write my adaptiveperanswersubmit behaviour.

Am I right in thinking I will have a lot less problems because in that case the behaviour can call all the question methods it wants to evaluate raw marks, and  then calculate marks, trials, trials left... on a per answer basis, serialize them, and store them using set_behaviour_var, and even my question renderer (not the behaviour renderer, the question's one !) can get them using get_behaviour_var ? Am I right ?

In that case it seems I will have not have the same problem as in the single submit version.

That's kind of funny !

Another thing : as answer submit buttons are scattered among the question text (after each answer submit field) it seems I can't use a behaviour renderer to render them but only a question renderer. Right ? Does that may cause any trouble ?

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

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 sounds basically right.

The fact that the qtype may choose to put bits of submit buttons mixed in with the quetsion formulations is perhaps a bit like the way multichoice chooses to put bits of feedback in amongst the formulation sometimes. That is, probably OK.

In reply to Tim Hunt

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Hello Tim,

I just noticed a minor thing but I don't know if it's a bug or a feature : as in question/format/xml/format.php both trans_format and get_format are declared reserved it is no more possible to use them in export_to_xml and import_from_xml methods in a third party questiontype.

Apparently other third party qtypes for QE2 that I know didn't have this problem because they don't have a format field in their own tables (formulas qtype don't use the question_answers table so I can't use import_answer and write_answers).

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

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 a bug then. Please report it in the tracker.

In reply to Tim Hunt

Re: Formulas question type fro Moodle 2.0

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Actually, don't file a bug. Jamie Pratt just discovered the same thing: MDL-29060. See also the discussion in MDL-29059.

In reply to Tim Hunt

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Hello Tim,

Unless I misunderstand the issues reported discovered by Jamie, they are somewhat related but more general than my (small) problem. they are related to the whole import/export code, qformat_default and also how save_question_options handle files in the case of an import.

Of course solving this bugs would also help me to handle files, but I have a problem Jamie (I think) don't have in any of his qtypes : I have a format field coded as a string in my xml file and that I must encode/decode to/from the internal numeric format used internally by Moodle.

Currently the only solution I have is to duplicate code from question/format/xml/format.php.

Not a big deal of course because these 2 functions are short and simple but code duplication should be avoided if possible.

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Sorry. I got confused. You are talking about different methods than Jamie. Sorry. Please do create a separate tracker issue for the methods you care about.

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

You are on the right track.

clear_wrong_from_response - look at match or multicoice_multi question type.

classify_  and get_possible_reponse these are used in the statistics report, when you click on the name of a particular question on the first page of the report, to get to the response analysis of a particular question. So, you are trying to classify responses into logically distinct classes. As and example, consider the calculated qtype (since I understand that). Suppose you have a question with three possible answers:

  • {x} + {y} (scores 100%)
  • {x} - {y}  (scores 0% but has special feedback)
  • * (score 0% generic feedback)
In this case, we classify all possible responses into one of those three classes. The exact numbers don't matter.
In reply to Tim Hunt

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Hello,

The problem is that in formulas the grading strategy can be very complex (everything is complex in formulas !) and when I say very complex I really mean it :

it can be a condition on error as _relerr < 0.01 meaning relative error between calculated answer and user response less than 0.01

it can be relations on user inputs as _0 == 42 || _0 == 49 meaning that the first coordinate of the response vector is either 42 or 49 (coordinates of the response vector for a subquestion are noted _0, _1, _3, ... and unit is noted _u

you can also define relation in another field of each subquestion as in

criterion1 = _0 % 7 == 0;
criterion2 = a < _0 && _0 < a+10

(first coordinate is a multiple of 7 between a and a + 10, a is a random variable) then use it to grade the subquestion :

criterion1 && criterion2

You can also use _err (absolute error) and _relerr (relative error) in these relations

case1 = _err < 0.01;
case2 = _err < 0.05

then uses it in grading

max (case1, 0.5*case2)

At that point I am only half way of the example file provided by Hon Wai Lau (this is the list of 26 examples I use to test my work)

Do I need to continue or are you convinced as I am that this defy classification wide eyes ?

I think formulas may not look good in statistics reports sad. Can I at least have 3 categories wrong, partially right and right based on the fraction for this question ?

 

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Well, you could just do what the essay question type does - and don't provide an analysis.

However, a better example would be to look at is the matching question type. Note that it provides a separate sub-analysis for each separate input.

Also, you don't have to provide a total analysis, you just have to analyse against the categories of answer the teacher set up, which for each part of a formula question type may just be right or wrong.

Anyway, that is why there is a pair of functions, get_possible_responses (which might be better named get_possible_response_classifications) and classify_response. You (as question type creator) can choose how detailed the analysis should be for your question type.

It also helps to remember the purpose of this report. We want teachers to be able to look at all the answers students gave in a way that helps them spot, for example, that several students got the question wrong becuase they made a certain mistake, therefore, we should edit the question to add extra feedback for students who made that mistake, explaining their misconception. At least that is the goal. It is not necessarily easy, or even possible.

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Mithil Sharma -

Hello Jean-Michel Védrine,

 _0 == 42 || _0 == 49 works fine for Numbers, and one answer only. But how do you incorporate it for Formula type questions, where we have TWO answer boxes (_0 and _1)

e.g. for quadratic equations, x=1/4 or x=3/5.

Student can type either 1/4 in the first answer box, and 3/5 in the second answer box, OR, 3/5 in the first answer box, and 1/4 in the second.


Is there a way to incorporate:

Answer = [a,b] or [b,a]


Thanks and Regards

Mithil

In reply to Mithil Sharma

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Hello Mithil,

Don't forget that you can not only use || for logical or but also && for logical and and you can combine them.

There are several ways to achieve what you want.

The first is to simply type in the grading criteria :

(_0 == 1/4  &&  _1 ==3/5) || (_0 ==3/5  &&  _1 ==1/4)

But I am worried that this would fail if student don't give the exact number so I think it is better to allow for some error.

type as a local for this part or as a global variable for the question

precision = 0.001;

then type in the grading variables field

case1 = abs(_0 - 1/4) < precision && abs(_1 - 3/5) < precision;
case2 = abs(_0 - 3/5) < precision && abs(_1 - 1/4) < precision;

and finally type in the grading criteria field

case1 || case2

Of course adjust precision value to your requirements.

Also you can complicate the game and replace 1/4 and 3/5 with variables and use random variables to allow each student to get a different equation. You will then have  a beautiful exercise to train your student smile

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Mithil Sharma -

Hello Jean-Michel Védrine,

Thanks, but this works only for Numeric type questions, not for Algebraic Formula questions - here, the answer is a string (1/4, or 2 + sqrt(3)), and not a numeric value (0.25).

Please see attached screenshot.


Algebraic Formula

In reply to Mithil Sharma

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Hello Mithil,

Please look at Hon Wai Lau' original documentation about answer types. For something like 1/4 or 2+sqrt(3) you should not use Algebraic Formula, you should use Numerical formula. Algebraic formula should only be used if you have variables in the answer like 2x+3y or sin(x+pi/2).

The difference is very important because as you mentioned Algebraic formulas are in fact strings so there are some things you can't do with that type of answer, all other types of answers (Number, Numeric, Numerical formula) are numbers.

Change your question and you will see that my help message is useful and permit to create the question you want.

If you don't manage to create the question you need, don't hesitate to post here, I am quite sure it will help other users to discover the many possibilities of formulas questions.

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Mithil Sharma -

Hello Jean

It's not what the student answers that is the issue - the issue is what Moodle responds:

If I use Numerical formula, for 1/3, moodle reports: One possible correct answer is 0.33333333, but if I use Algebraic Formula, Moodle reports: One possible correct answer is 1/3. (Refer screenshot). And I want students to see the answer as 1/3, not 0.333 (or 2 + 2 sqrt(4), not 6 ). Any way to address this, then?

answer2

In reply to Mithil Sharma

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Hello Mithil,

Sorry for not understanding your problem, I don't see any easy solution.

  • The display you want is only possible with algebraic formulas answer type
  • With algebraic formulas answer type I don't see any easy way to test both answers order
But maybe another formulas question user will have an idea ? Maybe there is a very simple solution and I don't see it ?

Maybe a workaround would be to hide the display of the correct answer and tell the student what the correct answer is using the general feedback, but unfortunately this choice is only available at the quiz level not the question level.
In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

I think I have a solution to your problem but I find it overcomplicated, there is surely a better one

Imagine your solutions are 1/4 and 3/5

Answer type: algebraic formula

Answer: ["1/4","3/5"]

Grading variables:

sol1 =["1/4","3/5"];

sol2 =["3/5","1/4"];
case1 = pick(1,diff(_r,sol1))==0 && pick(2,diff(_r,sol1))==0;
case2 = pick(1,diff(_r,sol2))==0 && pick(2,diff(_r,sol2))==0;

Grading criteria:

case1 || case2

Average of ratings: Useful (1)
In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -
Of course rather than checking that each coordinate of the diff(_r, sol1) or diff(_r, sol2) vector is zero, it surely would be safer to test that the euclidian norm of this vector is less than some small number.
In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Mithil Sharma -

Hey Jean... You cracked it!!! IT WORKS, and is not complicated, too. Thanks a lot!!

In reply to Mithil Sharma

Re: Formulas question type fro Moodle 2.0

by Mithil Sharma -

Hi Jean

Stumped again... how do I get it for 4 answer boxes? The below code works for {_0} and {_1}, but fails at {_3} and {_4}:

==============================

sol1 =[anz1,anz2,anz3,anz4];
sol2 =[anz2,anz1,anz3,anz4];
sol3 =[anz1,anz2,anz4,anz3];
sol4 =[anz2,anz1,anz4,anz3];
case1 = pick(1,diff(_r,sol1))==0 && pick(2,diff(_r,sol1))==0;
case2 = pick(1,diff(_r,sol2))==0 && pick(2,diff(_r,sol2))==0;
case3 = pick(3,diff(_r,sol3))==0 && pick(4,diff(_r,sol3))==0;
case4 = pick(3,diff(_r,sol4))==0 && pick(4,diff(_r,sol4))==0;

==============================

Thanks and Regards

Mithil

In reply to Mithil Sharma

Re: Formulas question type fro Moodle 2.0

by Mithil Sharma -

Hi Jean-Pierre,

Is there any way to have a variable element selected which has NOT been selected earlier from a variable list.

e.g. if U = {"John","Jack","Daniel","Alex"};

and if I write:

1) My name is {U}.

2) Your name is {any element of U, but not above element 1}

3) His name is {any element of U, but not element 1 or element 2 }


e.g. If it shows as

1) My name is Alex


Then 2) should show either

2a) Your name is John

2b) Your name is Jack

2b) Your name is Daniel

BUT NOT Your name is Alex


Going further, if 2) selects Your name is John

The 3) should show either

3a) His name is Jack

3b) His name is Daniel

BUT NOT His name is Alex, OR His name is John.


Basically, I want the variable list to reduce by THE one element which has been used earlier.

I am trying this with numbers, so, in the range from 1:5, If A=2, then B can be either 1 OR 3 OR 4 OR 5, but not 2.


Your help would be highly appreciated.

Thanks and Regards

Mithil

In reply to Mithil Sharma

Re: Formulas question type fro Moodle 2.0

by Thomas Killoran -

I tried the following, but then pick didn't do what it was supposed to:

Random:  n={0:3};

Global:

A=pick(n,["Tom","Dick","Harry","George"]);

n1=n+1;

B=pick(n1,["Tom","Dick","Harry","George"]);

n2=n==3?1:n+2;

C=pick(n2,["Tom","Dick","Harry","George"]);


It kept giving me wrong selections.  For instance:

Tom  n=3 (should have been George)

Dick  n1=4 (Should have been Tom)

Dick n2=1  (Should have been Dick)


This is the first time that pick has failed me.

From the description it should work:

pick(i,X) 
pick(i,x0,x1,...) 
pick(1<2,["A","B"]) 
"B" 
pick(10,"","A","B") 
"" 
pick(1,[1,2],[3,4]) 
[3,4] 
A safe variant of list subscript. It will pick the i-th element from the list X or the first element if index out of range. 
pick(i,x0,x1,...) will pick the i-th element in the [x0,x1,...] , or x0 if index out of range.


I removed the [  ] and it worked until n=4, then it would leave that one blank instead of picking the first element.

In reply to Thomas Killoran

Re: Formulas question type fro Moodle 2.0

by Bernat Martinez -

In my opinion  pick doesn't fail,  according your set up  n takes the values 0,1,2, to take the 4 values you have to write

Random:  n={0:4};  take  values 0,1,2,3

In reply to Bernat Martinez

Re: Formulas question type fro Moodle 2.0

by Thomas Killoran -

It is my limited understanding that the following code should produce 5, but I get zero back.


A=pick(5,[0,1,2,3,4,5,6]);

In reply to Thomas Killoran

Re: Formulas question type fro Moodle 2.0

by Bernat Martinez -

Take into account that you are picking from a list composed of one element,

A=pick(5,0,1,2,3,4,5,6); => A=5


In reply to Mithil Sharma

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Hello Mithil

I am not sure I understand correctly what you want but you could try this:

Random variables:

 F=shuffle(["John", "Jack", "Daniel", "Alex"]);

Global variables:

A =F[0];

B= F[1];

C= F[2];

Then A B and C will all contain a different firstname

So then in the question text if you write

1) My name is {=A}.

2) Your name is {=B}

3) His name is {=C}

You will get something like

1) My name is Jack.

2) Your name is Alex

3) His name is Daniel

Explanation

  F=shuffle(["John", "Jack", "Daniel", "Alex"]);

will put a permutation of the list ["John", "Jack", "Daniel", "Alex"] in variable F ( for instance["Jack", "Alex", "Daniel", "John"])

Then when we do something like A =F[0]; we will get the first element of the list F, Jack in our example

B= F[1]; will give us the second element of list F (Alex in our example)

C= F[2]; will give us the third element of listF (that is Daniel in our example)


In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Mithil Sharma -

You hit the nail on the head - that's exactly what I wanted.

Thanks a lot!!

Mithil

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Mithil Sharma -

Hi Jean

One more here:

How can I get a random list which can be shuffled?

e.g.:

A=5;

B=7;

C=3;

F=shuffle(5 numbers between 1 and 9, 7 numbers between 11 to 19, 3 numbers between 21 to 29);

Here, 5 numbers, 7 numbers and 3 numbers equate to variable A, B and C.


The resultant list could be something like this:

F = shuffle(2,1,2,3,5, #i.e. 5 numbers between 1 and 9

11,15,12,12,16,14,18, #i.e. 7 numbers between 11 and 19

22,26,23 #i.e. 3 numbers between 21 and 30);

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Pierre Pichet -
Hi Jean-Pierre,
Perhaps the new branch to Tim GitHub to add subscript superscript in the editor could help you although it is related to a different project (easy unit editing interface, I presume).
https://github.com/timhunt/moodle/tree/supsubeditor
Pierre
In reply to Pierre Pichet

Re: Formulas question type fro Moodle 2.0

by Pierre Pichet -
Hi Tim,
For your subsupeditor, you are adding a new lib application in the main lib directory (as you created the new MathLib functions).
As far as I understand from the limited access of an Ipad, Jean-Pierre modifiy the edittor at the question level. There was a recent bug on lang strings related to this.
What are the limits if any, of what can be done with the editor at the plug-in question level ?
This could be useful to discuss how improve the Cloze question editing interface.
Pierre
In reply to Pierre Pichet

Re: Formulas question type fro Moodle 2.0

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

The code I pushed is not 100% finished. I just wanted to push it to github before going home on Friday to make sure it was backed up. I still have to decide how best to organise it and include it in the question types, but just getting this far was hard enough: http://tjhunt.blogspot.com/2011/08/good-bad-and-ugly.html

You are right that the ability to customise TinyMCE opens up all sorts of interesting options for improving question editing.

In reply to Tim Hunt

Re: Formulas question type fro Moodle 2.0

by Pierre Pichet -
Your blog is a superb illustration of the amount of work behind your such valuable Moodle and OU contribution.
Pierre
P.S. And put me in a student role of TinyMCE internals... smile
In reply to Tim Hunt

Re: Cloze question editing improvements

by Pierre Pichet -
Tim,
There are many internal plug-ins or external tools that are proposed as a substitute to previous or actual (2,1) editing interface.
The editing help should be of increasing complexity to handle the different users needs.
1. Adding questions "squeletal examples" to copy and paste
As the help available in 2,0 is less detailed, a casual reminder of the different questions format could be usefull.
A select button synchronize to an input element (with a copy button) is one solution

2.The decode question text should pinpoint syntax error
The analysis code should be extended to be more helpfull ( +- at a debugger level).
3.The edition could be done with an detailed interface similar to the moodle form
This could be done integrated to the HTML editor or as a a variable editform.

There are many arguments pro and con that need to be discussed.
I let you decide if it this the appropriate time to start this discussion and if so, how do you want it to be done.
Should we first put proposals on docs ?
Pierre
P.S. the variable editform could be a variant of an old proposal smile
In reply to Tim Hunt

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Hello,

I feel like Piere has somewhat hijacked my thread big grin

And even been a math teacher I am somewhat lost in this story of supsub things wide eyes

Do you mean you want buttons to help students enter superscripts/subscripts ?

If yes, I strongly disagree (and I am not alone),

The TinyMCE buttons for exponents/subscripts will be the first ones I will suppress in tinymce on my Moodle 2.1 website for september 2001 !

Let me explain :

Clearly the last years have show a clear vinner between the "linear entry" of math formulas and the point and clic method (the Mathtype or DragMath method).

Typing math formulas as a string is certainly not new and TeX or LaTeX are here since many years but none of my students would bother learning them (they are not studying math or science !) too complicated !!

But quite a lot of simpler syntaxes for linear imput of math formulas are now widerly used even and by a lot more people than TeX ever was :

- Word (2007 or 2010) support a linear form of math expressions input. Murray Seargent has many interesting posts on his blog about why this was choosen when Microsoft decided to switch from the old point and clic tool (done by the same editor that sell Mathtype) to this one.

- the LibreOffice/OpenOffice suite has a component named math to enter equations that also implement a linear syntax (of course different from Microsoft one !)

- go to any blog/forum where pupils/students exchange about math (and ask for help to do their homework big grin) and you will see that even if the blog has no support for math they use a linear syntax that permit them to exchange their formulas quite effectivly even if it is a very primitive syntax.

- in September 2010 it was the first time my Moodle 1.9 website offered to my students 2 differents tools to enter formulas : one point and clic (Dragmath) and one linear (Asciimathml thanks to the work of Mauno Korpelainen). during the year I saw exactly 0 students using DragMath and 2 reported having tried and having abandonned because it was "to complicated" and it was "not doing what they wanted".

In fact I can divide my students in 3 groups :

  • the first one hate maths and would not bother to enter any formula,
  • the second one use the same primitive linear syntax you see on blogs without any tool at all,
  • and the last one has understood that asciimathml syntax is pretty similar to that primitive syntax but that if they clic on the magic button and type (x +3/2)^2 inside the backticks they will get a beautifull formula.

So for me linear syntax is the winner and point and clic formulas are obsoletes. I will no more offer Dragmath to my students.

Back to the formulas question type :

Luckily linear syntax was choosen to input responses to formulas questions (and to algebra question too, but with a button that display the resulting equation and also show to the student what the system understand from their typing) and I have no intention to change that feature.

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

This editor is part of a two-pronged attack on the problem.

For even moderately complicated maths input, we are going to use linear input with instant preview, just like the formula question type. I was quite pleased when I saw that. The system we are adapting (stolen from another Open Source project) looks a lot like that. Clearly great minds think alike.

But for really simple numerical of chemistry input, like 3x108 or SO42-, we want a very simple wysysg editor. Because it is so simple and limited we can use the up and down arrow keys as a shortcut for super and subscript. That makes typing the input even easier than typing something like 3x10^8 (by one key stroke!).

In reply to Tim Hunt

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

I understand the problem a lot better.

Clearly the input of ions like SO42- is a case where subscript and exponent buttons are better (I confess I used them to type this). For 3x10^8 I don't think there is a clear winner and for the number of keystrokes 3e8 (remember your small "scientific" calculator back in school ?) is the winner (formulas understand 3e8 with no problem)

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by hon wai lau -

Do you think that the subscribe display is useful? The current intrepretation of under the answer box will display "v_x^2" as "v_x2" but it should be able to display it as "vx2" by adding only one replacement rule in the format check javascript. Though SO42- will never be considered as a correct answer because it is not a mathematical formula.

In reply to hon wai lau

Re: Formulas question type fro Moodle 2.0

by Pierre Pichet -
  " Though SO42- will never be considered as a correct answer because it is not a mathematical formula." unless you use it in a chemistry kinetic equation smile .
Pierre
In reply to Pierre Pichet

Re: Formulas question type fro Moodle 2.0

by hon wai lau -

This is why the subsupeditor would be useful. The chemical formula here is prefectly fit within a short answer and likely there is only one/few answer, if I remember correctly since chemical formula of molecular should have a particular sequence rule.

In reply to Tim Hunt

Re: Formulas question type fro Moodle 2.0

by hon wai lau -

Hi Tim,

I think that most student will think that the linear input easy to use so that I have implement such a functionality. The students only need to know the following rules:

  • "x^y" means x to the power y
  • "x y" means x multiply y
  • "3e8" means 3x108

which will make them learn very quick and the editor will hint them when they are inputing wrong stuff. It is actually different from your supsubeditor which allows you to input the super and subscribe and it does not check for the validity of a formula.

My format check, however, will also check whether the student input a wrong stuff (under the answer type for the input box). For example, if students careless enter "log(3+exp(4)" without closing bracket, a warning sign will be shown. BUt the supsubeditor will not hint such thing. For the same reason, the

Hi Tim,

I think that most student will think that the linear input easy to use so that I have implement such a functionality. The students only need to know the following rules:

  • "x^y" means x to the power y
  • "x y" means x multiply y
  • "3e8" means 3x108

which will make them learn very quick and the editor will hint them when they are inputing wrong stuff. It is actually different from your supsubeditor which allows you to input the super and subscribe and it does not check for the validity of a formula.

My format check, however, will also check whether the student input a wrong stuff (under the answer type for the input box). For example, if students careless enter "log(3+exp(4)" without closing bracket, a warning sign will be shown. BUt the supsubeditor will not hint such thing. For the same reason, the SO42- will always be wrong in the formulas question type.

One more thing that I want to mention is that the formatcheck is very portable so that it can be easily used for other question type. Only few things needed to be done:

  • Include the javascript
  • Provide a correct path of the warning sign
  • Add the class 'formulas_number' the answer box

Then the format check will be attached to the answer box.

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Hello Tim,

I need your expertise to take the good decision in my upgrade of the formula question to QE2.

Let me explain my problem by showing you one example of formula question.

Imagine a question with its random and global variables :

formulas variables

here 2 random variables are sets (the first one is a set of lists) one element of each set will be choosen for each variable at instanciation. So data is a list and scale is a number.

3 global variables x, y, and Z are defined depending of these random variables.

Then we have the text of the main question :

In it you see place where the instanciated values of x, y and z will be displayed between curly braces and also the place of the 3 subquestions {#1}{#2} and {#3} each one will have it's answer field and it's submit button

I will ony show one of the 3 subquestions as they are pretty similar (only the local variables and the formula for the answer is different, the calculation of the average don't need any local variable

formula answer

Then (always in the question editing screen so I think Pierre would love it because it's complexity clearly beat any other question type editing screen  i have seen before big grin we have the possibily to ask for as many as we want instanciation of the variables to see what the results are :

instanciation

My problem is that for all this to work there is some functions that I need both in question.php and in questiontype.php (for instance to validate all this data when the form is submitted) and even with your explanation of the respectives roles of these 2 files, I can't decide.

Of course there are many solutions to this problem (including to put them in a third file) but in fact my real problem is that I can't decide if these functions are methods of my questiontype or of my question definition ! In fact I think my problem reveal I don't have a clear inderstanding of the role of question definition and questiontype I was beleiving type was just to "deal with the databases tables of my question" and initialise the question instance so I was tempted to put all these functions in question.php because after all they concern the "inner working" of the question. But if i do that what is the best method when I need them to validate the data entered in the form ?

After all word was simple when all we had was a bloated and mixed questiontype.php big grin just joking

Can you help me ?

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

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 would say that there is some lower-level back-end work to do with parsing input and calculating formulas which is then used in several places: by the question class at runtime, by the editing form validation method, and by some of the question type methods.

Therefore, I would write a separate class to handle this sort of thing, a bit like qtype_calculated_variable_substituter https://github.com/moodle/moodle/blob/master/question/type/calculated/question.php#L261

And advantage of doing it that way is that you can then write some tests for that class, to convince yourself it is working. E.g. https://github.com/moodle/moodle/blob/master/question/type/calculated/simpletest/testvariablesubstituter.php

Once you are certain that the basic operations are working properly, you can then go on to right the higher-level stuff like from validation without having to worry about all the details at the same time.

My example of the calculated qtype is not, however, ideal. I converted the calculated types to Moodle 2.1 in a rush just before the deadline, so although questiontype.php includes question.php in order to get access to some of the useful code there, it also still contains the definition of an old function qtype_calculated_find_formula_errors https://github.com/moodle/moodle/blob/master/question/type/calculated/questiontype.php#L1934an and you can see that some of the code in qtype_calculated_find_formula_errors was copied and pasted from there. It really ought to be cleaned up.

In reply to Tim Hunt

Re: Formulas question type fro Moodle 2.0

by Pierre Pichet -
Tim,
Perhaps we should set somehow ( forum, docs ) a more general view of numerical question handling by core or plug-in types.
As a first simple draw.
1-Numerical question types grade a number
--within a tolerance (relative or absolute)
-- expressed as regular form or exponential
--using decsep ( thousandsep if applied) specs
--with a number of significant figures
2-the number is
-- just a regular number
--rersult from a simple math formula
--result from a complex formula
----from a given formula already set like in spreasheets
----from a user built formula
3-The number is
-- individual so handled by a single question
-- one of the formula solution (quadratic roots) or part of a multistep question. This is handled
----by individual questions sharing a common set of values
----using a cloze question variant.
------ the cloze question editing interface can be done using regular moodle form or a specific html editor.
Pierre
In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Pierre Pichet -
"I feel like Piere has somewhat hijacked my thread "
This is more the result that our ( Tim, yourself, OU etc.) work are intermingled with a common objective to build question types to handle numerical value.
Your comments reflect the variety of teachers needs to build numerical questions.
Tim blog explains that his work on subsupscript is one of 3 new question projects that are more or less derivatives of OU development.
The other project uses a new "polish inverse stack" math library that was recently added in moodle/lib to create a math question with formulas somehow similar to this project.
This thread is about a question type that is put over cloze question.
Perhaps we are at the point to synchronize all these developments.
Let's the "boss" set us a proposal smile
Pierre
Tim new question types proposal was put somewhere on this forum.
In reply to Pierre Pichet

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Pierre,

I was just joking ! As when I said you love complicated question editing forms !

For the moment I am in fact quite happy that so many question type involving numerical problems are on the way for QE2. Because as you said "there is a variety of teachers needs to build numerical questions".

When you speak of "the other project" you are speaking of Jamie Pratt varnumeric question type ? I am following Jamie's progress on this one and on ddimagetoimage and I find varnumeric is quite intersting and the idea of variants is attractive. maybe people will find variants easier to understand than variables (as in formulas) or datasets (as in calculated) ? We will see ?

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by hon wai lau -

Most likely people need a simple way to make variants of similar question type. So if the varnumeric is simply to use and the variants is easier to understand, then people will choose it within their purpose. Though I have taken a look for the varinumeric qtype, but I bet that the formulas qtype has much more functionality than it.

At least now, you can create a question asking multiple algebraic answer, with variant! It is not even provided by the algebra question type in the Contrib. Though I know there are other plugin that allow even complex mathematics question and easier usage. However, those need setup other than a simple PHP environment and students need to learn diffcult syntax to input equations. In those question, it is better to ask students to write a paper homework because the intermediate step is also important. Hence, I think such functionality in the formulas qtype is already enough for most case.

In reply to hon wai lau

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Hello Hon Wai,
Don't misunderstand me, when I said that maybe people will find variants easier to understand than variables (as in formulas) or datasets (as in calculated), I will not be very happy if that happend, I will be sad !
Recently it was somewhat of a deception for me to read Tim survey results about uses of questions types and to see that so few people uses what I consider as "advanced" questions types and so many multichoices questions were in use. Even if Tim has given very sensibles reasons for that fact, it is still a deception for me.
But that won't stop me to be very interested in questions types like calculated, algebra, varnumeric and of course formulas (and other like java molecule editor or drag drop image to image to name a few).

I think each one can have it's users even if it is quite small vs the number of Moodle users creating multichoice questions
My method (I use Moodle quizes only for learning/training, not for testing/evaluating) is to first think to what I want to test : what mathematical concept, what ability, what knowledge, and after (but only after) to think what would be the best question to reach this goal.
This is why I found the 3 videoconferences on e-assesment recently posted by Tim Hunt so interesting (and easier to follow than I had expected for a french speaking teacher !).

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by hon wai lau -

Emm, sorry I really get the wrong meaning. The survey results really out of my expectation. The question bulid in type I find most useful is the multianswer and yet it turns out there are only 0.64%.

It seems that most teacher use it for testing only since the MC, T/F and shortanswer are 95%. The similar percentage of calculated and numerical also suggest that teachers want the variation in question. Luckily someone has used my question type sad, but the algebra question type is not include here so I would consisder it not a accurate statistic. I am interesting to know how many people are using the formulas question type.

BTW, why are you interested in so many question types? It is not likely that you will use them all.

In reply to hon wai lau

Re: Formulas question type fro Moodle 2.0

by Paola Manzini -

perhaps I am misunderstanding the issue, but I can tell you that several commercially available packages for higher University are marketed precisely because of the "algorithmic" feature of giving variable algebraic multiple answers. To give you an idea of what I mean have a look here:

http://wps.pearsoned.co.uk/ema_uk_he_sydsaeter_essmath_3/

this is freely available, and the randomization is only in the order of the answers by the look of it, but other (commercial) platforms that I have investigated for my course would allow variation in the anwers. For a calculus course this is very important, and if I understood correctly these are functions that can be implemented with STACK or Webwork, which however have to be integrated with Moodle, while the advantage that I see with a plugin is that it takes next to nothing to my system administrator to install it - but I am no techie and may be talking rubbish on this point.

The providers of the platforms I have seen are large publishers (Mc Graw Hill and Financial Times/prentice Hall), so there is definitely a market for this, otherwise these guys wouldn't spend their resources in marketing it. But it is very possible that many teachers, like me until a few months back, think it may be easier for them to get these packages bundled with the textbook than go for Moodle. Why don't they know about Moodle? If they are like me, they get a lot of correspondence for publishers (especially if you are teaching course with hundreds of students), while Moodle is something they've got to find out on their own...

So in short I am very sure there is a lot of untapped demand out there for the formula question type!

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Paola Manzini -

sorry, I am somewhat lost (forgive me, I am a non techie final user!): so does the updated formulas plugin work for 2.0?

 

EDIT: I meant 2.1, sorry!

In reply to Paola Manzini

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Hello,

Sorry there is no version for Moodle 2.1 available now. This thread was in fact questions I asked to Tim Hunt because I am in the process to upgrade this question type to Moodle 2.1.

But don't hold your breath because :

  • the formulas question type is complex
  • I din't wrote it, Mr Hon Wai Lau wrote it so I must understand what the code do before trying to modify it
  • I am not a professional coder, just a teacher like you, and doing that is just a hobby, I must also do my teacher work.

So I can't give any date for the release of a version for Moodle 2.1.

For Moodle users using Moodle 1.9 or 2.0, versions of the formulas question type are already available on this download page.

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Paola Manzini -

many thanks Jean-Michel, good to know about the timing, so that I can start to think of other way around it - and I wish I had your abilities smile

In reply to Jean-Michel Védrine

תשובה ל: Re: Formulas question type fro Moodle 2.0

by anat peri -

hello. 

1. thanks for yuors work, it is wery usefull.

2. how can i input the formula of power?

i tryed P=pow({a},{N})

and {a}^{N}. it doesn't work

In reply to anat peri

Re: תשובה ל: Re: Formulas question type fro Moodle 2.0

by hon wai lau -

Hi,

There is no need for the {} and the "^" means "exclusive or" in the editing interface. The correct syntax is P = pow(2,5); Or if a and N is variable, then P = pow(a,N);

To begin with, you may find the tutorial useful. You can also found the details of options and complete documentation. You may download and import the examples-new.xml to see how a workable example look like.

In reply to hon wai lau

תשובה ל: Re: תשובה ל: Re: Formulas question type fro Moodle 2.0

by anat peri -

thanks, it wirs.

i have another problem

how can i make the question for comparring between $${A}^{{N}}$$   and $${A}^{{N}+1}$$  if the {A} is real number

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by hon wai lau -

Hello Jean-Michel,

If you have finished the backup/restore, you may post it and notify me. I will merge it and make the appropriate change before releasing the final version. Note that the database table is a different from the version you post here and I may change the code for that part. Thanks

In reply to hon wai lau

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Hello,

I pushed a new version to my github account.

The only difference is in backup/restore functions: this version should correctly restore backups created in Moodle 2.0.x by the release 3.0 of the formulas qtype.

There were in fact 2 distinct problems:

  • 2.0 backups of formulas questions are missing some fields, so the restore code need to provide a default value,
  • but also I had (stupidly) changed an XML tag between versions. I reversed the change and now use the same XML tag as in 2.0 backups.

The consequence is that it is rather important that all people who have downloaded formulas from my github account since I announced it, download it again and install the new version, because if they don't do that, and they create course backups, these backups  will not be restorable in any future version.

Thanks to anat peri for providing me with a (huge smile) backup to diagnoze the problems.

It's quite funny my previous version was correctly restoring 1.9 backups but not 2.0 backups (but it was understandable given I never used Moodle 2.0.x)

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Paul Nicholls -

Hi Jean-Michel,

Thanks for your fantastic work on this - I was worried that I might have to do it myself wink

Your MOODLE_23_STABLE branch doesn't seem to have received the patch you mention (to fix restore of 2.0 backups); is the master branch currently in a usable state, or is it better to cherry-pick the backup fix onto MOODLE_23_STABLE?  If the best option is to cherry-pick onto 23_STABLE, are there any other patches which should be picked as well?

 

Cheers,
Paul

In reply to Paul Nicholls

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Hello Paul,

Thanks for reminding me I must work on other branchs !

For the few last weeks (months ?) I only worked on master branch and there are a lot of things I need to backport on the other branchs.

In fact nearly anything, except some changes I did in the master branch on the creation/edition form that are specific to Moodle 2.5, need to be backported.

I will do that and report here.

As you speak of restoration of 2.0 backups, I need to warn you this problem is not fixed even in the master branch and bad news are that this problem is more difficult to fix than anticipated.

Fortunately upgrade 1.9 -> 2.0 -> 2.2 ->2.4 is working (please note that the recommended path if you are running Moodle 1.9 is to completely skip Moodle 2.0 and to upgrade to Moodle 2.2 which is the latest Moodle release to support upgrade from 1.9) and all restores are working except the 2.0 one so a workaround would be to create a copy of your 2.0 website, upgrade it to 2.2 and create a backup.

It would be complicated to explain why I have big problem specifically with the restoration of 2.0 backups but the fact is I have !

 A last note, but very important when working with formulas: before attempting a "big" upgrade like 1.9 ->2.2 or 2.0-> 2.2 or 2.2->2.4 , you need to always upgrade first your moodle to the latest relase of the branch you are on, so for instance before doing a 1.9 -> 2.2 upgrade, first upgrade to 1.9.19+ or if you are upgrading from 2.0 to 2.2, first upgrade to 2.0.10.

And of course always backup your database and files before doing anything !

Note also that the upgrade to 2.2 if you have a lot of formulas questions attempts is very processor intensive and time consuming, I had upgrade running for hours on big sites. fortunately the tool to upgrade questions attempts (qeupgradehelper) can be used with formulas questions attempts like for any other questions types (see Moodle 2.1 release notes)

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Paul Nicholls -

Hi Jean-Michel,

Thanks for the update.  If the only issue is with 2.0 backups specifically, that's not a problem for us - we skipped 2.0 (we're moving from 1.9 to 2.4 by restoring backups - so we lose user data, which is not a problem for us).  I'll try out your updated MOODLE_24_STABLE branch on a test site and see how it handles our situation.

Cheers,
Paul

In reply to Paul Nicholls

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Thanks, don't forget to report if you find problems or have suggestions.

I am very interested by your experience as I don't know of a big site that has upgraded by restoring a lot of 1.9 backups (It was tested but with small or moderate size backups)

Good news is that I just pushed an update on all branchs except MOODLE_19_STABLE and restore of 2.0 backups is now working. In fact I was trying to build an awfully complicated solution and a very simple one (just 3 lines of code) was enough to solve the problem smile

Bad news is that while testing this solution I discovered a nasty typo in my latest commit to the MOODLE_20_STABLE branch a few months ago so all users of the formulas question type with Moodle 2.0.x should upgrade ASAP to the latest version available on github or their backups will fail miserably. Sorry for that. The problem is only on the MOODLE_20_STABLE branch so users of other branchs aren't affected by this problem.

You are wise to stay away from Moodle 2.0.x smile

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Paul Nicholls -

That's good news.  I've just submitted a pull request to fix the file migration (in the moodle1 backup converter) - I've only done it for the MOODLE_24_STABLE branch, but I expect that at least master (and maybe MOODLE_23_STABLE?) will also need it.

Our overall migration to 2.4 seems to be going well - I wrote an admin report for 1.9 which generates CSV files which can be used with a modified version of the "upload courses" admin tool in 2.4 to import the automated backups from 1.9; we've migrated several hundred courses so far, with no major issues.  We'll have to run 1.9 and 2.4 in parallel for a while yet, but intend to migrate the last courses over and shut down 1.9 at the end of the year.

In reply to Paul Nicholls

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

thanks Paul,

But I have a problem with your pull request.

The 2  lines with the call to $this->migrate_files function should do the migration of those files (I know this function very well, I wrote it smile see MDL-33424) it was introduced in Moodle versions 2.3.6 and 2.4.3. If it is not working for you, this is a bug either in Moodle or in formulas and this bug should be fixed rather than calling directly migrate_referenced_files. I will investigate.

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Doh, there is a stupid typo in one of the 2 lines calling $this->migrate_files blush !

$answer['subqtext'] = $this->migrate_files(($answer['subqtext'], 'qtype_formulas', 'answersubqtext', $answer

You see: one parenthesis too much !

I should have tested this when I uncommented this code after MDL-33424 was fixed.

I will push the fix to 23, 24 and master branchs smile

In reply to hon wai lau

Formulas question type adding new functions.

by Girish Belkar -

I would like to add some new functions in variable.php.

For example to find mean of data values.

I have written a php function for this and included in variable.php. But this is not working. Can anybody help what other modification are to be done in variable.php

In reply to Jean-Michel Védrine

תשובה ל: Formulas question type fro Moodle 2.0

by anat peri -
Dear all -
 I need your help again. I am trying to create a question (Moodle 2.0, Formulas 3.0) 
that includes images both in the main question field and in the subquestion field.
 While creating the question, I can see all the images displayed correctly in both fields 
(see attached screenshots 1 and 2). However, once the question is saved,
 it only displays the image in the MAIN question field - but not in the subquestion field 
(see attached screenshot 3).
Is there any reason why this should happen?
 Am I doing something wrong? Any ideas/suggestions? Thanx in advance!
Attachment 1.gif
In reply to anat peri

Re: תשובה ל: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Hello,

It seems you have found a bug. This should not happend.

I wil test and report.

If you display the html page sourcecode, what is the src= parameter for theses images (if you don't know how to find it, just save it in you browser and send it to me vedrine _AT_ vedrine _DOT_ net

If you try to re-edit these questions, what is displayed in the editor for the subquestion text ? images, nothing, broken images ?

Sorry for the inconvenience.

In reply to Jean-Michel Védrine

Re: תשובה ל: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

I think I see the problem.

At first I was surprised by your bug report because I had downloaded the 3.0-rc package from Hon wai Lau's website a few days ago and verified that image management in subquestion text was OK.

I did again some tests and was not able to replicate your problem, so i was puzzled surprise. Then fortunately i had the idea to delete my question/type/formula subfolder then download again formulas-3.0-rc.zip, unzip and test and bingo ! images were broken big grin. I checked and found the package is missing a very little but very important file for images management : question/type/formulas/lib.php. this file is only 3 lines of code but without it images are not displayed.

This file is in the zip I put on this forum on July 12th but is missing from formulas-3.0-rc.zip. Most probably I forgot it when I send the files to Hon Wai Laublush. But I hadn't spotted the problem the first time because I had put files from formulas-3.0-rc on top of my old files without deleting the old ones so lib.php was not missing on my website.

So I am attaching a lib.zip, file. Unzip, take just the lib.php file (not the folder, just the lib.php file and put it on your server in question/type/formulas subfolder so that you have question/type/formulas/lib.php. Display some of your questions, your images should be displayed OK. If not, report on this forum.

In reply to Jean-Michel Védrine

תשובה ל: Re: תשובה ל: Formulas question type fro Moodle 2.0

by anat peri -

thanks. it is great.

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Simon Maina -

Hey Jean,

Is there a formula plugin version for moodle2.2?

We got moodle2.2 and don't want to just move to 2.3 if the needed plugins are not supported.

 

Regards

In reply to Simon Maina

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Hello Susan,

I am still working on the version of the formulas question type for Moodle 2.3 (please note that it will most likely require a very recent version of Moodle 2.3.1+)

I hope to be able to release a first version at the end of this month (August) but I expect this version to be missing some features (for instance it is unlikely that the upgrade of students attempts or the restoration of 1.9/2.0 backups will be done). Also most probably the public release will reveal some bugs because a lot of code was rewritten due to the changes in the question engine between Moodle 2.0 and 2.3.

Once this version is done (I need it first because my production website will be running Moodle 2.3.1 starting from september and I use formulas questions) I will make the necessary changes for a Moodle 2.2 and maybe 2.1 version (not really sure for Moodle 2.1) but unfortunately as soon as my summer holidays are over in 4 weeks my spare time to work on this is a lot reduced so I can't give any schedule for the release of a 2.2 or 2.1 version.

It is also unlikely that restoration of 1.9 and 2.0 backups or upgrade of 1.9/2.0 students attempts will be ready in a near future because :

  1. due to the complexity of the formulas question type these features are very difficult to code
  2. I don't need them

I promise to look at these once I have the question itself done but it's better that I state they aren't on top of my to do list.

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Simon Maina -

Then better wait for the 2.3 version. I will give my hand in testing it coz we also need it and use it a lot, currently using version 1.9.4 and the 2.1 was used in a project but the formula plugin was not installed in it. There are plans to upgrade to a latest stable version. Am SImon btw not susan, if u were ref. to me or is it coz I wrote Jean instead of Jean-Michel

In reply to Simon Maina

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Hello Simon,

Sorry for the confusion about your firstname, I don't remember what I was doing while answering your previous post maybe writting 2 messages at the same time or thinking to some other post from somebody named Susan ?? I really don't know. I apoligize blush.

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Eugen Neuber -

Hello Jean-Michel!

This is great news!

I'm now using the question type "var numeric" (which is great for single questions!) but we need random variables and subquestions, so we have to turn off "random order of questions in quiz" sad

A version of formulas for moodle 2.3.x is very welcome smile

kind regards
Eugen
In reply to Eugen Neuber

Re: Formulas question type fro Moodle 2.0

by Rob Bowden -

Hello Jean-Michel.

It has been a little while since any updates, I know everybody is busy but how is the development going?

I used your old version which was fantastic, the best by miles for my classes. Now we have moved from a test (1.9 server) on to version 2.3 and I am missing the plugin!

Is there anything similar that I could use temporarily while I am waiting for release.

Kindest regards

Rob

In reply to Rob Bowden

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Hello,

I must admit it was a lot more work than expected to port this question type to Moodle 2.3.

When Summer holidays ended unfortunately I hadn't finished, and since september I didn't manage to find any time to work on this.

The problem is that you can't say "Today I will work on formulas for an hour or two" because to be productive you need to spend a lot more time on it.

My main problems are in renderer.php wich is now an awfull mix of old and new code and need to be rewritten almost entirely. There are also a few TODO left in question.php but they are details and notes to myself.

As the renderer is also responsible of feedback and grades' display there are a lot of bugs (feedback displayed when they shouldn't, ...) that makes the question type impossible to use in its actual state. Anyway my tests seems to show that all sample questions are now correctly graded using all behaviours, "only" the display is wrong;

Some weeks ago I took the decision to put it on my github account despite the poor state of the code (and all the debugging code) so that :

- it is hosted somewhere and can't be lost

- maybe somebody with more free time (and more skills) can help me

If you want to have a look it is here

But this is a work in progress so don't use it on a production server. You have been warned !!

Anybody wanting to help me to finish this ?

Note : to test it you need to install Tim's adaptivemultipart behaviour available here

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Rob Bowden -

Thanks for the reply Jean-Michel, I would love to help, but lack the php coding experience, however I found it very interesting looking through the code.

I am sure there are experts lurking on the forum that would be more than happy to help out.

In reply to Jean-Michel Védrine

תשובה ל: Re: Formulas question type fro Moodle 2.0

by anat peri -

hello, Jean-michel.' 

unfortunally i don't have skills for writing programs, but i'll install it on my probe server and will try it.

i really apresiate yours work and need the plagin, so i want to help

In reply to anat peri

Re: תשובה ל: Re: Formulas question type fro Moodle 2.0

by mana mboh -

Hi Jean-Michel,

Thanks for the effort you put in. Like previous posters, I have little PHP experience but would like to help anyway I can.

First though I need to install on a sandbox adn have a play. Could you indicate the steps to install it. For instance, my attempt comes up with an error message about a missing table. Would it be OK to create the table manually using PhpMyadmin?

Regards

Mana

In reply to mana mboh

Re: תשובה ל: Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Installation of the "work in progress" formulas question type.

As  a general warning I don't recommend to attempt this without some familiarity with installation of Moodle plugins from git repositories because I wont be able to spend a lot of time helping people to install this unfinished version even if I understand people are impatient to test it.

Also this should only be attempted on a test installation of Moodle and with a very recent release of Moodle 2.3.2+

I suggest that before installing anything you activate debugging and set error level to DEVELOPER on this test site so that all errors messages are diplayed because if something goes wrong it will be usefull for me if you can give me the full error message.

First step install Tim Hunt adaptive multipart question behaviour. You can get it here https://github.com/maths/moodle-qbehaviour_adaptivemultipart

If you download the zip file to install it be sure to read and follow the installation instructions and verify the folder have the right name, is installed in the right place and contains the right files.

second step install the formulas question type from my github account https://github.com/jmvedrine/moodle-qtype_formulas. There is no installation instructions for the moment.

You need to have all the files in the question/type/formulas subfolder, beware that when you download the zip file and unzip you get a folder with a strange name like "jmvedrine-moodle-qtype_formulas-898fc54" that needs to be changed to "formulas". Its also a common mistake that during the unzipping process people get a supplementary level of subfolder, you should see all files in question/type/formulas/ : the backup,db lang,overlib, pix, script, tests subfolders and all the other files.

Login to your moodle website as administrator and go to Site Administration Notifications. You should see 2 plugins needing to be installed : adaptive multipart question behaviour and formulas question type. Install as usual for all Moodle plugins.

That's all.

Once the installation is successfull, you should be able to create, edit, import (Moodle XML format only), export (Moodle XML format only), preview and include in quiz some formulas questions.

I suggest to go to Hon wai Lau's website to learn more about formulas questions. There are a few changes I was forced to do to adapt it to Moodle 2.3 but only minor ones ( mainly grading scheme and how grading is done in adaptive mode, the display during attempt is also somewhat different because I wanted to make it similar to other question types).

I also suggest to import the example-new.xml sample file from the download page as this will give you some formulas questions to play with and a good overview of formulas questions features.

To Mana : if you get a warning about a missing table this is the sign that installation was not done correctly (or that there is something defective in formulas). Don't attempt to create anything manually. See if you have followed all steps in installation and if you think you did it right, we need to understand why installation works on all my test sites but not on yours.

In reply to Jean-Michel Védrine

Re: Formulas question type for Moodle 2.x

by Simon Maina -

Congratulations!! Jean-Michel Védrine,

I got the formulas plugin installed successfully together with the full installation of adaptive multipart question behaviour, though I installed everything manually. We've began testing and willing to support you in testing. Will get back to you  soon.

In reply to Simon Maina

Re: Formulas question type for Moodle 2.x

by Jean-Michel Védrine -

Hello,

Just a short note to report I have uploaded a new version of the formulas question type for Moodle 2.3 to my github account.

I expect this version to be less buggy than the previous one wink.

I would be interested in bug reports, mainly about the display using various behaviours.

There are so many feedbacks in this question type that maybe I should explain what each one is used for

General feedback : as usual the only thing specific is that global variables are allowed and will be replaced by their value.

Combined feedback : I must underline that this feedback is related to the question as a whole not to each question's part (subquestion).

In adaptive and interactive with many tries behaviours this feedback is displayed after each check/try.

Global variables are allowed and will be replaced by their value.

Part (subquestion) feedback : there is one such feedback for each question's part. This is the only feedback where not only global but also local variables for that part are allowed and will be replaced by their value.

IMPORTANT: As discussed some month ago this feedback is only displayed if the student answer for this part is wrong !

Hint: Only used in interactive with many tries. The only specific thing to the formulas question type is that global variables are allowed in hints and will be replaced by their values.

Part grade display: when using adaptive behaviour, a grade for each part is displayed after each response check. It's in fact not a feature of the formulas question type but of Tim Hunt's adaptive multipart behaviour that you must install to be able to install the formulas question type.

In all other behaviours (including interacrtive with many tries) there is no grade display for each question part, only a global grade for the question sad.

But in interactive with many tries behaviour the "Clear incorrect responses" and "Show the number of responses" are available with each hint smile.

I must one more time emphasize that this is a work in progress and not ready in my opinion to be used on a production server. And also that a lot of feature are still missing : upgrade from Moodle 1.9 or 2.0, restoration of course backups made by Moodle 1.9 or 2.0.

The only goal of this message is that "motivated" users can help me to iron out as much bugs as we can before adding the remaining missing features.

As you can guess this question type is very complex and rewriting it for the new question engine is a big task (In fact now that I know the complexity of the task, I wonder whether I should have undertaken it smile, but it's too late, and I really think that the worst is behind me !)

I have tested this new version with Moodle 2.4 (and 2.5dev) and the only  problem I see is that Hon Wai Lau's javascript is no more working (it is still working well with Moodle 2.3.3+ latest version). That doesn't prevent the question type from working but the nice syntax checker tooltip for each response field with the incorrect syntax warning is gone sad

And the bad new is that I have very limited javascript knowledge !

In reply to Jean-Michel Védrine

תשובה ל: Re: Formulas question type for Moodle 2.x

by anat peri -

GOD bless you!big grin

In reply to Jean-Michel Védrine

Re: Formulas question type for Moodle 2.x

by Jean-Michel Védrine -

Another thing that I think need some explanations is how marks are calculated in interactive with many tries and in adaptive behaviours.

Interactive with many tries

The grading is done using a "countback" method for each part of the question.

The code look at the try when the student changed his reponse for this part for the last time.

  • If this response is wrong, part's mark is set to 0.
  • If this response is right, part grade is equal to mark calculated for that response (rules are unchanged for previous versions of formulas question type, except that I suppressed the "trial mark sequence" available in previous versions of the formulas question type) minus question's penalty multiplied by the number of tries until that last change.

Note that this is similar to what will be done for multianswer questions in Moodle 2.5 once MDL-36955 (accepted by Tim and currently waiting for integration revue) is integrated in Moodle.

Note that it's quite possible to have a right response at try 1, then  a wrong one at try 2, then again a right response at try 3 and in that case 2 time the penalty will be deduced. Of course if you have activated "Clear wrong responses" the student was stupid to change his response for that part between try1 and try 2 smile.

Adaptive

When you choose this behaviour, each time the student press the  "Check" button a new try is not necessarily recorded for each part of the question :

- a new try is recorded for a part if the student's response for that part is a new one (it has never be seen before for that part during the attempt). This is to make sure the same mistake is not penalized twice.

- no try is registered for a part if there is no response. This means that it is possible to try a response for some parts of the question and not been penalized for unanswered ones.

- once a part is correctly answered, input is disabled and no further try can be recorded for that part.

At the end of quiz attempt, each question part is graded separately and mark for a part is either 0 if final response is wrong or calculated mark minus question penalty multiplied by the number of tries recorded for that part.

Average of ratings: Useful (1)
In reply to Jean-Michel Védrine

תשובה ל: Re: Formulas question type fro Moodle 2.0

by anat peri -

Hello Jean Michel,

This is Anat Peri

I am sorry to bother you, but i was wondering when the Plug-in will be ready, since we are waiting anxiously for it. Would you please tell us approximatly when it will be ready?

Thank you very much for you're help we appreciate it very much.

In reply to anat peri

Re: Formulas question type for Moodle 2.0

by Jean-Michel Védrine -

Hello you, all fans of the formulas question type smile

I need your help again and you don't need to be a developer to help me.

I am begining to test the code to upgrade students attempts during 1.9 or 2.0 upgrade to the new question engine or to restore 2.0 backups with students data.

But I have no real data to test it on thoughtful (it has already been tested on sample data).

This is because as I only use quiz for practice not for evaluation, at the end of each academic year I delete all students quiz attempts. I surely have database backups of the time where I used Moodle 1.9 and formulas somewhere but that is sooo long ago !

Are some of you able to send me some 1.9 or 2.0 backups ? I am only interested in 1.9 or 2.0 backups with quizes containing formulas questions and user attempts for these quizes. I understand there may be concerns about privacy doing so but I can testify they will only be used for tests and by nobody but me, and all copies will be deleted after that.

If you are able to help me you can send me a private message.

Thanks.

In reply to Jean-Michel Védrine

Re: Formulas question type for Moodle 2.0

by Jean-Michel Védrine -

Hello,

I have now some courses with quiz and students attempts (Thanks go to anat peri again), so I am able to do all the testing I want.

Import of 1.9 and 2.0 backups seems to work quite well (you can test it yourself if you want, I uploaded the code to my github account, but of course only on a sandbox, not on any real data !!)

This has also permit to test the question code on a much wider base of questions and to spot and correct some bugs. The last one this morning was just a missing parenthesis in the renderer but it was producing quite strange feedback colors and icons (a wrong response could be yellow or even green smile).

So if you plan to test this question type it would be good to download it quite often from my github account to be sure to have the latest version because I upload it each time I fix a significant bug.

I will now test the complete upgrade of a Moodle 1.9 and 2.0 website with formulas questions to Moodle 2.2 (latest version to support the upgrade from 1.9).

In reply to Jean-Michel Védrine

Re: Formulas question type for Moodle 2.0

by Jean-Michel Védrine -

Hello,

Just a report on progress in the 2.3/2.4 version of the formulas question type.

  • The javascript checling student's reponse syntax while typing (the one that show the little red triangular warning if the response is invalid) is working again ! This quite a victory given my poor knowledge of javascript but the mistake (wich is here since the first version of formulas but was apparently only breaking with the new way scripts are minified in Moodle 2.4) was quite evident from a programming point of view : use of a reserved word as name.
  • There is now some kind of response analysis for formulas questions when you go to Results -> Statistics and click on a question. Limitations is that it doesn't work if the question is using a complex grading formula (questions where there is something in the "Grading criteria" that can return a result different from 0 and 1).
  • The right answer for each part is displayed as all the other outcomes under each part rather than using a popup (I am not a big fan of popups smileand this is one of things I don't like in the multianswer question type). If there is a strong demand I can create a setting to permit to switch to popup/no popup for the right answer display.
  • The display of answer fields (as a box, a select menu or a group of radio buttons) have been improved and is quite nice now in my opinion big grin. It's in fact using quite the same code as the multianswer question.
  • On a side note my course on probability start in 2 weeks and will be the first one to use quiz with formulas question with a group of 150 students. This will permit me to do some performance tests (I don't use tests for evaluation, just for training, so don't expect me to be able to answer the question "What happen if 150 students start a test with formulas questions exactly at the same time ?". Well I know the answer without testing: probably your server will hang !)
  • My tests on restoring a 1.9/2.0 backup or upgrading a 1.9/2.0 website unfortunately show that upgrading the attempts is a very calculation intensive operation and take quite a loooong time even on a powerful computer. So don't expect to be able to upgrade a big site or restore a monstruous backup. If I find the time I will try to cache some results because I know the bottleneck : calculation of the right answer and of the question summary for each attempt and hopefully these are the same for a big number of attempts on a big website. A shortcut is to put empty strings for these 2 fields as it only affect the responses report I think.
  • I am quite worried by the fact there is no bug report (only anat reported a missing feature that was re-implemented since). Does it mean that my code is bug free ? I don't think so ! Please provide some feedback.
In reply to Jean-Michel Védrine

Re: Formulas question type for Moodle 2.0

by Jean-Michel Védrine -

Maybe some of you will have noticed something in my previous message : the display of answer fields (as a box, a select menu or a group of radio buttons).

Yes this is a well hidden secret of the formulas question type: each coordinate of each part can be displayed not only as a "classical" text input (we can call this the "shortanswer display") but also as a select menu (we can call this the "menu display") or as a vertical group of radio button (we can call this the "multichoice display"). To my best knowledge this is not documented anywhere and Hon Wai Lau explained it only one time in this forum, giving an example.

I discovered it digging in the code, and was about to suppress it because I was thinking that nobody was using it but anat peri told me he was using it, so I decided to re-implement it, improve the code and document it.

To use this feature, rather than including the {_n} placeholder in the part text where you want the input for the nth coordinate of the part to appear (for instance {_0} for the first coordinate, {_1} for the second, ...) you use the syntax {_n:choices:MCE} for a select menu and {_n:choices} for a group of radio buttons.

choices is a list of strings to appear as the menu choices or the radio button choices. You can use all the power of the formulas calculation engine to build this list. They are indexed starting at 0.

For the "answer" of the part you must give an expression (can be a variable) that is equal to the index of the right answer in the choices list.

An example of each type is included in the attached xml file.

The only drawback is that if a coordinate of a part is a select menu or a group of radio buttons, the right answer for the part will not be displayed at the end of the attempt even if you check the corresponding option in the quiz settings (because I don't know how to do it !). But nothing prevent you from using the part, general or combined feedbacks to give the right answer.

In reply to Jean-Michel Védrine

Re: Formulas question type for Moodle 2.0

by Jean-Michel Védrine -

Hello,

After spending a lot of time creating questions and among them of course a lot of formulas questions smile (course are starting in a few days !), I want to make small changes in the editing process.

You know, I am very inattentive, so most of the time I create a question, but validation tell me I forgot to enter the mark for one of the question's parts. Or I realize after pressing "Save" that I have not changed the answer type for some parts (for most questions I want to choose numeric fomulas as this semester I am teaching probability and I don't mind if a student enter 2/10 or 0.2)

So I think I waste time for nothing. Better to improve the editing process to suit my needs, but of course, even if as the maintainer, I can do what I want, I don't want to complicate life of people using formulas !

Here is my thinking:

Now: During question validation a formulas part is discarted silently if it has not mark. If a formulas part has a mark but no answer, an error message is displayed.

Futur: A default mark equal to 1 is attribued to all new formulas parts. When validating question a formulas part is silently discarted if it has no mark OR no answer. If a part has no answer or no mark but the part's text, the part feedback or the part's local variables are non empty an error message is displayed (this is done so we don't lose valuable text or calculation smile).

I have also introduced questions settings so I can have a default value for default answer type and default grading criteria.

formulas settings

Please if this changes don't suit the way you create your formulas questions, tell me now because after a few days testing this changes to verify there is no regressions, I will commit them to github.

 

 

In reply to Jean-Michel Védrine

Tárgy: Formulas question type fro Moodle 2.0

by imre zsolt -

Hi,

I think this (and its pair by Hon Wai Lu) is the best plugin for moodle, with this plugin all needs of elementary maths (+physiscs/chem) can be solved easily.

One question is on the design side: how (if anyhow) can I change the size (width or length) of answer boxes ? the _1, _2 etc

In most cases the simple numerical answers needs only 2-6 digits, but the input box is 20-25 digit long, so it is very hard to implement an inline question with this size.

thx for support !

Zs

In reply to imre zsolt

Re: Tárgy: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Hello imre,

Sorry it took me so long to answer your question.

If you want to change the field size for all formulas questions then you can edit question/type/formulas/styles.css. these class have names formulas_unit, formulas_number,formulas_number_unit, formulas_numeric, formulas_numeric_unit, formulas_numerical_formula, formulas_numerical_formula_unit, formulas_algebraic_formula and are defined with sizes ranging from 130 to 300 pixels.

But I agree it would be a lot more interesting to be able to specify a size on a question part basis.

The problem is that I need to find a syntax to specify size and where it should be done (question text, part text, ...)

also it must not break the special syntax used in a formulas question to specify that a part must be rendered as a multichoice question.

No an easy problem but I will think to it.

Average of ratings: Useful (1)
In reply to Jean-Michel Védrine

Tárgy: Re: Tárgy: Formulas question type fro Moodle 2.0

by imre zsolt -

Hello Jean-Michel,

thank you for the answer; I modified the "width" values in the mentioned css but it has no effect to the displayed field sizes; the firefox developer info tells the input fields have "width=auto" with 153px effective value (moodle 2.7 latest formula qtype), somehow related to yui functions; do you have any idea which part of code rewrite the style.css value ?

BR

Zsolt


In reply to imre zsolt

Re: Tárgy: Re: Tárgy: Formulas question type fro Moodle 2.0

by Bernat Martinez -

Hi , 

I have tried to resize answer fields size in Moodle 2.6.6 and it doesn't work , strangely enough I have tried in M1.9.19 and  works, 

Any hint where to make changes?

BR

Bernat


In reply to imre zsolt

Re: Tárgy: Re: Tárgy: Formulas question type fro Moodle 2.0

by Bernat Martinez -

Hi Imre, 

I have changed the size of the answer  field in M2.7 , I have substituted the css file for the attached file, then I reinstalled Moodle and it works. 

I have also informed to Jean -Michel for additional testing. 

I hope this can help you.

Best wishes
In reply to Jean-Michel Védrine

Re: Formulas question type for Moodle 2.0

by Jean-Michel Védrine -

Today the formulas question type is finally available in the Moodle plugin Directory, see here.

Sorry it took so long  to do that.

Now the next task is without any doubt to document it properly because Hon Wai Lau's original documentation is not easy to understand and miss some pedagogical examples of formulas questions.

Also the changes I made to port this question type to the new question engine were never documented, apart some posts in this forum so part of the documentation is now obsolete and screenshots are not showng the current user interface.

Of course this is a huge task.

I had some discussions with Tim and the first thing is to decide if I go for

  1. some internal documentation like the Stack question type
  2. pages in  the Moodle Documentation

I need to take a decision

After that I think the most needed part are

- How to create a formulas question (including help for all the fields in the edit screen)

- cookbook of examples of formulas questions

Of course I know there are users of the formulas question type reading this (and I hope there will be more users now that it is more easily available) so I hope some of you will be able to help me with this task.

Thanks

Average of ratings: Useful (5)
In reply to Jean-Michel Védrine

Re: Formulas question type for Moodle 2.0

by Bernat Martinez -
Hello Jean Michel, 


Congratulations for your great work, now formulas being an "official" plugin, more people will know about it and it will improve their use in teaching. 

Of course I offer myself to assist you in the big task ahead, for the moment our group could present different examples of how we are using formulas questions in Maths and Physics teaching. But we could also help in other ways,  just say it.

Thanks for your effort and efficient work

Bernat

In reply to Bernat Martinez

Re: Formulas question type for Moodle 2.0

by hon wai lau -

Thanks for the contribution. A lot of examples would be an easiest way to help people to learn how to create variety of questions.

In reply to hon wai lau

Re: Formulas question type for Moodle 2.0

by Jean-Michel Védrine -

Yes a lot of examples is the main thing that would help people.

For instance when I speak with formulas question type users I see that most of them don't realize how powerful the pick and map functions are and what wonderful things you can do with them smile

In reply to Jean-Michel Védrine

Re: Formulas question type for Moodle 2.0

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Jean-Michel,

Hon Wai's 26 examples are excellent, short and simple. It is easy to understand the feature that is being illustrated. Maybe new examples could have the same format.

(https://code.google.com/p/moodle-coordinate-question/downloads/detail?name=examples-new.xml&can=2&q=label%3AFeatured)

_______

I have used the "pick" function which I found indeed quite neat. smile

In reply to Dominique Bauer

Re: Formulas question type for Moodle 2.0

by hon wai lau -

I am not sure if it is excellent, but the coverage is pretty complete. I do want to see some more fancy example using graphic (with random value), such as those with svg, etc. I do use Java animation together with the question which take the advantage of random values. Those questions require more than a simple equation, i.e., some forward and backward calculations that would be possible in this question type.

In reply to hon wai lau

Re: Formulas question type for Moodle 2.0

by Bernat Martinez -

Hon wai, congratulations for your great work, as someone has said in the forum, it is ALL a maths-science primary/secondary teacher need to develop nice and didactical questions. 

We are just starting to explore the design of formulas questions using graphic (with random value) in combination with jsxGraph ( http://jsxgraph.uni-bayreuth.de/wp/). The graphic is external to Moodle, maybe in the future we could insert the javascript code in the formulas question itself. 

You may have a look at http://mustpro.eu/moodle/course/view.php?id=5  login as alu/alu

What you say about forward and backward calculations sounds interesting....

Thank you very much

In reply to Jean-Michel Védrine

Re: Formulas question type for Moodle 2.0

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Jean-Michel,

Happy 60th anniversary !

I find the Formulas question type very useful. Now, I am using it for all my problem solving quizzes. Students also tell me that they like this question type.

Recently, I went through Hon Wai Lau's documentation and was able in a few days to make decent Formulas questions. I did not think that the documentation was particularly difficult to understand. In fact, it would have been even simpler if I had a better knowledge of modern programming languages such as JavaScript-- I have used only Fortran, Basic and Pascal dating back to before the advent of Internet...

I think that you could build on the original documentation. In my user's point of view, there are only a few small mistakes to fix, undocumented information to complete and some explanations to add.

In any case, congratulations and thank you for your excellent work !

In reply to Jean-Michel Védrine

Re: Formulas question type for Moodle 2.0

by Germán Valero -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hi Jean-Michel,

Congratulations on your formulas question type plugin available in the Moodle plugins database smile

I was translating the English language strings for it in AMOS and found a couple of minor typos:


vars1_help | qtype_formulas

You can define variables here in the same way as global variables are defined at the question level. Variables defined here can be used in the part's ansver or feedback and their scope of visibility is limited to the part


'ansver' should be 'answer'


settingusepopup | qtype_formulas
Use popups for correct anser and feedback

'anser' should be 'answer'

They are really two very tiny typos, but should be very easy to fix.

Thanks in advance.



In reply to Germán Valero

Re: Formulas question type for Moodle 2.0

by Jean-Michel Védrine -

Hi German,

Thanks for contributing to this plugin translation and reporting these typos.

I am amazed you managed to submit your translation before my own French translation wink (now submitted but not yet accepted by French pack manager).

I released a new version with your corrections and also some smalll changes as trying to complete the French translation discovered some untranslatables strings in the UI (mainly strings in javascript files).

So you now have some more strings to add smile

In reply to Jean-Michel Védrine

Re: Formulas question type for Moodle 2.0

by Germán Valero -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hi Jean-Michel,

All AMOS strings for this plugins are now fully translated into Mexican Spanish.

I just installed your formulas question type and it seems to work perfectly in Mexican Spanish cool.

I will try to translate into Spanish the sample questions that are included in the ZIP file, and send them to you as soon as I have them.

In the mean time, a Moodle Docs page stub about this question type was made at https://docs.moodle.org/28/en/Formulas_question_type , and its spanish translation at https://docs.moodle.org/all/es/question/type/formulas , but there is not yet a French translated Documentation page available surprise.

Congratulations again for a nice plugin.



In reply to Jean-Michel Védrine

Re: Formulas question type for Moodle 2.0

by hon wai lau -

Hi Jean-Michel,


Congratulation to successfully port the Formulas question type to the new Moodle version. I am surprised to receive an email notification of the revival of this plugin after three years since I was thinking it is dead now. It has costed me more than a year full time work to develop. Watching it obsoleted is kind of sad, but I can't spend anymore time on it. Developing it cost lots of time, but maintaining it requires even more patience. Thank you for your great work to keep this plugin working in the modern version of Moodle. I expect that a lot more people will find it useful.


Cheers,

Hon-Wai

Average of ratings: Useful (2)
In reply to Jean-Michel Védrine

Re: Formulas question type for Moodle 2.0

by hon wai lau -

Hello Jean-Michel,

I just have a very quick look of your new codes. You have changed almost all of the questiontype.php to adapt the new question engine. It must be a lot of works for you, thanks for you efforts. I am sure you know how to do that correctly. I have noticed about the extra function in the variables.php.

As the other developer mentioned, it may pollute the global namespace because of the common name. In particular the function "fact", which is not quite obvious to me that it means factorial. "fac" may be better. Also, I don't really know if it is useful to allow student to use the "fact" as algebraic function, probably it is. Anyway, just be care to add new function because it is hard to go back without any complain.

Also, if possible, you may consider to add the extra significant figure function sigfig(x,ns) which should be the most useful function for creating nice question. For example, if a variable A is taking value of A = 1/7. = 0.1428571428, then sigfig(A,4) = 0.1428. I was using round function for this purpose, but sigfig() is actually better than the round() function when the random number is over few order of magnitude.

Sorry for not having read the forum and not reply for the people's questions, but I see that you have done a good jobs. Thank you very much

In reply to hon wai lau

Re: Formulas question type for Moodle 2.0

by Jean-Michel Védrine -

Hello hon wai,

Thanks a lot for these good news. I was so sad no to have any news from you.

You created a wonderful question type and I use it a lot with my students.

I decided to use the name fact when I added the factorial function because it was the one used by Excel so I guess a lot of people around the world are already familiar with that name, this is for then same reason I choose combin for the number of combinations . Changing this now would break a lot of my existing questions sad

In fact I mainly use it when building questions about combinatoric and probability.

Yes sigfig would be a nice and useful addition. I will do it.

In reply to Jean-Michel Védrine

Re: Formulas question type for Moodle 2.0

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hon Wai,

You have done in "more than a year full time work" more than many people would have not been able to do in more than ten years.

Now that I have started using the Formulas question type in my course on Structural Steel Design, it would be a disaster for my class if, for some sad reason, this question type would become unavailable.

Your plugin (the way it is setup, the various features, etc.) is quite a remarkable and great piece of work!

Congratulations and thank you.

In reply to Jean-Michel Védrine

Re: Formulas question type for Moodle 2.0

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Jean-Michel,

I have worked around the fact that sigfig is not (yet) implemented in the Formulas question type by coming up with the following very short variable assignment which works with any real number:

xr=x==0?x:round(x*pow(10,nsf-1-floor(log10(abs(x)))),0)*pow(10,-nsf+1+floor(log10(abs(x))));

where nsf is the number of significant figures.

(https://moodle.org/mod/forum/discuss.php?d=274975#p1181946)

I am mentioning it in case it may help.

In reply to Jean-Michel Védrine

Re: Formulas question type for Moodle 2.0

by hon wai lau -
Hi Jean-Michel,

I am now a student studying physics PhD, as I find research is more interesting to me. So, I am not in education sector and I won't use this question type in the near future. Glad to see that you keep maintain it and give it a new life. Most open source project die in the same way when the original author leave without successor.

For the factorial, well, you can just use simple replacing in your database, right ;) It is not really a problem, since there are only few dozen functions there. I prefer the full name, but simplified name is not a serious problem and it may be more consistent. Just go ahead, I am not the one developing it now.

The actual problem is that I don't know your why you want to let the student to use it. Factorial is not that useful in the answer if they can type the answer as 4*3*2*1, isn't it? You may also notice that there are no javascript hint in students quiz page of "fact()" (the auto-calculation hint, do you understand what I mean?).
In reply to Jean-Michel Védrine

Re: Formulas question type for Moodle 2.0

by hon wai lau -

Here are some comments of the documentation and random stuffs that I still remember:

(1) About Algebraic answer type: I find that a lot of people get it confused how to make it work. It may be because this question type was never used in any of real courses. I have accidentally found out that a slight change in the core codes will allow it to grade an algebraic answer, so I finished that part in few weeks. And the documentation is not quite good on it. The evaluation method to grade the algebraic answer is similar to the Algebra Question Type, as follow:

Suppose the correct answer is f(x,y,z,...), and student's answer is g(x,y,z,...). Obviously, it is correct when f(x,y,z,...) - g(x,y,z,...) = 0 for all x,y,z,... In practice, if we evaluate at a subset of random points, and if all the difference are 0, then we know the answer is probabilistically correct. It may sound problematic, but the probability of wrong grading is actually decrease exponentially with the number of random points. With few dozens of random points, it will have wrong grading probability down to 10^-16.

This is the idea of grading, so when people want to use the algebraic answer type. They must define a set of random number as, say, A = {1:100}. It is likely enough for most case, or they can define larger points if they want, say, A = {1:100:0.1}. A set with single value such as A={1} with NEVER ever work. Please put this in the new documentation.

(2) About the Physical Unit system: This allow the real free form answer input from student, and the system will give hint when it is incorrect. This is actually the best part of codes I have ever written. I have put a lots of thought on how the physical unit system, and now I understand a much better about the physical meaning. I don't think there are any other question types out there have anything similar to it. Anyway, the documentation here is not that good, and I hope someone can help complete it.

(3) Probably the only missing thing in the core grading part is the ability to accept answer in any order. For example, the root of polynomial can be in any order. However, this is not a trivial task. The easiest implementation should be a special function to calculate all possible combination and return the smallest absolute error.

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Arcadio Perez Puig -

Hello. Thank you for this addon. It's the most powerful question type I'm using in moodle.

I started using this addon 2 months ago with no problems, but this week I detected one. When I use decimal numbers in the questions, sometimes the system marks wrongly even if i write rightly.

Here is an example:

Question

And here is the question data:

 <question type="formulas">
    <name>
      <text>Division por potencias de 10 (enteros)</text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>{dividendo} : {divisor} =</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.3333333</penalty>
    <hidden>0</hidden>
    <correctfeedback format="html">
      <text><![CDATA[<p>Respuesta correcta</p>]]></text>
    </correctfeedback>
    <partiallycorrectfeedback format="html">
      <text><![CDATA[<p>Respuesta parcialmente correcta.</p>]]></text>
    </partiallycorrectfeedback>
    <incorrectfeedback format="html">
      <text><![CDATA[<p>Respuesta incorrecta.</p>]]></text>
    </incorrectfeedback>
    <shownumcorrect/>
<varsrandom><text>origen={1:9999};
od={10,100,1000};
divisor={10,100,1000,10000};</text>
</varsrandom>
<varsglobal><text>dividendo=origen/od;</text>
</varsglobal>
<answers>
 <partindex>
  <text>0</text>
 </partindex>
 <placeholder>
  <text></text>
 </placeholder>
 <answermark>
  <text>1</text>
 </answermark>
 <answertype>
  <text>10</text>
 </answertype>
 <numbox>
  <text>1</text>
 </numbox>
 <vars1>
  <text></text>
 </vars1>
 <answer>
  <text>dividendo/divisor</text>
 </answer>
 <vars2>
  <text></text>
 </vars2>
 <correctness>
  <text>_err == 0.0</text>
 </correctness>
 <unitpenalty>
  <text>1</text>
 </unitpenalty>
 <postunit>
  <text></text>
 </postunit>
 <ruleid>
  <text>1</text>
 </ruleid>
 <otherrule>
  <text></text>
 </otherrule>
 <subqtext format="html">
<text></text>
 </subqtext>
 <feedback format="html">
<text></text>
 </feedback>
</answers>
  </question>

If I use absolute numbers, everything works fine.

Where is the mistake?

Thank you.

 

In reply to Arcadio Perez Puig

Re: Formulas question type fro Moodle 2.0

by Germán Valero -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hi Arcadio,

I tried it .

Please see the screendump at https://docs.moodle.org/all/es/Tipo_de_pregunta_fórmulas

SPANISH formula OK

And it works OK with the Mexican Spanish language pack, which uses a decimal point (just as Moodle in English does) , but the International Spanish language pack uses a decimal comma as a decimal separator.

In reply to Germán Valero

Re: Formulas question type fro Moodle 2.0

by Arcadio Perez Puig -

I forced my course to Mexican Spanish language pack and the problem remains.

Example (using Mexican language pack):

Formulas question

It's random. I use a 10 questions quiz, and the error appears once or twice in every quiz. Sometimes everything is ok. It's crazy! sad

It could be something related to the language pack. I don't know.

In reply to Arcadio Perez Puig

Re: Formulas question type fro Moodle 2.0

by Germán Valero -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hi Arcadio,

Can you make a question export of the questions that causes  the problem(Moodle XML format) and enclose the file, so that I can reproduce the problem ?

Average of ratings: Useful (1)
In reply to Germán Valero

Re: Formulas question type fro Moodle 2.0

by Arcadio Perez Puig -

Hello.

Here is a xml file with only one question. It's the question I used in my first post.

I forced to English language pack and the problem persits.


Thanks!!

In reply to Arcadio Perez Puig

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

I forgot to say it's useless to try different languages packs because all calculations in the formulas question type always use the decimal point even for countries where a comma is used.

Even if I live in a country where we use a comma (France), I am quite pleased with this decision made by Hon Wai Lau when creating the question so I never looked at changing it.


In reply to Arcadio Perez Puig

Re: Formulas question type fro Moodle 2.0

by Jean-Michel Védrine -

Hello,

I don't think this is a problem with the question code.

I think this is related to the fact you choose absolute error == 0 and floating point math not beeing exact for decimal numbers, so for some numbers it works and for some numbers it fails.

You must be very careful when you use absolute error with numbers that are not integers.

Average of ratings: Useful (1)
In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Arcadio Perez Puig -

Thank you! You're right. The problem was in the grading criteria. The divisiors are all 10 raised to the n and I forgot that computers don't move the comma, they divide ;)

I changed to relative error and now everything works fine! Thank you very much!!

In reply to Arcadio Perez Puig

Re: Formulas question type fro Moodle 2.0

by hon wai lau -

I didn't try, but I am pretty sure it is the numerical accuracy problem. You should always expect two different way of calculations will result in a difference in machine epsilon, which is less than 1e-15. That is also the reason why almost all numerical question type requires you to specify an acceptable error range.

Without any special reason, you should use something like _err < 1e-12 for those question that you want almost prefer match. The zero error only occur when the answer involved is integer and no division, etc. And some special case that you don't want to know.

Average of ratings: Useful (1)
In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Thomas Killoran -

Is there a repository where example questions can be uploaded to?  I would love to share what I have created and borrow what others have done.

In reply to Thomas Killoran

Re: Formulas question type fro Moodle 2.0

by Thomas Killoran -

I have found a problem with the Algebraic Answer part.  It will not allow for log(x) or log(x,b) as the algebraic string, but it will take log10(x).

Any insight?

Attachment Screen Shot 2015-07-11 at 10.50.58 AM.jpg
Attachment Screen Shot 2015-07-11 at 10.51.45 AM.jpg
In reply to Thomas Killoran

Re: Formulas question type fro Moodle 2.0

by mike thiem -

Hi i know about moodleshare.org, and then there is https://moodle.net/

Would love to collaborate on authoring some questions 

Mike thiem 

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Tom Dindorf -

Hi all!

Question: is there a way to use a student's response to Part 1 of a question to evaluate the validity of his/her answer to a question in Part 2?

I would like to allow for 'error carried forward' i.e. if the answer to Part 2 is correct in light of the answer to Part 1 (which may be itself incorrect), the student should score full marks for Part 2 despite scoring none for Part 1.

I can use an answer (_0, _1, _2 ...) to evaluate the accuracy of another answer in the same Part by using 'grading criteria' in that Part, e.g.

case0 = _0 == 25

case1 = _1 == _0/10, 

case2 = _2 == _1+5

case3 = _3 = _2*6

...etc

but this method does not allow for split marks - or does it?

Thanks.

In reply to Tom Dindorf

Re: Formulas question type fro Moodle 2.0

by Tom Dindorf -

Follow up:

With Grading criteria I can (somewhat) split marks.  If in the above example the answers were worth e.g. 20%, 20%, 30%, and 30% of the Part's mark respectively, the Grading criteria would be

case0*0.2 + case1*0.2 + case2*0.3 + case3*0.3

However, when one of the answers is incorrect, in adaptive mode (after clicking Check) all fields are yellow i.e. the student does not know where (s)he made a mistake, whereas what I'd like is for the answers where case# = 0/1 to be red/green, respectively.

Thanks.

In reply to Tom Dindorf

Re: Formulas question type fro Moodle 2.0

by Tom Dindorf -
Found a workaround:
  • declare a list as a Global variable, e.g. Answers = [0,0,0,...]
  • in one Part's Grading variables, assign the current answer to the list e.g. Answers[n] = _0
  • in another Part's Grading variables, create a grading condition/case e.g. c1 = _0 == Answer[n]+5, then use it in Grading criteria.

Curios by-product (bug?): from within Grading variables it appears possible to to change a value on an element in a global list when Check is clicked e.g. A[2] = 17 will now be available to other Parts; however, a global number: e.g. B = 17 will revert to whatever B was in Global variables after Check is clicked.

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Gary Marsh -

I am developing a Moodle site  (Moodle 2.9.2+) and just installed the Formulas Quiz Question plugin, which seems to be working properly and very well . . . this is an excellent calculated question plugin option and I congratulate all concerned for your brilliant work.

Question: How am I able to position the partial answer window next to and on the same line as the partial answer text?

Attachment Formula Test.png
In reply to Gary Marsh

Re: Formulas question type fro Moodle 2.0

by Gary Marsh -

Ok. I just figured out that I will need to change the TinyMCE forced_root_block option to remove the default <p></p> tags.  Now I just have to figure out how to do that!!!

Sorry!

In reply to Gary Marsh

Re: Formulas question type fro Moodle 2.0

by Bernat Martinez -

Hi Gary, 

Nice to know you solved the issue yourself . Sometimes it is useful to write yourself the answer {_0} and check HTML editor in order to remove any unwanted code.

I'm glad to know formulas is working in M2.9, I didn't know it could be used there. I'm using  M2.8 and I have posted a notice regarding answer fields length. Maybe it could interest you

https://moodle.org/plugins/view/qtype_formulas

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Steve Turley -

I'm looking into upgrading our Moodle site to Moodle 3.0, but won't make the change if we lose the formulas questions type in so doing? Does it work as is for Moodle 3.0 or do I need to wait for it to be upgraded?

In reply to Jean-Michel Védrine

Can the response be a string?

by Jennifer Miller -

Hello,

I am just starting to use this plug-in in a moodle economics course. Is it possible to have a question where the response is a text string? For example, students calculate GDP growth for 2 countries, then answer which country grew faster by typing the name of the country. The country names are values of variables Country1 and Country2. 

For this particular question it looks like I could do a workaround, like "Type 1 if 'Country1' grew faster and type 2 if 'Country2' grew faster. But this would be useful to know for future questions.

Thanks for any guidance you can provide. I have tried the various answer types, including algebraic formula, and could not get it to accept these strings as answers.

Jennifer Miller

In reply to Jennifer Miller

Re: Can the response be a string?

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Question : Which is the country with the largest GDP?
Answer : USA

  • In Global variables or in Local variables, enter :

USA=1;

United_States=USA;
UnitedStates=USA;
United_States_of_America=USA;
UnitedStatesofAmerica=USA;
US=USA;
UNITED_STATES=USA;
UNITED_STATES_OF_AMERICA=USA;

where USA=1; defines the variable USA. Any number can be used.

Note that spaces cannot be used. They must be replaced by _ (underscore) or omitted.

  • In Answer Type, choose "Algebraic formula"
  • In Answer, enter with the quotes: "USA"
  • In Grading criteria, choose: Absolute error == 0
  • In Subquestion text, enter: Which is the country with the largest GDP?

Valid answers include: USA, United_States, UnitedStates, etc.

In reply to Jennifer Miller

Re: Can the response be a string?

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Question : Which is the country with the largest GDP?
Answer : USA

METHOD 1 - Select the answer

  • In Global variables or in Local variables, enter:

country=["Japan","China","United States"];
largestGDP=2;

where 2 is the position (starting from 0) of the correct answer in the country list.

  • In Answer Type, choose "Number"
  • In Answer, enter: largestGDP
  • In Grading criteria, choose: Absolute error == 0
  • In Subquestion text, enter: Which is the country with the largest GDP? {_0:country}

Students must select between Japan, China and United States.

METHOD 2 - Enter the answer

  • In Global variables or in Local variables, enter:

USA=1;

United_States=USA;
UnitedStates=USA;
United_States_of_America=USA;
UnitedStatesofAmerica=USA;
US=USA;
UNITED_STATES=USA;
UNITED_STATES_OF_AMERICA=USA;

where USA=1; defines the variable USA. Any number can be used.

Note that spaces cannot be used. They must be replaced by _ (underscore) or omitted.

  • In Answer Type, choose "Algebraic formula"
  • In Answer, enter with the quotes: "USA"
  • In Grading criteria, choose: Absolute error == 0
  • In Subquestion text, enter: Which is the country with the largest GDP?

Correct answers include: USA, United_States, UnitedStates, etc.

In reply to Dominique Bauer

Re: Can the response be a string?

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Of course, my proposed solution is just a workaround since text string response does seem to be implemented in the Formulas question type (or is it, Jean-Michel?). This workaround is somewhat odd, some will say that it is an improper use of variables, but I think that it works just fine.

In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

What if the "Formulas question type" was modified to have only one part and sharing variables between questions added?

It would, imho, make the question easier to implement, simpler to use, while leaving all the nice features.

In reply to Dominique Bauer

Re: Formulas question type fro Moodle 2.0

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Of course, my suggestion (the Formulas question having only one part) does not make much sense for the Adaptive mode.

However, for the Interactive with multiple tries mode, it may be an idea for future development, unless sharing variables between questions is not or not easily feasible.

In reply to Jean-Michel Védrine

תשובה ל: Formulas question type fro Moodle 2.0

by yarden pinto mossensohn -

hello!

i was looking in the forum if this question was raised before, but didn't find one...

i am now working with some friends on physics problems using formulas.

in physics it is very common to ask the student first about a symbolizing equation for a question (like the second law of neuton- f=ma)

i want the formla to identify a multiple available answers as the same answer.

like:

f=m*a

f=ma

f=a*m

f=am


and some answers as half wrong:

f=0+m*a


do you know how is it possible to do so?

In reply to yarden pinto mossensohn

Re: תשובה ל: Formulas question type fro Moodle 2.0

by Bernat Martinez -

This are my two cents

- not problem for formulas to accept m*a or a*m, using an algebraic formula ( a, m variables)

- ma, & am are treated as  2 different single variables so, I couldn't find a way to  be equal to m*a ( Maybe is possible)

- it is not possible to distinguish among m*a and 0 +m*a


In my opinion this could be solved more easily using cloze Q


In reply to yarden pinto mossensohn

Re: תשובה ל: Formulas question type fro Moodle 2.0

by Maurício Reis -

Some time has passed since you posted your question, but maybe I can help. With formula type question you can check for literal/symbolic answers. You just have to be clever enough to build them up. The easy way is to explain to your students how they can write a formula adequately, so you take advantage from the formula type question implementation. The idea is that the expression used by students is evaluated in some points. If they match, they check as correct. So, it would not be able to distinguish this: "f=0+m*a" from "f=m*a". The formula type question would also accept "f=m a", but from what you wrote above,  "f=ma" would not be accepted as answer, since it would treat "ma" as a single variable.



In reply to Jean-Michel Védrine

Re: Formulas question type fro Moodle 2.0

by Maurício Reis -

Hi there,

I was thinking if it would be possible to have a plugin specially adapted for use in this "Formula Question Type" so it would generate and display it "on the fly", I mean, on each running of the plugin. This way we could have different graphics questions for each student.