New Algebra Question Type

New Algebra Question Type

by Roger Moore -
Number of replies: 129
This is something I've been playing around with for a while but only recently got a little more serious about since it would be useful to have for my course this september.

It is a new question type plugin for Moodle which implements symbolic algebraic responses. The students enter responses in a text box, like calculated and numeric questions, but underneath there is an extra button 'Display Formula' and a box. When they click on the button the textual formula they entered is rendered in the box so they can see that the program has understood it correctly. Since the comparison is algebraic responses like: x^2+x, x(x+1) and x^2+x+1-(cos(x))^2+(sin(x))^2 will all be regarded as the same.

There is an option of three different comparison methods which can be selected when writing a question: SAGE, Evaluation or Equivalence. The first of these uses a XML-RPC server connected to the open source SAGE symbolic maths software, the second 'cheats' by numerically evaluating the formula for random numerical variable values (ranges are configurable) and the last uses a very simple comparison of the answer and student response. More documentation is available by clicking the help buttons on the question edit form.

The Evaluation and Equivalence methods are completely PHP based and require no external servers. However the SAGE method requires installing SAGE and running the simple XML-RPC server included in the attachment (which you can also download from here).

Note that, although the basic functionality should work out of the box, the code is not been well tested and hence will not be very robust so please feel free to beat it up and let me know how it fails!

At the moment the XML-RPC server location is hard coded into the PHP code to be localhost (see included instructions on where to change this). I've looked at trying to implement an MNET server. However the SAGE end has to be in python and the python OpenSSL interface lacks the required crypto API to implement MNET. I could require use of the m2crypto package but this is not very commonly included outside Linux and would probably require compilation. So any suggestions on how to proceed here would be very welcome.

Detailed instructions on how to install the plugin are included in the download file as well as documentation, in the form of help files, for the different question options.

Since this is my first attempt writing PHP and also the first time I've written anything for Moodle my apologies if I've used things in a way I should not. However if you point out the problem I'll be happy to fix it! For this reason I would strongly recommend AGAINST installing this on a production server, especially if using the SAGE interface since this is an unencrypted connection and the SAGE end does not properly check its inputs.
Average of ratings: -
In reply to Roger Moore

Re: New Algebra Question Type

by Pierre Pichet -
Hi Roger
I work mostly in windows so I download AnyZip to decompress your gz archive but the decompressing does not work.
Could you put you files in another format like .zip or put the individual files.
Your algebgra formulas that are tested by there numerical values, puzzle me.

Pierre
In reply to Pierre Pichet

Re: New Algebra Question Type

by Roger Moore -
Ok, here it is in ZIP format as created by the version of zip included with OS X 10.5 so hopefully that will be compatible with your program - if not I'm open to further suggestions but there are quite a few separate files so single file uploads will unfortunately not be practical.

The numerical test of the formulae works by assigning a set of numerical values to all the algebraic variables and then evaluates the expression. e.g. if you are comparing "x(x+1)" and "x^2+x" it will randomly pick value for x in the allowed range, say x=3.8, and then it evaluates numerically each expression. This check is repeated a configurable number of times with a different random number each time and each time both the answer and the response must evaluate to the same number (within a configurable tolerance) for the expressions to be regarded as the same.

So really it is a bit of a cheat but it does allow simple expressions to be compared easily and quickly. For the more advanced cases where you want to do it properly there is the SAGE interface.
In reply to Roger Moore

Re: New Algebra Question Type

by Jeff Forssell -
I have used a PERL script, tutorial.pl, for many years (before moodle) that had an algebra module that worked well. (It lacked the ability to give feedback for expected wrong answers unfortunately). It used a random variable result comparison of the type you seem to be using (with 2 runs). Does yours support multiple variables?
Will Yours support alternative answer feedback?!

Here is where I got the original script:
http://http-server.carleton.ca/~nholtz/tut/doc/eg-se1s.html

Maybe it has some reusable algorithms.
In reply to Jeff Forssell

Re: New Algebra Question Type

by Roger Moore -
Yes - just like all the standard question types the algebra type supports multiple answer feedback. You can try out a demo quiz at:

http://thwaite.phys.ualberta.ca/moodle-dev

and try entering some close, but not quite correct answers (try resolving the forces the wrong way or forget to do it entirely). If you sign up for an account and then let me know I'll add you as a teacher so you can play with the question editing too - just please let me know if you find any bugs!

Thanks also for the link to the perl script. I'm actually away for a physics conference in Quebec next week so I probably won't have a chance to look at it before then (and might also be a little sluggish responding to questions here)...but thanks it looks interesting.
In reply to Roger Moore

Re: New Algebra Question Type

by Cristina Berisso -

Hello Roger,

I've tried the demo. This feature is fantastic! I am looking forward to go to Moodle version 1.9 to use it!

When I submitted far off answers, I got just a blank screen. The same happened when I typed "E 2/m" instead of "2 E/m" in question "3". When using "*" for multiplication between 2 and E, the formula was displayed correct. It accepted sqrt(2*E/m) as correct answer but not sqrt(E*2/m). So it seems that one needs to write the expression in "standard form" with numerical values first and variables next. Is that right?

Can it accept subindices? I am thinking about logarithms with base different from 10 or e. If it does, how do you enter subindices?

This is going to be a major solution to the big problem of how to make possible student typed math expressions, and most important correct evaluation, in short in on-line quizzes.

Congratulations!! Well done!!! Thank you for contributing this excellent feature to the forum!

In reply to Cristina Berisso

Re: New Algebra Question Type

by Roger Moore -
Thank you for testing it! What you found is part problem and part intended behaviour. The problem part is that it should not display a blank screen. This is one of the areas where I could actually do with some input. The problem is that with the algebra question the student can enter an invalid response i.e. a response which is neither wrong nor right but invalid. An simple example of this would be entering the formula "log(x+2". There are two ways I could imagine dealing with this:
  1. Count it as a wrong answer (trivial to implement)
  2. Somehow refuse to accept the response (i.e. it does not count as an attempt) and then let the student know why (like when making an invalid form entry).

So which way would people like to see the question handle it? My vote would be for option 2 since regard this type of error as either a trivial oversight or a problem caused by the interface and not one caused by a lack of understanding of what the question is testing. However the problem with this is that, as far as I can tell, the quiz engine only lets me say "yes" or "no" to a question response. I'll probably fix the code to do option 1 in the meantime since at least that will prevent a blank screen.

The part which is intended behaviour is that if you enter "E2" without a space then it treats it as a variable named "E2". This is to allow variables with numerical indices. However since the variables are specified in the question I could look at trying to improve the parser to handle this - I originally wrote the parser to identify the variables itself.

Regarding the log function it would certainly be possible to add that but it is not in at the moment. Since this would require a 3 argument function I don't see a trivial way to do it off the top of my head so I'd prefer to leave this until the more basic functionality has been hammered into shape. However it is definitely a feature we can add.


In reply to Roger Moore

Re: New Algebra Question Type

by Jeff Forssell -
I've logged in ID: jeffjeff

If you make me a teacher I can poke around some more.

FWIW:
I've only played with the 1st question so far. Fd F d F*d and F * d all gave the same "display formula" but only the last went to "correct" the others were white screen. Other tests:

Fd^1 became Fd1 but F*d^1 became F x d1

F / d*d^2 rendered OK (with a x after the fraction) and validated correct

f / d*d^2 rendered but gave a whitescreen on submission

