MantisBT

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0003174ATutorTests/Surveyspublic2007-09-06 01:142008-08-21 08:58
ReporterIndieRect 
Assigned Toharris 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version1.5.5 
Target VersionFixed in Version1.6 
Summary0003174: Test results display as "N/A"
DescriptionBug description:
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.

Cause:
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.

Solution:
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.
TagsNo tags attached.
Affects versionSVN
SVN Revision#
Attached Files

- Relationships

-  Notes
(0002594)
greg (administrator)
2007-12-09 05:44

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?
(0002618)
IndieRect (reporter)
2007-12-11 22:20

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.
(0002619)
IndieRect (reporter)
2007-12-11 22:34

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.
(0002635)
harris (developer)
2007-12-13 12:15

Confirmed.

The first resultset is not guaranteed to be "required".
(0002636)
harris (developer)
2007-12-13 12:15

Applied IndieRect's suggestion.

7155

- Issue History
Date Modified Username Field Change
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
Powered by Mantis Bugtracker