Having algebra type in a cloze question

Re: Having algebra type in a cloze question

by Dominique Bauer -
Number of replies: 20
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hello Ali,

No, I do not think you can have an algebra question in a Cloze. In a Cloze question, you can only have short answers, numerical answers and multiple choice. See https://docs.moodle.org/36/en/Embedded_Answers_(Cloze)_question_type.

Otherwise, the Formulas question can incorporate questions similar to algebra questions, numerical answers and, to a limited extent, multiple choice. 

Average of ratings: Useful (2)
In reply to Dominique Bauer

Re: Having algebra type in a cloze question

by ali rosta -

Thanks Dominique for your helpful answer. Is formulas a standalone plugin? or like stack qtype depends on external stuff  such as maxima.

In reply to Dominique Bauer

Re: Having algebra type in a cloze question

by ali rosta -

Thanks, we installed formulas on our moodle and now I'm playing with it.

I read through the docs but didn't find anything: Is it possible to have latex notation like \rho for variables and in the answer box? could be very useful

In reply to ali rosta

Re: Having algebra type in a cloze question

by Jean-Michel Védrine -

Hello,

Some answers:

  • Adding new subquestions types to the cloze question type is not easy. I wouldn't say it is impossible, because it can certainly be done, but the fact that since many years nobody (except Joseph Rezeau's work to add regexp grading to the shortanswer subquestion type) is a clear sign tof the complexity of such task. Additionnaly adding something like the algebra question type (wich needs variables) would be an even more challenging task.
  • Some years ago I looked at making the algebra question type combinable (usable by the combined question type) because I was thinking that as combined was developped to be easily extensible that would be easier than trying to add algebra to cloze, but even that prouved to be difficult (again because of all the settings and variables involved in algebra questions, and I must admit that I was not able to do it.
  • Unfortunately the rules for variables names in the formulas question type are that it must be a string of alphanumeric characters (a-z, A-Z, 0-9 and _) that cannot begin with a number or the underscore. Changing that would require changes to the parser so it is unlikely I will be able to do it. If your questions make huge use of greek letters, subscripts,... I suggest you look at the Stack question type but of course that would require to have Maxima running.
Average of ratings: Useful (2)
In reply to Jean-Michel Védrine

Re: Having algebra type in a cloze question

by ali rosta -

Thanks Jean-Michel for the comprehensive info. No I prefer formulas which is standalone and meets almost all our needs.

How about having unicode characters? Is it possible to use ρ for example in answer box or variable definition? that would be a perfect solution.

In reply to ali rosta

Re: Having algebra type in a cloze question

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

No, you can not use 'ρ'. A variable name is a string of alphanumeric characters (a-z, A-Z, 0-9 and _) that cannot begin with a number or the underscore.

In reply to Jean-Michel Védrine

Re: Having algebra type in a cloze question

by Jean-Michel Védrine -

Well after some thinking I am giving another try at making the algebra question compatible with the combined question type.

Currently my code has some limitations but it seems to be working (Warning: I only did a few tests)

  • There is no Answer box prefix as this is not needed in algebra subquestion included in combined question because you can write what you want in the combined question text before the algebra subquestion.
  • Allowed Functions is always "All" as this feature was never implemented wide eyes (I must remove it one day or finish it, it is here like that from the beginning when Roger Moore created this question type)
  • There is only one variable allowed in each algebra subquestion (this is the most important limitation unfortunately, I am still trying to allow several variables but I face some difficulties)
  • Each answer is always 100% and there is no answer feedback, only a global feedback for the subquestion when the student response is not correct (All combinable question types seems to have the same limitations so I don't know if this is a limitation of the combined API)
Currently the code is only available in my Github repository, but after some tests I will release a new version because I think that even with these limitations it could be of some use to Moodle users.
I must also warn that to do this I had to make changes to the code of the algebra question so it is quite possible that I broke something. Here also I must do some tests to be sure all is working as expected.
Average of ratings: Useful (2)
In reply to Jean-Michel Védrine

Re: Having algebra type in a cloze question

by ali rosta -
This is great. Actually one thing which I liked about algebra qtype is the

support for TeX variables like \beta,... which is not available in

Formulas. Wish the same happens for Formulas (or support for unicode chars

like θ :)



On Sun, Apr 28, 2019 at 11:16 AM Jean-Michel Védrine (via Moodle.org) <
In reply to Jean-Michel Védrine

Re: Having algebra type in a cloze question

by Jean-Michel Védrine -

As the Travis job is passing I think I have not broken the code too much but of course the combinable feature is still experimental, if you test it and find some bug then report.

While I was working on the algebra question I also used Marcus Green's huge work on adding mobile support to question types to add mobile support to the algebra question (works with Moodle 3.5, 3.6, ...) but I am totally unable to test it as I don't have a Moodle site running (only local install on my computer to do my coding). So, here also if you find some bugs, please report.

Thanks a lot Marcus, this was really helpful.

I will release the new version in the Moodle plugin database very soon.

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

Re: Having algebra type in a cloze question

by Jean-Michel Védrine -

I feel really stupid.

A few hours ago I released version 1.9 of the algebra question in The Moodle plugin database.

Then shortly after I found why my code to have several variables in an algebra question used as a subquestion of a combined question was not working. It was in fact a really stupid mistake because it was in fact rather easy to do.

So I have released version 1.91 and now I think it can be really useful to Moodle users to create algebra parts in combined questions.



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

Re: Having algebra type in a cloze question

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 have not had time to try it, but nice work Jean-Michel.

In reply to Jean-Michel Védrine

Re: Having algebra type in a cloze question

by ali rosta -

Dear Jean-Michel, sorry for the delay to install. Our sys admin installed both combined and the new version of algebra yesterday. Now I'm trying to make it work. But what syntax should I use for the algebra part? I tried:

An algebra question: 1:algebra:____


and got the error:

The question type identifier 'algebra' you entered in embedded code '1:algebra:___'is not known.

What would be the correct syntax to use?

In reply to ali rosta

Re: Having algebra type in a cloze question

by Jean-Michel Védrine -

Yes the identifier is algebra but there is no third parameter so the underscore should not be here, just something like

[ [ 1:algebra ] ]

Note that you should not put any space between the brackets but I added spaces here so that they are displayed in the forum

See the help here https://docs.moodle.org/36/en/Algebra_question_type#Using_Algebra_in_combined_questions

And when you create a new combined question in the question text there is a sample of the pattern you need to use for each subquestion type that is combinable to help you to find the right syntax.

As this feature is new, please tell me if you manage to make it work or not.

If you still get the same error message when you use the right syntax, please ask your sys manager to verify that he installed the right version of the algebra question type: there should be a subfolder named combinable in the question/type/algebra folder.

I am also interested in reports of Moodle users if they try to use algebra question in quizzes on the mobile app as I was not able to test this myself.

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

Re: Having algebra type in a cloze question

by ali rosta -

Thanks, they had forgot to update the algebra. Now it looks to partially work. But two problems:

1- I don't see the "display response" button when I put an algebra in a combined.

2- More important: It works only if I have one algebra. As soon as I combine two algebra question and press the "verify question text" it throws these exceptions:


Unsupported operand types

Debug info:
Error code: generalexceptionmessage

line 152 of /question/type/algebra/combinable/combinable.php: Error thrownline 178 of /question/type/combined/combiner/forform.php: call to qtype_combined_combinable_algebra->data_to_form()line 93 of /question/type/combined/edit_combined_form.php: call to qtype_combined_combiner_for_form->data_to_form()line 576 of /question/type/edit_question_form.php: call to qtype_combined_edit_form->data_preprocessing()line 222 of /question/question.php: call to question_edit_form->set_data
In reply to ali rosta

Re: Having algebra type in a cloze question

by Jean-Michel Védrine -

Unfortunately these are 2 limitations of the current version.

  1. I don't know how to display other elements than the input field, and I don't even know if the combined question type API support that
  2. Unfortunately currently only one algebra question is allowed in a combined question. I must modify the code so that this is enforced. Maybe there is a way to allow more than one algebra subquestion but I have not been able to do it.
I hope that despite these limitations, this feature can be of some use to Moodle teachers.
EDIT: Regarding issue #2, looking at the code it seems that I made a mistake that could cause this problem. Unfortunately I can't make any test to see if correcting that bug fix the problem because all my local installs of Moodle are broken since last week and I don't understand why. More: trying to create a new install of Moodle produce the same error so it seems that this is related to my setup (I use wampserver to run apache + php + mysql on my machine) but I don't understand why only Moodle is affected by the problem.
In reply to Jean-Michel Védrine

Re: Re: Having algebra type in a cloze question

by Jean-Michel Védrine -
I am pleased to report that today I have released version 1.93 of the algebra question that fix problem #2: it is now possible to have more than one algebra question in a combined question. In fact there was a bug in my code and it was only a 1 line change.
But as I wanted to be sure that this feature was working as expected I decided to add an automated test (Behat) of the creation of a combined question with 2 algebra subquestions and I must confess that it took me a lot more time to create and have the test passing than to fix the bug blush
Average of ratings: Useful (4)
In reply to Jean-Michel Védrine

Re: Re: Re: Having algebra type in a cloze question

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
"and I must confess that it took me a lot more time to create and have the test passing than to fix the bug blush"
Maybe, but that turns you from a hero to a super hero. Well done Jean-Michel.
Average of ratings: Useful (1)
In reply to Jean-Michel Védrine

Re: Re: Re: Having algebra type in a cloze question

by ali rosta -
This is great Jean-Michel. If you could workaround the limitation #1 somehow, then it would be the perfect solution for us and we won't need to go with complications of stack.
In reply to ali rosta

Re: Re: Re: Re: Having algebra type in a cloze question

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
is it the complexity of the setup that puts you off STACK or the process of creating questions with it?
In reply to Jean-Michel Védrine

Re: Having algebra type in a cloze question

by Miguel Bejarano -

Hi Jean-Michel

I am looking for specific information but I can't find any explanation.

What is "grading variable" for?

How is it used?

Thanks