|Anonymous | Login | Signup for a new account||2017-12-18 17:26 EST|
|My View | View Issues | Change Log | Roadmap | Repositories | My Account|
|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0003174||ATutor||Tests/Surveys||public||2007-09-06 01:14||2008-08-21 08:58|
|Target Version||Fixed in Version||1.6|
|Summary||0003174: Test results display as "N/A"|
If a randomized test has no required questions, editing it (tools/tests/edit_test.php) will assing AT_tests.out_of a zero and consequently cause substitution of any results in the test with "N/A" ? on all student and instructor pages.
Function get_total_weight() of /include/lib/test_result_functions.inc.php does not handle appropriately the values returned by SQL queries.
Just trace what would happen if there're no required question, and you'll see.
A straightforward fix is replacing lines 18...20 of /include/lib/test_result_functions.inc.php with:
$sql = "SELECT SUM(weight) AS weight, COUNT(*) AS cnt FROM ".TABLE_PREFIX."tests_questions_assoc WHERE test_id=$tid AND required = '1' GROUP BY required";
$result = mysql_query($sql, $db);
$row_required = mysql_fetch_assoc($result);
$sql = "SELECT SUM(weight) AS weight, COUNT(*) AS cnt FROM ".TABLE_PREFIX."tests_questions_assoc WHERE test_id=$tid AND required = '0' GROUP BY required";
$result = mysql_query($sql, $db);
BTW, I'm often amazed lately with your usage of clearly unsafe programming techniques, and apparent lack of testing.
|Tags||No tags attached.|
Are you still able to reproduce this problem? I can't seem to.
Re: testing, with new blood on the team, testing will improve.
What unsafe technique are you referring to?
It is still there as of beta 1, just moved to lines 89...91.
Steps to reproduce:
1. Create a randomized test (or use an existing one).
2. Add a few questions.
3. Assign them some weight.
4. None of the questions should be required.
5. Edit the test; the exact changes are not important. The bug creeps right after you click "Save".
6. Take the test.
7. After submission, you'll see that your result is "N/A".
If you compare the DB test entry before and after step 5, you'll see `out_of` field being reset.
By "unsafe techniques" I meant two things:
1. Insufficient planning, which might be the reason for not foreseeing a case when there are no required questions.
2. Not checking return values of SQL queries.
The first was the cause of at least one major bug - the one which rendered answers to MC questions always wrong (see http://www.atutor.ca/view/3/8595/1.html [^] ).
The second is an ubiquitous practice in the ATutor code, especially for INSERT queries. Changing DB table structure (by you or when tailoring ATutor to some particular site) may cause some INSERT...VALUES queries fail without any notice and hence create hard-to-trace bugs.
The first resultset is not guaranteed to be "required".
Applied IndieRect's suggestion.
|2007-09-06 01:14||IndieRect||New Issue|
|2007-09-06 01:14||IndieRect||Affects version||=> SVN|
|2007-12-09 05:44||greg||Note Added: 0002594|
|2007-12-11 22:20||IndieRect||Note Added: 0002618|
|2007-12-11 22:34||IndieRect||Note Added: 0002619|
|2007-12-12 08:12||greg||Status||new => assigned|
|2007-12-12 08:12||greg||Assigned To||=> harris|
|2007-12-13 12:15||harris||Note Added: 0002635|
|2007-12-13 12:15||harris||Status||assigned => resolved|
|2007-12-13 12:15||harris||Fixed in Version||=> 1.6|
|2007-12-13 12:15||harris||Resolution||open => fixed|
|2007-12-13 12:15||harris||Note Added: 0002636|
|2008-08-21 08:58||greg||Status||resolved => closed|
|Copyright © 2000 - 2017 MantisBT Team|