Question Practice icon

Question Practice

Maintained by Marcus Green
A teacher sets up a bank of questions organised into categories. Then the student can then choose what categories they want to practice when.
Price option: Free

Supports Moodle 2.5-5.2 See all versions
Latest release: 3 months ago
Installations: 42
Downloads (last 90 days): 114

Frankenstyle name: mod_qpractice
Activities

Comments

Comments are no longer open for new posts. Existing comments remain available to read.

No. It is module context by design. That is how the teacher controls which questions are available for practice. They move or copy them into that context.
It is also intentional that we only offer a choice of top-level categories in the UI (though that decision might get reviewed.)
p.s. - I added/modified the following lines and it seemed to work the way that I would expect:
$coursecontext = context_course::instance($course->id);
$categories = $DB->get_records_menu('question_categories', array('contextid'=>$coursecontext->id), 'name', 'id, name');
Tim - I am still getting an error:
[Wed Sep 11 09:13:10 2013] [error] [client 127.0.0.1] PHP Notice: Undefined property: stdClass::$categories in /var/www/m25/mod/qpractice/locallib.php on line 71, referer: http://localhost/m25/mod/qpractice/startattempt.php?id=594
[Wed Sep 11 09:13:10 2013] [error] [client 127.0.0.1] Default exception handler: Error writing to database Debug: Column 'categoryid' cannot be null\nINSERT INTO mdl_qpractice_session (time,goalpercentage,noofquestions,practicedate,typeofpractice,categoryid,userid,qpracticeid,questionusageid) VALUES(?,?,?,?,?,?,?,?,?)\n[array (\n 0 => NULL,\n 1 => NULL,\n 2 => NULL,\n 3 => 1378908790,\n 4 => '1',\n 5 => NULL,\n 6 => '2',\n 7 => 1,\n 8 => 12,\n)]\nError code: dmlwriteexception\n* line 426 of /lib/dml/moodle_database.php: dml_write_exception thrown\n* line 1089 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()\n* line 1131 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()\n* line 78 of /mod/qpractice/locallib.php: call to mysqli_native_moodle_database->insert_record()\n* line 71 of /mod/qpractice/startattempt.php: call to qpractice_session_create()\n, referer: http://localhost/m25/mod/qpractice/startattempt.php?id=594
I took a quick look and am wondering if we aren't sending the wrong context to populate categories:
$context = context_module::instance($cm->id);
$behaviours=get_options_behaviour($cm);
$categories = $DB->get_records_menu('question_categories', array('contextid'=>$context->id, 'parent'=>0), 'name', 'id, name');
It looks like we are sending the course module context id and I thought that the question_categories table stored the course context id. As a result I am getting an empty array of question categories. I also found myself wondering about the need for the parent=0 condition. Is the intention here to generate a list of all the question categories for the course?
Peace - Anthony
Anthony, I think the problem may be that during development, we have not correctly used upgrade.php. Can you try completely uninstalling the plugin (from admin/modules.php) then letting it re-install. That shoudl fix the DB error.
I uninstalled and used the code from Github and am still seeing the database write error. I'll let you upload a new version. I am still not seeing the question categories in a course so I suspect that the error may be related to that. I'm going to go ahead and edit the entry to provide the URLs. I'll leave this marked as needing some work until we can get past the database write error. Peace - Anthony
Please let me know if I missed something while answering to your response. Do I need to an attachement and update version here?
Thanks for reviewing the code.
Cheers!
Hi Anthony,
First of all thanks for including this as a part of Moodle plugins. I am glad that this module will help lot of people to practice and analyze themselves.
Coming back to the queries you reported, I will like to answer them in point by point.
1.) Yes the 2 small fix you talk about are missing namely :
Maturity information ($module->maturity) not found in version.php
Release name ($module->release) not found in version.php
2.) The code I uploaded while creating the request is old one. I have an updated codea at my github link, it will be kind of you if you can download code from their and test that. That code is kind of perfect code with no errors or so. You will need to uninstall the module and add module again and all the errors you reported will be solved. I have tested same with community and there was good response.
3) Yes documentation about the same is in progress, I will update it as soon as possible. Link to documentation is :
http://docs.moodle.org/dev/Self-assessment_activity_using_the_question_bank
p.s. - it looks as though you may have fixed up the if statement and just need to update the version but I am still seeing the write database errors when trying to create a session:
Tue Sep 10 15:09:39 2013] [error] [client 127.0.0.1] PHP Notice: Undefined property: stdClass::$categories in /var/www/m25/mod/qpractice/locallib.php on line 71, referer: http://localhost/m25/mod/qpractice/startattempt.php?id=591
[Tue Sep 10 15:09:39 2013] [error] [client 127.0.0.1] Default exception handler: Error writing to database Debug: Field 'sessionnumber' doesn't have a default value\nINSERT INTO mdl_qpractice_session (time,goalpercentage,noofquestions,practicedate,typeofpractice,categoryid,userid,qpracticeid,questionusageid) VALUES(?,?,?,?,?,?,?,?,?)\n[array (\n 0 => NULL,\n 1 => NULL,\n 2 => NULL,\n 3 => 1378843779,\n 4 => '1',\n 5 => NULL,\n 6 => '7',\n 7 => 2,\n 8 => 10,\n)]\nError code: dmlwriteexception\n* line 426 of /lib/dml/moodle_database.php: dml_write_exception thrown\n* line 1089 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()\n* line 1131 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()\n* line 78 of /mod/qpractice/locallib.php: call to mysqli_native_moodle_database->insert_record()\n* line 71 of /mod/qpractice/startattempt.php: call to qpractice_session_create()\n, referer: http://localhost/m25/mod/qpractice/startattempt.php?id=591
Jayesh - Congratulations on participating in GSOC 2013 and thanks for sharing your work back with the community! I like the idea of allowing students to practice whatever questions they want. When I was teaching I did something similar but I used the quiz activity module and simply allowed students to take the quizzes as often as they wanted and they would get the highest score from their attempts. This looks like it will give them much more autonomy.
I noticed that there were a couple of validation warnings that I would like to see fixed up. They are pretty self explanatory and easy fix:
Maturity information ($module->maturity) not found in version.php
Release name ($module->release) not found in version.php
If you need more information about these variables you can read http://docs.moodle.org/dev/version.php.
I also like to encourage folks to share the source, tracker, and documentation URLs. I saw in the tracker that you had referenced using Github so you can use Github's issues or the Moodle Tracker. If you want to use the Moodle Tracker just let me know so that I can create a component for you and make sure you have the permissions to manage those issues. Otherwise you can just use https://github.com/jacks92/moodle-mod_qpractice/issues. For documentation you probably want to use Moodle Docs. You may want to take a quick look at http://docs.moodle.org/en/Development:Guidelines_for_contributed_code for some general suggestions.
The module seems to install OK but when I tried to add an instance I received an error due to a missing closing parenthesis on line 85 in mod_form.php which should read:
if(isset($toform['behaviour'])) {
After that, I attempted to start a new session (as admin) and I was not able to see the question category so I could not select it. When I tried to proceed I saw "Error writing to database". It looks like we may want to do a little more testing before making this available to others.
I'm going to mark this as needing more work to give some time to tidy things up a bit. Thanks again for your work with GSOC and I hope we continue to see you around the Moodle community. Please do not hesitate to let me know if there is anything I can do to be supportive of your efforts.
Peace - Anthony