Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can no longer be used after clicking on "Create Attempt" #26

Closed
OgreTransporter opened this issue Sep 14, 2020 · 3 comments
Closed

Can no longer be used after clicking on "Create Attempt" #26

OgreTransporter opened this issue Sep 14, 2020 · 3 comments

Comments

@OgreTransporter
Copy link

I clicked on "Create Attempt". Now nothing works anymore:

Debug-Info:  Unknown column 'create_attempt' in 'order clause'
SELECT
DISTINCT CONCAT(u.id, '#', COALESCE(quiza.attempt, 0)) AS uniqueid,
quiza.uniqueid AS usageid,
quiza.id AS attempt,
u.id AS userid,
u.idnumber, u.firstnamephonetic,u.lastnamephonetic,u.middlename,u.alternatename,u.firstname,u.lastname,
u.picture,
u.username,
u.imagealt,
u.institution,
u.department,
u.email,
quiza.state,
quiza.sumgrades,
quiza.timefinish,
quiza.timestart,
CASE WHEN quiza.timefinish = 0 THEN null
WHEN quiza.timefinish > quiza.timestart THEN quiza.timefinish - quiza.timestart
ELSE 0 END AS duration, quiza.attempt AS attemptno
, CASE
-- If, for this user, attempts allowed (including overrids) is unlimited,
-- then they have not used all attempts.
WHEN COALESCE(
(SELECT attempts FROM mdl_quiz_overrides WHERE quiz = quiza.quiz AND userid = u.id),
(SELECT MIN(overrides1.attempts)
FROM mdl_quiz_overrides overrides1
JOIN mdl_groups_members overrides1_gm ON overrides1_gm.groupid = overrides1.groupid
WHERE overrides1.quiz = quiza.quiz
AND overrides1_gm.userid = u.id),
?) = 0 THEN 0
-- Or, if there is a finite limit, compare with the number of attempts they have.
WHEN (SELECT COUNT(1) FROM mdl_quiz_attempts WHERE quiz = quiza.quiz AND userid = quiza.userid) < COALESCE(
(SELECT attempts FROM mdl_quiz_overrides WHERE quiz = quiza.quiz AND userid = u.id),
(SELECT MAX(overrides2.attempts)
FROM mdl_quiz_overrides overrides2
JOIN mdl_groups_members overrides2_gm ON overrides2_gm.groupid = overrides2.groupid
WHERE overrides2.quiz = quiza.quiz
AND overrides2_gm.userid = u.id),
?) THEN 0
ELSE 1
END AS used_all_attempts
, CASE
-- User does not have an attempt yet, so only one row.
WHEN quiza.id IS NULL THEN 1
-- User woth one or more attempts.
WHEN quiza.attempt = (
SELECT MAX(attempt)
FROM mdl_quiz_attempts
WHERE quiz = quiza.quiz AND userid = quiza.userid
) THEN 1
ELSE 0
END AS last_attempt_for_this_user

FROM mdl_user u
LEFT JOIN mdl_quiz_attempts quiza ON
quiza.userid = u.id AND quiza.quiz = ?
JOIN mdl_user_enrolments ej1_ue ON ej1_ue.userid = u.id
JOIN mdl_enrol ej1_e ON (ej1_e.id = ej1_ue.enrolid AND ej1_e.courseid = ?)
JOIN (SELECT DISTINCT userid
FROM mdl_role_assignments
WHERE contextid IN (1,3,45,409)
AND roleid IN (5)
) ra ON ra.userid = u.id
WHERE (quiza.preview = 0 OR quiza.preview IS NULL) AND 1 = 1 AND u.deleted = 0 AND u.id <> ? AND u.deleted = 0
ORDER BY create_attempt DESC, quiza.id ASC LIMIT 0, 500
[array (
0 => '1',
1 => '1',
2 => '5',
3 => '2',
4 => '1',
)]
Error code: dmlreadexception
Stack trace:  
line 486 of /lib/dml/moodle_database.php: dml_read_exception thrown
line 1273 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
line 1997 of /lib/tablelib.php: call to mysqli_native_moodle_database->get_records_sql()
line 593 of /mod/quiz/report/attemptsreport_table.php: call to table_sql->query_db()
line 2019 of /lib/tablelib.php: call to quiz_attempts_report_table->query_db()
line 171 of /mod/quiz/report/answersheets/report.php: call to table_sql->out()
line 97 of /mod/quiz/report.php: call to quiz_answersheets_report->display()
@timhunt
Copy link
Member

timhunt commented Sep 14, 2020

It's a minor bug. Simple work-around: Don't click on that column heading ;-)

If you log out and log in again, things should start working.

@SAHellauer
Copy link

This will fix that #28

@timhunt
Copy link
Member

timhunt commented Dec 15, 2020

I;ve just pushed our latest code, which already had a fix for this.

@timhunt timhunt closed this as completed Dec 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants