diff --git a/entity/course_format_iena_completion.php b/entity/course_format_iena_completion.php index b5af69ad796a3fc6eefe10bb49ba5c42c5b044c8..b3880a37bb7b2f4ce84eb3d27b26682f31892fda 100644 --- a/entity/course_format_iena_completion.php +++ b/entity/course_format_iena_completion.php @@ -42,18 +42,6 @@ class course_format_iena_completion { return false; } - // $modules = $DB->get_records_sql('SELECT cmc.id, cmc.coursemoduleid, cmc.userid, cmc.completionstate, cm.section - // FROM {course_modules_completion} as cmc - // inner join {course_modules} as cm on cm.id = cmc.coursemoduleid - // inner join {user} as u on u.id = cmc.userid - // inner join {modules} as m on m.id = cm.module - // where cm.course = ? and cm.deletioninprogress = 0 - // and cmc.userid = ? - // order by section, coursemoduleid asc', array($course->id, $USER->id)); - - // echo "<pre>"; - // var_dump($modules); - // echo "</pre>"; $sections = []; @@ -65,7 +53,9 @@ class course_format_iena_completion { $module = $completion->get_data($cm, true, $USER->id, $fast_modinfo); $module->url = "$CFG->wwwroot/mod/$cm->modname/view.php?id=$cm->id"; $module->section = $cm->section; - if ( $cm->deletioninprogress == 0 && $cm->completion != 0 ) { + if ( $cm->deletioninprogress == 0 && $cm->completion != 0 && $cm->uservisible) { + $module->name = $cm->name; + $module->url = "$CFG->wwwroot/mod/$cm->modname/view.php?id=$cm->id"; $modules[] = $module; } } @@ -81,19 +71,15 @@ class course_format_iena_completion { $inner_modules = []; $inner_completed = 0; foreach ($modules as $module) { - if ( $module->section == $section_id ) { + if ( $module->section == $section_id) { $mod = new StdClass(); $mod->coursemoduleid = $module->coursemoduleid; $mod->completion = $module->completionstate; + $mod->name = $module->name; + $mod->url = $module->url; if ( $mod->completion == 1 || $mod->completion == 2 ) { $inner_completed++; } - foreach ($modinfos_cms as $cm) { - if ( $cm->id == $mod->coursemoduleid ) { - $mod->name = $cm->name; - $mod->url = "$CFG->wwwroot/mod/$cm->modname/view.php?id=$cm->id"; - } - } $inner_modules[] = $mod; } } @@ -111,11 +97,6 @@ class course_format_iena_completion { $progress = new StdClass(); $progress->total = number_format( 100 * $total_completed / $total_modules, 0); $progress->sections = $sections; - - // echo "<pre>"; - // var_dump($progress); - // echo "</pre>"; - return $progress; }