A training with no questions is meant to behave as a manual verification style training. The user is not able to complete this training, and a admin must manually add the training onto the user. This is to be used for things like safety seminar, where attendance is taken in person and later added into the system.
While the frontend includes no way to submit, the submission endpoint can used for the zero question training with an empty object as the body.
The only check in code (other than checking if the training is valid) is as follows:
if len(answers) != len(submission) {
return models.SubmissionResponse{}, errors.New("invalid submission")
}
Since an empty object matches the zero question training in the backend, this check passed and the program continues to grade the invalid submission. Some wacky division happens as well giving bogus submission data:
{"passed":true,"numCorrect":0,"numIncorrect":0,"grade":-9223372036854775808}
An additional check should be added for zero question trainings making any submission invalid.
A training with no questions is meant to behave as a manual verification style training. The user is not able to complete this training, and a admin must manually add the training onto the user. This is to be used for things like safety seminar, where attendance is taken in person and later added into the system.
While the frontend includes no way to submit, the submission endpoint can used for the zero question training with an empty object as the body.
The only check in code (other than checking if the training is valid) is as follows:
Since an empty object matches the zero question training in the backend, this check passed and the program continues to grade the invalid submission. Some wacky division happens as well giving bogus submission data:
{"passed":true,"numCorrect":0,"numIncorrect":0,"grade":-9223372036854775808}An additional check should be added for zero question trainings making any submission invalid.