2nd question (Couldn't control myself!)
Fd cos theta renders OK: Fd x cos(theta) but gave whitescreen on submission. Same result for F d cos theta and F*d cos theta.
What would happen if one entered a theta char UTF8?

3rd question
m g mu cos theta displays fine but gives white screen on submission, (I admit I haven't analyzed the effect of the vertical component of the tension, but I really should be out weeding my garden! Which I will do now.)




In reply to Roger Moore

Ang: Re: New Algebra Question Type

by Morten Brydensholt -

Roger,

In the zip-file the 'sage_server.py' file is identical to the 'readme' file.

The gz-file has got the correct version of the file.

I want to install SAGE on my win2003 server.

I downloaded the windows binary of SAGE 'sage-vmware-3.0.1.b' and unzipped it. Is this the rigth thing to download?

The instruction for installing says:

3) To run the SAGE XML-RPC server you will need an installed copy of SAGE (http://www.sagemath.org/). Edit the first line of the 'sage-server.py' file to point to your installed copy of the sage executable. Then simply execute the sage-server.py script. It will run a very simple XML-RPC server.

The first line of the 'sage-server.py' file is:

#!/usr/bin/env sage -python

But what would be 'the installed copy of the sage executable'? And how do I execute a py script?

In reply to Roger Moore

Re: New Algebra Question Type

by Cristina Berisso -

Hello Roger,

This sound absolutely great! Could you point me at a course where I can see it in action as a student? If it works as I think I understood from your posting, I would love to install it for my Math courses. I am such an ignorant as Moodle administrator, that I am afraid of messing up what I have running right now. Does it work with every version of Moodle? (I have my courses in Moodle 1.6)

Thank you very much!!!

Cristina

In reply to Cristina Berisso

Re: New Algebra Question Type

by Roger Moore -
Sorry - I did not think to set up a course to show the question in action so thanks for the suggestion. I've set up a quick demo server here:

http://thwaite.phys.ualberta.ca/moodle-dev

Hopefully you can register yourself and account there and try out the demo quiz in the only course on the server. I can also add you as a teacher so you can see the edit interface as well and make you own test questions.

I have only tried it in Moodle 1.9 and since this is the first version I have seriously looked at the code for I cannot say whether it will work in earlier versions. My guess would be possibly in Moodle 1.8 but not in Moodle 1.6 since I think the quiz engine underwent some reorganization. Also it requires PHP5 since I use exceptions in the parser to exit cleanly - this will be the default requirement for Moodle 2.0 but I realize I'm jumping the guna little!
In reply to Roger Moore

Ang: Re: New Algebra Question Type

by Morten Brydensholt -

It works pretty well on my server.

However if I enter the expression

3xycos(x)

and submits it the Moodle window will show up completely blank. I can then use my browsers 'back' button to have my Moodle window show up again.

Another thing: Would it be possible to indicate what is expressed by assigning this to the left of the answerbox?

Like, if the question is:

Differentiate f(x) = x2

Then to the left of the answerbox I would like to indicate

f'(x) =  (answerbox here)

Anyway the algebra question type is very usefull as it is - thanks!

Best regards

Morten

In reply to Morten Brydensholt

Re: Ang: Re: New Algebra Question Type

by Roger Moore -
Thanks for testing it. The blank screen problem is caused by two things. The parser finding a problem with your response and me not knowing how best to handle it! At the moment I trigger a PHP error and I just hoped that Moodle had a error handler setup. The problem is that the quiz engine only lets me return "match" or "no match" for each response/answer pair and what I want to do is say "invalid answer try again". If I just say "no match" then the student will get it graded wrong and I'm not sure that is the best thing to do (although it is certainly the easiest!). As I mentioned in another post I think I will change the code to do that and ask to see if anyone with more experience with the quiz engine can suggest a better way.

The reason why there was an error to start with is because the parser interpreted the "xycos(x)" as the variable "xycos" multiplied by "x". This is because I originally wrote the parser to not require a list of the variables beforehand. While I can (and will) improve this it will never be perfect. For example if there are three variables 'me', 'm' and 'e' then is the expression "mecos(x)" meaning "m e cos(x)" or "me cos(x)"? I don't see any way to make the parser infallible in such cases. I can certainly improve it though using the prior knowledge of the variables. In the meantime the fix is to put spaces in i.e. "x y cos(x)" should work fine.

Putting an expression to the left of the answer box is a very good idea - thank you. It should be very easy to add this two which is always a nice bonus!
In reply to Roger Moore

Re: Ang: Re: New Algebra Question Type

by Pierre Pichet -
"invalid answer try again"
This try again is handled by the quiz options when you set the number of attempts allowed and or the Adaptive mode.
This is why the question code is match or not...

Pierre
In reply to Roger Moore

Ang: Re: Ang: Re: New Algebra Question Type

by Morten Brydensholt -

Roger,

ofcourse the engine dislikes xycos(x) - which students should safely write as x*y*cos(x) - my point was the appearence of the blank screen.

One more minor problem: The LaTeX code for products should be 'cdot':

'a*b' is now being interpreted as 'aXb' rather than 'a·b'.

My fellow techers are exited by this great improvement of Moodle question types.

What would be the benefit of installing SAGE as the evaluation engine. Will SAGE be true CAS. That is, can it evaluate equations like 'y^2+x^2=4'?

Best regards
Morten

In reply to Morten Brydensholt

Re: Ang: Re: Ang: Re: New Algebra Question Type

by Jurgis Pralgauskis -
SAGE is CAS, it is for Maple or Matlab, what Moodle is for WebCT or Blackboard ;)
scheck out http://showmedo.com/videos/series?name=QZ0PAxn60
In reply to Jurgis Pralgauskis

Ang: Re: Ang: Re: Ang: Re: New Algebra Question Type

by Morten Brydensholt -

Jurgis,

I installed SAGE on my pc and find it a good alternative for various commercial CAS products, but what I want to know is, how it would be beneficial for Moodle on my server.

The algebra question type seems to work well without SAGE. So will the algebra question type work with more features using SAGE than without SAGE?

Best regards
Morten

In reply to Morten Brydensholt

Re: Ang: Re: Ang: Re: Ang: Re: New Algebra Question Type

by Roger Moore -
The non-SAGE way only works for expressions you can numerically evaluate. So when doing complex exponentials (e.g. for waves) you will need something like SAGE since you can't numerically evaluate them (unless PHP handles complex variables?).

There are also other possibilities down the line such as using SAGE's symbolic calculus feature to allow expressions to vary for each student - a merger between the algebraic and calculated question types if you will.

The other thing advantage with SAGE is that you do not need to specify a valid range for each variable. These might be hard to identify for some questions and tricky to get right for others e.g. ones with inverse trig functions.

However for the basic functionality you are completely correct that the evaluate method does it all and does not require any external installations - which was the entire reason for it.
In reply to Roger Moore

Ang: Re: Ang: Re: Ang: Re: Ang: Re: New Algebra Question Type

by Morten Brydensholt -

Thanks Roger,

I really like the idea of installing a true CAS server along with Moodle. Do you have any experience regarding the extra load on the server?

Would it be possible down the line to write your own python script lines to fx have SAGE produce plots in a quiz?

Best regards
Morten

In reply to Morten Brydensholt

Re: Ang: Re: Ang: Re: Ang: Re: Ang: Re: New Algebra Question Type

by Roger Moore -
Using the SAGE server to make plots via a Moodle filter was one of the things I've already looked at briefly. At least one of the pacakges SAGE uses to make plots can output a PNG so it should not be too hard to wrap this up and return it via XML-RPC. However I want to concentrate on the algebra question type and get that fully working first!

In reply to Roger Moore

Re: Ang: Re: Ang: Re: Ang: Re: New Algebra Question Type

by Jeff Forssell -
I don't know what advantages there could be with SAGE compared to STACK (which I think is connected to Maxima), but I just want to be sure everyone here has seen the the work that has been done with STACK in Moodle. There may be things that everyone can learn from in both. See:
http://stack.bham.ac.uk/course/view.php?id=2
It's a powerful thing too, and also needs an extra server install.

So I still think the "simpler" variant that could be totally Moodle Internal is very interesting.




In reply to Jurgis Pralgauskis

Re: Ang: Re: Ang: Re: New Algebra Question Type

by Jaime Villate -
SAGE is a collection of several free packages, including a CAS: Maxima. For the purpose of accepting algebraic expressions in a question type, I think Maxima should be enough, without having to install the whole SAGE package.
(http://maxima.sourceforge.net)
In reply to Jaime Villate

Re: Ang: Re: Ang: Re: New Algebra Question Type

by Thomas Bachert -
Jaime - How extensively have you tested this Maxima program? Dos Maxima support all forms of algebraic expressions?
In reply to Thomas Bachert

Re: Ang: Re: Ang: Re: New Algebra Question Type

by Robert Marik -
Hi Thomas, Maxima is full computer algebra system, much older than Maple and others. It supports all kinds of math expressions, of course. In fact, Sage calls Maxima to make all symbolic computations and hence, installing Maxima should be sufficient to test if two expressions are equivalent (zeroequiv command in Maxima)

Another nice program which allows to evaluate math questions is AcroTeX at www.acrotex.net. Have you seen it? Pure numerics in java inside PDF, but allows to aks questions for which the ansre is ordered or undordered set of expressions, expressions in more variables, questions where the answer is unique up to a constant multiple and so on. It allows also to write 2xsin^2(x) instead of 2*x*(sin(x))^2 . I created several tests in PDF with this software and pdflatex. Look here if you wish.
In reply to Roger Moore

Re: New Algebra Question Type

by Tobias Oberascher -
Thanks for the plugin. However, exporting this question type in Moodle-XML format leads to the following error-message:

Unsupported question type algebra

I'm using Moodle 1.9.3+ (Build 20081119) - any ideas? I'd like to avoid any changes in the core-files to fix that problem.

Appreciate!
In reply to Tobias Oberascher

Re: New Algebra Question Type

by Roger Moore -
There is a XML output format in the head version on CVS (not the one attached to this thread). You should be able to download it from Module and Plugins download page on the main Moodle site (search for 'algebra' and choose the question type). Alternatively try this link.
In reply to Roger Moore

Re: New Algebra Question Type

by Diego Racero -

I was trying to set up a new question but I find an error saying that the first of my variables couldn’t be loaded.

Could you give me some directions to help me solve the problem?

Thanks in advance.

In reply to Diego Racero

Re: New Algebra Question Type

by Roger Moore -
First my apologies for the slow response - the site update has stopped me getting emails from this forum and the email you sent today provided no link for me to respond to nor did it include your email address. Fortunately I navigated here manually!

I'm not sure what you mean by not being able to be loaded. There is no error message in the algebra question type which has 'loaded' in it so my only guess is that you may not have gone to the admin page after installing the module. You need to do this to create the required database tables to store the additional information needed for the question. My guess is that it is complaining about the lack of a 'variable' table and so cannot load the variables which should be stored there for the question.

Note, if this is the problem you will need to delete all algebra question types you have already entered since none of them will work.
In reply to Roger Moore

Re: New Algebra Question Type

by Thomas Bachert -
Could you post the algebra.html help file? It is missing from the help folder. If you could post this in zip format I would appreciate it.
In reply to Roger Moore

Re: New Algebra Question Type

by Steve Turley -
Thanks for your work on this. I started developing a similar question type on my own before I discovered yours. This will save me a lot of work.

I'm having trouble getting the displayed questions to work correctly with the using the jsmath filter. The text displays correctly in the question but not not in the box that displays the processed answers. Instead I see the raw TeX code.

I can work around this by including both filters and avoiding using $$ to delimit TeX expressions, but I wondered if there was a quick fix which would make the jsmath filter work in the box which displays the processed answers as well.
In reply to Steve Turley

Re: New Algebra Question Type

by Nicolas Dunand -
Picture of Core developers Picture of Plugin developers
Steve,

I guess the displayed questions are filtered (through TeX, etc.) correctly because they come from a standard Moodle HTML editor. I encountered the same in my multinumerical question type. To force some raw text through Moodle's filters, you may use the filter_text() function on the text you want to filter. Of course then, your expression will only be TeX-filtered if (as usually) it begins and ends with "$$".
In reply to Roger Moore

Re: New Algebra Question Type

by Philippe Chadefaux -
hello

I use Algebra.
It's really very good.

The field "Disallowed answer" is not yet implemented.
Is it meant to be ?

For example, I want to calculate the following factorization : 4x^2+2x

I want as a result : 2x(2x+1) but not 4x^2+2x smile ou 2(2x^2+x), so I would like to exclude these two expressions.

If this is not possible with this add-on, can I do this kind of test with some other tool? If not, it would be a shame because Algebra is really convenient.

Thank you

In reply to Philippe Chadefaux

Re: New Algebra Question Type

by Roger Moore -
It is not yet implemented because it is very hard to do what (I think) you would like it to do. I have added a simple "equivalence" check to the PHP parser which sits behind the algebra question type with the aim of performing a match for commuting operations i.e. x(x-1) and (x-1)x would match. This works for two commuting terms but not for 3 or more i.e. x+y+z and x+z+y would work but not z+x+y because of the internal structure of the parsed expression. Fixing this seemed too much like developing a CAS!

I have recently hugely improved the SAGE interface (by implementing a Moodle network XMLRPC fully encrypted interface in Python and including a filter to add SAGE-generated plots into Moodle on the fly - it is still in testing though). This will give far more freedom to consider what expressions you want to exclude but it is still not completely trivial. For example if you ask "expand (x+1)^2" you probably want to exclude "(x+1)*(x+1)" and "x+1 + x*(x+1)" plus all permutations but possibly allow x+1+x^2+x as well as x^2+2x+1 and all permutations. I am not sure if SAGE (or any CAS) can be fine-grained enough to do that (but please correct me if I am wrong - indeed I would very much like to be wrong!). Also the degree of expansion might vary from one instructor to the next e.g. perhaps you personally would disallow x+1+x^2+x.

If anyone has a good idea on how to allow this flexibility - or if they have a good set of rules as to what functionality would be most useful - I'd be very interested. Some of it might be achievable through a weaker comparison n the CAS side and mutiple answers. Since I'm a physics prof I'm far more interested in the students getting any equivalent answer than worrying about the formatting so I have not thought of this a lot beyond realising that others would probably want such functionality. Hence the rather feeble attempt at implementing it - sorry!
In reply to Roger Moore

Re: New Algebra Question Type

by James Choi -

I have a simple work-around suggestion.

Instead of disallowed expression, have simple two fields.

1. "Must have" characters field.

2. "Should never have" characters field

If the the problem is factoring, then the "must have" should be ( and ) which can be entered using some separator that won't conflict with mathematical expressions.  I think semicolon will do it.

If the problem is expanding a bionomial, then the "should never have"  would be (, ) or ^.  That way, the students won't be able to copy the problem itself into the answer box.

For sin(2t) identity problem you can require 2t to never appear, etc.

In reply to Roger Moore

Re: New Algebra Question Type

by Steve Turley -

I'm checking out the beta version of Moodle 2.0 to see what impediments there would be in moving to that in January.  One of the problems I've encountered is that the upgrade process stops when trying to convert the algebra questions in my quizzes.  I get the message:

Plugin "qtype_algebra" is defective or outdated, can not continue, sorry.

Is there an available version of the filter which will work with moodle2.0?

In reply to Steve Turley

Re: New Algebra Question Type

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
As a plugin developer, everything you will need to know to update you plugin should be explained on the pages linked to from Moodle_2.0_release_notes#For_developers:_API_changes - and there is already a lot of good information there. However, it is not yet complete.

Can I suggest that you start reading there, and every time you get stuck, make a post in the general developer forum along the lines of "I am trying to upgrade my plugin to Moodle 2.0. Specifically, I am trying to do X, and I have read Y, but I still don't understand because ..."

We need good feedback like that in order to get the documentation complete and comprehensible.

Actually, the answer to the question you ask above is missing. I just added the first bullet point, in the hope it would encourage someone to write the answer.

Basically, the way different types of plugin work has been made more consistent, so all plugins can have a /db/ folder with install.xml, upgrade.php, access.php, ... and so on. These are not fundamental changes, you probably just have to tweak some things. Make sure you set Debugging to DEVELOPER level (set it in config.php, so you see the messages during install). Often that provides more information about exactly what is wrong.
In reply to Steve Turley

Re: New Algebra Question Type

by Stefan Raffeiner -

Hi,

I have the same problem, I would like to use algebra-question-type with moodle2. Did you find a solution? I have to use this question-type because in our database there are already more than 1000 algebra questions and teachers will kill me if I delete these questions smile.

If you don't have a solution I will start to make the modifications at the code for moodle2.

In reply to Roger Moore

Re: New Algebra Question Type

by Paola Manzini -

Hi,

I am a newcomer to Moodle, and I would really define myself as a non techie user. The algebra type question is exactly what I need for my calculus course, but I have two questions:

1) does the plugin work in Moodle 2.0?

2) if I want this plugin installed for my course, am I right in presuming that I'll have to ask the system administrator of my University to install it?

