Update self developed report to Moodle 4.3

Update self developed report to Moodle 4.3

par Sarah Rudd,
Nombre de réponses : 3

Hello,

In an earlier Moodle-version (Moodle 3.x) we developed a report for quizzes. That report takes an object "cm" which includes a the data of a quiz activity. The moduleid of that quiz activity is 135. Moodle provides for the reports an object similar to:


Versuche: 54966
object(stdClass)#72 (23) { ["id"]=> string(3) "135" ["course"]=> string(1) "7" ["module"]=> string(2) "16" ["instance"]=> string(2) "57" ["section"]=> string(2) "23" ["idnumber"]=> string(0) "" ["added"]=> string(10) "1548925287" ["score"]=> string(1) "0" ["indent"]=> string(1) "0" ["visible"]=> string(1) "1" ["visibleoncoursepage"]=> string(1) "1" ["visibleold"]=> string(1) "1" ["groupmode"]=> string(1) "2" ["groupingid"]=> string(1) "0" ["completion"]=> string(1) "2" ["completiongradeitemnumber"]=> string(1) "0" ["completionview"]=> string(1) "1" ["completionexpected"]=> string(1) "0" ["showdescription"]=> string(1) "0" ["availability"]=> string(68) "{"op":"&","c":[{"type":"completion","cm":137,"e":1}],"showc":[true]}" ["deletioninprogress"]=> string(1) "0" ["name"]=> string(109) "Our Country Quiz" ["modname"]=> string(4) "quiz" } 

In our new Moodle Version 4.3 Moodle provides an the following object


object(cm_info)#238 (48) { ["modinfo":"cm_info":private]=> object(course_modinfo)#147 (8) {

....

The quiz info is also included in that object:


 [135]=>
      object(cm_info)#237 (48) {
        ["modinfo":"cm_info":private]=>
        *RECURSION*
        ["state":"cm_info":private]=>
        int(2)
        ["id":"cm_info":private]=>
        string(3) "135"
        ["instance":"cm_info":private]=>
        string(2) "57"
        ["idnumber":"cm_info":private]=>
        string(0) ""
 ...
        ["modname":"cm_info":private]=>
        string(4) "quiz"
        ["module":"cm_info":private]=>
        string(2) "16"
        ["name":"cm_info":private]=>
        string(109) "Our Country Quiz"
...

Is there a chance to extract these quiz info and pass it to our report.

Thanks for your help!

Best,

Sarah

Moyenne des évaluations: -
En réponse à Sarah Rudd

Re: Update self developed report to Moodle 4.3

par Sarah Rudd,
I fixed the prob!
En réponse à Sarah Rudd

Re: Update self developed report to Moodle 4.3

par Séverin TERRIER,
Avatar Documentation writers Avatar Particularly helpful Moodlers Avatar Testers Avatar Translators
Nice sourire

Indicating how would potentially help other people reading here.

Séverin
Moyenne des évaluations:Useful (1)
En réponse à Séverin TERRIER

Re: Update self developed report to Moodle 4.3

par Sarah Rudd,
The object "$cm" contains a lot more than in older versions. I just created a new object "$cmData" and took the Values from "$cm" and assigned them to it.


$cmData = new stdClass();

$cmData->id = $cm->id;
$cmData->course = $cm->course;
$cmData->module = $cm->module;
$cmData->instance = $cm->instance;
$cmData->section = $cm->section;
$cmData->idnumber = $cm->idnumber;
$cmData->added = $cm->added;
$cmData->score = $cm->score;
$cmData->indent = $cm->indent ?? "0"; // Default if not set
$cmData->visible = "1";
$cmData->visibleoncoursepage = $cm->visibleoncoursepage;
$cmData->visibleold = $cm->visibleold;
$cmData->groupmode = $cm->groupmode;
$cmData->groupingid = $cm->groupingid;
$cmData->completion = $cm->completion;
$cmData->completiongradeitemnumber = $cm->completiongradeitemnumber;
$cmData->completionview = $cm->completionview;
$cmData->completionexpected = $cm->completionexpected;
$cmData->showdescription = $cm->showdescription;
$cmData->availability = $cm->availability;
$cmData->deletioninprogress = $cm->deletioninprogress;
$cmData->name = $cm->name;
$cmData->modname = $cm->modname;


It is stupid but now it works.
Moyenne des évaluations:Useful (1)