Offline Quiz Module for Moodle 2.x

Offline Quiz Module for Moodle 2.x

by Juergen Zimmer -
Number of replies: 11

Dear all,

we use Moodle as our main LMS at the University of Vienna (Austria).

I'm currently the only developer for Moodle at the University of Vienna and we are planning to upgrade to Moodle 2.x next summer.

My predecessor (Richard Rode) has developed a Module for offline-quizes where teachers can create question and answer sheets for Multiple-Choice tests. The students then fill in the answer sheets with crosses which are automatically analysed and graded by the module. The module is heavily used by teachers in offline-quizes with several hundred students. R. Rode created the offlinequiz module by cloning the quiz module (including the link to the question DB) and heavily adapting the clone. This resulted in necessary Moodle Core patches (mainly in the question bank) which we want to avoid in the future, if possible.

I should also mention that offline-quizes support several groups with different question sets and the shuffling of question answers.

Now I'm faced with the task to migrate the Offlinequiz module to Moodle 2.x and I don't really know where to start. AFAIK, both the question bank and the quiz module have been completely rewritten (for instance, there are not question_states anymore, as far as I can see).

I wonder what other developers' suggestion would be on how to build a new offlinequiz module for Moodle 2.x. Should I try to adapt the existing 1.9.x code to Moodle 2.x (which seems impossible)? Or should I clone the quiz module again and change it (~23.000 lines of code, ...)? Or should I write a new module which manages the questions, e.g., like the lesson module which only imports question to its own DB tables, but doesn't support, e.g., groups or answer shuffling?

I suppose, Tim Hunt is the person to ask here, but I saw that he also reads this forum, so I hope I'm at the right place.

All help and suggestions are greatly appreciated.

best regards

  Juergen Zimmer

Average of ratings: -
In reply to Juergen Zimmer

Re: Offline Quiz Module for Moodle 2.x

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

It looks like you have worked out that the correct advice is "don't do that again!". You certainly don't want to be duplicating a lot of standard Moodle code.

Let me check that understand you requirements correctly. You want to use the Moodle quiz to:

  1. set up your quiz with particular questions;
  2. automatically grade the students reponses;
  3. display detailed reports about the students responses and grades; and
  4. get the grades into the Moodle gradebook.

But you don't want to use the sandard quiz functionality that lets the student

  1. input their responses.

Instead you want new functonality that

  1. Prints the quiz, so the student can answer it on paper.
  2. Scans the paper after the student has written their answer on it, and then feeds those responses to the standard Moodle grading routines.
  3. Prevents the student from putting in their responses in the normal way.

I think that it would be possible to do this as a new quiz report plugin, even though it is not really a report. Then you should not have to change the quiz core code at all.

The report plugin would include scripts to do 1. and 2.

1. I just pretty boring load the data from the database and generate the output code. To load/setup the blank attempt for each student, you need to copy the code in mod/quiz/startattempt.php

