From 6d8f7213167554e59cf566d9eb5b4cc54153ab38 Mon Sep 17 00:00:00 2001 From: Sesostris Vieira Date: Thu, 6 Feb 2014 14:20:30 -0200 Subject: [PATCH] =?UTF-8?q?Corre=C3=A7=C3=A3o=20do=20certificado=20para=20?= =?UTF-8?q?funcionar=20com=20certificate=20no=20Moodle=202.5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.php | 68 ++++++++++++++----------- lang/de/block_verify_certificate.php | 2 +- lang/en/block_verify_certificate.php | 2 +- lang/pt_br/block_verify_certificate.php | 2 +- 4 files changed, 41 insertions(+), 33 deletions(-) diff --git a/index.php b/index.php index 156c861..fbe0e84 100644 --- a/index.php +++ b/index.php @@ -3,44 +3,52 @@ require_once("../../config.php"); global $DB; - $id = required_param('certnumber', PARAM_ALPHANUM); // certificate code to verify + $code = required_param('certnumber', PARAM_ALPHANUM); // certificate code to verify - $PAGE->set_pagelayout('standard'); - $strverify = get_string('verifycertificate', 'block_verify_certificate'); - $PAGE->set_url('/blocks/verify_certificate/index.php', array('certnumber' => $id)); + $PAGE->set_pagelayout('standard'); + $strverify = get_string('verifycertificate', 'block_verify_certificate'); + $PAGE->set_url('/blocks/verify_certificate/index.php', array('certnumber' => $id)); $context = get_context_instance(CONTEXT_SYSTEM); $PAGE->set_context($context); - /// Print the header + /// Print the header $PAGE->navbar->add($strverify); $PAGE->set_title($strverify); $PAGE->set_heading($strverify); - $PAGE->requires->css('/blocks/verify_certificate/printstyle.css'); + $PAGE->requires->css('/blocks/verify_certificate/printstyle.css'); echo $OUTPUT->header(); - $certificate = $DB->get_records_sql("SELECT s.* - FROM {certificate_issues} s - WHERE s.code = ?", array($id)); - if (! $certificate) { - echo $OUTPUT->box_start('generalbox boxaligncenter'); + + // Print results + + echo $OUTPUT->box_start('generalbox boxaligncenter'); + if (!$issues = $DB->get_records('certificate_issues', array('code' => $code))) { echo get_string('notfound', 'block_verify_certificate'); - echo $OUTPUT->box_end(); } else { - echo $OUTPUT->box_start('generalbox boxaligncenter'); - echo "
"; - echo "
"; - /// Print Section - foreach ($certificate as $certrecord) { - $certificatedate = userdate($certrecord->timecreated); - echo '

' . get_string('certificate', 'block_verify_certificate') . ' ' . $certrecord->code . '

'; - echo '

' . get_string('to', 'block_verify_certificate') . ': ' . $certrecord->studentname . '
'; - echo '

' . get_string('course', 'block_verify_certificate') . ': ' . $certrecord->classname . '
'; - echo '

' . get_string('date', 'block_verify_certificate') . ': ' . $certificatedate . '

'; - if ($certrecord->reportgrade != null) { - echo '

' . get_string('grade', 'block_verify_certificate') . ': ' . $certrecord->reportgrade . '

'; - } - } - echo $OUTPUT->box_end(); - } - echo $OUTPUT->footer(); \ No newline at end of file + echo "
"; + echo "
"; + /// Print Section + foreach ($issues as $issue) { + if (!$certificate = $DB->get_record('certificate', array('id'=> $issue->certificateid))) { + print_error('course module is incorrect'); + } + if (!$course = $DB->get_record('course', array('id'=> $certificate->course))) { + print_error('course is misconfigured'); + } + if (!$user = $DB->get_record('user', array('id'=> $issue->userid))) { + print_error('user is unreachable'); + } + $certificatedate = userdate($issue->timecreated); + echo '

' . get_string('certificate', 'block_verify_certificate') . ' ' . $issue->code . '

'; + echo '

' . get_string('to', 'block_verify_certificate') . ': ' . fullname($user) . '
'; + echo '

' . get_string('course', 'block_verify_certificate') . ': ' . $course->fullname . '
'; + echo '

' . get_string('date', 'block_verify_certificate') . ': ' . $certificatedate . '

'; + if ($certificate->customtext !== '') { + echo '

' . get_string('customtext', 'block_verify_certificate') . ':

'; + echo $certificate->customtext; + } + } + } + echo $OUTPUT->box_end(); + echo $OUTPUT->footer(); diff --git a/lang/de/block_verify_certificate.php b/lang/de/block_verify_certificate.php index e863964..67b6920 100644 --- a/lang/de/block_verify_certificate.php +++ b/lang/de/block_verify_certificate.php @@ -8,4 +8,4 @@ $string['to'] = 'Zuerkannt'; $string['course'] = 'Kurs'; $string['date'] = 'Am'; $string['grade'] = 'Bewertung'; - +$string['customtext'] = 'Kurs details'; diff --git a/lang/en/block_verify_certificate.php b/lang/en/block_verify_certificate.php index 577be95..4c91c98 100644 --- a/lang/en/block_verify_certificate.php +++ b/lang/en/block_verify_certificate.php @@ -8,4 +8,4 @@ $string['to'] = 'Awarded to'; $string['course'] = 'Course'; $string['date'] = 'On'; $string['grade'] = 'Grade'; - +$string['customtext'] = 'Course details'; diff --git a/lang/pt_br/block_verify_certificate.php b/lang/pt_br/block_verify_certificate.php index dcd37b4..b562690 100644 --- a/lang/pt_br/block_verify_certificate.php +++ b/lang/pt_br/block_verify_certificate.php @@ -8,4 +8,4 @@ $string['to'] = 'Emitido para'; $string['course'] = 'Curso'; $string['date'] = 'Data'; $string['grade'] = 'Nota'; - +$string['customtext'] = 'Programa do curso';