Many thanks!

In reply to Roger Moore

Algebra Question Type for Moodle2

by Stefan Raffeiner -

Hi,

I updated now the code for moodle2. At my installation it works, but I didn't test it in detail.
You find the code here: www.rg-me.it/development/algebra.zip
Please tell me if the questiontype works at your installation and send me bugs.

Most of the work was to add $DB as global variable in each method and to change $db to $DB.

In reply to Stefan Raffeiner

Re: Algebra Question Type for Moodle2

by Jean-Michel Védrine -

Hello,

You sould drop all the ENUM="false" from the install.xml file.

If you want and if nonbody has already done it, I can make the backup/restore files (no problem as i have done it for upgrading other questiontypes to 2.0)

thanks for this work.

I will look at the other files to see if I find anything needing correction.

In reply to Jean-Michel Védrine

Re: Algebra Question Type for Moodle2

by Jean-Michel Védrine -

In the file db/upgrade.php, for people having a very outdated version installed, it would be better to change the upgrade to :

function xmldb_qtype_algebra_upgrade($oldversion=0) {

    global $CFG, $THEME, $DB;
    
    $dbman = $DB->get_manager();

    // Add the field to store the string which is placed in front of the answer
    // box when the question is displayed
    if ($oldversion < 2008061500) {
        $table = new xmldb_table('question_algebra');
        $field = new xmldb_field('answerprefix', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, '', 'allowedfuncs');
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        upgrade_plugin_savepoint(true, 2008061500, 'qtype', 'algebra');
    }
    return true;
}

In reply to Jean-Michel Védrine

Re: Algebra Question Type for Moodle2

by Jean-Michel Védrine -

You must change all  $a in language files to {$a} (this is why the answers and variables numbers are not displayed correctly on the question creation page).

In reply to Jean-Michel Védrine

Re: Algebra Question Type for Moodle2

by Stefan Raffeiner -

Thank you for your help! It's the first time i upgrade a plugin, so I don't know everything smile

I uploaded now the corrected version: http://www.rg-me.it/development/algebra2.zip

Please check it

regards, stefan

In reply to Stefan Raffeiner

Re: Algebra Question Type for Moodle2

by Jean-Michel Védrine -

Hello,

No need to appalogize for not knowing everything, I don't know everything either blush. In fact my goal is that you and other learn something about Moodle coding.

This is in fact why I post these messages rather than just sending a corrected version or sending you a private message : i hope it will help others to understand how to upgrade a question type to 2.0.

It is not in fact that complicated, and you have done the most paintfull and boring job to change all the db queries !! wink

2 more little changes and I think we are nearly done :

in the display.html file suppress the lines

<?php if ($image) { ?>
  <img class="qimage" src="<?php echo $image; ?>" alt="" />
<?php } ?>

because the image field is no more here in Moodle 2.0

in questiontype.php add the line:       'answers',

so that the lines :

return array('question_algebra',
                     'compareby',        // Name of comparison algorithm to use
                     'variables',        // Comma separated list of variable names in the question
                     'nchecks',          // Number of evaluate checks to make when comparing by evaluation
                     'tolerance',        // Max. fractional difference allowed for evaluation checks
                     'allowedfuncs',     // Comma separated list of functions allowed in responses
                     'disallow',         // Response which may be correct but which is not allowed
                     'answerprefix'      // String which is placed in front of the asnwer box
                     );

