Anu LMS Quizzes throws exception when saving results for custom question types

Created on 2 August 2024, 4 months ago
Updated 7 August 2024, 4 months ago

Problem/Motivation

In the Anu LMS Quizzes module, it's currently possible to create a custom question type and corresponding question result type entity, and display the custom question by following the documentation for customizing Anu LMS β†’ . However, the questions REST API throws an exception that prevents custom question types from saving their results.

There's also a related thread in the anu-lms Slack channel.

Steps to reproduce

Either: look at line 187 of QuestionRestResource.php in the Anu LMS Quizzes module.
Or: Add a question type, question result type, paragraph to hold the question type, and React component for the question Type. Add the custom question to a lesson, click "Submit", and look at your Drupal installation's log messages (/admin/reports/dblog) for the error from anu_lms_assessments, which will take the following format: Error on question submission: Question 12 has not supported bundle. Payload: Array ( [questionId] => 12 [value] => 1 ) .

Proposed resolution

In order to implement full support for custom question types and saving their results, Anu LMS Quizzes will need to implement and expose its own hook that a developer could use in a custom module to write their own question result handlers. In the short term, it would be helpful if line 187 (see link above) could be commented out or deleted. I've noticed commenting out that line on a local site with Anu LMS Quizzes doesn't seem to break the rest of the module's functionality.

API changes

The QuestionRestResource.php and possibly even AssessmentRestResource.php will need to change to accommodate invoking a hook. Unfortunately, I'm not quite sure how all of that would work.

πŸ› Bug report
Status

RTBC

Version

2.10

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States kwiseman

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024