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

Long draggable items break quiz statistics. #60

Open
OT-AndreyUskov opened this issue Mar 12, 2021 · 4 comments
Open

Long draggable items break quiz statistics. #60

OT-AndreyUskov opened this issue Mar 12, 2021 · 4 comments

Comments

@OT-AndreyUskov
Copy link

Ordering question type allows to create questions with draggable items longer than quiz statistics overview can handle.

'subqid' field is varchar(100). In lib/db/install.xml 'question_response_analysis' table is defined as follows:

<TABLE NAME="question_response_analysis" COMMENT="Analysis of student responses given to questions.">
     <FIELDS>
        ...
         <FIELD NAME="subqid" TYPE="char" LENGTH="100" NOTNULL="true" SEQUENCE="false"/>
        ...
    </FIELDS>
     ...
 </TABLE>

Error:
Error writing to database

[More information about this error|http://docs.moodle.org/35/en/error/moodle/dmlwriteexception]
×Debug info: Data too long for column 'subqid' at row 1
INSERT INTO mdl_question_response_analysis (hashcode,whichtries,questionid,variant,subqid,aid,response,credit,timemodified) VALUES(?,?,?,?,?,?,?,?,?)
[array (
0 => '1afcbec028f7ca4b759200c2b2aa39303f30bdba',
1 => 'lasttry',
2 => '2443',
3 => 1,
4 => 'This is the second item. This item is quite long and you may enter this item and save the ordering question but you will get an error when you try to check statistics of the quiz and recalculate the data.',
5 => 2,
6 => 'Position 2',
7 => 0.33333333333333331,
8 => 1615364109,
)]
Error code: dmlwriteexception
×Stack trace: * line 489 of /lib/dml/moodle_database.php: dml_write_exception thrown

  • line 1329 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
  • line 1375 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
  • line 131 of /question/classes/statistics/responses/analysis_for_actual_response.php: call to mysqli_native_moodle_database->insert_record()
  • line 110 of /question/classes/statistics/responses/analysis_for_class.php: call to core_question\statistics\responses\analysis_for_actual_response->cache()
  • line 126 of /question/classes/statistics/responses/analysis_for_subpart.php: call to core_question\statistics\responses\analysis_for_class->cache()
  • line 207 of /question/classes/statistics/responses/analysis_for_question.php: call to core_question\statistics\responses\analysis_for_subpart->cache()
  • line 134 of /question/classes/statistics/responses/analyser.php: call to core_question\statistics\responses\analysis_for_question->cache()
  • line 720 of /mod/quiz/report/statistics/report.php: call to core_question\statistics\responses\analyser->calculate()
  • line 688 of /mod/quiz/report/statistics/report.php: call to quiz_statistics_report->analyse_responses_for_questions()
  • line 645 of /mod/quiz/report/statistics/report.php: call to quiz_statistics_report->analyse_responses_for_all_questions_and_subquestions()
  • line 153 of /mod/quiz/report/statistics/report.php: call to quiz_statistics_report->get_all_stats_and_analysis()
  • line 97 of /mod/quiz/report.php: call to quiz_statistics_report->display()

To reproduce this error:

  1. Create a quiz with an ordering question and a long option in the question (example in debug info).
  2. Login as a student and do the quiz.
  3. Login as an admin and go to Quiz administration > Results > Statistics
  4. See the error. If you are already in statistics, click 'Recalculate now' button.

Screenshot from 2021-03-10 12-04-59

It would be nice to not allow users to create content that the system cannot handle.

Ordering question item must be limited to 100.

Reproduced in LTS Moodle 3.5 and 3.9.

In Moodle tracker:
https://tracker.moodle.org/browse/MDL-71085

@gbateson
Copy link
Owner

100 chars is not very long, especially if we consider that a draggable item could contain HTML code for multimedia. Perhaps there's a nother way to shorten the text before it gets inserted into the response analysis table. I'll try to find time to investigate.

@gbateson
Copy link
Owner

I took a brief look at the code, but it's pretty complex inside the "question/classes/statistics/responses". I can't fix it quickly I'm afraid.

@timhunt
Copy link
Contributor

timhunt commented Oct 28, 2021

In the ordering questoin type, the two pleces you control this are

  • qtype_ordering::get_possible_responses
  • qtype_ordering_question::classify_response

The bit you are currently creating as

question_utils::to_plain_text($answer->answer, $answer->answerformat)

is what is becoming subqid.

LOL. Looking at git history, I see I wrote this code. Sorry.

@timhunt
Copy link
Contributor

timhunt commented Oct 28, 2021

Also, Gordon, while I am writing, it would nice if you could review some of the pull requests that are waiting here. Thanks.

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