become

return array('question_algebra',
                     'answers',
                     'compareby',        // Name of comparison algorithm to use
                     'variables',        // Comma separated list of variable names in the question
                     'nchecks',          // Number of evaluate checks to make when comparing by evaluation
                     'tolerance',        // Max. fractional difference allowed for evaluation checks
                     'allowedfuncs',     // Comma separated list of functions allowed in responses
                     'disallow',         // Response which may be correct but which is not allowed
                     'answerprefix'      // String which is placed in front of the asnwer box
                     );

this is needed because this question type has the answers field in the question_algebra table and it is declared NOTNULL so we want that when we call parent::save_question_options in save_question_options the value is correctly saved in database

My small advice : To see a lot of small coding errors, it is helpfull to go to Site administration > Development > Debugging and set debugging level to DEVELOPER to see a lot more of errors and warning notices. In fact this is how I catched most of this. Additionnaly most of these errors weren't preventing the code from working, but it will work better with these corrections.

Sincerely I think you have done a great job approve to upgrade this question type and all algebra users should thank you very much for that.

Additionnaly I am quite sure Tim will also congratulate you when he come back from his holidays because he like a lot when users start to not only ask for things in the forums or in the tracker but do something.cool

Again thank you very much for upgrading this very interesting questiontype.



In reply to Jean-Michel Védrine

Re: Algebra Question Type for Moodle2

by Stefan Raffeiner -

Hi,

i made now also these changes. I had to reinstall the questiontype, but now it works, I get no error-messages in the developer mode.

An other thing: if I click on "display formula" (during a quiz-attempt) there is loaded "displayformula.php" in an iframe, where the formula should be displayed using "format_text()". But I get only the error: Coding problem: this page does not set $PAGE->context properly.

I added a line (before callint format_text()):
$PAGE->set_context(0)
and now it works, but I don't know if this is the right way. I think I should use the context-id from the course/quiz? To do this my only idea is to add a GET-variable to the call of displayformula.php.

The new version of the code: www.rg-me.it/development/algebra3.zip

In reply to Stefan Raffeiner

Re: Algebra Question Type for Moodle2

by Jean-Michel Védrine -

Hello Stefan,

While working on the code of the algebra question type I discovered that a bug in the xml import function I reported months ago in the tracker (see CONTRIB-1911 ) is still here

symptom : if you try to import an xml file with some questions of another third party  question type (this bug don't affect core questions types, only third party ones) the algebra question type will "greedily swallow" all of them but not beeing able to do something with them, nothing will be imported.

This is because the import_from_xml function don't check the type of the question.

I will try to bring Roger Moore's attention on this bug again.

In the meantime can you correct it in the 2.0 version please. For that modify the import_from_xml function in the questiontype.php to :

function import_from_xml(&$data,&$question,&$format,&$extra) {
        if (!array_key_exists('@', $data)) {
            return false;
        }
        if (!array_key_exists('type', $data['@'])) {
            return false;
        }
        if ($data['@']['type'] == 'algebra') {
            // Import the common question headers
            $qo = $format->import_headers($data);
            // Set the question type
            $qo->qtype='algebra';
        
            $qo->compareby = $format->getpath($data, array('#','compareby',0,'#'),'eval');
            $qo->tolerance = $format->getpath($data, array('#','tolerance',0,'#'),'0');
            $qo->nchecks   = $format->getpath($data, array('#','nchecks',0,'#'),'10');
            $qo->disallow  = $format->getpath($data, array('#','disallow',0,'#','text',0,'#'),'',true);
            $allowedfuncs  = $format->getpath($data, array('#','allowedfuncs',0,'#'), '');
            if($allowedfuncs=='') {
                $qo->allowedfuncs=array('all' => 1);
            }
            // Need to separate the allowed functions into an array of strings and then
            // flip the values of this array into the keys because this is what the
            // save options method requires
            else {
                $qo->allowedfuncs=array_flip(explode(',',$allowedfuncs));
            }
            $qo->answerprefix = $format->getpath($data, array('#','answerprefix',0,'#','text',0,'#'),'',true);
        
            // Import all the answers
            $answers = $data['#']['answer'];
            $a_count = 0;
            // Loop over each answer block found in the XML
            foreach($answers as $answer) {
                // Use the common answer import function in the format class to load the data
                $ans = $format->import_answer($answer);
                $qo->answer[$a_count] = $ans->answer;
                $qo->fraction[$a_count] = $ans->fraction;
                $qo->feedback[$a_count] = $ans->feedback;
                ++$a_count;
            }
        
            // Import all the variables
            $vars = $data['#']['variable'];  
            $v_count = 0;
            // Loop over each answer block found in the XML
            foreach($vars as $var) {
                $qo->variable[$v_count] = $format->getpath($var, array('@','name'),0);
                $qo->varmin[$v_count]   = $format->getpath($var, array('#','min',0,'#'),'0',false,get_string('novarmin','qtype_algebra'));
                $qo->varmax[$v_count]   = $format->getpath($var, array('#','max',0,'#'),'0',false,get_string('novarmax','qtype_algebra'));
                ++$v_count;
            }

            return $qo;
        }
        return false;
    }
   
As you see it's just a few lines to add at the begining and at the end and indentation to change. Thanks

In reply to Stefan Raffeiner

Re: Algebra Question Type for Moodle2

by Jean-Michel Védrine -

Hello Stefan,

Yes I spotted this also.

Not a big problem. In previous Moodle version it was possible to call the format_text Moodle function with just the text to filter.

But now you must pass a valid context also.

If no context is given format_text try to use the $PAGE-> context and as there was none this is why this message is displayed.

I think maybe we can pass it a system context as we want the function to succeed in all cases.

Passing the course id is a bad idea as this is deprecated. See lib/weblib.php

* @param int $courseid_do_not_use deprecated course id, use context option instead

In fact we are somewhat abusing the format_text function as what we want in fact is to convert the answer to TeX using the tex filter.

I will look at the tex filter to see if we can call it directly without the format_tex function.

Maybe Tim will have a better idea ?

In reply to Jean-Michel Védrine

Re: Algebra Question Type for Moodle2

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

Passing the system context will not work - there is a reason the function wants you to tell it the context - because it needs to know to do its job properly. The issue is that the filter settings can be different in different contexts, and so you need to context to use the right filter settings.

This is solved properly in Moodle 2.1, as far as I know. The replacement for the print_question function gets told the current context.

In 2.0, there are problems with a all the core question types failing to send the right context. See MDL-25885. I really must find time to fix that. There may well be no easy fix in 2.0. The good news is that the default behaviour of using $PAGE->context will work just fine - apart from generating the debug warning.

In reply to Jean-Michel Védrine

New version of the algebra question type for Moodle 2.1

by Jean-Michel Védrine -

Hello,

Here is my first version of Roger Moore's algebra questiontype updated for Moodle 2.1.

Warning : this version will absolutely NOT work with Moodle versions < 2.1 (you will find in the same thread in other messages versions for Moodle 1.9 and 2.0)

There is no new feature in this version except that it should support all Moodle 2.1 niceties (including restoration of algebra questions in backups made with Moodle 1.9). It should also import XML exports of questions made with Moodle 1.9 and 2.0.

The upgrade process will modify your question_algebra database table so don't forget to make a backup of your data before upgrading just in case.

To install just unzip and put the algebra folder into your question/type folder on your moodle server. Verify that the unzipping process has not introduced an added layer : all files should be in question/type/algebra and not question/type/algebra/algebra

Then go to Site administration > Notifications and upgrade the plugin.

As this is the first version, it would be wise to test before using on a production server !! Please test and report all problems.

 

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

Re: New version of the algebra question type for Moodle 2.1

by Paola Manzini -

sorry to pester you Jean-Michel, but it looks like you are working on all the things I need smile

Am I correct that the one linked in your last message, "algebra.zip", is the latest version, and not the "algebra3.zip" linked in the top message of this thread?

I am going to point my system admin to this, so want to make sure I get it right.

Many thanks

Paola

In reply to Paola Manzini

Re: New version of the algebra question type for Moodle 2.1

by Stefan Raffeiner -

Hi,

algebra3.zip is the latest version of algebra for moodle2.0

algebra.zip in the last message is the version for moodle2.1

In reply to Jean-Michel Védrine

Re: New version of the algebra question type for Moodle 2.1

by Paola Manzini -

Jean Michel, I am having problems in making this work (Moodle 2.1) - how shall I enter the right answer? For instance, I have asked to differentiate $$ax^b$$.

If I enter the answer with the dollar signs, I get an error message (while creating the question) while if I enter the answer as (a*b)*x^(b-1), when the answer is displayed it reads exactly like that (i.e. no nice latex). What am I doing wrong? Many thanks!

In reply to Paola Manzini

Re: New version of the algebra question type for Moodle 2.1

by Jean-Michel Védrine -

Hi Paola,

I tested your question and all seems to be working as expected (but maybe this is not what you were expecting).

Question creation

In the question text, the formula is entered with dollars and teX syntax

You define 3 variables a, b and x with min and max value

In the answer field you enter a*b*x^(b-1) no Tex syntax here, no dollars, this is the answer as it is expected from students.

Here is a preview of the question, I entered the correct answer and when I click the "Display Response" button, the answer (either correct or not) is displayed nicely formatted.

Here I entered an incorrect response but with a correct syntax, so the system accept it (but it will tell me I am wrong when I click on the Check button !)

Here I entered a response with a wrong syntax so when I click on "Display Response" a message is displayed

One thing we can change is the fact that during a quiz review, if the correct answer is displayed it is not formatted. The idea was that the student want to see what he should have entered to get the question correct but maybe it would be better to show a nicely formatted formula ? Or both ? This is easy to do if everybody agree.

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

Re: New version of the algebra question type for Moodle 2.1

by Paola Manzini -

Dear Jean-Michel,

as usual you are priceless smile

Yes, you reproduced exactly what I have, and what I thought was an error is the last thing you mention, namely that " if the correct answer is displayed it is not formatted."

The way around it I thought could be not to display the correct answer, but only general question feedback, and in there I can put the nicely formatted answer.The problem here is that I do not know whether I can have some questions display the correct asnwer and some question not display it if they are in the same Quiz, which may create me additional problems.

But if it is not a bug, then forget about it - I can explain to the students that they will get an answer which looks unformatted because this is how they are supposed to input it.

In reply to Paola Manzini

Re: New version of the algebra question type for Moodle 2.1

by Jean-Michel Védrine -

If you want both the unformatted and formatted answer to be displayed it's not that hard big grin :

Maybe the verb given is not the best choice but it's easy to change.

For your problem about displaying something only for some questions in a quiz, this can't be done with the correct answer as this is a global quiz setting. You must use the feedback for this as you can write what you want in each question's feedback.

In reply to Jean-Michel Védrine

Re: New version of the algebra question type for Moodle 2.1

by Paola Manzini -

Thank you Jean-Michel: but how did you do it? What do I have to enter as answer when creating the question? Gosh, I feel so stupid!

In reply to Paola Manzini

Re: New version of the algebra question type for Moodle 2.1

by Jean-Michel Védrine -

Well I somewhat "cheated", don't forget I know php programming, so I just modified the code in question.php and renderer.php to do that big grin but when creating the question, I just typed a*b*x^(b-1) for the answer as usual. If you want the modified version, I can send it to you but tell me what would be the best sentence to present both versions to the student (don't forget english is not my native language so this is why I need an advice)

