Moodle

SQL error in exercise_get_best_submission_grades()

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Won't Fix
  • Affects Version/s: 1.8.2
  • Fix Version/s: None
  • Component/s: Exercise
  • Labels:
    None
  • Environment:
    Linux, Apache 2, MySQL 5.0.27, PHP 5.1.6, Moodle 1.8.2+ (2007021520)
  • Database:
    MySQL
  • Affected Branches:
    MOODLE_18_STABLE

Description

When going to the Grades page I get an SQL syntax error. The traceback goes to the exercise_get_best_submission_grades() function in mod/exercise/locallib.php. The current code (MOODLE_18_STABLE) of the function reads as follows:

function exercise_get_best_submission_grades($exercise) {
// Returns the grades of students' best submissions
global $CFG;

// make sure it works on the site course
$select = "u.course = '$exercise->course' AND";
if ($exercise->course == SITEID) { $select = ''; }

return get_records_sql("SELECT DISTINCT s.userid, MAX(a.grade) AS grade FROM
{$CFG->prefix}exercise_submissions s,
{$CFG->prefix}exercise_assessments a
WHERE $select
AND s.exerciseid = $exercise->id
AND s.late = 0
AND a.submissionid = s.id
GROUP BY s.userid");
}

According to the CVS log several inconsistencies were introduced in the 1.22 revision of locallib.php (http://eu.cvs.moodle.org/moodle/moodle/mod/exercise/locallib.php?r1=1.21&r2=1.22&pathrev=MOODLE_18_STABLE).

1) The $select variable ends with an 'AND'; the WHERE clause starts 'WHERE $select AND s.exerciseid = $exercise->id'; so two ANDs stand next to each other.

2) The $select variable contains the 'u.course' reference but the main SQL statement does not give the 'u' alias name.

If I get it right, the function can be shortened to this (patch attached):

function exercise_get_best_submission_grades($exercise) {
// Returns the grades of students' best submissions
global $CFG;

return get_records_sql("SELECT DISTINCT s.userid, MAX(a.grade) AS grade FROM
{$CFG->prefix}exercise_submissions s,
{$CFG->prefix}exercise_assessments a
WHERE s.exerciseid = $exercise->id
AND s.late = 0
AND a.submissionid = s.id
GROUP BY s.userid");
}

Activity

Hide
Peter Sereinigg added a comment -

Exercise ist not longer supported in 1.8 ... did you install the modul manually?

Peter

Show
Peter Sereinigg added a comment - Exercise ist not longer supported in 1.8 ... did you install the modul manually? Peter
Hide
Daniel Miksik added a comment -

I did an upgrade from Moodle 1.6.3+ to the latest MOODLE_18_STABLE (in the CVS repository the module is still in its usual place and there are quite recent commits so there was nothing suspicious about it).

I can see the module is not included in the standard Moodle 1.8 download package. Does it mean that it is not maintained neither as a third-party module?

Also, the info at http://moodle.org/mod/data/view.php?d=13&rid=322 should perhaps be updated.

Show
Daniel Miksik added a comment - I did an upgrade from Moodle 1.6.3+ to the latest MOODLE_18_STABLE (in the CVS repository the module is still in its usual place and there are quite recent commits so there was nothing suspicious about it). I can see the module is not included in the standard Moodle 1.8 download package. Does it mean that it is not maintained neither as a third-party module? Also, the info at http://moodle.org/mod/data/view.php?d=13&rid=322 should perhaps be updated.
Hide
Peter Sereinigg added a comment -

Fuctunality will be included in the new workshop modul.
Peter

Show
Peter Sereinigg added a comment - Fuctunality will be included in the new workshop modul. Peter
Hide
Daniel Miksik added a comment -

OK. So the Workshop module is included in the standard Moodle 1.8 package (supported and maintained), the Exercise module is unmaintained since 1.8 onward. I think this should be written somewhere in big letters. I browsed the Exercise forum module and Docs at moodle.org but have not come across an announcement on dropping the Exercise module.

Show
Daniel Miksik added a comment - OK. So the Workshop module is included in the standard Moodle 1.8 package (supported and maintained), the Exercise module is unmaintained since 1.8 onward. I think this should be written somewhere in big letters. I browsed the Exercise forum module and Docs at moodle.org but have not come across an announcement on dropping the Exercise module.
Hide
Michael de Raadt added a comment -

Thanks for reporting this issue.

We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported.

If you believe that this issue is still relevant to current versions (2.1 and beyond), please comment on the issue. Issues left inactive for a further month will be closed.

Michael d;

lqjjLKA0p6

Show
Michael de Raadt added a comment - Thanks for reporting this issue. We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported. If you believe that this issue is still relevant to current versions (2.1 and beyond), please comment on the issue. Issues left inactive for a further month will be closed. Michael d; lqjjLKA0p6
Hide
Michael de Raadt added a comment -

I'm closing this issue as it has become inactive and does not appear to affect a current supported version. If you are encountering this problem or one similar, please launch a new issue.

Show
Michael de Raadt added a comment - I'm closing this issue as it has become inactive and does not appear to affect a current supported version. If you are encountering this problem or one similar, please launch a new issue.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: