thoriqadillah / moodle-qtype_essaysimilarity

Is a moodle question type plugin that compares the similarity between student's answer and teacher's answer key using machine learning (natural language processing), and uses the similarity to auto grade the answer. The automatic grade can be manually overridden by the teacher
https://thoriqadillah.github.io/cat-n-code/projects/essay-similarity/#demo
GNU General Public License v3.0
2 stars 3 forks source link

debugging warnings after a question has been created #22

Open danmarsden opened 5 months ago

danmarsden commented 5 months ago

(probably related to new version of PHP)

Deprecated: Creation of dynamic property qtype_essaysimilarity_question::$showfeedback is deprecated in /home/dan/www/moodle/question/type/questiontypebase.php on line 1015

Deprecated: Creation of dynamic property qtype_essaysimilarity_question::$answerkey is deprecated in /home/dan/www/moodle/question/type/questiontypebase.php on line 1015

Deprecated: Creation of dynamic property qtype_essaysimilarity_question::$answerkeyformat is deprecated in /home/dan/www/moodle/question/type/questiontypebase.php on line 1015

Deprecated: Creation of dynamic property qtype_essaysimilarity_question::$showanswerkey is deprecated in /home/dan/www/moodle/question/type/questiontypebase.php on line 1015

Deprecated: Creation of dynamic property qtype_essaysimilarity_question::$showtextstats is deprecated in /home/dan/www/moodle/question/type/questiontypebase.php on line 1015

Deprecated: Creation of dynamic property qtype_essaysimilarity_question::$textstatitems is deprecated in /home/dan/www/moodle/question/type/questiontypebase.php on line 1015

Deprecated: Creation of dynamic property qtype_essaysimilarity_question::$questionlanguage is deprecated in /home/dan/www/moodle/question/type/questiontypebase.php on line 1015

Deprecated: Creation of dynamic property qtype_essaysimilarity_question::$upper_correctness is deprecated in /home/dan/www/moodle/question/type/questiontypebase.php on line 1015

Deprecated: Creation of dynamic property qtype_essaysimilarity_question::$lower_correctness is deprecated in /home/dan/www/moodle/question/type/questiontypebase.php on line 1015

thoriqadillah commented 5 months ago

i think this is because of the newer PHP version that deprecates this feature so the PHP can be more stricter about typing. based on the implementation of said debug warning, this the code

$extraquestionfields = $this->extra_question_fields();
if (is_array($extraquestionfields)) {
    // Omit table name.
    array_shift($extraquestionfields);
    foreach ($extraquestionfields as $field) {
        $question->$field = $questiondata->options->$field;
    }
}

but, because of this stricter type feature, based on this SO, i think moodle needs to add #[\AllowDynamicProperties] decorator on their code base so the the warning not come up. And i think this is outside my plugin scope, because i'm just implementing the $this->extra_question_fields() for the plugin. I might be wrong, because i don't really know about the moodle code base really well. Let me know if you need discussion

danmarsden commented 5 months ago

nah - you need to fix your base question class - here's an example of a commit from a core question type that I think fixes this particular issue for that qtype: https://github.com/moodle/moodle/commit/e8d5dc93e08410a0fb98b7136b0554988bda9081

danmarsden commented 5 months ago

another example: https://github.com/moodle/moodle/commit/d84389391cd5616b231d13796ce0e12645f6cfb9

there are probably better examples best suited to your specific case though.