Maybe something like :

The correct answer is: $$ a_{} x_{}^{\left( b_{} - 1 \right)}$$ that can be typed a*b*x^(b-1)

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

Re: New version of the algebra question type for Moodle 2.1

by Paola Manzini -

wow, very clever - and definitely beyond me!

Well, I am not a native speaker either, but your phrasing sounds pretty good to me! If it is not too much trouble, I'd love it if you could send this version to me - though my system administrator is probably not going to have kind thoughts about you ;)

Again, many thanks!

In reply to Jean-Michel Védrine

Re: New version of the algebra question type for Moodle 2.1

by Steve Turley -

I tried using your latest version of algebra.zip from this post in Moodle 2.1. Thank you for your work on it.  It doesn't seem to be displaying the formulas properly.  I'm wondering if your code depends on a particular math filter being installed.  I use mathjax instead of the algebra filter in moodle since it seems to give me a better display of formulas.  However, when I use this question, I see a display like the following:

The problem displays correctly if I turn on the TeX filter.

In reply to Steve Turley

Re: New version of the algebra question type for Moodle 2.1

by Stefan Raffeiner -

Have you enabled the Tex-Filter? The algebra question type uses latex, so I don't think that it works with mathjax/algebra filter. You have also to install latex on your server.

In reply to Jean-Michel Védrine

Re: New version of the algebra question type for Moodle 2.1

by Stefan Raffeiner -

Hi Jean-Michel

I found two small bugs in the question type (the first one is in each version of this questiontype, also in the one for moodle1.x):

- the "display response" button is not translated (renderer.php, line 28)

- there is an error in the translation file:
when you enter 2*2*x the tex-filter will display "2\times2x" instead of "2*2*x",
lang/en/qtype_algebra_parser.php, line 13, $string['multiply'] = '\\\\times'; should be $string['multiply'] = '\\times'; or better: '\\cdot'

kind regards

stefan

In reply to Jean-Michel Védrine

Re: New version of the algebra question type for Moodle 2.1

by Kevin Wheelock -
Hi Jean-Michel,

Merci beaucoup pour votre excellent travail! Il est très apprécié.

I am trying to use greek symbols (sigma, epsilon) in my answers; when I try, though, I get the following error message on the "Editing an algebra question" page, in the "Answer 1" field:

"Syntax Error: Unknown term found at 'σ/(2*b)' in the expression"

I inserted the σ from the palette, which means (I believe) that it is & sigma in HTML, or & #963 in Unicode.

Is there a way to use greek symbols in the answers? This is crucial in physics!

Thanks!

Kevin
In reply to Kevin Wheelock

Re: New version of the algebra question type for Moodle 2.1

by Kevin Wheelock -

Okay, as a followup to my own question...

I found the answer after reading through the parser.php file; very useful! The answer is to simply type out the name of the greek letter, thus: sigma/mu gives σ/μ. However, in so doing, I have run into a different problem...

When I try to use epsilon, the parser for the Answer fields throw the following exception:

Undefined variable(s) 'psilon' used in one or more answers

Thus, I cannot type in sigma/epsilon (giving σ/ε)--which, unfortunately, is the correct answer to one of my homework problems...

Further testing shows that ANY variable (not just the greek ones) that start with the letter 'e' will fail; for example, the variable "erg" throws the exception "Undefined variable(s) 'rg' used in one or more answers"

Any thoughts?

Cheers,

K.

In reply to Kevin Wheelock

Ang: Re: New version of the algebra question type for Moodle 2.1

by Morten Brydensholt -

Hi Kevin

I guess 'e' is reserved for Eulers number.

Best regards
Morten

In reply to Morten Brydensholt

Re: Ang: Re: New version of the algebra question type for Moodle 2.1

by Kevin Wheelock -

Yes, that's what it looks like to me, also. I have been reading the method that parses the answers, but I haven't found a way to fix this behavior that wouldn't break a dozen other things. I'm not really a programmer, though...

In reply to Kevin Wheelock

Re: Ang: Re: New version of the algebra question type for Moodle 2.1

by Jean-Michel Védrine -

Hello Morten and Kevin,

My work on this question was only to take over Stephan Raffeiner's work to upgrade it to Moodle 2.1.2.2.

But I think I didn't make any change to the parser.

This parser was coded by Roger Moore when he created the question for Moodle 1.9.

I will verify the problem is also present in the latest 1.9 version and send a mail to Roger to see if he has any idea of a possible fix.

In reply to Jean-Michel Védrine

Re: Ang: Re: New version of the algebra question type for Moodle 2.1

by Jean-Michel Védrine -

I have made some tests and as I was expecting the result is the same with the version for Moodle 1.9 downloaded from the old Modules & plugins database.

I will try to contact Roger.

In reply to Jean-Michel Védrine

Re: Ang: Re: New version of the algebra question type for Moodle 2.1

by Kevin Wheelock -

Thanks very much, Jean-Michel! I will keep looking at it also. 

K.

In reply to Jean-Michel Védrine

Re: New version of the algebra question type for Moodle 2.1

by Michael Buescher -

First off, thanks so much for the creating and updating of the Algebra question type that you have done!  I used it on other installations and think it's great.

I'm new to administering a Moodle site, however, and ran into a problem.  I installed Moodle 2.3 (using Simple Scripts) and then installed the Algebra version listed here (the one posted 31 July 2011), including logging in as admin and updating the database.  Unfortunately, the "Create a New Question" popup no longer cooperates - see screen shot attached.  (It worked before, though I didn't actually create any questions before installing algebra.zip). 

I'd greatly appreciate any suggestions anyone has ... thanks!

Michael

Attachment Capture_2012-09-17.JPG
In reply to Michael Buescher

Re: New version of the algebra question type for Moodle 2.1

by Jean-Michel Védrine -

Hello Michael,

For Moodle 2.3, please download the version I posted on github:

https://github.com/jmvedrine/moodle-qtype_algebra

and see if it solve your problem.

If you still have problems, go to Site administration -> Development -> Debugging and set debugging messages level to developer to see if any error message is printed and post this message here.

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

Re: New version of the algebra question type for Moodle 2.1

by Lev Abramov -

Hi Jean-Michel!

One of our teachers requested this plugin. I downloaded it, uploaded it to the /question/type/ folder, unzipped, and logged in to the Notification page. However, no DB update process started.

It is a clean Moodle 2.3 installation; the downloaded plugin version is the one you indicated as suitable for 2.3.

Any ideas?

TIA -

Lev

In reply to Lev Abramov

Re: New version of the algebra question type for Moodle 2.1

by Jean-Michel Védrine -

Hello Lev,

I don't understand.

If there is a question/type/algebra/db/install.xml file and it is correct (It has not changed since several versions, I know I should remove UNSIGNED !) I don't see how going to notifications can't create the tables.

Just to be sure I re-downloaded the plugin from my github account and installed it on a fresh Moodle 2.3.2+ install and all worked as expected.

