Browse Source

Opção de imprimir campos de perfil na validação do certificado

MOODLE_34_STABLE
Sesostris Vieira 11 years ago
parent
commit
121945ad02
  1. 10
      block_verify_certificate.php
  2. 14
      index.php
  3. 2
      lang/de/block_verify_certificate.php
  4. 2
      lang/en/block_verify_certificate.php
  5. 2
      lang/pt_br/block_verify_certificate.php

10
block_verify_certificate.php

@ -11,10 +11,10 @@ class block_verify_certificate extends block_base {
}
function get_content() {
if ($this->content !== NULL) {
return $this->content;
}
$fieldid = implode(',', $this->config->fieldid);
$this->content = new stdClass;
$this->content->text = '<p>'.get_string('entercode', 'certificate').'</p>';
@ -22,6 +22,7 @@ class block_verify_certificate extends block_base {
$this->content->text .= '<center><form class="loginform" name="cert" method="post" action="'. $url . '">';
$this->content->text .= '<input type="text" name="certnumber" id="certnumber" size="10" value="" />';
$this->content->text .= "<input type='hidden' name='list' id='list' value='{$fieldid}' />";
$this->content->text .= '<input type="submit" value="'.get_string('validate', 'certificate').'"/></form>';
$this->content->text .= '<center>';
$this->content->footer = '';
@ -29,7 +30,12 @@ class block_verify_certificate extends block_base {
return $this->content;
}
/* function has_config() {
return true;
}
*/
function instance_allow_config() {
return false;
return true;
}
}

14
index.php

@ -1,14 +1,19 @@
<?php
require_once("../../config.php");
require_once("$CFG->dirroot/enrol/locallib.php");
require_once("$CFG->libdir/blocklib.php");
require_once("$CFG->dirroot/user/profile/lib.php");
global $DB;
$code = required_param('certnumber', PARAM_ALPHANUM); // certificate code to verify
$fieldid = required_param('list', PARAM_SEQUENCE);
$fieldid = explode(',', $fieldid);
$profile_fields = $DB->get_records_list('user_info_field', 'id', $fieldid);
$PAGE->set_pagelayout('standard');
$strverify = get_string('verifycertificate', 'block_verify_certificate');
$PAGE->set_url('/blocks/verify_certificate/index.php', array('certnumber' => $id));
$PAGE->set_url('/blocks/verify_certificate/index.php', array('certnumber' => $code));
$context = get_context_instance(CONTEXT_SYSTEM);
$PAGE->set_context($context);
@ -42,6 +47,8 @@ global $DB;
print_error('user is unreachable');
}
profile_load_data($user);
$enrol_manager = new course_enrolment_manager($PAGE, $course);
$user_enrols = $enrol_manager->get_user_enrolments($user->id);
$start_date = 0;
@ -83,6 +90,11 @@ global $DB;
$certificatedate = userdate($issue->timecreated);
echo '<p>' . get_string('certificate', 'block_verify_certificate') . " <strong>{$issue->code}</strong></p>";
echo '<p><strong>' . get_string('to', 'block_verify_certificate') . ': </strong>' . fullname($user) . '</p>';
foreach ($profile_fields as $field) {
$fieldname = "profile_field_{$field->shortname}";
$fieldvalue = $user->$fieldname;
echo "<p><strong>{$field->name}: <strong>{$fieldvalue}";
}
echo '<p><strong>' . get_string('course', 'block_verify_certificate') . ": </strong>{$course->fullname}</p>";
echo '<p><strong>' . get_string('date', 'block_verify_certificate') . ": </strong>$certificatedate</p>";
echo '<p><strong>' . get_string('enrol_period', 'block_verify_certificate') . ": </strong>$start_date - $end_date</p>";

2
lang/de/block_verify_certificate.php

@ -11,3 +11,5 @@ $string['grade'] = 'Bewertung';
$string['customtext'] = 'Kurs details';
$string['enrol_period'] = 'Einschreiben Zeitraum';
$string['printhours'] = 'Stunden';
$string['chooseprofilefields'] = 'Wählen Sie Profilfelder angezeigt';
$string['nofields'] = 'Kein ProfilFeld definiert';

2
lang/en/block_verify_certificate.php

@ -11,3 +11,5 @@ $string['grade'] = 'Grade';
$string['customtext'] = 'Course details';
$string['enrol_period'] = 'Enroll period';
$string['printhours'] = 'Hours';
$string['chooseprofilefields'] = 'Choose profilefields to display';
$string['nofields'] = 'No profilefields defined';

2
lang/pt_br/block_verify_certificate.php

@ -11,3 +11,5 @@ $string['grade'] = 'Nota';
$string['customtext'] = 'Programa do curso';
$string['enrol_period'] = 'Período de realização';
$string['printhours'] = 'Carga horária';
$string['chooseprofilefields'] = 'Escolha os campos de perfil para mostrar';
$string['nofields'] = 'Nenhum campo de perfil definido';

Loading…
Cancel
Save