/** * Takes a record and transforms it into an appropriate format * This method is set up as a hook to be implented by actual report class * * @param stdClass $record The current report record * @param string $export_format The format being used to render the report * @uses $CFG * @return stdClass The reformatted record */ function transform_record($record, $export_format) { //add entity links if ($export_format == table_report::$EXPORT_FORMAT_HTML) { //link curriculum name to its "view" page if the the current record has a curriculum if (!empty($record->curid) && isset($record->curriculumname)) { $page = new curriculumpage(array('id' => $record->curid, 'action' => 'view')); if ($page->can_do()) { $record->curriculumname = '<span class="external_report_link"><a href="' . $page->url . '" target="_blank">' . $record->curriculumname . '</a></span>'; } } else { //non-curriculum course, so use status string with no link $record->curriculumname = get_string('noncurriculumcourse', $this->languagefile); } //link course name to its "view" page $page = new coursepage(array('id' => $record->courseid, 'action' => 'view')); if ($page->can_do()) { $record->coursename = '<span class="external_report_link"><a href="' . $page->url . '" target="_blank">' . $record->coursename . '</a></span>'; } //link class name to its "view" page $page = new pmclasspage(array('id' => $record->classid, 'action' => 'view')); if ($page->can_do()) { $record->classidnumber = '<span class="external_report_link"><a href="' . $page->url . '" target="_blank">' . $record->classidnumber . '</a></span>'; } } //show environment as N/A if not set if (empty($record->envname)) { $record->envname = get_string('na', $this->languagefile); } //format the start date $record->startdate = $this->format_date($record->startdate); //show number of passed and total number of completion elements $record->elementsdisplayed = get_string('compelements_passed', $this->languagefile, $record); //convert status id to a display string if ($record->completestatusid == STUSTATUS_PASSED) { $record->completionstatus = get_string('status_passed', $this->languagefile); } else { if ($record->completestatusid == STUSTATUS_FAILED) { $record->completionstatus = get_string('status_failed', $this->languagefile); } else { if ($record->completestatusid == STUSTATUS_NOTCOMPLETE) { $record->completionstatus = get_string('status_notcomplete', $this->languagefile); } else { $record->completionstatus = get_string('status_notstarted', $this->languagefile); } } } //if not passed, shouldn't have any credits if ($record->completestatusid != STUSTATUS_PASSED) { $record->credits = 0; } //copy result of complex sub-query into simple field $record->creditsdisplayed = $this->format_credits($record->credits); //format the completion time if ($record->completestatusid == STUSTATUS_NOTCOMPLETE) { //not complete, so don't show a completion time $record->completetime = '0'; } //only show a completion time if passed if ($record->completestatusid == STUSTATUS_PASSED || $record->completestatusid == STUSTATUS_FAILED) { $record->completetime = $this->format_date($record->completetime); } else { $record->completetime = get_string('na', $this->languagefile); } //display whether the current record is a student or an instructor assignment if ($record->isinstructor) { $record->classrole = get_string('instructor', $this->languagefile); } else { $record->classrole = get_string('student', $this->languagefile); } //handle custom field default values and display logic $this->transform_custom_field_data($record); return $record; }
/** * Whether the user has access to see the main page (assigned list) * * @return bool Whether the user has access. */ public function can_do_default() { $id = $this->required_param('id', PARAM_INT); $pmclasspage = new pmclasspage(array('id' => $id, 'action' => 'enrol')); return $pmclasspage->can_do(); }
function can_do_default() { $id = $this->required_param('id', PARAM_INT); $pmclasspage = new pmclasspage(array('id' => $id)); return $pmclasspage->can_do('edit'); }