function definition() { global $COURSE; $mform =& $this->_form; $mform->addElement('header', 'general', get_string('general', 'form')); $options = array(); if ($quizes = get_coursemodules_in_course('quiz', $COURSE->id)) { foreach ($quizes as $quiz) { $options[$quiz->id] = $quiz->name; } } $mform->addElement('select', 'quiz', get_string('originalquiz', 'quizcopy'), $options); $mform->addRule('quiz', null, 'required', null, 'client'); /// Adding the standard "name" field $mform->addElement('text', 'name', get_string('quizcopyname', 'quizcopy'), array('size' => '64')); $mform->setType('name', PARAM_TEXT); $mform->addRule('name', null, 'required', null, 'client'); $this->standard_hidden_coursemodule_elements(); $this->add_action_buttons(); }
/** * get all resources! * */ function block_resources_get_all_resources() { global $DB; // get courses list in wich logged user was enrolled $courses = enrol_get_my_courses(); if (empty($courses)) { return false; } $ids = implode(',', array_keys($courses)); // --------- cycle by courses foreach ($courses as $key => $course) { if (!isset($courses[$key]->resources)) { $courses[$key]->resources = array(); } // get videoresources list from courses and then render it // * link to videoresource = link to course modules $courses[$key]->videoresources = get_coursemodules_in_course('videoresource', $course->id); } // get resources list from all courses with AVG rating $resources = $DB->get_records_sql(' SELECT DISTINCT rl.course * 10000 + si.id as id, si.id as section_id, rl.course, r.id as resource_id, r.url, r.title, r.internal_title, r.description, r.author, r.source , (SELECT AVG(t.rating) FROM mdl_rating t LEFT JOIN mdl_resource_section_items si ON si.id = t.itemid WHERE si.resource_item_id = r.id) as avgrate FROM mdl_resourcelib rl RIGHT JOIN mdl_resourcelib_content rc ON rl.id = rc.resourcelib_id RIGHT JOIN mdl_resource_lists l ON rc.instance_id = l.id RIGHT JOIN mdl_resource_list_sections ls ON l.id = ls.resource_list_id RIGHT JOIN mdl_resource_section_items si ON ls.resource_section_id = si.resource_section_id RIGHT JOIN mdl_resource_items r ON r.id = si.resource_item_id WHERE rl.course IN (' . $ids . ') ORDER BY ls.sort_order, si.sort_order'); foreach ($resources as $key => $resource) { if (!isset($courses[$resource->course]->resources[$resource->resource_id])) { $courses[$resource->course]->resources[$resource->resource_id] = $resource; } } return $courses; }
function definition() { $mform =& $this->_form; $id = $this->vpl->get_course_module()->id; $mform->addElement('hidden', 'id', $id); $mform->setType('id', PARAM_INT); $mform->addElement('header', 'header_execution_options', get_string('executionoptions', VPL)); $strbasedon = get_string('basedon', VPL); $basedonlist = array(); $basedonlist[0] = ''; $courseid = $this->vpl->get_course()->id; $listcm = get_coursemodules_in_course(VPL, $courseid); $instance = $this->vpl->get_instance(); $vplid = $instance->id; foreach ($listcm as $aux) { if ($aux->instance != $vplid) { $vpl = new mod_vpl($aux->id); $basedonlist[$aux->instance] = $vpl->get_printable_name(); } } asort($basedonlist); $basedonlist[0] = get_string('select'); $mform->addElement('select', 'basedon', $strbasedon, $basedonlist); $mform->setDefault('basedon', $instance->basedon); $mform->addElement('selectyesno', 'run', get_string('run', VPL)); $mform->setDefault('run', 1); $mform->addElement('selectyesno', 'debug', get_string('debug', VPL)); $mform->setDefault('debug', $instance->debug); $mform->addElement('selectyesno', 'evaluate', get_string('evaluate', VPL)); $mform->setDefault('evaluate', 1); $mform->addElement('selectyesno', 'evaluateonsubmission', get_string('evaluateonsubmission', VPL)); $mform->setDefault('evaluateonsubmission', 1); $mform->disabledIf('evaluateonsubmission', 'evaluate', 'eq', 0); $mform->addElement('selectyesno', 'automaticgrading', get_string('automaticgrading', VPL)); $mform->setDefault('automaticgrading', 1); $mform->disabledIf('automaticgrading', 'evaluate', 'eq', 0); $mform->addElement('submit', 'saveoptions', get_string('saveoptions', VPL)); }
/** * Returns an array of courses the user is enrolled, and for each course all of the assignments that the user can * view within that course. * * @param array $courseids An optional array of course ids. If provided only assignments within the given course * will be returned. If the user is not enrolled in or can't view a given course a warning will be generated and returned. * @param array $capabilities An array of additional capability checks you wish to be made on the course context. * @param bool $includenotenrolledcourses Wheter to return courses that the user can see even if is not enroled in. * This requires the parameter $courseids to not be empty. * @return An array of courses and warnings. * @since Moodle 2.4 */ public static function get_assignments($courseids = array(), $capabilities = array(), $includenotenrolledcourses = false) { global $USER, $DB, $CFG; $params = self::validate_parameters(self::get_assignments_parameters(), array('courseids' => $courseids, 'capabilities' => $capabilities, 'includenotenrolledcourses' => $includenotenrolledcourses)); $warnings = array(); $courses = array(); $fields = 'sortorder,shortname,fullname,timemodified'; // If the courseids list is empty, we return only the courses where the user is enrolled in. if (empty($params['courseids'])) { $courses = enrol_get_users_courses($USER->id, true, $fields); $courseids = array_keys($courses); } else { if ($includenotenrolledcourses) { // In this case, we don't have to check here for enrolmnents. Maybe the user can see the course even if is not enrolled. $courseids = $params['courseids']; } else { // We need to check for enrolments. $mycourses = enrol_get_users_courses($USER->id, true, $fields); $mycourseids = array_keys($mycourses); foreach ($params['courseids'] as $courseid) { if (!in_array($courseid, $mycourseids)) { unset($courses[$courseid]); $warnings[] = array('item' => 'course', 'itemid' => $courseid, 'warningcode' => '2', 'message' => 'User is not enrolled or does not have requested capability'); } else { $courses[$courseid] = $mycourses[$courseid]; } } $courseids = array_keys($courses); } } foreach ($courseids as $cid) { try { $context = context_course::instance($cid); self::validate_context($context); // Check if this course was already loaded (by enrol_get_users_courses). if (!isset($courses[$cid])) { $courses[$cid] = get_course($cid); } $courses[$cid]->contextid = $context->id; } catch (Exception $e) { unset($courses[$cid]); $warnings[] = array('item' => 'course', 'itemid' => $cid, 'warningcode' => '1', 'message' => 'No access rights in course context ' . $e->getMessage()); continue; } if (count($params['capabilities']) > 0 && !has_all_capabilities($params['capabilities'], $context)) { unset($courses[$cid]); } } $extrafields = 'm.id as assignmentid, ' . 'm.course, ' . 'm.nosubmissions, ' . 'm.submissiondrafts, ' . 'm.sendnotifications, ' . 'm.sendlatenotifications, ' . 'm.sendstudentnotifications, ' . 'm.duedate, ' . 'm.allowsubmissionsfromdate, ' . 'm.grade, ' . 'm.timemodified, ' . 'm.completionsubmit, ' . 'm.cutoffdate, ' . 'm.teamsubmission, ' . 'm.requireallteammemberssubmit, ' . 'm.teamsubmissiongroupingid, ' . 'm.blindmarking, ' . 'm.revealidentities, ' . 'm.attemptreopenmethod, ' . 'm.maxattempts, ' . 'm.markingworkflow, ' . 'm.markingallocation, ' . 'm.requiresubmissionstatement, ' . 'm.preventsubmissionnotingroup, ' . 'm.intro, ' . 'm.introformat'; $coursearray = array(); foreach ($courses as $id => $course) { $assignmentarray = array(); // Get a list of assignments for the course. if ($modules = get_coursemodules_in_course('assign', $courses[$id]->id, $extrafields)) { foreach ($modules as $module) { $context = context_module::instance($module->id); try { self::validate_context($context); require_capability('mod/assign:view', $context); } catch (Exception $e) { $warnings[] = array('item' => 'module', 'itemid' => $module->id, 'warningcode' => '1', 'message' => 'No access rights in module context'); continue; } $assign = new assign($context, null, null); // Get configurations for only enabled plugins. $plugins = $assign->get_submission_plugins(); $plugins = array_merge($plugins, $assign->get_feedback_plugins()); $configarray = array(); foreach ($plugins as $plugin) { if ($plugin->is_enabled() && $plugin->is_visible()) { $configrecords = $plugin->get_config_for_external(); foreach ($configrecords as $name => $value) { $configarray[] = array('plugin' => $plugin->get_type(), 'subtype' => $plugin->get_subtype(), 'name' => $name, 'value' => $value); } } } $assignment = array('id' => $module->assignmentid, 'cmid' => $module->id, 'course' => $module->course, 'name' => $module->name, 'nosubmissions' => $module->nosubmissions, 'submissiondrafts' => $module->submissiondrafts, 'sendnotifications' => $module->sendnotifications, 'sendlatenotifications' => $module->sendlatenotifications, 'sendstudentnotifications' => $module->sendstudentnotifications, 'duedate' => $module->duedate, 'allowsubmissionsfromdate' => $module->allowsubmissionsfromdate, 'grade' => $module->grade, 'timemodified' => $module->timemodified, 'completionsubmit' => $module->completionsubmit, 'cutoffdate' => $module->cutoffdate, 'teamsubmission' => $module->teamsubmission, 'requireallteammemberssubmit' => $module->requireallteammemberssubmit, 'teamsubmissiongroupingid' => $module->teamsubmissiongroupingid, 'blindmarking' => $module->blindmarking, 'revealidentities' => $module->revealidentities, 'attemptreopenmethod' => $module->attemptreopenmethod, 'maxattempts' => $module->maxattempts, 'markingworkflow' => $module->markingworkflow, 'markingallocation' => $module->markingallocation, 'requiresubmissionstatement' => $module->requiresubmissionstatement, 'preventsubmissionnotingroup' => $module->preventsubmissionnotingroup, 'configs' => $configarray); // Return or not intro and file attachments depending on the plugin settings. if ($assign->show_intro()) { list($assignment['intro'], $assignment['introformat']) = external_format_text($module->intro, $module->introformat, $context->id, 'mod_assign', 'intro', null); $assignment['introfiles'] = external_util::get_area_files($context->id, 'mod_assign', 'intro', false, false); $assignment['introattachments'] = external_util::get_area_files($context->id, 'mod_assign', ASSIGN_INTROATTACHMENT_FILEAREA, 0); } if ($module->requiresubmissionstatement) { // Submission statement is required, return the submission statement value. $adminconfig = get_config('assign'); list($assignment['submissionstatement'], $assignment['submissionstatementformat']) = external_format_text($adminconfig->submissionstatement, FORMAT_MOODLE, $context->id, 'mod_assign', '', 0); } $assignmentarray[] = $assignment; } } $coursearray[] = array('id' => $courses[$id]->id, 'fullname' => external_format_string($courses[$id]->fullname, $course->contextid), 'shortname' => external_format_string($courses[$id]->shortname, $course->contextid), 'timemodified' => $courses[$id]->timemodified, 'assignments' => $assignmentarray); } $result = array('courses' => $coursearray, 'warnings' => $warnings); return $result; }
/** * This function is used by the reset_course_userdata function in moodlelib. * This function will remove all posts from the specified vpl instance * and clean up any related data. * @param $data the data submitted from the reset course. * @return array status array */ function vpl_reset_userdata($data) { global $CFG, $DB; $status = array(); if ($data->reset_vpl_submissions) { $componentstr = get_string('modulenameplural', VPL); if ($cms = get_coursemodules_in_course(VPL, $data->courseid)) { foreach ($cms as $cmid => $cm) { //For each vpl instance in course $vpl = new mod_vpl($cmid); $instance = $vpl->get_instance(); //Delete submissions records $DB->delete_records(VPL_SUBMISSIONS, array('vpl' => $instance->id)); //Delete variations assigned $DB->delete_records(VPL_ASSIGNED_VARIATIONS, array('vpl' => $instance->id)); //Delete submission files fulldelete($CFG->dataroot . '/vpl_data/' . $data->courseid . '/' . $instance->id . '/usersdata'); $status[] = array('component' => $componentstr, 'item' => get_string('resetvpl', VPL, $instance->name), 'error' => false); } } } return $status; }
require_course_login($course); add_to_log($course->id, "assignment", "view all", "index.php?id={$course->id}", ""); $strassignments = get_string("modulenameplural", "assignment"); $strassignment = get_string("modulename", "assignment"); $strassignmenttype = get_string("assignmenttype", "assignment"); $strweek = get_string("week"); $strtopic = get_string("topic"); $strname = get_string("name"); $strduedate = get_string("duedate", "assignment"); $strsubmitted = get_string("submitted", "assignment"); $strgrade = get_string("grade"); $navlinks = array(); $navlinks[] = array('name' => $strassignments, 'link' => '', 'type' => 'activity'); $navigation = build_navigation($navlinks); print_header_simple($strassignments, "", $navigation, "", "", true, "", navmenu($course)); if (!($cms = get_coursemodules_in_course('assignment', $course->id, 'm.assignmenttype, m.timedue'))) { notice(get_string('noassignments', 'assignment'), "../../course/view.php?id={$course->id}"); die; } $timenow = time(); if ($course->format == "weeks") { $table->head = array($strweek, $strname, $strassignmenttype, $strduedate, $strsubmitted, $strgrade); $table->align = array("center", "left", "left", "left", "right"); } else { if ($course->format == "topics") { $table->head = array($strtopic, $strname, $strassignmenttype, $strduedate, $strsubmitted, $strgrade); $table->align = array("center", "left", "left", "left", "right"); } else { $table->head = array($strname, $strassignmenttype, $strduedate, $strsubmitted, $strgrade); $table->align = array("left", "left", "left", "right"); }
} emarking_json_resultset($results); } else { if ($action === 'courses') { $rs = get_user_capability_course($capability, $user->id); $results = array(); foreach ($rs as $r) { $results[] = $r; } emarking_json_resultset($results); } else { if ($action === 'activities') { if (!($course = $DB->get_record('course', array('id' => $courseid)))) { emarking_json_error('Invalid course id'); } $rs = get_coursemodules_in_course('emarking', $course->id); $results = array(); foreach ($rs as $r) { $results[] = $r; } emarking_json_resultset($results); } else { if ($action === 'courseinfo') { if (!($course = $DB->get_record('course', array('id' => $courseid)))) { emarking_json_error('Invalid course id'); } $results = array(); $results[] = $course; emarking_json_resultset($results); } else { if ($action === 'coursesearch') {
function RWSGUVQList($r_cid) { global $RWSUID; $r_vqms = array(); $r_qzms = get_coursemodules_in_course("quiz", $r_cid); if ($r_qzms === false || count($r_qzms) == 0) { return $r_vqms; } foreach ($r_qzms as $r_qzm) { if (coursemodule_visible_for_user($r_qzm, $RWSUID)) { $r_vqms[] = $r_qzm; } } return $r_vqms; }
function lockdownbrowser_MonitorActionExamSync($parameters) { global $DB; if (!isloggedin()) { lockdownbrowser_MonitorServiceError(2004, "Must be logged in to perform the requested action"); } if (!is_siteadmin()) { lockdownbrowser_MonitorServiceError(2024, "Must be logged in as admin to perform the requested action"); } if (!isset($parameters["courseRefId"]) || strlen($parameters["courseRefId"]) == 0) { lockdownbrowser_MonitorServiceError(2025, "No courseRefId parameter was specified"); } $course_id = intval($parameters["courseRefId"]); $coursemodules = get_coursemodules_in_course("quiz", $course_id); if ($coursemodules === FALSE) { $coursemodules = array(); } $body = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"; if (empty($coursemodules)) { $body .= "<assessmentList />\r\n"; lockdownbrowser_MonitorServiceResponse("text/xml", $body, TRUE); } $body .= "<assessmentList>\r\n"; foreach ($coursemodules as $cm) { $modrec = $DB->get_record("modules", array("id" => $cm->module)); if ($modrec === FALSE) { continue; } $quiz = $DB->get_record($modrec->name, array("id" => $cm->instance)); if ($quiz === FALSE) { continue; } $body .= "\t<assessment>\r\n"; $body .= "\t\t<id>"; $body .= utf8_encode(htmlspecialchars(trim($cm->id))); $body .= "</id>\r\n"; $body .= "\t\t<title>"; $body .= utf8_encode(htmlspecialchars(trim($cm->name))); $body .= "</title>\r\n"; $settings = lockdownbrowser_get_quiz_options($cm->instance); if ($settings !== FALSE) { $body .= "\t\t<ldbEnabled>true</ldbEnabled>\r\n"; } else { $body .= "\t\t<ldbEnabled>false</ldbEnabled>\r\n"; } if ($settings !== FALSE && isset($settings->password) && !is_null($settings->password) && strlen($settings->password) > 0) { $body .= "\t\t<exitPassword>"; $body .= utf8_encode(htmlspecialchars($settings->password)); $body .= "</exitPassword>\r\n"; } if ($settings !== FALSE && isset($settings->monitor) && !is_null($settings->monitor) && strlen($settings->monitor) > 0) { $body .= "\t\t<monitorEnabled>true</monitorEnabled>\r\n"; $body .= "\t\t<extendedData>"; $body .= utf8_encode(htmlspecialchars($settings->monitor)); $body .= "</extendedData>\r\n"; } else { $body .= "\t\t<monitorEnabled>false</monitorEnabled>\r\n"; } // Moodle browser security // popup (0=none, 1=full screen pop-up with some JavaScript security) // Moodle 2.2.0+ (quiz module 2011100600+) // browsersecurity ('-', 'securewindow', 'safebrowser') // if this setting is not disabled, it will interfere with the LDB integration if (isset($quiz->browsersecurity)) { if ($quiz->browsersecurity != "-") { $launch_in_new_window = TRUE; } else { $launch_in_new_window = FALSE; } } else { if ($quiz->popup != 0) { $launch_in_new_window = TRUE; } else { $launch_in_new_window = FALSE; } } if ($launch_in_new_window) { $body .= "\t\t<launchInNewWindow>true</launchInNewWindow>\r\n"; } else { $body .= "\t\t<launchInNewWindow>false</launchInNewWindow>\r\n"; } if ($settings !== FALSE && $launch_in_new_window) { $body .= "\t\t<ok>false</ok>\r\n"; } else { $body .= "\t\t<ok>true</ok>\r\n"; } $body .= "\t</assessment>\r\n"; } $body .= "</assessmentList>\r\n"; lockdownbrowser_MonitorServiceResponse("text/xml", $body, TRUE); }
public function test_get_coursemodules_in_course() { global $CFG; $this->resetAfterTest(); $this->setAdminUser(); // Some generators have bogus access control. $this->assertFileExists("{$CFG->dirroot}/mod/folder/lib.php"); $this->assertFileExists("{$CFG->dirroot}/mod/glossary/lib.php"); $this->assertFileExists("{$CFG->dirroot}/mod/label/lib.php"); $course1 = $this->getDataGenerator()->create_course(); $course2 = $this->getDataGenerator()->create_course(); $folder1a = $this->getDataGenerator()->create_module('folder', array('course' => $course1, 'section' => 3)); $folder1b = $this->getDataGenerator()->create_module('folder', array('course' => $course1)); $glossary1 = $this->getDataGenerator()->create_module('glossary', array('course' => $course1)); $folder2 = $this->getDataGenerator()->create_module('folder', array('course' => $course2)); $glossary2a = $this->getDataGenerator()->create_module('glossary', array('course' => $course2)); $glossary2b = $this->getDataGenerator()->create_module('glossary', array('course' => $course2)); $modules = get_coursemodules_in_course('folder', $course1->id); $this->assertCount(2, $modules); $cm = $modules[$folder1a->cmid]; $this->assertSame('folder', $cm->modname); $this->assertSame($folder1a->id, $cm->instance); $this->assertSame($folder1a->course, $cm->course); $this->assertObjectNotHasAttribute('sectionnum', $cm); $this->assertObjectNotHasAttribute('revision', $cm); $this->assertObjectNotHasAttribute('display', $cm); $cm = $modules[$folder1b->cmid]; $this->assertSame('folder', $cm->modname); $this->assertSame($folder1b->id, $cm->instance); $this->assertSame($folder1b->course, $cm->course); $this->assertObjectNotHasAttribute('sectionnum', $cm); $this->assertObjectNotHasAttribute('revision', $cm); $this->assertObjectNotHasAttribute('display', $cm); $modules = get_coursemodules_in_course('folder', $course1->id, 'revision, display'); $this->assertCount(2, $modules); $cm = $modules[$folder1a->cmid]; $this->assertSame('folder', $cm->modname); $this->assertSame($folder1a->id, $cm->instance); $this->assertSame($folder1a->course, $cm->course); $this->assertObjectNotHasAttribute('sectionnum', $cm); $this->assertObjectHasAttribute('revision', $cm); $this->assertObjectHasAttribute('display', $cm); $modules = get_coursemodules_in_course('label', $course1->id); $this->assertCount(0, $modules); try { get_coursemodules_in_course('a b', $course1->id); $this->fail('coding_exception expected'); } catch (moodle_exception $e) { $this->assertInstanceOf('coding_exception', $e); } try { get_coursemodules_in_course('abc', $course1->id); $this->fail('dml_read_exception expected'); } catch (moodle_exception $e) { $this->assertInstanceOf('dml_read_exception', $e); } }
$strassignment = get_string("modulename", "assignment"); $strassignmenttype = get_string("assignmenttype", "assignment"); $strsectionname = get_string('sectionname', 'format_'.$course->format); $strname = get_string("name"); $strduedate = get_string("duedate", "assignment"); $strsubmitted = get_string("submitted", "assignment"); $strgrade = get_string("grade"); $PAGE->set_url('/mod/assignment/index.php', array('id'=>$course->id)); $PAGE->navbar->add($strassignments); $PAGE->set_title($strassignments); $PAGE->set_heading($course->fullname); echo $OUTPUT->header(); if (!$cms = get_coursemodules_in_course('assignment', $course->id, 'cm.idnumber, m.assignmenttype, m.timedue')) { notice(get_string('noassignments', 'assignment'), "../../course/view.php?id=$course->id"); die; } $usesections = course_format_uses_sections($course->format); if ($usesections) { $sections = get_all_sections($course->id); } $timenow = time(); $table = new html_table(); if ($usesections) { $table->head = array ($strsectionname, $strname, $strassignmenttype, $strduedate, $strsubmitted, $strgrade);
require_course_login($course); $PAGE->set_pagelayout('incourse'); $event = \mod_publication\event\course_module_instance_list_viewed::create(array('context' => context_course::instance($course->id))); $event->trigger(); $strmodulenameplural = get_string('modulenameplural', 'publication'); $strmodulname = get_string('modulename', 'publication'); $strsectionname = get_string('sectionname', 'format_' . $course->format); $strname = get_string('name'); $strdesc = get_string('description'); $PAGE->set_url('/mod/publication/index.php', array('id' => $course->id)); $PAGE->navbar->add($strmodulenameplural); $PAGE->set_title($strmodulenameplural); $PAGE->set_heading($course->fullname); echo $OUTPUT->header(); echo $OUTPUT->heading($strmodulname); if (!($cms = get_coursemodules_in_course('publication', $course->id, 'cm.idnumber'))) { notice(get_string('nopublicationsincourse', 'publication'), '../../course/view.php?id=' . $course->id); die; } $usesections = course_format_uses_sections($course->format); if ($usesections) { $sections = get_fast_modinfo($course->id)->get_section_info_all(); } $timenow = time(); $table = new html_table(); if ($usesections) { $table->head = array($strsectionname, $strname, $strdesc); } else { $table->head = array($strname, $strdesc); } $currentsection = '';
/** * Actual implementation of the reset course functionality, delete all * oublog posts. * * @global object * @global object * @param object $data the data submitted from the reset course. * @return array status array */ function oublog_reset_userdata($data) { global $DB; $componentstr = get_string('modulenameplural', 'oublog'); $status = array(); if (!empty($data->reset_oublog)) { // Delete post-related data. $postidsql = "\n SELECT pst.id\n FROM {oublog_posts} pst\n JOIN {oublog_instances} ins ON (ins.id = pst.oubloginstancesid)\n JOIN {oublog} obl ON (obl.id = ins.oublogid)\n WHERE obl.course = ?\n "; $params = array($data->courseid); $DB->delete_records_select('oublog_comments', "postid IN ({$postidsql})", $params); $DB->delete_records_select('oublog_comments_moderated', "postid IN ({$postidsql})", $params); $DB->delete_records_select('oublog_edits', "postid IN ({$postidsql})", $params); // Delete instance-related data. $insidsql = "\n SELECT ins.id\n FROM {oublog_instances} ins\n JOIN {oublog} obl ON (obl.id = ins.oublogid)\n WHERE obl.course = ?\n "; $DB->delete_records_select('oublog_links', "oubloginstancesid IN ({$insidsql})", $params); $DB->delete_records_select('oublog_taginstances', "oubloginstancesid IN ({$insidsql})", $params); $DB->delete_records_select('oublog_posts', "oubloginstancesid IN ({$insidsql})", $params); $blogidsql = "\n SELECT obl.id\n FROM {oublog} obl\n WHERE obl.course = ?\n "; // Delete instances: $DB->delete_records_select('oublog_instances', "oublogid IN ({$blogidsql})", $params); // Reset views: $DB->execute("UPDATE {oublog} SET views = 0 WHERE course = ?", $params); // Now get rid of all attachments. $fs = get_file_storage(); $oublogs = get_coursemodules_in_course('oublog', $data->courseid); if ($oublogs) { foreach ($oublogs as $oublogid => $unused) { if (!($cm = get_coursemodule_from_instance('oublog', $oublogid))) { continue; } $context = context_module::instance($cm->id); $fs->delete_area_files($context->id, 'mod_oublog', 'attachment'); $fs->delete_area_files($context->id, 'mod_oublog', 'message'); $fs->delete_area_files($context->id, 'mod_oublog', 'messagecomment'); } } $status[] = array('component' => $componentstr, 'item' => get_string('removeblogs', 'oublog'), 'error' => false); } return $status; }
$event->trigger(); //Print selection by instance state $url_base = new moodle_url('/mod/vpl/index.php', array('id' => $id, 'sort' => $sort, 'sortdir' => $sortdir)); $urls = array(); $urlindex = array(); $url_base->param('selection', 'all'); $selected = $url_base->out(false); $urls[$selected] = get_string('all'); $urlindex['all'] = $selected; foreach (array('open', 'closed', 'timelimited', 'timeunlimited', 'automaticgrading', 'manualgrading', 'examples') as $sel) { $url_base->param('selection', $sel); $urls[$url_base->out(false)] = get_string($sel, VPL); $urlindex[$sel] = $url_base->out(false); } echo $OUTPUT->url_select($urls, $urlindex[$instanceselection], array()); if (!($cms = get_coursemodules_in_course(VPL, $course->id, "m.shortdescription, m.startdate, m.duedate"))) { notice($strnopls, vpl_abs_href('/course/view.php', 'id', $course->id)); die; } $ovpls = get_all_instances_in_course(VPL, $course); $timenow = time(); $vpls = array(); //Get and select vpls to show foreach ($ovpls as $ovpl) { $vpl = new mod_vpl(false, $ovpl->id); $instance = $vpl->get_instance(); if ($vpl->is_visible()) { switch ($instanceselection) { case 'all': $vpls[] = $vpl; break;
/** * Returns a recordset of emarking objects which are in courses parallel * to a course parameter * * @param unknown $course * @param unknown $includeown * @return multitype: */ function emarking_get_parallel_emarkings($course, $includeown) { global $DB; $parallelcourses = emarking_get_parallel_courses($course, $includeown); if (!$parallelcourses) { return false; } $parallelsids = array(); foreach ($parallelcourses as $parallelcourse) { if ($parallelcourse->id == $course->id) { continue; } foreach (get_coursemodules_in_course('emarking', $parallelcourse->id) as $cmdst) { $parallelsids[] = $cmdst->instance; } } $parallelsids = implode(",", $parallelsids); $parallelemarkings = $DB->get_records_sql("\n SELECT e.*, c.id as courseid, c.shortname, c.fullname\n FROM {emarking} AS e\n INNER JOIN {course} AS c ON (e.course = c.id AND c.id <> ?)\n WHERE e.id IN ({$parallelsids})\n ORDER BY c.fullname, e.name", array($course->id)); return $parallelemarkings; }
/** * Returns an array of courses the user is enrolled in, and for each course all of the seplments that the user can * view within that course. * * @param array $courseids An optional array of course ids. If provided only seplments within the given course * will be returned. If the user is not enrolled in a given course a warning will be generated and returned. * @param array $capabilities An array of additional capability checks you wish to be made on the course context. * @return An array of courses and warnings. * @since Moodle 2.4 */ public static function get_seplments($courseids = array(), $capabilities = array()) { global $USER, $DB, $CFG; require_once "{$CFG->dirroot}/mod/sepl/locallib.php"; $params = self::validate_parameters(self::get_seplments_parameters(), array('courseids' => $courseids, 'capabilities' => $capabilities)); $warnings = array(); $fields = 'sortorder,shortname,fullname,timemodified'; $courses = enrol_get_users_courses($USER->id, true, $fields); // Used to test for ids that have been requested but can't be returned. if (count($params['courseids']) > 0) { foreach ($params['courseids'] as $courseid) { if (!in_array($courseid, array_keys($courses))) { unset($courses[$courseid]); $warnings[] = array('item' => 'course', 'itemid' => $courseid, 'warningcode' => '2', 'message' => 'User is not enrolled or does not have requested capability'); } } } foreach ($courses as $id => $course) { if (count($params['courseids']) > 0 && !in_array($id, $params['courseids'])) { unset($courses[$id]); } $context = context_course::instance($id); try { self::validate_context($context); } catch (Exception $e) { unset($courses[$id]); $warnings[] = array('item' => 'course', 'itemid' => $id, 'warningcode' => '1', 'message' => 'No access rights in course context ' . $e->getMessage() . $e->getTraceAsString()); continue; } if (count($params['capabilities']) > 0 && !has_all_capabilities($params['capabilities'], $context)) { unset($courses[$id]); } } $extrafields = 'm.id as seplmentid, ' . 'm.course, ' . 'm.nosubmissions, ' . 'm.submissiondrafts, ' . 'm.sendnotifications, ' . 'm.sendlatenotifications, ' . 'm.sendstudentnotifications, ' . 'm.duedate, ' . 'm.allowsubmissionsfromdate, ' . 'm.grade, ' . 'm.timemodified, ' . 'm.completionsubmit, ' . 'm.cutoffdate, ' . 'm.teamsubmission, ' . 'm.requireallteammemberssubmit, ' . 'm.teamsubmissiongroupingid, ' . 'm.blindmarking, ' . 'm.revealidentities, ' . 'm.attemptreopenmethod, ' . 'm.maxattempts, ' . 'm.markingworkflow, ' . 'm.markingallocation, ' . 'm.requiresubmissionstatement, ' . 'm.intro, ' . 'm.introformat'; $coursearray = array(); foreach ($courses as $id => $course) { $seplmentarray = array(); // Get a list of seplments for the course. if ($modules = get_coursemodules_in_course('sepl', $courses[$id]->id, $extrafields)) { foreach ($modules as $module) { $context = context_module::instance($module->id); try { self::validate_context($context); require_capability('mod/sepl:view', $context); } catch (Exception $e) { $warnings[] = array('item' => 'module', 'itemid' => $module->id, 'warningcode' => '1', 'message' => 'No access rights in module context'); continue; } $configrecords = $DB->get_recordset('sepl_plugin_config', array('seplment' => $module->seplmentid)); $configarray = array(); foreach ($configrecords as $configrecord) { $configarray[] = array('id' => $configrecord->id, 'seplment' => $configrecord->seplment, 'plugin' => $configrecord->plugin, 'subtype' => $configrecord->subtype, 'name' => $configrecord->name, 'value' => $configrecord->value); } $configrecords->close(); $seplment = array('id' => $module->seplmentid, 'cmid' => $module->id, 'course' => $module->course, 'name' => $module->name, 'nosubmissions' => $module->nosubmissions, 'submissiondrafts' => $module->submissiondrafts, 'sendnotifications' => $module->sendnotifications, 'sendlatenotifications' => $module->sendlatenotifications, 'sendstudentnotifications' => $module->sendstudentnotifications, 'duedate' => $module->duedate, 'allowsubmissionsfromdate' => $module->allowsubmissionsfromdate, 'grade' => $module->grade, 'timemodified' => $module->timemodified, 'completionsubmit' => $module->completionsubmit, 'cutoffdate' => $module->cutoffdate, 'teamsubmission' => $module->teamsubmission, 'requireallteammemberssubmit' => $module->requireallteammemberssubmit, 'teamsubmissiongroupingid' => $module->teamsubmissiongroupingid, 'blindmarking' => $module->blindmarking, 'revealidentities' => $module->revealidentities, 'attemptreopenmethod' => $module->attemptreopenmethod, 'maxattempts' => $module->maxattempts, 'markingworkflow' => $module->markingworkflow, 'markingallocation' => $module->markingallocation, 'requiresubmissionstatement' => $module->requiresubmissionstatement, 'configs' => $configarray); // Return or not intro and file attachments depending on the plugin settings. $sepl = new sepl($context, null, null); if ($sepl->show_intro()) { list($seplment['intro'], $seplment['introformat']) = external_format_text($module->intro, $module->introformat, $context->id, 'mod_sepl', ASSIGN_INTROATTACHMENT_FILEAREA, 0); $fs = get_file_storage(); if ($files = $fs->get_area_files($context->id, 'mod_sepl', ASSIGN_INTROATTACHMENT_FILEAREA, 0, 'timemodified', false)) { $seplment['introattachments'] = array(); foreach ($files as $file) { $filename = $file->get_filename(); $seplment['introattachments'][] = array('filename' => $filename, 'mimetype' => $file->get_mimetype(), 'fileurl' => moodle_url::make_webservice_pluginfile_url($context->id, 'mod_sepl', ASSIGN_INTROATTACHMENT_FILEAREA, 0, '/', $filename)->out(false)); } } } $seplmentarray[] = $seplment; } } $coursearray[] = array('id' => $courses[$id]->id, 'fullname' => $courses[$id]->fullname, 'shortname' => $courses[$id]->shortname, 'timemodified' => $courses[$id]->timemodified, 'seplments' => $seplmentarray); } $result = array('courses' => $coursearray, 'warnings' => $warnings); return $result; }
function scormcloud_get_coursemodule($id) { $cms = get_coursemodules_in_course('scormcloud', $id); return current($cms); }
/** * Returns an array of courses the user is enrolled in, and for each course all of the assignments that the user can * view within that course. * * @param array $courseids An optional array of course ids. If provided only assignments within the given course * will be returned. If the user is not enrolled in a given course a warning will be generated and returned. * @param array $capabilities An array of additional capability checks you wish to be made on the course context. * @return An array of courses and warnings. * @since Moodle 2.4 */ public static function get_assignments($courseids = array(), $capabilities = array()) { global $USER, $DB; $params = self::validate_parameters(self::get_assignments_parameters(), array('courseids' => $courseids, 'capabilities' => $capabilities)); $warnings = array(); $fields = 'sortorder,shortname,fullname,timemodified'; $courses = enrol_get_users_courses($USER->id, true, $fields); // Used to test for ids that have been requested but can't be returned. if (count($params['courseids']) > 0) { foreach ($params['courseids'] as $courseid) { if (!in_array($courseid, array_keys($courses))) { unset($courses[$courseid]); $warnings[] = array('item' => 'course', 'itemid' => $courseid, 'warningcode' => '2', 'message' => 'User is not enrolled or does not have requested capability'); } } } foreach ($courses as $id => $course) { if (count($params['courseids']) > 0 && !in_array($id, $params['courseids'])) { unset($courses[$id]); } $context = context_course::instance($id); try { self::validate_context($context); } catch (Exception $e) { unset($courses[$id]); $warnings[] = array('item' => 'course', 'itemid' => $id, 'warningcode' => '1', 'message' => 'No access rights in course context ' . $e->getMessage() . $e->getTraceAsString()); continue; } if (count($params['capabilities']) > 0 && !has_all_capabilities($params['capabilities'], $context)) { unset($courses[$id]); } } $extrafields = 'm.id as assignmentid, ' . 'm.course, ' . 'm.nosubmissions, ' . 'm.submissiondrafts, ' . 'm.sendnotifications, ' . 'm.sendlatenotifications, ' . 'm.sendstudentnotifications, ' . 'm.duedate, ' . 'm.allowsubmissionsfromdate, ' . 'm.grade, ' . 'm.timemodified, ' . 'm.completionsubmit, ' . 'm.cutoffdate, ' . 'm.teamsubmission, ' . 'm.requireallteammemberssubmit, ' . 'm.teamsubmissiongroupingid, ' . 'm.blindmarking, ' . 'm.revealidentities, ' . 'm.attemptreopenmethod, ' . 'm.maxattempts, ' . 'm.markingworkflow, ' . 'm.markingallocation, ' . 'm.requiresubmissionstatement'; $coursearray = array(); foreach ($courses as $id => $course) { $assignmentarray = array(); // Get a list of assignments for the course. if ($modules = get_coursemodules_in_course('assign', $courses[$id]->id, $extrafields)) { foreach ($modules as $module) { $context = context_module::instance($module->id); try { self::validate_context($context); require_capability('mod/assign:view', $context); } catch (Exception $e) { $warnings[] = array('item' => 'module', 'itemid' => $module->id, 'warningcode' => '1', 'message' => 'No access rights in module context'); continue; } $configrecords = $DB->get_recordset('assign_plugin_config', array('assignment' => $module->assignmentid)); $configarray = array(); foreach ($configrecords as $configrecord) { $configarray[] = array('id' => $configrecord->id, 'assignment' => $configrecord->assignment, 'plugin' => $configrecord->plugin, 'subtype' => $configrecord->subtype, 'name' => $configrecord->name, 'value' => $configrecord->value); } $configrecords->close(); $assignmentarray[] = array('id' => $module->assignmentid, 'cmid' => $module->id, 'course' => $module->course, 'name' => $module->name, 'nosubmissions' => $module->nosubmissions, 'submissiondrafts' => $module->submissiondrafts, 'sendnotifications' => $module->sendnotifications, 'sendlatenotifications' => $module->sendlatenotifications, 'sendstudentnotifications' => $module->sendstudentnotifications, 'duedate' => $module->duedate, 'allowsubmissionsfromdate' => $module->allowsubmissionsfromdate, 'grade' => $module->grade, 'timemodified' => $module->timemodified, 'completionsubmit' => $module->completionsubmit, 'cutoffdate' => $module->cutoffdate, 'teamsubmission' => $module->teamsubmission, 'requireallteammemberssubmit' => $module->requireallteammemberssubmit, 'teamsubmissiongroupingid' => $module->teamsubmissiongroupingid, 'blindmarking' => $module->blindmarking, 'revealidentities' => $module->revealidentities, 'attemptreopenmethod' => $module->attemptreopenmethod, 'maxattempts' => $module->maxattempts, 'markingworkflow' => $module->markingworkflow, 'markingallocation' => $module->markingallocation, 'requiresubmissionstatement' => $module->requiresubmissionstatement, 'configs' => $configarray); } } $coursearray[] = array('id' => $courses[$id]->id, 'fullname' => $courses[$id]->fullname, 'shortname' => $courses[$id]->shortname, 'timemodified' => $courses[$id]->timemodified, 'assignments' => $assignmentarray); } $result = array('courses' => $coursearray, 'warnings' => $warnings); return $result; }
/** * View a summary listing of all assignments in the current course. * * @return string */ private function view_course_index() { global $USER; $o = ''; $course = $this->get_course(); $strplural = get_string('modulenameplural', 'assign'); if (!($cms = get_coursemodules_in_course('assign', $course->id, 'm.duedate'))) { $o .= $this->get_renderer()->notification(get_string('thereareno', 'moodle', $strplural)); $o .= $this->get_renderer()->continue_button(new moodle_url('/course/view.php', array('id' => $course->id))); return $o; } $strsectionname = ''; $usesections = course_format_uses_sections($course->format); $modinfo = get_fast_modinfo($course); if ($usesections) { $strsectionname = get_string('sectionname', 'format_' . $course->format); $sections = $modinfo->get_section_info_all(); } $courseindexsummary = new assign_course_index_summary($usesections, $strsectionname); $timenow = time(); $currentsection = ''; foreach ($modinfo->instances['assign'] as $cm) { if (!$cm->uservisible) { continue; } $timedue = $cms[$cm->id]->duedate; $sectionname = ''; if ($usesections && $cm->sectionnum) { $sectionname = get_section_name($course, $sections[$cm->sectionnum]); } $submitted = ''; $context = context_module::instance($cm->id); $assignment = new assign($context, $cm, $course); if (has_capability('mod/assign:grade', $context)) { $submitted = $assignment->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_SUBMITTED); } else { if (has_capability('mod/assign:submit', $context)) { $usersubmission = $assignment->get_user_submission($USER->id, false); if (!empty($usersubmission->status)) { $submitted = get_string('submissionstatus_' . $usersubmission->status, 'assign'); } else { $submitted = get_string('submissionstatus_', 'assign'); } } } $gradinginfo = grade_get_grades($course->id, 'mod', 'assign', $cm->instance, $USER->id); if (isset($gradinginfo->items[0]->grades[$USER->id]) && !$gradinginfo->items[0]->grades[$USER->id]->hidden) { $grade = $gradinginfo->items[0]->grades[$USER->id]->str_grade; } else { $grade = '-'; } $courseindexsummary->add_assign_info($cm->id, $cm->name, $sectionname, $timedue, $submitted, $grade); } $o .= $this->get_renderer()->render($courseindexsummary); $o .= $this->view_footer(); return $o; }
/** * Construct contents of course_overview block * * @param array $courses list of courses in sorted order * @param array $overviews list of course overviews * @return string html to be displayed in course_overview block */ public function course_overview($courses, $overviews) { $html = ''; $config = get_config('block_course_overview'); $ismovingcourse = false; $courseordernumber = 0; $maxcourses = count($courses); $userediting = false; // Intialise string/icon etc if user is editing and courses > 1 if ($this->page->user_is_editing() && count($courses) > 1) { $userediting = true; $this->page->requires->js_init_call('M.block_course_overview.add_handles'); // Check if course is moving $ismovingcourse = optional_param('movecourse', FALSE, PARAM_BOOL); $movingcourseid = optional_param('courseid', 0, PARAM_INT); } // Render first movehere icon. if ($ismovingcourse) { // Remove movecourse param from url. $this->page->ensure_param_not_in_url('movecourse'); // Show moving course notice, so user knows what is being moved. $html .= $this->output->box_start('notice'); $a = new stdClass(); $a->fullname = $courses[$movingcourseid]->fullname; $a->cancellink = html_writer::link($this->page->url, get_string('cancel')); $html .= get_string('movingcourse', 'block_course_overview', $a); $html .= $this->output->box_end(); $moveurl = new moodle_url('/blocks/course_overview/move.php', array('sesskey' => sesskey(), 'moveto' => 0, 'courseid' => $movingcourseid)); // Create move icon, so it can be used. $movetofirsticon = html_writer::empty_tag('img', array('src' => $this->output->pix_url('movehere'), 'alt' => get_string('movetofirst', 'block_course_overview', $courses[$movingcourseid]->fullname), 'title' => get_string('movehere'))); $moveurl = html_writer::link($moveurl, $movetofirsticon); $html .= html_writer::tag('div', $moveurl, array('class' => 'movehere')); } $completedcourseshtml = ''; $inprogresscourseshtml = ''; $coursehtmlrecord = ''; foreach ($courses as $key => $course) { $coursehtmlrecord = ''; // If moving course, then don't show course which needs to be moved. if ($ismovingcourse && $course->id == $movingcourseid) { continue; } $coursehtmlrecord .= $this->output->box_start('coursebox', "course-{$course->id}"); $coursehtmlrecord .= html_writer::start_tag('div', array('class' => 'course_title')); // If user is editing, then add move icons. //GWL Display course image - Start global $CFG, $DB, $USER; $course = new course_in_list($course); //Getting progress percentage. $progress = get_course_progress_percentage($course, $USER); $completionstate = get_course_lesson_completionstate($course); $info = new completion_info($course); //GWL - Add this to add contion to generate certificate when instructor mark completed $completionstate = $info->is_course_complete($USER->id); //GWL - Add this to add contion to generate certificate when instructor mark completed // display course overview files $contentimages = $contentfiles = ''; foreach ($course->get_course_overviewfiles() as $file) { $isimage = $file->is_valid_image(); $url = file_encode_url("{$CFG->wwwroot}/pluginfile.php", '/' . $file->get_contextid() . '/' . $file->get_component() . '/' . $file->get_filearea() . $file->get_filepath() . $file->get_filename(), !$isimage); if ($isimage) { $contentimages .= html_writer::tag('div', html_writer::empty_tag('img', array('src' => $url)), array('class' => 'courseimage')); } else { $image = $this->output->pix_icon(file_file_icon($file, 24), $file->get_filename(), 'moodle'); $filename = html_writer::tag('span', $image, array('class' => 'fp-icon')) . html_writer::tag('span', $file->get_filename(), array('class' => 'fp-filename')); $contentfiles .= html_writer::tag('span', html_writer::link($url, $filename), array('class' => 'coursefile fp-filename-icon')); } } $content .= $contentimages . $contentfiles; $coursehtmlrecord .= $content; $attributes = array('title' => $course->fullname); if ($course->id > 0) { if (empty($course->visible)) { $attributes['class'] = 'dimmed'; } $courseurl = new moodle_url('/course/view.php', array('id' => $course->id)); $lession_id = get_course_lesson_id($course); if ($lession_id) { $courseurl = new moodle_url('/mod/lesson/view.php', array('id' => $lession_id)); } $coursefullname = format_string(get_course_display_name_for_list($course), true, $course->id); $link = html_writer::link($courseurl, $coursefullname, $attributes); if ($progress >= 100 || $completionstate == 1) { $coursehtmlrecord .= $this->output->heading($coursefullname, 2, 'title'); } else { $coursehtmlrecord .= $this->output->heading($link, 2, 'title'); } } else { $coursehtmlrecord .= $this->output->heading(html_writer::link(new moodle_url('/auth/mnet/jump.php', array('hostid' => $course->hostid, 'wantsurl' => '/course/view.php?id=' . $course->remoteid)), format_string($course->shortname, true), $attributes) . ' (' . format_string($course->hostname) . ')', 2, 'title'); } $result = $DB->get_field("course", "summary", array("id" => $course->id)); $coursehtmlrecord .= $result; //GWL Display course image - END //GWL to get download certificate link if ($progress < 100 && !$completionstate) { $coursehtmlrecord .= '<div style=" background-color: #ccc; color: #fff; text-align: right; vertical-align: middle; height: 20px; border-radius: 10px; overflow: hidden; margin-bottom: 5px;"><div style="width: ' . $progress . '%; float: left; background-color: green; padding-right: 10px;">' . $progress . '%</div></div>'; } else { $certificates = get_coursemodules_in_course('iomadcertificate', $course->id); $certificatelink = '-'; if ($certificates) { $showcertificate = 1; foreach ($certificates as $certficate) { $modinfo = get_fast_modinfo($course->id); $cm = $modinfo->get_cm($certficate->id); if ($cm && $cm->uservisible) { $coursehtmlrecord .= '<div><a href="' . $CFG->wwwroot . '/mod/iomadcertificate/view.php?id=' . $certficate->id . '&action=get" class="pull-right" style="color:#f5811e;"> <i class="fa fa-cloud-download" style="color:#f5811e;" ></i> Download Certificate</a> </div>'; } } } } //GWL to get download certificate link // GWL - Course Status On Dashboard / if ($userediting && !$ismovingcourse) { $moveicon = html_writer::empty_tag('img', array('src' => $this->pix_url('t/move')->out(false), 'alt' => get_string('movecourse', 'block_course_overview', $course->fullname), 'title' => get_string('move'))); $moveurl = new moodle_url($this->page->url, array('sesskey' => sesskey(), 'movecourse' => 1, 'courseid' => $course->id)); $moveurl = html_writer::link($moveurl, $moveicon); $coursehtmlrecord .= html_writer::tag('div', $moveurl, array('class' => 'move')); } // No need to pass title through s() here as it will be done automatically by html_writer. $coursehtmlrecord .= $this->output->box('', 'flush'); $coursehtmlrecord .= html_writer::end_tag('div'); if (!empty($config->showchildren) && $course->id > 0) { // List children here. if ($children = block_course_overview_get_child_shortnames($course->id)) { $coursehtmlrecord .= html_writer::tag('span', $children, array('class' => 'coursechildren')); } } // If user is moving courses, then down't show overview. if (isset($overviews[$course->id]) && !$ismovingcourse) { $coursehtmlrecord .= $this->activity_display($course->id, $overviews[$course->id]); } $coursehtmlrecord .= $this->output->box('', 'flush'); $coursehtmlrecord .= $this->output->box_end(); $courseordernumber++; if ($ismovingcourse) { $moveurl = new moodle_url('/blocks/course_overview/move.php', array('sesskey' => sesskey(), 'moveto' => $courseordernumber, 'courseid' => $movingcourseid)); $a = new stdClass(); $a->movingcoursename = $courses[$movingcourseid]->fullname; $a->currentcoursename = $course->fullname; $movehereicon = html_writer::empty_tag('img', array('src' => $this->output->pix_url('movehere'), 'alt' => get_string('moveafterhere', 'block_course_overview', $a), 'title' => get_string('movehere'))); $moveurl = html_writer::link($moveurl, $movehereicon); $coursehtmlrecord .= html_writer::tag('div', $moveurl, array('class' => 'movehere')); } if ($progress >= 100 || $completionstate == 1) { $completedcourseshtml .= $coursehtmlrecord; } else { $inprogresscourseshtml .= $coursehtmlrecord; } } $html .= '<div class="inprogresscourse">In Progress Courses</div>'; $html .= $inprogresscourseshtml; $html .= '<div class="completecourse">Completed Courses</div>'; $html .= $completedcourseshtml; // Wrap course list in a div and return. return html_writer::tag('div', $html, array('class' => 'course_list')); }