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

BUG: Unknown column 'lastattempttime' in 'order clause' #796

Closed
ralferlebach opened this issue Jan 21, 2025 · 1 comment
Closed

BUG: Unknown column 'lastattempttime' in 'order clause' #796

ralferlebach opened this issue Jan 21, 2025 · 1 comment
Assignees
Labels
ALISE bug Something isn't working

Comments

@ralferlebach
Copy link
Contributor

Image

Error reading from database (Unknown column 'lastattempttime' in 'order clause' SELECT * FROM ( SELECT -- Information about the question q.id, lci.componentid, qbe.idnumber as label, COALESCE (qbe.idnumber, CAST(qbe.id AS CHAR)) as idnumber, q.name as questionname, q.questiontext as questiontext, q.qtype as qtype, qc.name as categoryname, -- Information about CAT scales, parameters and contexts lci.catscaleid catscaleid, lci.status testitemstatus, lci.componentname component, lci.id as itemid, lccs.name as catscalename, lccs.id as lccscatscaleid, lcip.model as model, lcip.difficulty, lcip.discrimination, lcip.guessing, lcip.json, lcip.timecreated, lcip.timemodified, lcip.status, lcip.contextid AS lcipcontextid, -- Information about usage statisitcs COALESCE(astat.numberattempts,0) attempts, COALESCE(astat.lastattempt,0) as astatlastattempttime, ustat.userid, ustat.numberattempts userattempts, ustat.lastattempt as userlastattempttime FROM mdl_local_catquiz_catscales lccs -- Get all corresponding items of those scales, skip if not existent -- (INNER JOIN) JOIN mdl_local_catquiz_items lci ON lci.catscaleid=lccs.id -- Get all the item parameter for the question for the given context(s), -- skip if not existent JOIN mdl_local_catquiz_itemparams lcip ON lcip.itemid = lci.id AND lci.activeparamid = lcip.id -- Get all information about the question from the questionbank itself JOIN mdl_question q ON q.id=lci.componentid JOIN mdl_question_versions qv ON qv.questionid=q.id JOIN mdl_question_bank_entries qbe ON qbe.id=qv.questionbankentryid JOIN mdl_question_categories qc ON qc.id=qbe.questioncategoryid -- Get all information about the attempts in the scale(s) -- and context(s) in general and for specific user(s) LEFT JOIN (SELECT lca.scaleid, lca.contextid, qa.questionid, COUNT(qa.id) numberattempts, MAX(qas.timecreated) as lastattempt FROM mdl_local_catquiz_attempts lca JOIN mdl_adaptivequiz_attempt aqa ON lca.attemptid = aqa.id JOIN mdl_question_attempts qa ON qa.questionusageid = aqa.uniqueid JOIN mdl_question_attempt_steps qas ON qas.questionattemptid = qa.id AND qas.fraction IS NOT NULL GROUP BY lca.scaleid, lca.contextid, qa.questionid ) astat ON astat.contextid = lcip.contextid AND astat.questionid = q.id AND astat.scaleid = ? LEFT JOIN (SELECT NULL AS userid, NULL AS numberattempts, NULL AS lastattempt) as ustat ON 1=1 ) s WHERE 1=1 AND lcipcontextid COLLATE utf8mb4_bin = 5 AND lccscatscaleid = ? ORDER BY

@ralferlebach ralferlebach added bug Something isn't working ALISE labels Jan 21, 2025
@davidszkiba
Copy link
Contributor

davidszkiba commented Jan 21, 2025

Ich vermute, dass das Problem bei wunderbyte_table liegt.

Ich kann den Fehler triggern, wenn ich nach last attempt time sortiere und dann eine fulltext search ausführe.

In unserer SQL query geben wir kein Feld lastattempttime zurück, sondern astatlastattempttime.
Beim Erzeugen der wunderbyte table geben wir als column name lastattempttime an aber wir haben dafür in der Table Klasse folgende Funktion:

    /**
     * Return value for lastattempttime column.
     *
     * @param \stdClass $values
     * @return string
     */
    public function col_lastattempttime($values) {

        if (intval($values->astatlastattempttime) === 0) {
            return get_string('notyetcalculated', 'local_catquiz');
        }
        return userdate($values->astatlastattempttime);
    }

Vielleicht muss einfach bei $table->define_sortablecolumns statt 'lastattempttime' 'astatlastattempttime' verwendet werden - das werd ich überprüfen

davidszkiba added a commit that referenced this issue Jan 24, 2025
Previously, sorting the questions of a scale by attempt time and then
switching the page via pagination or doing a fulltext search would cause
an error. This is fixed now by using the same column name for the
col_NAME() function as for the sortable column.
mona-shakiba pushed a commit that referenced this issue Feb 10, 2025
Previously, sorting the questions of a scale by attempt time and then
switching the page via pagination or doing a fulltext search would cause
an error. This is fixed now by using the same column name for the
col_NAME() function as for the sortable column.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ALISE bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants