/**
  * 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)
 {
     if ($export_format != php_report::$EXPORT_FORMAT_CSV && $export_format != php_report::$EXPORT_FORMAT_EXCEL) {
         $user = new stdClass();
         $user->firstname = $record->firstname;
         $user->lastname = $record->r_student;
         $record->r_student = php_report::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 ? '&lt;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-4916: now using ELIS grade!
     if (!empty($record->elisgrade)) {
         $record->r_total_grade = pm_display_grade($record->elisgrade);
         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);
         }
     } else {
         $record->r_total_grade = get_string('na', $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 summary row 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 last report record
  * @param   stdClass  $nextrecord     The next report record
  * @param   string    $export_format  The format being used to render the report
  * @return stdClass  The reformatted record
  */
 function transform_group_column_summary($record, $nextrecord, $export_format)
 {
     //$this->err_dump($record, 'transform_group_column_summary($record, $nextrecord, '. $export_format .')');
     $record->coursename = '';
     $record->classid = '';
     $prevfield = '';
     // clear all not required columns - saving 2nd last for label
     switch ($this->segment) {
         case 'noseg':
             $prevfield = 'gcslabel';
             // 'classid'
             break;
         case 'years':
             foreach ($this->months as $month) {
                 $record->{$month} = '';
                 $prevfield = $month;
             }
             break;
         case 'months':
             foreach ($this->weeks as $wk) {
                 $record->{$wk} = '';
                 $prevfield = $wk;
             }
             if (!empty($record->month)) {
                 $sparam = new stdClass();
                 $sparam->int_month = $record->month;
                 $sparam->str_month = get_string($this->months[$record->month - 1], $this->langfile);
                 $record->month = get_string('month_format', $this->langfile, $sparam);
             }
             break;
         case 'weeks':
             foreach ($this->wkdays as $day) {
                 $record->{$day} = '';
                 $prevfield = $day;
             }
             break;
         default:
             error_log("sitewide_time_summmary_report::transform_group_column_summary() - illegal segment: {$this->segment}");
     }
     if (empty($record->year)) {
         $record->year = get_string('no_time_logged', $this->langfile, strtolower(get_string('seg_years', $this->langfile)));
     }
     if (empty($record->year) || empty($record->month)) {
         $record->month = get_string('no_time_logged', $this->langfile, strtolower(get_string('seg_months', $this->langfile)));
     }
     if (empty($record->year) || empty($record->week)) {
         $record->week = get_string('no_time_logged', $this->langfile, strtolower(get_string('seg_weeks', $this->langfile)));
     }
     if (!empty($prevfield)) {
         $record->{$prevfield} = get_string('grouping_totaltime', $this->langfile);
     }
     $totaltime_fmt = $export_format == php_report::$EXPORT_FORMAT_CSV ? 'time_format' : 'totaltime_format';
     $record->totaltime = $this->format_time(get_string($totaltime_fmt, $this->langfile), $this->grouptotal);
     $this->grouptotal = 0;
     // reset for next time
     $record->user_id = php_report::fullname($record);
     return $record;
 }
 /**
  * Transforms a heading element displayed above the columns into a listing of such heading elements
  *
  * @param   string array           $grouping_current  Mapping of field names to current values in the grouping
  * @param   table_report_grouping  $grouping          Object containing all info about the current level of grouping
  *                                                    being handled
  * @param   stdClass               $datum             The most recent record encountered
  * @param   string    $export_format  The format being used to render the report
  *
  * @return  string array                              Set of text entries to display
  */
 function transform_grouping_header_label($grouping_current, $grouping, $datum, $export_format)
 {
     if ($grouping->id == 'studentname') {
         $user = new stdClass();
         $user->firstname = $datum->firstname;
         $user->lastname = $datum->lastname;
         $fullname = php_report::fullname($user);
         $result = array($this->add_grouping_header($grouping->label, $fullname, $export_format));
     } else {
         $result = array($this->add_grouping_header($grouping->label, $grouping_current[$grouping->field], $export_format));
     }
     return $result;
 }
 /**
  * Transforms a column-based header entry into the form required by the report
  *
  * @param   stdClass  $element        The record representing the current grouping row
  *                                    (including only fields that are part of that grouping row)
  * @param   stdClass  $datum          The record representing the current report row
  * @param   string    $export_format  The format being used to render the report
  * @uses    $CFG
  * @return  stdClass                  The current grouping row, in its final state
  */
 function transform_grouping_header_record($element, $datum, $export_format)
 {
     global $CFG;
     $induser_report_location = "{$CFG->wwwroot}/local/elisreports/render_report_page.php?report=individual_user&userid={$datum->userid}";
     //make this a link if we're in HTML format
     if ($export_format == php_report::$EXPORT_FORMAT_HTML) {
         $element->useridnumber = '<span class="external_report_link"><a href="' . $induser_report_location . '"" target="_blank">' . $element->useridnumber . '</a></span>';
     }
     if ($export_format != php_report::$EXPORT_FORMAT_CSV && $export_format != php_report::$EXPORT_FORMAT_EXCEL) {
         //use the user's full name
         $element->firstname = php_report::fullname($datum);
     }
     //make this a link if we're in HTML format
     if ($export_format == php_report::$EXPORT_FORMAT_HTML) {
         $element->firstname = '<span class="external_report_link"><a href="' . $induser_report_location . '"" target="_blank">' . $element->firstname . '</a></span>';
     }
     return $element;
 }