2. Requires that you scan the response (I've no idea what code you use for that, but obviously such code already exists) and then feed them to Moodle. That requires that you copy the code in processattempt.php

To do 3. you just need to use Quiz administration -> Permissions from the settings block to remove the mod/quiz:attempt capability from students (but leave the mod/quiz:review one). No coding required.

Does that sound plausible?

 

Note that http://moodle.org/mod/data/view.php?d=13&rid=3601&filter=1 exists. I don't know if that does you any good. I know nothing beyond what is in that database entry.

Average of ratings: Useful (1)
In reply to Tim Hunt

Re: Offline Quiz Module for Moodle 2.x

by Jean-Michel Védrine -

Hello,

I have tested the quizomr plugin That Tim pointed out in his link. More exactly it's not a plugin but a (rather big) patch.

When I tested it, I had trouble applying the patch so I used my usual patch machine (me + a text editor smile) and I think I still have a working (I think, but not tested since many months !) Moodle 1.9.6 or 7 with quizomr test install somewhere on my laptop.

After testing it, I decided not to go this way, because quite a lot of Moodle core files were patched and did not wanted to lock me out of future Moodle upgrades. Of course with the release of Moodle 2.0 and even more 2.1, I never regretted this decision !

Even if quizomr appears as a tab as other reports it is not coded as a real report at all.

Implementing offline quizzes as a report sound doable but maybe I have one objection : on most systems using optical marks recognition (OMR) that I know, there is not really a different exam sheet for each student because it would not be manageable to distribute such sheets to hundreds of students at the begining of the exam, but to prevent cheating, there is a small number of "variants" and the id of the variant is coded on the sheet, and later this id is read by the OMR machine so you need a way to prepare several variants of the quiz before printing it and later you need to know when you input students answers back in the quiz wich variant he got during the exam.

I see no way to do that without any db tables and I was thinking quiz reports plugins were not "real" Moodle plugins and can't have a db subfolder ? I hope I am wrong and  (edit : I just looked at the statistics report and it has a db subfolder so my objection is irrelevant. Note to myself : next time, verify before writting something in the forum !)

if a project to write such an "offline quizz" plugin start I would be happy to participate but my clear condition is that it would be a real plugin, requiring no patching of Moodle core files !!

Most probably I will have to write my own code to feed the students results to the Moodle quiz grading routines because my OMR sytem is a (french) very non standard sytem wink

 

In reply to Jean-Michel Védrine

Re: Offline Quiz Module for Moodle 2.x

by Juergen Zimmer -

Dear Jean-Michel,

thanks for your reply. I've already added further information in my reply to Tim, please have a look at that too.

We would very much welcome your participation in the project. The project has actually already started because we are planning to upgrade to Moodle 2.x in Summer 2012 in cooperation with the Technical University of Vienna which also contributes some ressources.  The offlinequiz module is already in use and is one of the 'must-haves' for Moodle 2.x. However, we don't need a complete rewrite. Core components of the existing module (creating question and answer sheets, scanning the responses, correcting errors) can more or less be reused. Of course, these parts of the module heavily depend on file management which has to be rewritten.

My predecessor had the attitude of patching the Moodle core whenever wanted (new interface in Moodle core pages, using jQuery, etc). We decided that this approach is not maintainable and are also planning to avoid Moodle core patches at all costs.

About the variants in the question sheets. The teachers typically print the sheets for different groups and then seat the students in  A B A B  order with space in  between.

About the OMR system. Our module only requires you to have a standard (potentially high-speed) scanner. The analysis of the answer sheets is done by our proprietary php code which basically "searches in the pixels"... Which is why we have all the markings on the sheets attached to my previous post.

The students can also cross out a field completely to undo mistakes. The question whether a marking is a cross or not is answered by counting the black pixels in the appropriate squares and using percentage bounds to determine whether there is a cross, a cross-out or an emtpy box. It works pretty well and can also cope with some common problems: slanted sheets from the scanner, wrong matriculation number, sheets are scanned upside-down, the same sheet occurs twice, etc.

The module is already configurable to use a different user identification. E.g. at our University the username for a student with matriculation number  9999999 is  a9999999. This might be different at your University.

I'll have to look at the quizomr you mentioned.
I hope we stay in contact.

all the best

   Juergen

In reply to Tim Hunt

Re: Offline Quiz Module for Moodle 2.x

by Juergen Zimmer -

Dear Tim,

thank you for your quick reply. I think you assessed the situation quite accurately. Maybe I just add some more details.

For better understanding you can find our latest 1.9.11 production code at

http://homepage.univie.ac.at/juergen.zimmer/mod-offlinequiz-30.09.2011.tgz

If you are interested I can also check whether I can give you a lightuser account on our moodle installation and you can see the module in action.

To the requirements:

1. The user can build the quiz by only using multichoice and description questions (edit.php).The questions can be arranged on pages and explicit page breaks can be inserted. The offlinequiz suports up to 5 groups in which students may be put. Each group has a different set of questions.

Then, proprietary question sheets and answer sheets are created using the FPDF (we will switch to another library to support UTF8). Also answer sheets are created using the same library (createquiz.php)  (I attached a fake answer sheet to this post, sorry all in German). Also a list of possible participants with bar code identification can be printed, to be filled in by the tutors.

2. The question sheets are then printed, handed out to students and filled in. The teacher scans the answer sheets and uploads the pictures in a ZIP file. The pictures are then analysed online in  report/rimport/report.php or offline in a queue (lib.php). During the analysis, log entries are written in the DB table offlinequiz_i_log which contains the raw data as strings like  0100,0010,...  with '1' for recognised crossed answers, etc.  I think this was taken from the 1.9.x quiz module, am I correct?

3. The 'rimport' report shows a detailed report for teachers including potential errors that occurred while analysing the picture (wrong matriculation number, etc). The errors can then be corrected by the teacher (correct.php). An overview of the results is show with report/overview/report.php.

The students can have a detailed report (image.php) in which they see their answer sheet including marks that indicate which crosses where identified correctly and (if activated) which answer where right or wrong. (I also inserted screenshot on the bottom of the post).

And you are right: The student never inputs responses online in the system! Students only see the result (image.php) and, potentially, a small tutorial which shows them how make proper crosses. Of course the students must have selected access to module files (the images). In Moodle 1.9.x. the file access code was patched for this. I've read in Moodle 2.x modules can regulate access to files. However, would that be possible in a quiz report plugin?

Your suggestion with the quiz report plugin sounds plausible, but before I can make a final decision I would have to look into this in more detail first. I also want to check the answer of jean-michel vedrine

first.

I'm actually pretty new in Moodle and was forced to take over development in May. So i'm not quite as proficient as others in this forum.

all the best

  Juergen

(Edited by Helen Foster to delete attachment as requested by poster - original submission Friday, 30 September 2011, 11:06 AM)

In reply to Tim Hunt

Re: Offline Quiz Module for Moodle 2.x

by Juergen Zimmer -

Dear Tim,

one thing I forgot to mention before is the fact that the offline-quizzes have additional settings which are not

present in normal quizzes, namely the 'papergray' setting where teachers can change the grey-value of the paper used for the answer sheets, and the introductory text shown on the question sheets. Maybe the standard description of the test could used for the latter, but I'm not quite sure how the papergray setting could be realised in a quiz report plugin...

Cheers

 Juergen

In reply to Juergen Zimmer

Re: Offline Quiz Module for Moodle 2.x

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

Well, the quiz report idea is just one way to do it. That is the way that stresses maximising the amount of Moodle code you can reuse without changing.

The alternative is to keep it as a separate module. That lets you build a UI that is optimised for your requirements, but at the cost of writing a bit more code.

I hope that the new question engine in Moodle 2.1 plus the gradebook and the question bank, means that you can still re-use a lot of existing Moodle code.

In reply to Tim Hunt

Re: Offline Quiz Module for Moodle 2.x

by Juergen Zimmer -

Dear Tim,

that brings me back to my original question. What do you think is more advisable from your point of view (as a senior Moodle developer), take the new quiz code and adjust a clone of it or take my own code and adjust it to the new question engine and gradebook?

Thanks

  Juergen

In reply to Juergen Zimmer

Re: Offline Quiz Module for Moodle 2.x

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

Don't clone the quiz code. (But look at it for reference if you can't work out how to interact with parts of the core system like the question bank.)