I am puzzled.

In reply to Jean-Michel Védrine

Re: New version of the algebra question type for Moodle 2.1

by Lev Abramov -

Found the culprit. The archive has a long name, and when unzipped, it retains the same long name: jmvedrine-moodle-qtype_algebra-96bee2b. Once I figured it out (prompted by your posting above - "If there is a question/type/algebra/db/install.xml file" etc.), deleted everything except for the word "algebra" and re-logged the system immediately found the new plugin and requested approval for installation.

Do I need to install anything else? There's that SAGE server - do I need it? Where is the ReadMe for this plugin, anyway? wink

Thanx muchly. I will let the teachers play with it, and will report any suspicious behavior if encountered.

Best -

Lev

 

In reply to Lev Abramov

Re: New version of the algebra question type for Moodle 2.1

by Jean-Michel Védrine -

Hello Lev,

Glad you sorted your problem.

I think the only available doc is the one written by Roger Moore when he created this question type see here.

My only role was to upgrade it each time it stops working when a new Moodle version is released smile.

I have never used it with a SAGE server (I only use a cheap shared hosting for my production website, so it would not be possible for me to install SAGE !) so I use evalutation method only.

I should have tested that SAGE and equivalence methods are still working but I never had time ... If you make some tests with SAGE or equivalence methods, please report so that I know if it works or not.

In reply to Jean-Michel Védrine

Re: New version of the algebra question type for Moodle 2.1

by Lev Abramov -

Right. All looks good except for one element: once the plugin has been installed and recognized by the system - is there any way to select the default method, or is it mandatory to select it every time a question is created? The web page you referred me to does not say a word about it... Ah well, we'll figure it out somehow.

Many thanx for your help!!!

Best -

Lev

In reply to Lev Abramov

Re: New version of the algebra question type for Moodle 2.1

by Jean-Michel Védrine -

Including a setting to choose default evaluation method seems as a good idea, and as algebra already include settings for the SAGE server, it doesn't seems difficult to do (jus a few lines to add here and there).

I will look at this as soon as I find some time to work on it.

In reply to Jean-Michel Védrine

Re: New version of the algebra question type for Moodle 2.1

by Jean-Michel Védrine -

Just pushed to github a new version of algebra question type for Moodle 2.3 with a new admin setting to choose default evaluation method.

As I bumped version number it should ask for this new setting's value during upgrade.

In reply to Jean-Michel Védrine

Re: New version of the algebra question type for Moodle 2.1

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

Hi,

I am very interested in the algebra qtype plugin. I installed it, and I could make a local translation of the english strings into spanish, but when I tried to upload the translated strings into AMOS, it did not find the plugin strings.

According to David Mudrak's september 5th 2012's post in AMOS page,:

"Good news! Almost all contributed plugins published in Moodle Plugins directory have been imported into AMOS and are ready to be translated. As a part of MDLSITE-1836, changes were made on both AMOS and Plugins sites so that these two are now integrated.

From now on, whenever a maintainer publishes a new version of their contributed plugin, strings are automatically sent via a web service to the AMOS. This process respects the supported Moodle version setting so the strings appear at the correct Moodle branch in AMOS.

This works for new plugins that will be uploaded into Plugins in the future, too. With the exception that the strings appear in AMOS only after when the plugin is approved as a part of its validation.

This new mechanism works for all plugins that were uploaded into the Plugins directory and are written for Moodle 2.0 and higher. Contributed plugin maintainers are now encouraged to transfer all their current code to this new scheme:

  • The plugin code itself should now contain just the English strings in the /lang/en folder.
  • All other translations are to be maintained via AMOS and you as the plugin maintainer do not need to look after them any more! Translated strings for contributed plugins are part of the standard language packs generated by AMOS.
  • If your plugin code currently contains some translation, you (as the plugin maintainer) should submit it as a contribution into AMOS prior to dropping it from your plugin's source code. AMOS stage page provides a form to upload strings from an existing PHP file. You are supposed to import all non-English string files you currently have shipped with your plugin (eg. /lang/cs/yourmodule.php) into the AMOS stage and then submit them language pack maintainers.

We believe that this new procedure will make translation of contributed plugins much easier than it ever been - for both the plugin maintainer and translators, too.

Should you have any questions regarding this new feature, do not hesitate to ask in AMOS support forum at this site.

Thank you all for you great work on contributed plugins and their translations!"

I am including the translated strings for the mexican spanish language pack. If this nice plugin could be translated to languages other than English, more people would use it.

Thanks

In reply to Germán Valero

Re: New version of the algebra question type for Moodle 2.1

by Jean-Michel Védrine -

Hello German,

I am aware of the ability to use AMOS to translate 3rd party plugins, but as you know for it to work,s the plugin needs to be in Moodle plugins directory and this is where I have some problems !

For nearly all the questions types for witch I have versions upgraded for Moodle 2.3 in my git account, I am not the original author so I am unsure if I am entitled to put them in Moodle Plugins directory myself.

Algebra question type original author is Roger Moore and despite many mails I have been unable to get in touch with him for more than a year.

Maybe my hesitations seem stupid, but I wanted his approval before submitting algebra.

In reply to Jean-Michel Védrine

Re: New version of the algebra question type for Moodle 2.1

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 right to be senstitive to this issue Jean-Michel. However, there must come a time when all the work you have done on this plugin entitles to some sense of ownership over the code.

I will just note that if you chose to upload the plugin, you could certainly meantion in the descriptive text you write that it was originally created by Roger Moore. You can also add Roger Moore to the plugin as a co-maintainer, just like I added Phil and Mahmoud at https://moodle.org/plugins/view.php?plugin=qtype_oumultiresponse. I wonder if that is enough?

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

Re: New version of the algebra question type for Moodle 2.1

by Aparup Banerjee -

Hi Jean-Michel,

Further to Tim's post which is pretty much spot on, i think when adding a  contributor (when in the form), you can also name the 'Contributor role' to what ever you like, perhaps 'Original author'. 

ps: Approval also comes in the form of the GPL smile

 

In reply to Jean-Michel Védrine

Re: New version of the algebra question type for Moodle 2.4

by K S Ramachandran -

Can you please give me the link to download and install Algebra Question type for Moodle 2.4? I am still new to Moodle (!) and wish to test this out. Thanks in advance.

In reply to K S Ramachandran

Re: New version of the algebra question type for Moodle 2.4

by Jean-Michel Védrine -

Hello,

According to my tests, the link in one of my previous messages:

https://github.com/jmvedrine/moodle-qtype_algebra

is working with no problem with Moodle 2.4 and no problem has been reported.

Short installation instructions:

Go to the adress above

Click on the ZIP button ZIP button

This will download a zip archive named moodle-qtype_algebra-master.zip on your computer

Unzip and rename the folder from moodle-qtype_algebra-master to just algebra

move or upload this folder and all its content inside question/type/ on your Moodle server

Login to your Moodle website as an administrator

Go to Site Administration -> Notifications and install as any other Moodle plugin

That's all.

As I sais the only documentation available to learn how to use this question type is the one written by Roger Moore. See http://docs.moodle.org/24/en/Algebra_question_type

In reply to Jean-Michel Védrine

Re: New version of the algebra question type for Moodle 2.4

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

I just downloaded and installed it and it seems to install OK for me.

In reply to Jean-Michel Védrine

Re: New version of the algebra question type for Moodle 2.4

by K S Ramachandran -

Hi, Thanks a lot; my software administrator has just installed it; it seems to be working. Regards Rama

In reply to K S Ramachandran

Re: New version of the algebra question type for Moodle 2.4

by K S Ramachandran -

I need help on these two doubts:

  1. If the student does not know the Latex code well, is there some website that she/he can open separately which converts the math symbols to latex code online?

For example, student enters

 

and it shows the correct latex code as a*b*x^(b-1).

This latex code can be copy/ pasted in the answer space and then Display Response pressed.

2. In addition, is there a need to install some filters too in Moodle 2.4 for algebra question type to work?

Kind regards Rama

 

In reply to K S Ramachandran

Re: New version of the algebra question type for Moodle 2.4

by Jean-Michel Védrine -

I think you are confused.

The student must not use latex coding to input his/her response and the box is just here to show him how the system interpret this response.

So in your example the student would enter a*b*x^(b-1) in the answer box and press the "Display response" button to see this response nicely displayed as a TeX formula.

I use this question type with my first year students and I don't think one of them know how to write a TeX formula (in fact I doubt one of them know what is TeX smile apart if I tell them it's the strange characters they see when they use the Dragmath editor button).

But trying this example in the latest version of algebra question  type produce strange results in Moodle 2.4. And I also realized TeX display is not working if your use MathJax rather than Moodle TeX filter.

So I need to wok on this again.

 

In reply to Jean-Michel Védrine

Re: New version of the algebra question type for Moodle 2.4

by Jean-Michel Védrine -

Sorry, there is no strange results, but I made a stupid mistake when creating the question ! So all seems to be working as expected.

It's pretty easy to make the TeX display work with MathJax :

in the question/type/algebra/displayformula.php you need to make 2 changes

change

global $PAGE;

to

global $PAGE, $CFG;

and add the lines