Пример #5
0
 /**
  * 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 stdClass();
     $user->firstname = $record->firstname;
     $user->lastname = $record->r_student;
     $fullname = php_report::fullname($user);
     if (property_exists($record, 'r_clst_name')) {
         //reformat userset name(s)
         if (empty($record->r_clst_name)) {
             $record->r_clst_name = get_string('na', 'local_elisreports');
         } elseif ($export_format == php_report::$EXPORT_FORMAT_EXCEL || $export_format == php_report::$EXPORT_FORMAT_CSV) {
             $record->r_clst_name = str_replace(',', '/', $record->r_clst_name);
         } else {
             $record->r_clst_name = str_replace(',', '<br>', $record->r_clst_name);
         }
     }
     if (isset($record->r_country)) {
         //get readable country
         $countries = get_string_manager()->get_list_of_countries();
         if (isset($countries[$record->r_country])) {
             $record->r_country = $countries[$record->r_country];
         }
     }
     if (isset($record->r_language)) {
         //get readable language
         $languages = get_string_manager()->get_list_of_languages();
         if (isset($languages[$record->r_language])) {
             $record->r_language = $languages[$record->r_language];
         }
     }
     if (isset($record->r_birthdate)) {
         //reformat the birthdate
         $record->r_birthdate = date('d F Y', strtotime($record->r_birthdate));
     }
     if (isset($record->r_gender)) {
         //get readable gender
         $record->r_gender = $record->r_gender == 'F' ? get_string('female', 'local_elisprogram') : get_string('male', 'local_elisprogram');
     }
     if (isset($record->r_inactive)) {
         //reformat inactive
         $record->r_inactive = $record->r_inactive ? get_string('yes') : get_string('no');
     }
     if ($export_format == php_report::$EXPORT_FORMAT_HTML) {
         $userpage = new userpage(array('id' => $record->cmuserid, 'action' => 'view'));
         $record->r_student = '<span class="external_report_link"><a href="' . $userpage->url . '">' . $fullname . '</a></span>';
     } else {
         if ($export_format != php_report::$EXPORT_FORMAT_CSV && $export_format != php_report::$EXPORT_FORMAT_EXCEL) {
             $record->r_student = $fullname;
         }
     }
     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;
     $showcurricula = $this->check_curricula();
     if (isset($record->id)) {
         //add a default curriculum name if appropriate
         if ($showcurricula && (empty($record->curid) || empty($record->name))) {
             if (!empty($record->preservecurname)) {
                 //actually corresponds to class enrolments
                 $record->name = get_string('noncurriculumcourses', $this->languagefile);
             } else {
                 //doesn't correspond to anything
                 $record->name = get_string('na', $this->languagefile);
             }
         }
         //link curriculum name to its "view" page if the the current record has a curriculum
         if ($export_format == table_report::$EXPORT_FORMAT_HTML && !empty($record->curid)) {
             $page = new curriculumpage(array('id' => $record->curid, 'action' => 'view'));
             if ($page->can_do()) {
                 $url = $page->url;
                 $record->name = '<span class="external_report_link">' . "<a href=\"{$url}\" target=\"_blank\">{$record->name}</a></span>";
             }
         }
         //base url
         $url = "{$CFG->wwwroot}/local/elisreports/render_report_page.php";
         //params being passed via url
         $url_params = array('report' => 'user_class_completion_details', 'filter-up-idnumber' => urlencode($record->useridnumber), 'filter-up-idnumber_op' => generalized_filter_text::$OPERATOR_IS_EQUAL_TO);
         $preferences = php_report_filtering_get_user_preferences($this->reportname);
         if (!empty($preferences)) {
             foreach ($preferences as $key => $val) {
                 // Determine if this is one of the completion range filter values
                 preg_match('/.+\\/(filter\\-completerange\\_[a-z]{3})/', $key, $matches);
                 if (isset($matches[1])) {
                     $url_params[$matches[1]] = $val;
                 }
             }
         }
         //used to track whether to add a ? or a &
         $first = true;
         foreach ($url_params as $key => $value) {
             //append the parameter to the url
             if ($first) {
                 $url .= '?';
             } else {
                 $url .= '&';
             }
             $url .= "{$key}={$value}";
             //signal the use of & on subsequent iterations
             $first = false;
         }
         //add parameters related to all these groups to the report
         $groupnames = array('filter-detailheaders', 'filter-detailcolumns');
         foreach ($groupnames as $groupname) {
             if ($first) {
                 $url .= '?';
             } else {
                 $url .= '&';
             }
             $url .= $this->get_param_url_string($groupname);
         }
         //extra attributes we are including in the anchor tag
         $tag_attributes = array('target' => '_blank');
         //build the additional attributes
         $attribute_string = '';
         foreach ($tag_attributes as $key => $value) {
             $attribute_string .= " {$key}={$value}";
         }
         // details label for the link.  First check to see if this is the first instance of the
         // student's record.  If so then show the details link.
         $record->id = '';
         if ($this->student_id_num != $record->useridnumber) {
             $link_text = get_string('details', $this->languagefile);
             $this->student_id_num = $record->useridnumber;
             $record->id = '<span class="external_report_link"><a href="' . $url . '"' . $attribute_string . '>' . $link_text . '</a></span>';
         }
     }
     //show link to user's profile based on capability to view the student management capability
     $fullname = php_report::fullname($record);
     if ($export_format == php_report::$EXPORT_FORMAT_HTML) {
         $userpage = new userpage(array('id' => $record->userid, 'action' => 'view'));
         if ($userpage->can_do()) {
             $record->lastname = '<span class="external_report_link"><a href="' . $userpage->url . '" target="_blank">' . $fullname . '</a></span>';
         } else {
             $record->lastname = $fullname;
         }
     } else {
         $record->lastname = $fullname;
     }
     //convert times to appropriate format
     if (!empty($record->timecompleted) && !empty($record->completed)) {
         $record->timecompleted = $this->format_date($record->timecompleted);
     } else {
         $record->timecompleted = get_string('na', $this->languagefile);
     }
     if (!empty($record->timeexpired) && !empty($record->completed)) {
         $record->timeexpired = $this->format_date($record->timeexpired);
     } else {
         $record->timeexpired = get_string('na', $this->languagefile);
     }
     //N/A for cretificate number if a valid one is not set
     if (empty($record->certificatecode) || empty($record->completed)) {
         $record->certificatecode = get_string('na', $this->languagefile);
     }
     //copy result of complex query into simple field
     if (!empty($record->numcredits)) {
         //use the provided value
         $record->displaynumcredits = $this->format_credits($record->numcredits);
     } else {
         //default to zero
         $record->displaynumcredits = $this->format_credits(0);
     }
     //handle custom field default values and display logic
     $this->transform_custom_field_data($record);
     return $record;
 }
 /**
  * Transforms a heading element displayed above the columns into a listing of such heading elements
  *
  * @param   string array           $grouping_current  Mapping of field names to current values in the grouping
  * @param   table_report_grouping  $grouping          Object containing all info about the current level of grouping
  *                                                    being handled
  * @param   stdClass               $datum             The most recent record encountered
  * @param   string    $export_format  The format being used to render the report
  *
  * @return  string array                              Set of text entries to display
  */
 function transform_grouping_header_label($grouping_current, $grouping, $datum, $export_format)
 {
     //TBD: dependencies for custom fields
     $labels = array();
     //user fullname
     if ($export_format == table_report::$EXPORT_FORMAT_HTML) {
         //label for this grouping element
         $text_label = get_string('grouping_name', $this->languagefile);
     } else {
         //label for all groupings
         $text_label = get_string('grouping_name_csv', $this->languagefile);
     }
     $fullname_text = php_report::fullname($datum);
     $labels[] = $this->add_grouping_header($text_label, $fullname_text, $export_format);
     $filters = php_report_filtering_get_active_filter_values($this->get_report_shortname(), 'filter-detailheaders', $this->filter);
     $headers = $filters[0]['value'];
     $this->_userfieldids = array();
     if (!empty($headers)) {
         foreach ($headers as $field => $active) {
             if ($active && substr($field, 0, 7) == 'custom_') {
                 $fieldid = substr($field, 7);
                 $this->_userfieldids[] = $fieldid;
             }
         }
     }
     //configured user custom fields
     if (!empty($this->_userfieldids)) {
         //only need to obtain the user information once
         $user = \local_elisprogram\context\user::instance($datum->userid);
         //add a row for each field
         foreach ($this->_userfieldids as $userfieldid) {
             $field = new field($userfieldid);
             //needed to store just the actual data value
             $rawdata = array();
             if ($customdata = field_data::get_for_context_and_field($user, $field)) {
                 //could potentially have multiple values
                 foreach ($customdata as $customdatum) {
                     if ($field->datatype == 'bool') {
                         //special display handling for boolean values
                         $rawdata[] = !empty($customdatum->data) ? get_string('yes') : get_string('no');
                     } else {
                         if (isset($field->owners['manual']) && ($manual = new field_owner($field->owners['manual'])) && $manual->param_control == 'datetime') {
                             //special display handling for datetime fields
                             $rawdata[] = $this->userdate($customdatum->data, get_string(!empty($manual->param_inctime) ? 'customfield_datetime_format' : 'customfield_date_format', $this->languagefile));
                         } else {
                             $rawdata[] = $customdatum->data;
                         }
                     }
                 }
             }
             $labels[] = $this->add_grouping_header($field->name . ': ', implode(', ', $rawdata), $export_format);
         }
     }
     //user address
     if (!empty($headers['user_address'])) {
         $text_label = get_string('grouping_address', $this->languagefile);
         $address_text = get_string('grouping_address_format', $this->languagefile, $datum);
         $labels[] = $this->add_grouping_header($text_label, $address_text, $export_format);
     }
     //user city / town
     if (!empty($headers['user_city'])) {
         $text_label = get_string('grouping_city', $this->languagefile);
         $labels[] = $this->add_grouping_header($text_label, $datum->city, $export_format);
     }
     //user state / province
     if (!empty($headers['user_state'])) {
         $text_label = get_string('grouping_state', $this->languagefile);
         $labels[] = $this->add_grouping_header($text_label, $datum->state, $export_format);
     }
     //user email address
     if (!empty($headers['user_email'])) {
         $text_label = get_string('grouping_email', $this->languagefile);
         $labels[] = $this->add_grouping_header($text_label, $datum->email, $export_format);
     }
     // Get the credit total
     $num_credits = $this->get_total_credits($grouping_current, $grouping, $datum, $export_format);
     //create the header item
     $text_label = get_string('grouping_credits', $this->languagefile);
     $labels[] = $this->add_grouping_header($text_label, $num_credits, $export_format);
     return $labels;
 }
 /**
  * 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 userpage(array('id' => $record->cmuserid, 'action' => 'view'));
         $record->firstname = '<span class="external_report_link"><a href="' . $userpage->url . '" target="_blank">' . php_report::fullname($record) . '</a></span>';
     } else {
         if ($export_format != php_report::$EXPORT_FORMAT_CSV && $export_format != php_report::$EXPORT_FORMAT_EXCEL) {
             $record->firstname = php_report::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-4916(ELIS-4439): now using ELIS grade!
     //if ($record->score === NULL || empty($record->grademax)) {
     if (!empty($record->elisgrade)) {
         $record->score = pm_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;
 }
Пример #9
0
 /**
  * Mainline for showing all jobs currently set up for an existing
  * report
  *
  * @uses $CFG
  * @uses $USER
  * @uses $OUTPUT
  * @uses $PAGE
  */
 function display_listinstancejobs()
 {
     global $CFG, $USER, $OUTPUT, $PAGE;
     //report specified by URL
     $report = $this->required_param('report', PARAM_ALPHAEXT);
     //get the necessary data
     $recordset = local_elisreports_get_report_jobs_recordset($report);
     //set up a job if none exist and a special parameter
     //is passed in to signal this functinality
     $createifnone = optional_param('createifnone', 0, PARAM_INT);
     if ($createifnone) {
         if (!$recordset or !$recordset->valid()) {
             //set up a job for this report
             $this->display_default();
             return;
         }
     }
     if ($recordset = local_elisreports_get_report_jobs_recordset($report) and $recordset->valid()) {
         //we actually have scheduled instances for this report
         //display appropriate headers
         $this->render_listinstancejobs_header(true, NULL, php_report::EXECUTION_MODE_SCHEDULED);
         //set up our form
         echo '<form action="' . $this->url . '" method="post">';
         //used by the "select all" functionality to identify a defining div
         echo '<div id="list_display">';
         echo '<input type="hidden" id="report" name="report" value="' . $report . '"/>';
         //table setup
         $table = new html_table();
         //headers, with a "select all" checkbox in the first column
         $PAGE->requires->js('/local/elisreports/js/lib.js');
         //checkbox for selecting all
         $checkbox_label = get_string('listinstancejobs_header_select', 'local_elisreports');
         $checkbox_attributes = array('onclick' => 'select_all()');
         $checkbox = html_writer::checkbox('selectall', '', false, $checkbox_label, $checkbox_attributes);
         $table->head = array($checkbox, get_string('listinstancejobs_header_label', 'local_elisreports'), get_string('listinstancejobs_header_owner', 'local_elisreports'), get_string('listinstancejobs_header_lastrun', 'local_elisreports'), get_string('listinstancejobs_header_nextrun', 'local_elisreports'), get_string('listinstancejobs_header_lastmodified', 'local_elisreports'));
         //left align all columns
         $table->align = array();
         foreach ($table->head as $column_header) {
             $table->align[] = 'left';
         }
         $table->data = array();
         //run through available schedules
         foreach ($recordset as $record) {
             $config_data = unserialize($record->config);
             $tz = $config_data['timezone'];
             //echo "action_listinstancejobs():: {$config_data['label']}: nextruntime = {$record->nextruntime}<br/>";
             //convert the last run time to the appropraite format
             if ($record->lastruntime == 0) {
                 //special case: never run before
                 $lastruntime = get_string('no_last_runtime', 'local_elisreports');
             } else {
                 $lastruntime = userdate($record->lastruntime, '', $tz) . ' (' . usertimezone($tz) . ')';
                 debug_error_log("/local/elisreports/lib/schedulelib.php::action_listinstancejobs(); {$config_data['label']}: record->lastruntime = {$record->lastruntime}, tz = {$tz}");
             }
             // convert 'will run next at' time to appropriate format
             $jobenddate = $config_data['schedule']['enddate'];
             debug_error_log("/local/elisreports/lib/schedulelib.php::action_listinstancejobs(); {$config_data['label']}: nextruntime = {$record->nextruntime}, jobenddate = {$jobenddate}");
             if (!empty($record->nextruntime) && (empty($jobenddate) || $record->nextruntime < $jobenddate + DAYSECS)) {
                 $nextruntime = userdate($record->nextruntime, '', $tz) . ' (' . usertimezone($tz) . ')';
             } else {
                 $nextruntime = get_string('job_completed', 'local_elisreports');
             }
             $checkbox = '<input type="checkbox" name="schedule_' . $record->scheduleid . '">';
             //link for editing this particular schedule instance
             $edit_schedule_params = array('id' => $record->scheduleid, 'action' => 'default');
             $edit_schedule_page = $this->get_new_page($edit_schedule_params);
             $edit_schedule_link = '<a href="' . $edit_schedule_page->url . '">' . $config_data['label'] . '</a>';
             //data row
             $table->data[] = array($checkbox, $edit_schedule_link, php_report::fullname($record), $lastruntime, $nextruntime, userdate($config_data['timemodified']));
         }
         echo html_writer::table($table);
         echo $OUTPUT->spacer();
         //display the dropdown and button in an enabled state
         $this->render_listinstancejobs_actions_dropdown(true);
         echo '</div>';
         echo '</form>';
     } else {
         //display header info
         $this->render_listinstancejobs_header(false, NULL, php_report::EXECUTION_MODE_SCHEDULED);
         //display the dropdown and button in a disabled state
         $this->render_listinstancejobs_actions_dropdown(false);
         echo $OUTPUT->spacer();
     }
     //general footer
     $this->render_listinstancejobs_footer();
 }
 /**
  * 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)
 {
     if ($export_format != php_report::$EXPORT_FORMAT_CSV && $export_format != php_report::$EXPORT_FORMAT_EXCEL) {
         $user = new stdClass();
         $user->firstname = $record->firstname;
         $user->lastname = $record->r_student;
         $record->r_student = php_report::fullname($user);
     }
     $record->curriculum_name = $record->curriculum_name == '' ? get_string('na', $this->lang_file) : $record->curriculum_name;
     $record->r_startdate = $record->r_startdate == 0 ? get_string('na', $this->lang_file) : $this->userdate($record->r_startdate, get_string('strftimedaydate'));
     return $record;
 }
Пример #11
0
 /**
  * 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)
 {
     if ($export_format != php_report::$EXPORT_FORMAT_CSV && $export_format != php_report::$EXPORT_FORMAT_EXCEL) {
         $record->lastname = php_report::fullname($record);
         //unset($record->firstname);
     }
     return $record;
 }
Пример #12
0
 /**
  * Transforms a column-based header entry into the form required by the report
  *
  * @param   stdClass  $element        The record representing the current grouping row
  *                                    (including only fields that are part of that grouping row)
  * @param   stdClass  $datum          The record representing the current report row
  * @param   string    $export_format  The format being used to render the report
  *
  * @return  stdClass                  The current grouping row, in its final state
  */
 function transform_grouping_header_record($element, $datum, $export_format)
 {
     global $CFG;
     /**
      * Correct formatting for certain fields
      **/
     require_once $CFG->dirroot . '/local/elisprogram/lib/data/student.class.php';
     /**
      * Set up link to individual user report
      **/
     $single_student_report_url = "{$CFG->wwwroot}/local/elisreports/render_report_page.php?report=individual_user&userid={$datum->userid}";
     // Use the datum object to get first and last name for fullname
     $fullname = php_report::fullname($datum);
     if ($export_format == php_report::$EXPORT_FORMAT_HTML) {
         $element->lastname = "<span class=\"external_report_link\">\n                             <a href=\"{$single_student_report_url}\">{$fullname}</a>\n                             </span>";
     } else {
         if ($export_format != php_report::$EXPORT_FORMAT_CSV && $export_format != php_report::$EXPORT_FORMAT_EXCEL) {
             $element->lastname = $fullname;
         }
     }
     return $element;
 }
 /**
  * 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, 'local_elisprogram');
     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 userpage(array('id' => $record->cmuserid, 'action' => 'view'));
         $record->firstname = '<span class="external_report_link"><a href="' . $userpage->url . '" target="_blank">' . php_report::fullname($record) . '</a></span>';
     } else {
         if ($export_format != php_report::$EXPORT_FORMAT_CSV && $export_format != php_report::$EXPORT_FORMAT_EXCEL) {
             $record->firstname = php_report::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);
     // ELIS-4916(ELIS-4439): now using ELIS grade!
     //if ($record->score === NULL || empty($record->grademax)) {
     if (!empty($record->elisgrade)) {
         $record->score = pm_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 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 = php_report::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 = pm_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;
 }