[qtype_kprime] Throwing qtype_kprime_edit_form::get_default_value()

[qtype_kprime] Throwing qtype_kprime_edit_form::get_default_value()

by Visvanath Ratnaweera -
Number of replies: 3
Picture of Particularly helpful Moodlers Picture of Translators

Question type Kprime(ETH) https://moodle.org/plugins/qtype_kprime started throwing the error "Call to undefined method qtype_kprime_edit_form::get_default_value()" when creating a new question.

Full debug trace at DEVELOPER level is:

Debug-Info: 
Error code: generalexceptionmessage
Stack trace: 
  • line 135 of /question/type/kprime/edit_kprime_form.php: Error thrown
  • line 214 of /lib/formslib.php: call to qtype_kprime_edit_form->definition()
  • line 113 of /question/type/edit_question_form.php: call to moodleform->__construct()
  • line 217 of /question/type/questiontypebase.php: call to question_edit_form->__construct()
  • line 202 of /question/question.php: call to question_type->create_editing_form()
Obviously /lib/formslib.php can not instanciate a kprime question which breaks the edit. It is possible that Kprime has not been used for some time and this error crept in with an update.

Here are the current versions:
- Moodle '3.9.14 (Build: 20220509)'
- Kprime '4 for Moodle 3.9+ (Transitional)'
- PHP 7.3.31

Anybody has a clue?

Average of ratings: -
In reply to Visvanath Ratnaweera

Re: [qtype_kprime] Throwing qtype_kprime_edit_form::get_default_value()

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
It looks like that the latest verion of KPrime has been upgraded to take advantage of a new feature in Moodle 3.11 (MDL-70895) and that version has been pused to github saying it is compatible with Moodle 3.9 when it is not.

I think the problem only arises in one place:
https://github.com/ethz-let/moodle-qtype_kprime/blob/master/edit_kprime_form.php#L135

If you can change that line to

$mform->setDefault('defaultmark', 1);

the error will go away.
Average of ratings: Useful (1)
In reply to Tim Hunt

Re: [qtype_kprime] Throwing qtype_kprime_edit_form::get_default_value() [RESOLVED]

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators

That was it! Problem RESOLVED. Many thanks Tim!

IT looks like that the problem was never reported on moodle.org forums. I posted a note in the plug-in forum https://moodle.org/plugins/qtype_kprime. (scroll down to the bottom)