/**
  * 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->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->get_url();
                 $record->name = '<a href="' . $url . '" target="_blank">' . $record->name . '</a>';
             }
         }
         //base url
         $url = "{$CFG->wwwroot}/blocks/php_report/render_report_page.php";
         //params being passed via url
         $url_params = array('report' => 'user_class_completion_details', 'idnumber' => urlencode($record->useridnumber), 'idnumber_op' => generalized_filter_text::$OPERATOR_IS_EQUAL_TO);
         //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('class' => 'external_report_link', '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.
         $link_text = '';
         if (0 != strcmp($this->student_id_num, $record->useridnumber)) {
             $link_text = get_string('details', $this->languagefile);
             $this->student_id_num = $record->useridnumber;
         }
         if ($export_format == table_report::$EXPORT_FORMAT_HTML) {
             //replace the empty column with the appropriate link
             $record->id = '<a href="' . $url . '"' . $attribute_string . '>' . $link_text . '</a>';
         } else {
             //in an export, so don't show link
             $record->id = '';
         }
     }
     //show link to user's profile based on capability to view the student management capability
     $fullname = fullname($record);
     if ($export_format == php_report::$EXPORT_FORMAT_HTML) {
         $userpage = new usermanagementpage(array('id' => $record->userid, 'action' => 'view'));
         if ($userpage->can_do()) {
             $record->lastname = '<span class="external_report_link"><a href="' . $userpage->get_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;
 }
 /**
  * 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 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
  *
  * @return  stdClass                  The reformatted record
  */
 function transform_record($record, $export_format)
 {
     $user = new user();
     $user->firstname = $record->firstname;
     $user->lastname = $record->r_student;
     $fullname = fullname($user);
     $userpage = new usermanagementpage(array('id' => $record->cmuserid, 'action' => 'view'));
     if ($export_format == php_report::$EXPORT_FORMAT_HTML) {
         $record->r_student = '<span class="external_report_link"><a href="' . $userpage->get_url() . '">' . $fullname . '</a></span>';
     } else {
         $record->r_student = $fullname;
     }
     return $record;
 }