Make your own module starting from the newmodule template.

In reply to Tim Hunt

Re: Offline Quiz Module for Moodle 2.x

by Juergen Zimmer -

Dear Tim, I hope don't mind me discussing my ideas with you in this forum since nobody in my institution has the technical background.

I've just discussed this with my superior and first we came up with a hybrid solution: 

1) Offlinequiz attempts are realised in a separate module. Teachers first create a normal (online) quiz with all the questions inside. Then  they create an offlinequiz which refers to the online quiz. Automatically, the students are prevented to make attempts in the online quiz. Additional settings, creating and analysing answer sheets, etc. are all handled by the offlinequiz module instance. However, questions,  grades, etc. are handled in the onlinequiz module instance. This way, we would get rid of all the question management things which the online quiz can do for us.

But there are two problems with this approach:

 1a) The teacher has to handle two objects, the offline quiz and the corresponding online quiz. This is not nice!

 1b)  We have to decide which object (quiz or offlinequiz) is visible to the students. I suppose that would be the original quiz. However, then we needed a patch to link to the specialised review code for offlinequiz.

 

Realising these problems we also discussed your original proposal to realise offline attempts as report plugins in the quiz module:

2) Offlinequiz funktionality is performed in additional report types for the quiz module. This overcomes problem (1a), the teacher works only with one quiz object. However, we need some way to trigger offline attempts, e.g. an additional setting in the quiz settings which activates offline attempts (and deactivates online attempts) and activates the additional settings (tabs).  Offlinequiz-specific settings (for the review) would be available on one of these tabs. However, I see also some problems there:

