Proyectos de Subversion Moodle

Rev

Rev 871 | Rev 876 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 871 Rev 872
Línea 131... Línea 131...
131
$primarymenu = $primary->export_for_template($renderer);
131
$primarymenu = $primary->export_for_template($renderer);
132
$buildregionmainsettings = !$PAGE->include_region_main_settings_in_header_actions() && !$PAGE->has_secondary_navigation();
132
$buildregionmainsettings = !$PAGE->include_region_main_settings_in_header_actions() && !$PAGE->has_secondary_navigation();
133
// If the settings menu will be included in the header then don't add it here.
133
// If the settings menu will be included in the header then don't add it here.
134
$regionmainsettingsmenu = $buildregionmainsettings ? $OUTPUT->region_main_settings_menu() : false;
134
$regionmainsettingsmenu = $buildregionmainsettings ? $OUTPUT->region_main_settings_menu() : false;
Línea 135... Línea -...
135
 
-
 
136
$category = '';
-
 
137
$title = '';
-
 
138
$summary = '';
-
 
139
$completed = false;
-
 
140
if ($PAGE->pagelayout == 'incourse' && !empty($COURSE->id)) {
-
 
141
 
-
 
142
    $record = $DB->get_record('course_categories', array('id' => $COURSE->category));
-
 
143
    if ($record) {
-
 
144
        $category = $record->name;
-
 
145
    }
-
 
146
 
-
 
147
    $title = $COURSE->fullname;
-
 
148
    $summary = format_text($COURSE->summary, $COURSE->summaryformat);
-
 
149
 
-
 
150
    if (!empty($USER->id)) {
-
 
151
 
-
 
152
        $course_context = \context_course::instance($COURSE->id);
-
 
153
        $roles = get_user_roles($course_context, $USER->id, true);
-
 
154
 
-
 
155
        $completion_visible = true;
-
 
156
        foreach ($roles as $role) {
-
 
157
 
-
 
158
            if ($role->shortname != 'student') {
-
 
159
                $completion_visible  = false;
-
 
160
            } else {
-
 
161
                $completion_visible = true;
-
 
162
                break;
-
 
163
            }
-
 
164
        }
-
 
165
 
-
 
166
        if ($completion_visible) {
-
 
167
            $page_context = $PAGE->cm;
-
 
168
 
-
 
169
            $modules = get_fast_modinfo($COURSE->id)->get_cms();
-
 
170
 
-
 
171
            $mods = [];
-
 
172
            foreach ($modules as $module) {
-
 
173
                if (!$module->uservisible || $module->is_stealth() || empty($module->url)) {
-
 
174
                    continue;
-
 
175
                }
-
 
176
                $mods[$module->id] = $module;
-
 
177
            }
-
 
178
 
-
 
179
 
-
 
180
 
-
 
181
 
-
 
182
            $nummods = count($mods);
-
 
183
 
-
 
184
            if ($nummods >= 1) {
-
 
185
                $modids = array_keys($mods);
-
 
186
                $position = array_search($page_context->id, $modids);   //array_search($this->page->cm->id, $modids);
-
 
187
                $currentmod = $mods[$modids[$position]];
-
 
188
            } else {
-
 
189
                $currentmod = null;
-
 
190
            }
-
 
191
 
-
 
192
 
-
 
193
            $module_type = '';
-
 
194
            if ($currentmod) {
-
 
195
 
-
 
196
                $sql = 'SELECT md.name, cm.instance  FROM {modules} md  ' .
-
 
197
                    ' JOIN {course_modules} cm ON cm.module = md.id ' .
-
 
198
                    ' WHERE cm.id = '  . $currentmod->id . ' LIMIT 1 ';
-
 
199
 
-
 
200
                $recordCourseModule = $DB->get_record_sql($sql);
-
 
201
 
-
 
202
 
-
 
203
                if ($recordCourseModule) {
-
 
204
                    $module_type = $recordCourseModule->name;
-
 
205
                }
-
 
206
            }
-
 
207
 
-
 
208
            // If there is only one mod then do nothing.
-
 
209
            if ($nummods > 1 && $currentmod) {
-
 
210
 
-
 
211
 
-
 
212
 
-
 
213
 
-
 
214
                $completioninfo = new \completion_info($COURSE);
-
 
215
                $completiondata = $completioninfo->get_data($currentmod, true);
-
 
216
 
-
 
217
                // if (!$currentmod->completionview==1){
-
 
218
                if ($currentmod->completionview != 1 && $currentmod->completion != 2) {
-
 
219
                    // var_dump($currentmod->completionview);
-
 
220
 
-
 
221
                    if ($completiondata->completionstate == COMPLETION_COMPLETE || $completiondata->completionstate == COMPLETION_COMPLETE_PASS) {
-
 
222
                        $completed = true;
-
 
223
                    }
-
 
224
                }
-
 
225
            }
-
 
226
        }
-
 
227
    }
-
 
228
}
-
 
229
 
135
 
230
if ($PAGE->course->enablecompletion == '1') {
136
if ($PAGE->course->enablecompletion == '1') {
231
    $extraclasses[] = 'rui-course--enablecompletion';
137
    $extraclasses[] = 'rui-course--enablecompletion';
232
    $header = $PAGE->activityheader;
138
    $header = $PAGE->activityheader;
233
    $headercontent = $header->export_for_template($renderer);
139
    $headercontent = $header->export_for_template($renderer);
-
 
140
    $completed = false;
-
 
141
} else {
-
 
142
    if ($currentmod->completionview != 1 && $currentmod->completion != 2) {
-
 
143
        if ($completiondata->completionstate == COMPLETION_COMPLETE || $completiondata->completionstate == COMPLETION_COMPLETE_PASS) {
-
 
144
            $completed = true;
-
 
145
        }
-
 
146
    }
234
    $completed = false;
147
    $completed = true;
Línea 235... Línea 148...
235
}
148
}
236
 
149