From ed40b90b030f96a3063fa1a7b206caa162bc2797 Mon Sep 17 00:00:00 2001 From: Sesostris Vieira Date: Thu, 13 Feb 2014 17:00:05 -0200 Subject: [PATCH] =?UTF-8?q?Modifica=C3=A7=C3=B5es=20solicitadas=20pela=20S?= =?UTF-8?q?=C3=B4nia=20no=20certificado?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- type/ILB_Sem_tutoria_2014/certificate.php | 76 +++++++++-------------- 1 file changed, 31 insertions(+), 45 deletions(-) diff --git a/type/ILB_Sem_tutoria_2014/certificate.php b/type/ILB_Sem_tutoria_2014/certificate.php index 2cb4b0b..d3f492b 100644 --- a/type/ILB_Sem_tutoria_2014/certificate.php +++ b/type/ILB_Sem_tutoria_2014/certificate.php @@ -29,47 +29,31 @@ if (!defined('MOODLE_INTERNAL')) { } /** - * Calcs the course start and end date to the user - * using user enrollment timestart and timeend + * Gets the course start date (for ILB start date is the date of enrollment) + * and completion date from course completion framework. + * Finally format them to print */ -require_once("$CFG->dirroot/enrol/locallib.php"); -$enrol_manager = new course_enrolment_manager($PAGE, $course); -$user_enrols = $enrol_manager->get_user_enrolments($USER->id); -$start_date = NULL; -$end_date = NULL; -foreach ($user_enrols as $enrol) { - if ($enrol->timestart > 0) { - $start_date = $enrol->timestart; - } - if ($enrol->timeend > 0) { - $end_date = $enrol->timeend; - } -} -if ($start_date > 0 and $end_date > 0) { - $fmt = '%d/%m/%Y'; // Default format - if ($certificate->datefmt == 1) { - $fmt = '%B %d, %Y'; - $certificatedate = userdate($ts, '%B %d, %Y') . " a " . userdate($te, '%B %d, %Y'); - } else if ($certificate->datefmt == 2) { - $suffix = certificate_get_ordinal_number_suffix(userdate($ts, '%d')); - $fmt = '%B %d' . $suffix . ', %Y'; - $certificatedate = userdate($ts, '%B %d' . $suffix . ', %Y') . " a " . userdate($te, '%B %d' . $suffix . ', %Y'); - } else if ($certificate->datefmt == 3) { - $fmt = '%d %B %Y'; - $certificatedate = userdate($ts, '%d %B %Y') . " a " . userdate($te, '%d %B %Y'); - } else if ($certificate->datefmt == 4) { - $fmt = '%B %Y'; - $certificatedate = userdate($ts, '%B %Y') . " a " . userdate($te, '%B %Y'); - } else if ($certificate->datefmt == 5) { - $fmt = get_string('strftimedate', 'langconfig'); - $certificatedate = userdate($ts, get_string('strftimedate', 'langconfig')) . " a " . userdate($te, get_string('strftimedate', 'langconfig')); - } - $start_date = userdate($start_date, $fmt); - $end_date = userdate($end_date, $fmt); -} else { - $start_date = ''; - $end_date = ''; +require_once("$CFG->dirroot/completion/completion_completion.php"); +$cc = new completion_completion(array('userid'=>$USER->id, 'course'=>$course->id)); + +$start_date = $cc->timeenrolled; +$end_date = $cc->timecompleted; + +$fmt = '%d/%m/%Y'; // Default format +if ($certificate->datefmt == 1) { + $fmt = '%B %d, %Y'; +} else if ($certificate->datefmt == 2) { + $suffix = certificate_get_ordinal_number_suffix(userdate($ts, '%d')); + $fmt = '%B %d' . $suffix . ', %Y'; +} else if ($certificate->datefmt == 3) { + $fmt = '%d %B %Y'; +} else if ($certificate->datefmt == 4) { + $fmt = '%B %Y'; +} else if ($certificate->datefmt == 5) { + $fmt = get_string('strftimedate', 'langconfig'); } +$start_date = userdate($start_date, $fmt); +$end_date = userdate($end_date, $fmt); $pdf = new PDF($certificate->orientation, 'mm', 'A4', true, 'UTF-8', false); @@ -141,14 +125,16 @@ certificate_print_image($pdf, $certificate, CERT_IMAGE_SIGNATURE, $sigx, $sigy, // Add text $pdf->SetTextColor(0, 0, 0); certificate_print_text($pdf, $x, $y, 'C', 'freesans', '', 20, get_string('title', 'certificate')); -certificate_print_text($pdf, $x, $y + 15, 'C', 'freesans', '', 20, get_string('certify', 'certificate')); -certificate_print_text($pdf, $x, $y + 27, 'C', 'freesans', 'B', 20, mystrtoupper(fullname($USER)).", CPF nº {$USER->profile['cpf']}"); -certificate_print_text($pdf, $x, $y + 39, 'C', 'freesans', '', 20, "realizou, no período de {$start_date} a {$end_date}, o curso sem tutoria"); -certificate_print_text($pdf, $x, $y + 51, 'C', 'freesans', 'B', 20, mystrtoupper($course->fullname)); +certificate_print_text($pdf, $x, $y + 15, 'C', 'freesans', '', 18, get_string('certify', 'certificate')); +certificate_print_text($pdf, $x, $y + 25, 'C', 'freesans', 'B', 18, mystrtoupper(fullname($USER)).", CPF nº {$USER->profile['cpf']}"); +certificate_print_text($pdf, $x, $y + 35, 'C', 'freesans', '', 18, "realizou, na modalidade a distância, o curso sem tutoria"); +certificate_print_text($pdf, $x, $y + 45, 'C', 'freesans', 'B', 18, mystrtoupper($course->fullname)); +certificate_print_text($pdf, $x, $y + 55, 'C', 'freesans', '', 18, "no período de {$start_date} a {$end_date}"); if ($certificate->printhours) { - certificate_print_text($pdf, $x, $y + 63, 'C', 'freesans', '', 20, "com carga horária de {$certificate->printhours} na modalidade a distância."); + certificate_print_text($pdf, $x, $y + 65, 'C', 'freesans', '', 18, "com carga horária de {$certificate->printhours}"); } -certificate_print_text($pdf, $x, $y + 82, 'R', 'freesans', 'B', 14, "Brasília, " . certificate_get_date($certificate, $certrecord, $course)); +certificate_print_text($pdf, $x, $y + 75, 'C', 'freesans', '', 18, certificate_get_grade($certificate, $course)); +certificate_print_text($pdf, $x, $y + 85, 'R', 'freesans', 'B', 14, "Brasília, " . certificate_get_date($certificate, $certrecord, $course)); // Verse page ----------------------------------------------------------------------------------------------------------- $pdf->AddPage();