<?php
if (!empty($CFG->additionalhtmlhead) && strpos($CFG->additionalhtmlhead, 'MathJax') !== false) {
            echo $CFG->additionalhtmlhead;
}
?>

between the lines

<title>Formula</title>

and

</head>

I will push a new version to my github account.

What is really strange is that none of my students reported the problem and I am quite sure the TeX filter is disabled on my production webiste since I use MathJax wide eyes (there are some extra points to earn when you report a bug, this is how I enrol an army of little testers big grin)

 

In reply to Jean-Michel Védrine

Re: New version of the algebra question type for Moodle 2.4

by Victor Goff -

If they don't know the tex language do they need to use the visual (WYSIWYG) editor?  There currently is none, as it causes other issues.

 

As an aside, good incentive to students to not 'live with' problems, but report them instead.

In reply to Victor Goff

Re: New version of the algebra question type for Moodle 2.4

by Jean-Michel Védrine -

No student don't need to use the visual editor, and in fact they can't as the answer box is just a plain text input. They use what is called a linear syntax to input math formulas : *, +, -, /, /, (, [, ], ), pi, e, and the known functions sqrt, log, ln, sin, cos, tan, cosh, sinh, asin, acos, atan.

Variables can be letters, single words, greek letters are recognized and subscripts too, for instance u_1 will be intepreted as $$u_{1}$$. Obviously e and pi can't be variables names as they are already constants.

I surely forget some features of the parser (Roger Moore wrote it in 2007)

In reply to Jean-Michel Védrine

Re: New version of the algebra question type for Moodle 2.4

by K S Ramachandran -

Dear Jean,

Thanks a lot; it was very helpful. My students are not so familiar in instantly recalling text abbreviations for math symbols. I wish to give them a visual help. I use Moodle 2.4 and read about Dragmath Editor in Moodledocs. See: http://docs.moodle.org/24/en/DragMath_equation_editor

However, my web administrator for Moodle has not enabled the html format as it seems to make the website unstable but has enabled the LateX filter. Perhaps there is an online conversion facility to get the abbreviations/ codes? I found this website to type simple formulae and get codes that can be copy pasted in the answer field. Can this be used? See: http://www.codecogs.com/latex/eqneditor.php

I am new to Moodle and trying to set up a help facility for failed students in school math and need some hints from you.

Regards Rama

In reply to K S Ramachandran

Re: New version of the algebra question type for Moodle 2.4

by Victor Goff -

As we discussed, the HTML is available in Moodle Autoformat, the thing that is disabled is the WYSIWYG editor.

In reply to Victor Goff

Re: New version of the algebra question type for Moodle 2.4

by Ramon Eixarch -

You may have a look into WIRIS quizzes. It is a commercial plugin for Moodle to create math/science questions. It includes a WYSIWYG math editor.

www.wiris.com/moodle

In reply to Ramon Eixarch

Re: New version of the algebra question type for Moodle 2.4

by K S Ramachandran -

Dear Mr. Ramon Eixarch, 

Thank you for the information about WIRIS quizzes. I found it very interesting and useful; your products seem to understand what mathematics teachers are needing! My friend conducts many Ruby software courses online with Moodle 2.4 and is helping to host my experimental diagnostic mathematics course free. My tuition site is added as just another course. I wish to know from you if installing WIRIS will affect only Question type in Quizzes or will it affect all the other courses and stuff like Lessons, Texts in the entire website. He has disabled html feature due to some technical reasons (software related). Kind regards Rama

PS: I notice in your demo site that WIRIS is added as another Question type in Quizzes. I just need a confirmation from you that it is safe to add your plugin.

In reply to K S Ramachandran

Re: New version of the algebra question type for Moodle 2.4

by Victor Goff -

I assure you the HTML is not disabled, just the WYSIWYG editor is not activated.  The forums need to continue to have this in this manner, as it causes too much support work when students have the WYSIWYG for forums.

In reply to Victor Goff

Re: New version of the algebra question type for Moodle 2.4

by Ramon Eixarch -

WIRIS quizzes includes new types of question into Moodle. No risk to install it.

During this week we will upload a new version of our tool that is compatible with Moodle 2.4

Our tools usually work with the WYSIWYG mode. An email exchange with our Support team will clarify what may happen in your scenario support@wiris.com

In reply to Ramon Eixarch

Re: New version of the algebra question type for Moodle 2.4

by Jean-Michel Védrine -

Please Ramon can you stop immediately hijacking this thread about algebra question wich was given for FREE to Moodle community by his author Roger Moore (and that I maintain no asking for anything in return) and open a new thread to discuss Wiris products with your customers.

Thanks.

 

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

How to handle inequality problem answers

by James Choi -

Is there a way to handle inequality answers using numerical evaluation?  One could set the random variable generation range very close to edges, but I wonder if there is a way to handle the borders.  That is, is there a way to differentiate x>2 vs. x>=2?

In reply to James Choi

Re: How to handle inequality problem answers

by Jean-Michel Védrine -

Internally numerical evaluation uses php lcg_value function, and I think this function returns a float between 0 and 1 inclusive so there is a small chance (very small) that it returns 0 or 1.

I would set min value to 2 if I want x variable to verify x >= 2

and min value to something like 2.0001 if I want it to verify x > 2

I don't have a better solution.


In reply to Jean-Michel Védrine

Re: How to handle inequality problem answers

by James Choi -

I guess one has to resort to CAS to handle it.  Thank you.

In reply to Roger Moore

Re: New Algebra Question Type

by Jean-Michel Védrine -

Hello,

I have uploaded a new version to my github account

Changes in this version :

  1. I changed the names of the tables form question_... to qtype_... everywhere in the code to comply with current rules for Moodle plugins. The upgrade procedure will take care of renaming your tables.
  2. All lang files are now in a single file, because I think this will ease of management of these strings in non english languages using AMOS once this plugin is in the Moodle Plugins Directory.
  3. MathJax can be used for TeX rendering.
  4. This is of no interest for users, but I tried to improve code style to current standards. I think that it will be a good thing for the future, but I hope I didn't introduce too much typos or bugs in the process.

Changes # 1 and 2 required a bump in the plugin version number, so don't forget to visit Site Administration Notifications after installing the new files on your server.

As I said I will now submit this plugin to the Moodle Plugins Directory because I think it will improve its diffusion and ease installation.

In reply to Jean-Michel Védrine

Re: New Algebra Question Type

by Victor Goff -

You have not given your github information.  And no hints in your profile to find it there either. sad

 

I will be installing this shortly.

In reply to Victor Goff

Re: New Algebra Question Type

by Jean-Michel Védrine -

It is in my message dated Sunday, December 16th 2012 in this thread.

But I will give it again:

https://github.com/jmvedrine/moodle-qtype_algebra

As I said I will submit it to the Moodle plugins dirrectory so that it is easier for Moodle users to find it.

In reply to Jean-Michel Védrine

Re: New Algebra Question Type

by Victor Goff -

Thanks, I probably didn't search references to github enough times to get there.  (I also need to change my preferences to not have the message bodies minimized.)

I have it now.

In reply to Victor Goff

Re: New Algebra Question Type

by Victor Goff -

There is something strange going on in that when students want to type in @@ in the forums it will come up with an error message.  This wasn't happening prior to the plugin install.  Is there some setting or customization that I still need to do?

In reply to Victor Goff

Re: New Algebra Question Type

by Victor Goff -

Resolved, not sure what happened.  But it is no longer happening.

In reply to Victor Goff

Re: New Algebra Question Type

by Jean-Michel Védrine -

Hello,

Your problem with @@ in the forums surely has nothing to do with the algebra question type. Most likely someone had activated the algebra filter (wich is not needed for the algebra question type and in fact has no relation with it).

Going to Site Administration -> plugins -> Filters -> Manage filters and deactivating the algebra filter will resolve the problem.

In reply to Jean-Michel Védrine

Iteractive with multiple tries

by James Choi -

I am having trouble setting the "hints" in "Interactive with Multiple Tries" Question Behavior Setting.

Basically, it does not store any hints.  Therefore, those who take the test/quiz will have only one shot at getting the right answer, as the number of allowed tries is controlled by the number of hints.

Is there a way to work around this?  I would like to give three tries to my students.

Thank you.


In reply to James Choi

Re: Iteractive with multiple tries

by Jean-Michel Védrine -

Hello James,

Do you only have this problem with the algebra question type and is it working as it should with other question types ?

If yes then that is  a bug and I will study it and correct it.

PS : What version of Moodle and what version of the algebra question type are you using ?

In reply to Jean-Michel Védrine

Re: Iteractive with multiple tries

by Jean-Michel Védrine -

Oops,

I did a quick test and I can confirm there is a problem with hints in interactive with multiples tries for the algebra question type.

Sorry for that. I will fix the bug and publish a new version.

In reply to Jean-Michel Védrine

Re: Iteractive with multiple tries

by Jean-Michel Védrine -

I created CONTRIB-5128 to track this bug.

In reply to Jean-Michel Védrine

Re: Iteractive with multiple tries

by Jean-Michel Védrine -

Hello,

I just published in the Moodle plugins Directory a new version of the algebra question type (version 1.31 for Moodle 2.5, 2.6 and 2.7) see https://moodle.org/plugins/view.php?plugin=qtype_algebra

This version fix the bug with hints that were not saved.

