gocodebox / gocodebox/lifterlms

[Quiz] Deleting a quiz questions causes issues when grading / reviewing quiz attempts

Open
#840 2 comments 0 reactions 1 assignee Claimed by @thomasplevy View on GitHub
Severity: High Type: Bug
Dominant language
PHP
Stars
212
Forks
140
Avg merge
2d 14h
Merged PRs (30d)
19

Description

### Reproduction Steps

+ Create and publish a quiz
+ Take the quiz as a student to create a quiz attempt (you can do this as the course creator/instructor)
+ Delete one or more questions from the published quiz
+ Review the quiz attempt as an admin & attempt to grade it or leave remarks

### Expected Behavior

+ The quiz should display information about the deleted question despite it being deleted

### Actual Behavior

+ The deleted question is not visibly displayed on the attempt grade
+ An error is encountered when saving the grade (see below)
+ The quiz still counts the deleted question for points, number of questions, and grading purposes
+ The widgets on the quiz attempt page display this quiz in counts, grades, points, etc...

### Error Messages / Logs

+ Include any relevant error messages or log files
```
**[26-Apr-2019 18:16:39 UTC] PHP Fatal error: Uncaught Error: Call to a member function get_auto_grade_type() on null in /srv/www/llms-72/public_html/wp-content/plugins/lifterlms/includes/models/model.llms.quiz.attempt.question.php:250
Stack trace:
#0 /srv/www/llms-72/public_html/wp-content/plugins/lifterlms/includes/models/model.llms.quiz.attempt.php(553): LLMS_Quiz_Attempt_Question->get_status()
#1 /srv/www/llms-72/public_html/wp-content/plugins/lifterlms/includes/models/model.llms.quiz.attempt.php(122): LLMS_Quiz_Attempt->is_auto_gradeable()
#2 /srv/www/llms-72/public_html/wp-content/plugins/lifterlms/includes/controllers/class.llms.controller.admin.quiz.attempts.php(103): LLMS_Quiz_Attempt->calculate_grade()
#3 /srv/www/llms-72/public_html/wp-content/plugins/lifterlms/includes/controllers/class.llms.controller.admin.quiz.attempts.php(61): LLMS_Controller_Admin_Quiz_Attempts->save_grade(Object(LLMS_Quiz_Attempt))
#4 /srv/www/llms-72/public_html/wp-includes/class-wp-hook.php(286): LLMS_Controller_Admin_Quiz_Attempts->maybe_run_actions('')
#5 /srv/www/l in /srv/www/llms-72/public_html/wp-content/plugins/lifterlms/includes/models/model.llms.quiz.attempt.question.php on line 250
**

```

### Possible Solutions

+ When a question is deleted from a quiz LifterLMS should determine if the question exists in any existing attempts. If it does, the question should be *archived* instead of deleted.
+ This could be a new custom post status reserved for this post type.
+ An archived question should be excluded from all quiz related queries EXCEPT with relation to quiz attempts
+ When an attempt is deleted all archived questions should be checked to see if that archived question can now safely be deleted
+ An interface on the admin review may need to display that the question is an archived question (?)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.