/** * Handles rendering the element on the pdf. * * @param pdf $pdf the pdf object * @param bool $preview true if it is a preview, false otherwise */ public function render($pdf, $preview) { global $DB; $teacher = $DB->get_record('user', array('id' => $this->element->data)); $teachername = fullname($teacher); parent::render_content($pdf, $teachername); }
/** * Handles rendering the element on the pdf. * * @param pdf $pdf the pdf object * @param bool $preview true if it is a preview, false otherwise */ public function render($pdf, $preview) { global $DB; // Check that the grade item is not empty. if (!empty($this->element->data)) { // Get the course module information. $cm = $DB->get_record('course_modules', array('id' => $this->element->data), '*', MUST_EXIST); $module = $DB->get_record('modules', array('id' => $cm->module), '*', MUST_EXIST); // Get the name of the item. $itemname = $DB->get_field($module->name, 'name', array('id' => $cm->instance), MUST_EXIST); parent::render_content($pdf, $itemname); } }
/** * Handles rendering the element on the pdf. * * @param pdf $pdf the pdf object * @param bool $preview true if it is a preview, false otherwise */ public function render($pdf, $preview) { global $DB, $USER; if ($preview) { $code = customcert_generate_code(); } else { // Get the page. $page = $DB->get_record('customcert_pages', array('id' => $this->element->pageid), '*', MUST_EXIST); // Now we can get the issue for this user. $issue = $DB->get_record('customcert_issues', array('userid' => $USER->id, 'customcertid' => $page->customcertid), '*', MUST_EXIST); $code = $issue->code; } parent::render_content($pdf, $code); }
/** * Handles rendering the element on the pdf. * * @param pdf $pdf the pdf object * @param bool $preview true if it is a preview, false otherwise */ public function render($pdf, $preview) { global $DB, $USER; // The user field to display. $field = $this->element->data; // The value to display on the PDF. $value = ''; if (is_number($field)) { // Must be a custom user profile field. if ($field = $DB->get_record('user_info_field', array('id' => $field))) { $value = $USER->profile[$field->shortname]; } } else { if (!empty($USER->{$field})) { // Field in the user table. $value = $USER->{$field}; } } parent::render_content($pdf, $value); }
/** * Handles rendering the element on the pdf. * * @param pdf $pdf the pdf object * @param bool $preview true if it is a preview, false otherwise */ public function render($pdf, $preview) { parent::render_content($pdf, $this->element->data); }
/** * Handles rendering the element on the pdf. * * @param pdf $pdf the pdf object * @param bool $preview true if it is a preview, false otherwise */ public function render($pdf, $preview) { global $DB, $COURSE; $categoryname = $DB->get_field('course_categories', 'name', array('id' => $COURSE->category), MUST_EXIST); parent::render_content($pdf, $categoryname); }
/** * Handles rendering the element on the pdf. * * @param pdf $pdf the pdf object * @param bool $preview true if it is a preview, false otherwise */ public function render($pdf, $preview) { global $COURSE, $DB, $USER; // If there is no element data, we have nothing to display. if (empty($this->element->data)) { return; } // Decode the information stored in the database. $dateinfo = json_decode($this->element->data); $dateitem = $dateinfo->dateitem; $dateformat = $dateinfo->dateformat; // If we are previewing this certificate then just show a demonstration date. if ($preview) { $date = time(); } else { // Get the page. $page = $DB->get_record('customcert_pages', array('id' => $this->element->pageid), '*', MUST_EXIST); // Now we can get the issue for this user. $issue = $DB->get_record('customcert_issues', array('userid' => $USER->id, 'customcertid' => $page->customcertid), '*', MUST_EXIST); if ($dateitem == CUSTOMCERT_DATE_ISSUE) { $date = $issue->timecreated; } else { if ($dateitem == CUSTOMCERT_DATE_COMPLETION) { // Get the enrolment end date. $sql = "SELECT MAX(c.timecompleted) as timecompleted\n FROM {course_completions} c\n WHERE c.userid = :userid\n AND c.course = :courseid"; if ($timecompleted = $DB->get_record_sql($sql, array('userid' => $issue->userid, 'courseid' => $COURSE->id))) { if (!empty($timecompleted->timecompleted)) { $date = $timecompleted->timecompleted; } } } else { $gradeitem = new stdClass(); $gradeitem->gradeitem = $dateitem; $gradeitem->gradeformat = GRADE_DISPLAY_TYPE_PERCENTAGE; if ($modinfo = customcert_element_grade::get_grade($gradeitem, $issue->userid)) { $date = $modinfo->dategraded; } } } } // Ensure that a date has been set. if (!empty($date)) { switch ($dateformat) { case 1: $certificatedate = userdate($date, '%B %d, %Y'); break; case 2: $suffix = $this->get_ordinal_number_suffix(userdate($date, '%d')); $certificatedate = userdate($date, '%B %d' . $suffix . ', %Y'); break; case 3: $certificatedate = userdate($date, '%d %B %Y'); break; case 4: $certificatedate = userdate($date, '%B %Y'); break; default: $certificatedate = userdate($date, get_string('strftimedate', 'langconfig')); } parent::render_content($pdf, $certificatedate); } }
/** * Handles rendering the element on the pdf. * * @param pdf $pdf the pdf object * @param bool $preview true if it is a preview, false otherwise */ public function render($pdf, $preview) { global $COURSE, $USER; // If there is no element data, we have nothing to display. if (empty($this->element->data)) { return; } // Decode the information stored in the database. $gradeinfo = json_decode($this->element->data); // If we are previewing this certificate then just show a demonstration grade. if ($preview) { $courseitem = grade_item::fetch_course_item($COURSE->id); $grade = grade_format_gradevalue('100', $courseitem, true, $gradeinfo->gradeformat, 2); } else { // Get the grade for the grade item. $grade = self::get_grade($gradeinfo, $USER->id); } parent::render_content($pdf, $grade); }
/** * Handles rendering the element on the pdf. * * @param pdf $pdf the pdf object * @param bool $preview true if it is a preview, false otherwise */ public function render($pdf, $preview) { global $COURSE; parent::render_content($pdf, $COURSE->fullname); }
/** * Handles rendering the element on the pdf. * * @param pdf $pdf the pdf object * @param bool $preview true if it is a preview, false otherwise */ public function render($pdf, $preview) { global $USER; parent::render_content($pdf, fullname($USER)); }