/** * 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 * * @return stdClass The reformatted record */ function transform_record($record, $export_format) { $user = new user(); $user->firstname = $record->firstname; $user->lastname = $record->r_student; $record->r_student = fullname($user); if (empty($record->r_elements)) { $record->r_elements = '0'; $record->r_percent = '0'; } else { //$percentage = round($record->r_complete / $record->r_elements * 10000) / 100; $percentage = round($record->r_percent / $record->r_elements * 10000) / 100; $percentage = $percentage > 100 ? 100 : $percentage; $record->r_percent = $percentage; } if ($export_format != php_report::$EXPORT_FORMAT_CSV) { $record->r_percent .= get_string('percent_symbol', $this->lang_file); } if (empty($record->r_graded)) { $record->r_graded = '0'; } if (empty($record->r_total_elements)) { $record->r_total_elements = '0'; } $secs_in_hour = 3600; if (!empty($record->r_timespent)) { if ($record->r_timespent > 0 && $record->r_timespent < $secs_in_hour) { $timespent = 1; $record->r_timespent = $export_format == php_report::$EXPORT_FORMAT_HTML ? '<1' : '1'; } else { $timespent = floor($record->r_timespent / $secs_in_hour); $record->r_timespent = $timespent; } } else { $timespent = 0; $record->r_timespent = "0"; } if ($export_format != php_report::$EXPORT_FORMAT_CSV) { $record->r_timespent .= ' ' . get_string($timespent == 1 ? 'hour' : 'hours', $this->lang_file); } // ELIS-4439: now using ELIS grade! //if (!empty($record->r_total_grade)) { // $record->r_total_grade = cm_display_grade($record->r_total_grade); //} else if (!empty($record->elisgrade)) { $record->r_total_grade = cm_display_grade($record->elisgrade); } else { $record->r_total_grade = get_string('na', $this->lang_file); } if (is_numeric($record->r_total_grade) && $export_format != php_report::$EXPORT_FORMAT_CSV) { $record->r_total_grade .= get_string('percent_symbol', $this->lang_file); } $record->r_status = $record->r_status == 1 ? get_string('complete', $this->lang_file) : get_string('incomplete', $this->lang_file); $record->curriculum_name = $record->curriculum_name == '' ? get_string('na', $this->lang_file) : $record->curriculum_name; return $record; }
/** * 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 * * @return stdClass The reformatted record */ function transform_record($record, $export_format) { $record->startdate = $record->startdate == 0 ? get_string('na', $this->lang_file) : $this->cmclassdate($record, 'start'); $today = strtotime(date('Y-m-d')); if ($record->enddate > $today) { $record->enddate = get_string('transform_column_in_progress', $this->lang_file); } else { $record->enddate = $record->enddate == 0 ? get_string('na', $this->lang_file) : $this->cmclassdate($record, 'end'); } //make sure this is set to something so that the horizontal bar graph doesn't disappear if (empty($record->stucompletedprogress)) { $record->stucompletedprogress = 0; } $a = new stdClass(); if (isset($record->stucompletedprogress)) { $a->value = $record->stucompletedprogress; $a->total = $record->numprogress; } else { $a->value = 0; $a->total = 0; } $record->completedprogress = get_string('of', $this->lang_file, $a); if (empty($record->numresources)) { $record->numresources = 0; } if (!empty($record->pretestscore)) { $record->pretestscore = cm_display_grade($record->pretestscore); if ($export_format != php_report::$EXPORT_FORMAT_CSV) { $record->pretestscore .= get_string('percent_symbol', $this->lang_file); } } else { $record->pretestscore = get_string('no_test_symbol', $this->lang_file); } if (!empty($record->posttestscore)) { $record->posttestscore = cm_display_grade($record->posttestscore); if ($export_format != php_report::$EXPORT_FORMAT_CSV) { $record->posttestscore .= get_string('percent_symbol', $this->lang_file); } } else { $record->posttestscore = get_string('no_test_symbol', $this->lang_file); } if (empty($record->numposts)) { $record->numposts = 0; } $record->enrol_status = empty($record->enrol_status) ? get_string('grouping_course_in_progress', $this->lang_file) : get_string('grouping_course_complete', $this->lang_file); // Default values for custom fields IF not set foreach ($this->field_default as $key => $value) { //error_log("ICPR:transform_record(), checking default for {$key} => {$value}"); if (!isset($record->{$key})) { $record->{$key} = $value; } } return $record; }
function get_item_display_grade($column, $item) { return cm_display_grade($item->grade); }
/** * Takes a record and transform 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 * * @return stdClass The reformatted record */ function transform_record($record, $export_format) { $record->user_id = fullname($record); // start-end dates $sdate = cm_timestamp_to_date($record->startdate, STR_DATE_FORMAT); $edate = !empty($record->enddate) ? cm_timestamp_to_date($record->enddate, STR_DATE_FORMAT) : get_string('present', $this->langfile); $record->startdate = empty($record->startdate) && empty($record->enddate) ? get_string('na', $this->langfile) : "{$sdate} - {$edate}"; // completed date $record->completed = $record->status != STUSTATUS_NOTCOMPLETE && !empty($record->completed) ? cm_timestamp_to_date($record->completed, STR_DATE_FORMAT) : get_string('incomplete', $this->langfile); // status mapping $statusmap = array(STUSTATUS_NOTCOMPLETE => 'na', STUSTATUS_FAILED => 'status_failed', STUSTATUS_PASSED => 'status_passed'); $record->status = get_string($statusmap[$record->status], $this->langfile); if (!empty($record->grade)) { $record->grade = cm_display_grade($record->grade); if ($export_format != php_report::$EXPORT_FORMAT_CSV) { $record->grade .= get_string('percent_symbol', $this->langfile); } } else { $record->grade = get_string('na', $this->langfile); } return $record; }
/** * Takes a record and transoforms 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 * * @return stdClass The reformatted record */ function transform_record($record, $export_format) { if ($record->completestatus == STUSTATUS_PASSED) { $record->completestatus = get_string('status_complete', 'rlreport_course_completion_gas_gauge'); } else { $record->completestatus = get_string('status_incomplete', 'rlreport_course_completion_gas_gauge'); } if ($export_format == php_report::$EXPORT_FORMAT_HTML) { //convert user name to their full name and link to the CM user page for that user $userpage = new usermanagementpage(array('id' => $record->cmuserid, 'action' => 'view')); $record->firstname = '<span class="external_report_link"><a href="' . $userpage->get_url() . '" target="_blank">' . fullname($record) . '</a></span>'; } else { $record->firstname = fullname($record); } //calculate the percentage of completion elements satisfied if ($record->numcompletionelements == 0) { $record->percentcomplete = get_string('na', 'rlreport_course_completion_gas_gauge'); } else { $record->percentcomplete = $record->numcompleted / $record->numcompletionelements * 100; $record->percentcomplete = number_format($record->percentcomplete, 1); } //display logic for the count of completion elements //$record->numcompleted = $record->numcompleted . ' / ' . $record->numcompletionelements; $record->numcompleted = get_string('completed_tally', 'rlreport_course_completion_gas_gauge', $record); //format the Moodle gradebook course score // ELIS-4439: now using ELIS grade! //if (empty($record->score) || empty($record->grademax)) { if (!empty($record->elisgrade)) { $record->score = cm_display_grade($record->elisgrade); if (is_numeric($record->score) && $export_format != php_report::$EXPORT_FORMAT_CSV) { $record->score .= get_string('percent_symbol', 'rlreport_course_completion_gas_gauge'); } } else { $record->score = get_string('na', 'rlreport_course_completion_gas_gauge'); } return $record; }
/** * 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) { global $CFG; //is this a required course? if ($record->curriculumid === NULL) { //not part of a curriculum $record->required = get_string('na', 'rlreport_course_completion_by_cluster'); } else { if ($record->required == 1) { $record->required = get_string('required_yes', 'rlreport_course_completion_by_cluster'); } else { $record->required = get_string('required_no', 'rlreport_course_completion_by_cluster'); } } //make sure we want to display this column if (property_exists($record, 'completestatusid')) { if ($record->completestatusid === NULL) { //not enrolled in the class $record->completestatusid = get_string('stustatus_notenrolled', 'rlreport_course_completion_by_cluster'); } else { if ($record->completestatusid == STUSTATUS_NOTCOMPLETE) { $record->completestatusid = get_string('stustatus_notcomplete', 'rlreport_course_completion_by_cluster'); } else { if ($record->completestatusid == STUSTATUS_PASSED) { //flag the class enrolment as passed and show completion date $a = $this->format_date($record->enrolcompletetime); $record->completestatusid = get_string('stustatus_passed', 'rlreport_course_completion_by_cluster', $a); } else { //flag the class enrolment as failed and show completion date $a = $this->format_date($record->enrolcompletetime); $record->completestatusid = get_string('stustatus_failed', 'rlreport_course_completion_by_cluster', $a); } } } } //class grade if ($record->grade === NULL) { //not enrolled $record->grade = get_string('na', 'rlreport_course_completion_by_cluster'); } else { //format the grade value $record->grade = get_string($export_format == php_report::$EXPORT_FORMAT_CSV ? 'formatted_grade_csv' : 'formatted_grade', 'rlreport_course_completion_by_cluster', cm_display_grade($record->grade)); } if (isset($record->numcomplete)) { $record->numcomplete = get_string('numcomplete_tally', 'rlreport_course_completion_by_cluster', $record); } return $record; }
/** * 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 * * @return stdClass The reformatted record */ function transform_record($record, $export_format) { //clear out the class info if there is only one class enrolment for the user and course if (isset($record->numclasses) && $record->numclasses == 1) { $record->classidnumber = ''; } $status = student::$completestatusid_values[$record->completestatus]; $record->completestatus = get_string($status, 'block_curr_admin'); if ($export_format == php_report::$EXPORT_FORMAT_HTML) { //convert user name to their full name and link to the CM user page for that user $userpage = new usermanagementpage(array('id' => $record->cmuserid, 'action' => 'view')); $record->firstname = '<span class="external_report_link"><a href="' . $userpage->get_url() . '" target="_blank">' . fullname($record) . '</a></span>'; } else { $record->firstname = fullname($record); } //calculate the percentage of completion elements satisfied if ($record->numcompletionelements == 0) { $record->percentcomplete = get_string('na', $this->lang_file); } else { $record->percentcomplete = $record->numcompleted / $record->numcompletionelements * 100; $record->percentcomplete = number_format($record->percentcomplete, 1); } //display logic for the count of completion elements //$record->numcompleted = $record->numcompleted . ' / ' . $record->numcompletionelements; $record->numcompleted = get_string('completed_tally', $this->lang_file, $record); //format the Moodle gradebook course score // ELIS-4439: now using ELIS grade! //if (empty($record->score) || empty($record->grademax)) { if (!empty($record->elisgrade)) { $record->score = cm_display_grade($record->elisgrade); if (is_numeric($record->score) && $export_format != php_report::$EXPORT_FORMAT_CSV) { $record->score .= get_string('percent_symbol', $this->lang_file); } } else { $record->score = get_string('na', $this->lang_file); } return $record; }
/** * 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 * * @return stdClass The reformatted record */ function transform_record($record, $export_format) { $record->curriculum_name = $record->curriculum_name == '' ? get_string('na', $this->lang_file) : $record->curriculum_name; $record->element = empty($record->element) ? get_string('none', $this->lang_file) : $record->element; $record->score = empty($record->score) ? get_string('na', $this->lang_file) : cm_display_grade($record->score) . ($export_format == php_report::$EXPORT_FORMAT_CSV ? '' : get_string('percent_symbol', $this->lang_file)); return $record; }