moodle-qtype_formulas icon indicating copy to clipboard operation
moodle-qtype_formulas copied to clipboard

Allow parts to have empty fields

Open PhilippImhof opened this issue 5 months ago • 2 comments

This PR will add the following:

  • For each part, teachers can decide whether or not that part should accept empty answers.
  • For fields that the student is expected to leave empty, they will be able to define a special model answer. The current idea is $EMPTY. (This concept is borrowed from the excellent STACK plugin, because the people over there are much smarter than I am.)
  • If the part is configured to allow empty fields, it will be considered complete regardless of the number of fields that have been filled. (Therefore, there will be no error if the student clicks "Check" in adaptive mode and one or even all fields have been left empty.)
  • If the student enters any value into a field that should have been empty, that will give the largest possible difference PHP_FLOAT_MAX. The same happens if the student leaves empty a field that is not supposed to be empty. If both the model and the student answer are empty, the difference is 0.
  • For the custom grading criterion, I will add a function is_empty() or something the like, in order for the teacher to be able to check for an empty response.

This is currently in a very early stage and should absolutely not be installed on any production server.

PhilippImhof avatar Jul 28 '25 15:07 PhilippImhof

Tests are now passing. This means, the implementation of the new functionality should now no longer break any existing stuff.

However, stuff is still not ready yet, because I haven't implemented the tests that actually check whether the new feature really works in various conditions.

PhilippImhof avatar Aug 02 '25 16:08 PhilippImhof

Pull Request Test Coverage Report for Build 17019138792

Details

  • 78 of 92 (84.78%) changed or added relevant lines in 10 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.2%) to 97.399%

Changes Missing Coverage Covered Lines Changed/Added Lines %
classes/local/token.php 1 2 50.0%
questiontype.php 9 10 90.0%
renderer.php 4 5 80.0%
backup/moodle2/restore_qtype_formulas_plugin.class.php 2 4 50.0%
classes/local/answer_parser.php 7 9 77.78%
question.php 20 22 90.91%
classes/local/evaluator.php 17 22 77.27%
<!-- Total: 78 92
Totals Coverage Status
Change from base Build 16770520117: -0.2%
Covered Lines: 4381
Relevant Lines: 4498

💛 - Coveralls

coveralls avatar Aug 02 '25 16:08 coveralls