This version also introduce a new admin setting to choose the delimiters for TeX expressions (when students press the "Display" button after typing an answer during attempt and when the correct response is displayed during quiz review) you can choose the old double dollars delimiters or the new delimiters used by the MathJax filter in Moodle 2.7.

If no new problem is reported I will backport the fix for hints to algebra question type for older Moodle versions. I will not backport the TeX delimiters setting.


In reply to Jean-Michel Védrine

Re: Iteractive with multiple tries

by James Choi -

Thank you so much!  I have a dumb questions.  Would it work with Moodle 2.3, (which is what I have)?  Or do I have to upgrade Moodle first to use this one?

In reply to Jean-Michel Védrine

Re: Iteractive with multiple tries

by James Choi -

Thank you for such a quick fix!  I am sorry to bug you, but if it not too much trouble on your end, could you also make it work with Moodle 2.3?  I am afraid upgrading of my Moodle to use Algebra Type would cause other things to break and I won't be able to get out of the mess.

Thank you very much.

In reply to Jean-Michel Védrine

Re: Iteractive with multiple tries

by James Choi -

Thank you for responding so fast!

Looks like you fixed it already.  Yes, it was happening with only Algebra type.  I noticed it because xml export of algebra type stripped off the <hint> tags then I realized that it is not just export/import issue.  It won't save any hints period.

My Moodle is 2.3.3. and I was using the latest algebra type that worked for that version.

In reply to Roger Moore

Re: New Algebra Question Type: comprehensive list of functions, and exp(x).

by Gabriel Villalobos Camargo -

Hi there,

I have used the algebra question type since a few months now, and it's been very good. Thanks for the good work. 

I have two questions. First, is there a more comprehensive list of features/help? I find the webpage rather sparse on details of how this work (http://docs.moodle.org/24/en/Algebra_question_type). For instance, it does not say that the math expressions in the question have to be entered as tex, while in the student answer this does not apply.

Secondly,  I do not see the exp(x) function in the list of allowed functions to use. Nonetheless cosh(x) and sin(x) are there. If I type exp(x) as an answer I get the error:


Undefined variable(s) 'xp' used in one or more answers


Is this something that has to be ironed out, or maybe I need to ask the moodle support in my University to upgrade the algebra question type to the latest?

Thanks!

Attachment exp_does_not_work.png
In reply to Gabriel Villalobos Camargo

Re: New Algebra Question Type: comprehensive list of functions, and exp(x).

by Jean-Michel Védrine -

Hello Gabriel,

This question type was created by Roger Moore back in 2007. I lost contact with him several years ago.

I published new versions of this question type so that it can be used with recent Moodle versions but that's all.

The doc was written by Roger when he created the algebra question type and apart adding a link to download latest versions from the plugin directory I don't modified it a lot. I agree it would need to be improved.

But good news is that Moodle docs is a wiki so all users of the algebra question type can participate in improving the dcumentation. I suggest you edit the latest version http://docs.moodle.org/27/en/Algebra_question_type

About your question (and it would be good to add this to the documentation wink ) users of the algebra question type must understand the difference between

- the question text (just used for display) where the usual rules for entering math apply (you type a math formula exactly in the same way you would do to include it in a forum post) so you must use TeX syntax here.

- the formula used by the teacher to enter the right answer when creating the question and by student during quiz attempts to enter their answer. These formulas must be parsed by the formula question code so a special syntax is used here and TeX syntax must not be used here.

As I said in a previous message in that thread the algebra question type uses what is called a linear syntax to input math formulas : *, +, -, /, /, (, [, ], ), pi, e, and the known functions sqrt, log, ln, sin, cos, tan, cosh, sinh, asin, acos, atan.
Variables can be letters, single words, greek letters are recognized and subscripts too, for instance u_1 will be intepreted as \( u_1 \)
. Obviously e and pi can't be variables names as they are already constants.

So this also gives the answer to your question about the missing exp function : you must use e^x and not exp(x).

Last thing is that if you use the "evaluation" method you must understand that as long as the student response gives the same numerical result as the teacher answer it will be graded as correct.

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

Re: New Algebra Question Type: comprehensive list of functions, and exp(x).

by Gabriel Villalobos Camargo -

Thanks for the answer Jean, you covered it all. I'll certainly would like to help with the documentation.

In reply to Jean-Michel Védrine

Re: New Algebra Question Type: comprehensive list of functions, and exp(x).

by Hendrik Rommeswinkel -

Hello Jean-Michel,

Thank you for maintaining such a great tool. It was probably the main reason why I chose to use moodle.

I noticed what could be a bug or maybe just wrong settings on my part: I tried to use subscripts for variables and the plugin would alert me that a variable is not used.

In the variable definition of variable 1 I used "Y_1", "0.1", and "2" in the respective fields.

In the answer I used "2 - 1/Y_1" in the field (all without quotation marks).

The plugin rejected this, saying that undefined variable "Y1" [sic] is used in an answer and that my first variable is not used in any answer. Thus, I could not save the question as intended. However, the following trick still allowed me to save the question: I typed "2-1/Y__1" (with two underscores "_") in the answer field and now it saved the question without complaints.

However, when trying out the question, moodle gave me an error on submission saying that Y1 is undefined and thus could not be evaluated numerically. Submitting the answer as "2-1/Y__1" did not help here.

Note: I am using moodle 2.9.

In reply to Hendrik Rommeswinkel

Re: New Algebra Question Type: comprehensive list of functions, and exp(x).

by Jean-Michel Védrine -

Sorry it took me more than 2 years to answer this.

In short : you don't need the underscore, defining and using a variable named Y1 will result as if it was Y_1 big grin

This is now explained in the documentation

In reply to Roger Moore

diplay/preview problem for Algebra Question Type

by sophie CASANOVA -

First, thank you for your work on algebra type questions.

It's great and working well beside a display/preview problem we have, which is similar to the pb of 

Attachment Pb-display.GIF
In reply to sophie CASANOVA

Re: diplay/preview problem for Algebra Question Type

by Frank Doheny -

I have been using the algebra question type for a couple of years and it has really expanded the type of questions I can ask my students in a quiz. Thank you for all your work on it.

I recently exported some questions I had developed to a colleague in another institution and they have the same problem with the display box where the students work is converted into TeX. They have both TeX notation filter and Mathjax filters turned on. 

My colleague tells me that their Moodle is set up only to require the use of \ (   \ ) or \ [   \ ] to indicate LaTeX and does not accept $ $ to indicate LaTeX content. 

Could this be the cause of the problem? If so is there any way around it? 

Thanks again,

Frank

In reply to Frank Doheny

Re: diplay/preview problem for Algebra Question Type

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

How many question are there? A simple (but boring) option is to edit the file before importing it, to replace $ with \( or \[ as applicable.

In reply to Tim Hunt

Re: diplay/preview problem for Algebra Question Type

by Frank Doheny -

Thanks Tim.

I tried that and it did convert all the TeX that I had in my questions. The  problem is that the preview of the students input is converted only into TeX.

Apparently the fix mentioned by Lukas can not be implemented on the server. Something to do with using Moodle 2.8.

Thanks again,

Frank. 

In reply to Roger Moore

moodle 3 : Notice: Undefined property: qtype_algebra_parser_bracket::$_sign

by sophie CASANOVA -

Dear all,

Since the upgrade to moodle 3,0 the algebra questions won't work any more on our site:

As soon as there is a parenthesis in the answer (example 8*(4x−3) ) we get this error message:

"Notice: Undefined property: qtype_algebra_parser_bracket::$_sign in /var/www/moodle-3.1.1plus/question/type/algebra/parser.php on line 896" (or sometimes "line 1339"

(bug already notified by Bernhard Piazzi on https://moodle.org/plugins/qtype_algebra )

If you came accross this problem and were able to solve it, could you please help me ?

We have no moodle developper on our site and without your help our hundreds of algebra questions are just going to get lost !

Many thanks in advance!

Sophie

In reply to sophie CASANOVA

Re: moodle 3 : Notice: Undefined property: qtype_algebra_parser_bracket::$_sign

by sophie CASANOVA -

Dear all,
a friend helped me with the above problem
(Notice: Undefined property: qtype_algebra_parser_bracket::$_sign in /var/www/moodle-3.1.1plus/question/type/algebra/parser.php on line 896" (or sometimes "line 1339"))
I'll try to translate the solution:

A variable was not initialized ($_sign) in the constructor of the class qtype_algebra_parser_bracket.
To correct this you have to modify the file : question/type/algebra/parser.php (line 1309) and add an initializing line :

function qtype_algebra_parser_bracket($text) {
parent::qtype_algebra_parser_term(self::NARGS,self::$formats[$text],$text);
$this->_sign=''; // line added
$this->_open=$text;

I hope it helps if you come accross the same problem.
Sophie

Average of ratings: Useful (1)
In reply to Roger Moore

Re: New Algebra Question Type

by Jean-Michel Védrine -

Well,

As I am preparing a new release (nothing really new but a lot of small fixes), I began working on an improved documentation page for this question type. See https://docs.moodle.org/34/en/Algebra_question_type

The current one was very outdated and not a good help to use this question type.

I still need to add a lot of small details, screenshots and some examples.

Feel free to participate smile

Average of ratings: Useful (2)