mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-31987 Assignment module: fix sql for postgres.
This commit is contained in:
parent
b8ba23ca23
commit
74fc24a916
@ -35,24 +35,24 @@ function xmldb_assignment_upgrade($oldversion) {
|
||||
|
||||
if ($oldversion < 2012062800) {
|
||||
// Fixed/updated numfiles field in assignment_submissions table to count the actual
|
||||
// number of files has been uploaded.
|
||||
// number of files has been uploaded when sendformarking is disabled
|
||||
upgrade_set_timeout(600); // increase excution time for in large sites
|
||||
$fs = get_file_storage();
|
||||
|
||||
$selectcount = 'SELECT COUNT(s.id), cm.id AS cmid';
|
||||
$select = 'SELECT s.id, cm.id AS cmid';
|
||||
$query = " FROM {assignment_submissions} s
|
||||
INNER JOIN {course_modules} cm
|
||||
ON s.assignment = cm.instance
|
||||
JOIN {assignment} a
|
||||
ON a.id = s.assignment
|
||||
WHERE a.assignmenttype in ('upload', 'uploadsingle') AND
|
||||
cm.module = (SELECT id
|
||||
FROM {modules}
|
||||
WHERE name = 'assignment')";
|
||||
// Fetch the moduleid for use in the course_modules table
|
||||
$moduleid = $DB->get_field('modules', 'id', array('name' => 'assignment'), MUST_EXIST);
|
||||
|
||||
$countsubmissions = $DB->count_records_sql($selectcount. $query);
|
||||
$submissions = $DB->get_recordset_sql($select. $query);
|
||||
$selectcount = 'SELECT COUNT(s.id) ';
|
||||
$select = 'SELECT s.id, cm.id AS cmid ';
|
||||
$query = 'FROM {assignment_submissions} s
|
||||
JOIN {assignment} a ON a.id = s.assignment
|
||||
JOIN {course_modules} cm ON a.id = cm.instance AND cm.module = :moduleid
|
||||
WHERE assignmenttype = :assignmenttype';
|
||||
|
||||
$params = array('moduleid' => $moduleid, 'assignmenttype' => 'upload');
|
||||
|
||||
$countsubmissions = $DB->count_records_sql($selectcount.$query, $params);
|
||||
$submissions = $DB->get_recordset_sql($select.$query, $params);
|
||||
|
||||
$pbar = new progress_bar('assignmentupgradenumfiles', 500, true);
|
||||
$i = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user