General developer forum

Not able to understand certain methods from the moodle quiz module

 
Picture of Mohanish Nagarkar
Not able to understand certain methods from the moodle quiz module
 

I am currently on moodle version 3.2.3+

I am working on the quiz module. I am not able to understand some of the methods in the mod/quiz/lib.php file. The methods are:

1. quiz_add_instance($quiz)
and

2. quiz_after_add_or_update($quiz)
The first method is not called anywhere so what is the need for it?

And in the second method, there's a feedback object getting generated. I am trying to use the method in my code but everytime I get 'mingrade value cannot be null'. I am not understanding the contents of the feedback object, mainly feedbacktext[$i][text], feedbackboundaries[$i] and feedbackboundarycount.

I am stuck as my quiz is not getting created so a quick help is what is needed


Thanks,

Mohanish

 
Average of ratings: -
Picture of Mark Johnson
Re: Not able to understand certain methods from the moodle quiz module
Core developersParticularly helpful MoodlersPlugin developers

You wont find a call to quiz_add_instance() specifically in the codebase, but it is being called.  It is a conventionally-named function that all activity module plugins define in lib.php so that Moodle knows where to find it.  You can read more about these functions in the example module documentation on the wiki: https://docs.moodle.org/dev/NEWMODULE_Documentation#lib.php

 
Average of ratings: -