I was talking with my customer and we were ready to turn them off, deep six them, retire to the pasture of irrelivance. But, wait, something happened along the way.
We decided that we would only turn them on for grades activities. Our course page would look like this. Note the box only appearing for the quizzes, assignments and forums.
There are no blocks for the content URL activities, they are not graded. The quizzes and forum activities each have their own checkbox. The checkboxes cannot be updated by the students. Moodle updates the checkbox when the student has completed it AND the teacher has graded it.
Edit the activity to control the activity completion rules. The rules vary slightly per activity type. Editing the activities manually is a time consuming en devour. There are over 100 courses to apply these rules to. Fortunately, I have access to the moodle DB, so I opened MySQL workbench and created a script to automate the updating of the activities.
Finally, updated my php course scripter. This is my utility I built that sets a lot of the course activities directly in the DB. No need to use the slow cumbersome moodle form to update this data. This is what the page looks like in action.
After I choose a course and click Run Script. All the tedious course DB updating is complete.
This is the php/mysql code used to identify only graded activities and skip the other activities like URLs, pages, files to read etc.
//get modules for the course
$modules = $DB->get_records_sql('
SELECT id,course,module
FROM mdl_course_modules
WHERE course = '.$cid.'
');
//loop and update module recs
$cnt=0;
foreach($modules as $i){
$dataObj = new stdClass();
$dataObj->id = $i->id;
$table = 'course_modules';
/*
in July 2014 - we added more *complexity to the completion tracking functionality. This code now
identifies the main 3 types of graded activities (forum, quiz, assignment) and activates those activity
types with a requirement of viewing and teacher grading, before the item will mark as completed.
the other activity types, like content URLs , documents etc do not have completion tracking bits active.
jmergenthaler
*/
if($i->module==7 OR $i->module==1 OR $i->module==14 OR $i->module==19 ){//turn these on (forum,assignment,quiz)
$dataObj->completion = 2;//conditions must be meet
$dataObj->completiongradeitemnumber = 0;//required grade
$dataObj->completionview = 1;//student must view
}else{//turn off completion tracking for this entity
$dataObj->completion = 0;
$dataObj->completiongradeitemnumber = null;
$dataObj->completionview = 0;
}
$DB->update_record($table, $dataObj);//actual update
$cnt++;
}
echo "".$cnt." modules updated.
";


No comments:
Post a Comment