PHP 8.2 has deprecated setting properties on objects dynamically.
The qtype_calculatedmulti question type had two properties being
set this way($correctanswerlength and$correctanswerformat).
This patch extends the question_answer class to add the properties
when the object is instantiated.
Declare qformat_xml::answerfiles and qformat_xml::feedbackfiles instead
of dynamically declaring answerfiles and feedbackfiles for the
question_answer instance when exporting questions and answers to XML
format.
The question answers for question type plugins extending
\qtype_calculated now have the type
\qtype_calculated\qtype_calculated_answer. So the answers for test
helper functions make_calculatedmulti_question_singleresponse() and
make_calculatedmulti_question_multiresponse() should also be changed
accordingly.
The question answers for question type plugins extending
\qtype_calculated now have the type
\qtype_calculated\qtype_calculated_answer. So the answers for
make_calculatedsimple_question_sum() should be changed accordingly.
* Question type plugins that extend qtype_calculated should be made
aware of the changes about the new question_answer type
\qtype_calculated\qtype_calculated_answer.
This commit addresses compatibility issues in the qtype_multianswer
question type. The following changes were made:
- The usage of the undeclared property $maxmark on subquestions in
qtype_multianswer was identified as problematic. To resolve this,
the existing declared property $defaultmark is now being used for
the same purpose.
By switching to the declared property $defaultmark, compatibility with
PHP 8.2 is ensured and the issue with the undeclared property is
resolved.
This commit addresses compatibility issues in the qtype_calculated
question type. The following problems were identified and resolved:
- qtype_calculated was reusing the qtype_numerical_answer class and
setting two additional properties ($correctanswerlength and
$correctanswerformat) that were not declared. To resolve this, a new
class, qtype_calculated_answer, was defined and utilised.
- During grading in qtype_numerical, there were references to an
undeclared property ($unitisright) used to track calculation details.
This issue was fixed using a 'replace temp with query' refactoring.
These changes ensure the qtype_calculated question type is compatible
with PHP 8.2 and addresses the identified issues.
This commit addresses the following issues and improvements in the
qtype_truefalse class:
- Added missing class properties:
- public $truefeedbackformat
- public $falsefeedbackformat
- public $showstandardinstruction
- Updated qtype_truefalse_question to include type hinting for better
IDE support.
Replaced custom loading of data and then question object
creation using internal question_bank functionality with
question_bank::load_question.
Removed the call $quizobj->load_questions as it is
redundant.
@const is not a valid phpdoc tag and @var should be used to
document both classes properties and constants (no matter how
weird that may sound, heh).
Link to (draft right now) PHP-FIG:
https://github.com/php-fig/fig-standards/blob/master/proposed/phpdoc-tags.md#518-var
So, with this commit we are just replacing all uses by the correct
@var one. Note that the type is entirely optional, in fact I think
that there isn't much need of it for constants because it's obvious
for both humans and machines which the type is. But, as far as it's
also correct to specify it, we haven't modified that detail.
The only detail modified are the cases where the constant name was
specified in the phpdoc, that's not needed, hence, the names have
been removed from there when present (a couple of cases).
It turns out that there are plugins which don't (currently)
clean up their question attempts when a context is deleted.
Therefore, we need to make Moodle core robust to that.