Perl-Compatible Regular Expression

Maintained by Oleg Sychev
A question that could check student's response against several regular expressions and could give next character and next word hints. If you do not know what regular expression is, it could also work like Moodle Shortanswer question with hints, just choose "Moodle shortanswer" as notation and you could enter answers just like in shortanswer question type.
Price option: Free

Supports Moodle 2.3-4.3 See all versions
Latest release: 2 years ago
Installations: 34
Downloads (last 90 days): 68

Frankenstyle name: qtype_preg
Question types

Comments

Product ratings and reviews are coming to Moodle Marketplace. Until then, existing comments remain available to read, but new posts have been disabled.

Preg v3.6 (qtype_preg) is not compatible with Moodle v3.9 and probably higher versions!
It breaks the complete upgrade process resulting 404 errors on
/admin/index.php?cache=1
/admin/search.php
and other pages.
Thank for the notion
Hi, Pramith. Yes, we are currently testing Preg 3.1 and working on support for Moodle 3.2 (the big UI changes affects Javascript question editing interface too much, but core questions should work fine). We are currently on vacations now, but I hope to do this in September.
What unit tests file gives failure to you? If you run cross_tests.php (more than 2500 tests) there are tests that are expected to break for several very obscure cases. There are also 1-2 obsolete unit-tests files probably too.
Hi Oleg, do you plan to provide Moodle 3.1+ support, I am in the process of upgrading a Moodle from 2.8 to 3.1, and it seems to be breaking Unit tests. So I am willing to know about 3.1 compatibility.
Well, not correct but 95% for such answers is too much IMHO.
Sepp, it's not that easy. You example with Java would accept "for(i++;int i=0; i<10)" as a correct answer which is far from what Java expects. It also will accept something like for(int i=0 some_strange_additionally_garbage_can_be_inserted_in_many_places;i<10;i++)" as a correct too,
Thanks for your quick response. I had a look on your correct writing plugin and it seems very useful for learning.
I think, to grade fully correct answers with regex is a trivial thing. The difficult job is to grade partially correct answers.
My idea was to search (with regex) in the student's answer for special expressions and have points for it.
e.g: in Java: for(int i=0;i<10;i++)
One regex checks for fully correctness; if not a serie of regexes looks for correct parts like
"int i=0" or "i<10|i<=9" or "i++|i+=1|i=i+1|i=1+i" or "for(.*;.*;)"
and have 30%+30%+30%+5% points for it. A student answer can have a combination of errors, but the correct parts give percents of points.
This is what I meant. Each regex needs two fields for successor regexes for matched / unmatched. (like in the math plugin STACK). So it is possible to build up a decision tree with matching or unmatching regexes. (Sure, I can use use the math plugin and take usage of maxima's regex capabilities, but this plugin is more performant)
Sepp, if you are really into creating an asnwers from some words in some order, this (my) question type may suit you much better - https://moodle.org/plugins/view.php?plugin=qtype_correctwriting . It can break up answer to words, detect missing, extraneous and misplaced words and grade it accordingly, giving hints.
Regular expressions are used to write all kind of nasty thing, they can be non-linear, use repetitions, backreferences, recursion etc. I can not imagine right now how what you want should behave for complex regular expression. If you still wish to discuss this to example - let's do it on the tracker (link above). But I think than CorrectWriting question will give you what you want without regular expressions.
Hi, Sepp. This is more another grading algorithm than matching engine. It will also require separate interface to enter answers, as you will need to enter both complete (for hinting generation) and partial answers. Also, not in every case you would want to allow elements of the answer in any order. This will require thorought discussion. Please create an issue on https://code.google.com/p/oasychev-moodle-plugins/issues/list to discuss this.
Thanks for the nice plugin. A typical problem is an correct answer ( as in your example) like
"blue, white, red". Is it possible to add an matching engine which goes through all answers and calcs additive the matching percents, eg.:
33% for .*blue.*
33% for .*white.*
33% for .*red.*
(-10% for not .*,.*and.*)
? This would strongly simplify the permutations of partly correct answers.
Thank for the notion, Jaroslaw, but some uint-tests there (like fa_intersection_test.php) are part of ongoing development features for future releases and code under testing doesn't called anywhere from released production code.
Fatal error: Cannot redeclare qtype_preg_fa_avoid_wordbreaks_test::test_two_lines() in /warehouse/lampp/htdocs/moodle/question/type/preg/tests/fa_intersection_test.php on line 540