2a) We need to change the quiz settings to allow for a trigger for offline attempts.

2b) We need to add code to the quiz module which writes information in new database tables. And, anyway, we needed to change the quizes install.xml and upgrade code to create those tables in the first place. Not nice!

 

Either way, we need to patch the quiz module in some ways. Either we need links to the offlinequiz review (1) or we need an additional setting to activate offline attempts (2).

The way I see it the separate module (1) seems to be the only option (with reduced usability) and the solution with the least patches on the quiz module.

What is your opinion on this?

Cheers

   Juergen

In reply to Juergen Zimmer

Re: Offline Quiz Module for Moodle 2.x

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

The separate parallel module idea is quite plausible. I think that the main entry point for the new hybrid module should be the offlinequiz module, not the quiz. That reduces the number of changes you need to make to the quiz code.

Some evil hacks you might not have realised yet, and which you might be able to use.

1. You can make the quiz you are wrapping invisible to students, but visible to teachers, but setting 'visible' to 0 - that is, closing the eye-icon in the UI.

2. Alternatively, if you need finer-grained control, leave it visible, but automaticaly create permissions overrides, so students cannot attempt that quiz, but the can still review past attempts or something.

3. To reall get the quiz instance out of the way, you can move it to a non-existant section like 99999. That will mean that it never shows up in the UI, but Moodle will still happily let people access it if they follow a link there, and you can give them a link in your offlinequiz module.

4. For really evil hacks, if you are using a custom theme, look at http://docs.moodle.org/dev/Themes_2.0_overriding_a_renderer. Note that in Moodle 2.1 the quiz was converted so that all the student-visible output is generated through renderers, so you can change it just in your theme. However, if you go this route, then no one else will be able to use your module.

5. If it helps, we can probalby move some of the code from scripts like mod/quiz/review.php into library files, so they are eaiser to reuse. Similarly, you may already be able to reuse methods from the quiz renderer.

You should know that I am currently hacking around with the quiz code (MDL-29627). I am taking this opportunity to try to clean some things up, so if possible, you should start building on 2.2 dev in a few weeks time. Otherwise, you might fine yourself having to re-do some parts of the work later.

In reply to Tim Hunt

Re: Offline Quiz Module for Moodle 2.x

by Juergen Zimmer -

Dear Tim,

I'm really very thankful for your sharing your expertise with me. As I see things I will probably have to communicate more often with you in the future. I hope that is OK for you. The question is whether we find another channel (direct e-mail) or keep it here in the forum.

ad 1) that was what I also had in mind

ad 2) I also thought of that. I would basically manipulate the DB entries for the permissions in the hidden quiz. Of course the teacher could always change those permissions again... This is a general problem we have with Moodle. In another part we actually needed to 'lock' objects (in that case grades), s.t. they can not be changed anymore. But I'll start another thread for that. 

ad 3) That sounds really interesting. So the teacher would only interact with the quiz instance via the offlinequiz instance. Students can review past attempts (the ones created by the offlinequiz module) via the offlinequiz instance. The question is whether I can render some of the quiz functionality inside an offlinequiz page, e.g. in a separate frame, or course, without the navigation stuff. So in the end the teacher could e.g. add/remove questions to/from the hidden quiz while he's actually on an offlinequiz page (.../mod/offlinequiz/edit.php). I suppose that is what you are referring to in (5), aren't you? That would also solve my problems with linking the answer sheets in the attempt review. I would simply display the usual attempt review with functions from the quiz module and, on top of that, offlinequiz specific stuff. At the moment the attempt review looks like this

Moodle 1.9.x offlinequiz attempt review

 

Anyway, I still have to think things through a bit more.

Of course, since you are re-organising the quiz code anyway, I would welcome any changes you can make that would

make the integration of offlinetests smoother.

 

Thanks again

  Juergen