/** * Return a table containing all the assignments in the relevant course * * @global type $CFG * @global type $OUTPUT * @param obj $course the moodle course data * @return output */ public function show_assignments($course) { global $CFG, $OUTPUT, $USER; $turnitintooltwos = turnitintooltwo_assignment::get_all_assignments_in_course($course); $table = new html_table(); $table->id = "dataTable"; $rows = array(); // Do the table headers. $cells = array(); if ($course->format == "weeks") { $cells["weeks"] = new html_table_cell(get_string("week")); } else { if ($course->format == "topics") { $cells["topics"] = new html_table_cell(get_string("topic")); } } $cells["name"] = new html_table_cell(get_string("name")); $cells["start_date"] = new html_table_cell(get_string("dtstart", "turnitintooltwo")); $cells["number_of_parts"] = new html_table_cell(get_string("numberofparts", "turnitintooltwo")); $cells["submissions"] = new html_table_cell(get_string("submissions", "turnitintooltwo")); $table->head = $cells; $i = 1; foreach ($turnitintooltwos as $turnitintooltwo) { $cm = get_coursemodule_from_id('turnitintooltwo', $turnitintooltwo->coursemodule, $course->id); $turnitintooltwoassignment = new turnitintooltwo_assignment($turnitintooltwo->id, $turnitintooltwo); if ($course->format == "weeks" || $course->format == "topics") { $cells[$course->format] = new html_table_cell($turnitintooltwoassignment->turnitintooltwo->section); $cells[$course->format]->attributes["class"] = "centered_cell"; } // Show links dimmed if the mod is hidden. $attributes["class"] = !$turnitintooltwo->visible ? 'dimmed' : ''; $linkurl = $CFG->wwwroot . '/mod/turnitintooltwo/view.php?id=' . $turnitintooltwoassignment->turnitintooltwo->coursemodule . '&do=submissions'; $cells["name"] = new html_table_cell(html_writer::link($linkurl, $turnitintooltwo->name, $attributes)); $cells["start_date"] = new html_table_cell(userdate($turnitintooltwoassignment->get_start_date(), get_string('strftimedatetimeshort', 'langconfig'))); $cells["start_date"]->attributes["class"] = "centered_cell"; $cells["number_of_parts"] = new html_table_cell(count($turnitintooltwoassignment->get_parts())); $cells["number_of_parts"]->attributes["class"] = "centered_cell"; if (has_capability('mod/turnitintooltwo:grade', context_module::instance($cm->id))) { $noofsubmissions = $turnitintooltwoassignment->count_submissions($cm, 0); } else { $noofsubmissions = count($turnitintooltwoassignment->get_user_submissions($USER->id, $turnitintooltwoassignment->turnitintooltwo->id)); } $cells["submissions"] = new html_table_cell(html_writer::link($linkurl, $noofsubmissions, $attributes)); $cells["submissions"]->attributes["class"] = "centered_cell"; $rows[$i] = new html_table_row($cells); $i++; } $table->data = $rows; return $OUTPUT->box(html_writer::table($table), 'generalbox boxaligncenter'); }