Update self developed report to Moodle 4.3

Update self developed report to Moodle 4.3

by Sarah Rudd -
Number of replies: 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

Average of ratings: -
In reply to Sarah Rudd

Re: Update self developed report to Moodle 4.3

by Sarah Rudd -
I fixed the prob!
In reply to Sarah Rudd

Re: Update self developed report to Moodle 4.3

by Séverin TERRIER -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators
Nice smile

Indicating how would potentially help other people reading here.

Séverin
Average of ratings: Useful (1)
In reply to Séverin TERRIER

Re: Update self developed report to Moodle 4.3

by 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.
Average of ratings: Useful (1)