/** * Handle showing the box that allows a user to mark a unit as completed. */ function WPCW_units_processUnitContent($content) { // #### Ensure we're only showing a course unit, a single item if (!is_single() || 'course_unit' != get_post_type()) { return $content; } // Use object to handle the rendering of the unit on the frontend. include_once WPCW_plugin_getPluginDirPath() . 'classes/class_frontend_unit.inc.php'; global $post; $fe = new WPCW_UnitFrontend($post); // #### Get associated data for this unit. No course/module data, then it's not a unit if (!$fe->check_unit_doesUnitHaveParentData()) { return $content; } // #### Ensure we're logged in if (!$fe->check_user_isUserLoggedIn()) { return $fe->message_user_notLoggedIn(); } // #### User not allowed access to content, so certainly can't say they've done this unit. if (!$fe->check_user_canUserAccessCourse()) { return $fe->message_user_cannotAccessCourse(); } // #### Is user allowed to access this unit yet? if (!$fe->check_user_canUserAccessUnit()) { return $fe->message_user_cannotAccessUnit(); } // ### Do the remaining rendering... return $fe->render_detailsForUnit($content); }
<?php /** * WP Courseware * * Functions relating to modifying a quiz. */ include_once WPCW_plugin_getPluginDirPath() . 'classes/class_custom_feedback.inc.php'; /** * Function that allows a quiz to be created or edited. */ function WPCW_showPage_ModifyQuiz_load() { // Thickbox needed for random and quiz windows. add_thickbox(); $page = new PageBuilder(true); $quizDetails = false; $adding = false; $quizID = false; // Check POST and GET if (isset($_GET['quiz_id'])) { $quizID = $_GET['quiz_id'] + 0; } else { if (isset($_POST['quiz_id'])) { $quizID = $_POST['quiz_id'] + 0; } } // Trying to edit a quiz if ($quizDetails = WPCW_quizzes_getQuizDetails($quizID, false, false, false)) { // Abort if quiz not found. if (!$quizDetails) {
/** * Works out if we're showing any custom feedback messages to the user. * @return $resultsList The list of messages to show (or an empty array). */ function fetch_customFeedbackMessage_calculateMessages() { $resultsList = array(); // #### 1) - Check we have graded questions for a quiz if ($this->check_quizzes_validQuizDetails() && $this->unitQuizProgress && 'survey' != $this->unitQuizDetails->quiz_type && $this->unitQuizProgress->quiz_needs_marking == 0) { // #### 2) - See if we have any tag grades for this quiz $tagBucketList = $this->fetch_quizzes_questionResultsByTag(); // No tags to check data against if (empty($tagBucketList)) { return $resultsList; } // #### 3) - See if we have any feedback messages for this quiz using // a combination of the tags from above, and the quiz ID. This saves // how much data we load from the database. $tagIDList = array_keys($tagBucketList); $feedbackList = WPCW_quizzes_feedback_getFeedbackMessagesForQuiz($this->unitQuizDetails->quiz_id, $tagIDList); // #### 4) - Now we process each feedback message to see if it matches the criteria. if (!empty($feedbackList)) { // Now include custom feedback class, as we need it. include_once WPCW_plugin_getPluginDirPath() . 'classes/class_custom_feedback.inc.php'; foreach ($feedbackList as $feedbackItem) { $fb = new WPCW_quiz_CustomFeedback($this->unitQuizDetails->quiz_id, $feedbackItem); // See if the message matches the feedback we've got. if ($fb->doesMessageMatchCriteria($tagBucketList)) { $resultsList[] = $fb->getMessage(); } //echo $fb->generate_editForm(); } } // end if $feedbackList. } // end if quiz check return $resultsList; }
/** * Generate the certificate PDF. * * @param String $student The name of the student. * @param String $courseName The name of the course. */ function generatePDF($student, $courseName, $showMode = 'download') { $topLineY = 45; // Set the background image $bgType = WPCW_arrays_getValue($this->settingsList, 'cert_background_type', 'use_default'); $bgImg = WPCW_arrays_getValue($this->settingsList, 'cert_background_custom_url'); // Use custom image if ($bgType == 'use_custom') { if ($bgImg) { $this->pdffile->Image($bgImg, 0, 0, $this->size_width, $this->size_height); } } else { $this->pdffile->Image(WPCW_plugin_getPluginDirPath() . 'img/certificates/certificate_bg.jpg', 0, 0, $this->size_width, $this->size_height); } // ...Certify... $this->pdffile->SetFont('Helvetica', 'B', 32); $this->centerString(strtoupper(__('This is to certify that', 'wp_courseware')), $topLineY); // Name with a line underneath $this->pdffile->SetFont('ArchitectsDaughter', '', 16); $this->centerString($student, $topLineY + 20); $this->centerLine(120, $topLineY + 24); // ...Completed... $this->pdffile->SetFont('Helvetica', 'B', 32); $this->centerString(strtoupper(__('has successfully completed', 'wp_courseware')), $topLineY + 50); // Course $this->pdffile->SetFont('ArchitectsDaughter', '', 16); $this->centerString($courseName, $topLineY + 70); $this->centerLine(180, $topLineY + 74); $this->footer_line_length = 60; $this->footer_Y = 162; $footer_font_size = 15; $date_X = 40; $this->signature_X = $this->size_width - 100; $this->pdffile->SetFont('Helvetica', '', 14); // Date - field $this->pdffile->SetXY($date_X, $this->footer_Y + 8); $this->pdffile->Cell(0, 0, __('Date', 'wp_courseware'), false, false, 'L'); // Signature - field $this->pdffile->SetXY($this->signature_X, $this->footer_Y + 8); $this->pdffile->Cell(0, 0, __('Instructor', 'wp_courseware'), false, false, 'L'); // Lines - Date, Signature $this->pdffile->Line($date_X, $this->footer_Y + 3, $date_X + $this->footer_line_length, $this->footer_Y + 3); $this->pdffile->Line($this->signature_X, $this->footer_Y + 3, $this->signature_X + $this->footer_line_length, $this->footer_Y + 3); // Date - the date itself. Centre on the line $this->pdffile->SetFont('ArchitectsDaughter', '', $footer_font_size); // Use local date $date_localFormat = get_option('date_format'); $date_str = date_i18n($date_localFormat, current_time('timestamp')); $date_str_len = $this->pdffile->GetStringWidth($date_str); $this->pdffile->SetXY($date_X + ($this->footer_line_length - $date_str_len) / 2, $this->footer_Y); $this->pdffile->Cell(0, 0, $date_str, false, false); // Signature - signature itself $this->render_handleSignature(); // Logo - handle rendering a logo if one exists $this->render_handleLogo(); // Change output based on what's been specified as a parameter. if ('browser' == $showMode) { $this->pdffile->Output('certificate.pdf', 'I'); } else { $this->pdffile->Output('certificate.pdf', 'D'); } }
<?php /** * Frontend only AJAX functions. */ include_once 'frontend_only.inc.php'; // Ensure we have frontend functions // Use object to handle the rendering of the unit on the frontend. include_once WPCW_plugin_getPluginDirPath() . 'classes/class_frontend_unit.inc.php'; /** * Function called when user is requesting a retake of a quiz. Lots of checking * needs to go on here for security reasons to ensure that they don't manipulate * their own progress (or somebody elses). */ function WPCW_AJAX_units_handleQuizRetakeRequest() { // Security check if (!wp_verify_nonce(WPCW_arrays_getValue($_POST, 'progress_nonce'), 'wpcw-progress-nonce')) { die(__('Security check failed!', 'wp_courseware')); } // Get unit and quiz ID $unitID = intval(WPCW_arrays_getValue($_POST, 'unitid')); $quizID = intval(WPCW_arrays_getValue($_POST, 'quizid')); // Get the post object for this quiz item. $post = get_post($unitID); if (!$post) { echo WPCW_UnitFrontend::message_createMessage_error(__('Error - could not request a retake for the quiz.', 'wp_courseware') . ' ' . __('Could not find training unit.', 'wp_courseware')); die; } // Initalise the unit details $fe = new WPCW_UnitFrontend($post);
/** * Generate the certificate PDF. * * @param String $student The name of the student. * @param String $courseName The name of the course. * @param String $certificateDetails The raw certificate details. * @param String $showMode What type of export to do. ('download' to force a download or 'browser' to do it inline.) */ function generatePDF($student, $courseName, $certificateDetails, $showMode = 'download') { // Do codepage conversions of text used in the certificate. $encoding = WPCW_arrays_getValue($this->settingsList, 'certificate_encoding', 'ISO-8859-1'); // GW 150217 Umlaute zerschießen hier alles! // GW 150217 $student = iconv('UTF-8', $encoding.'//TRANSLIT//IGNORE', $student); // GW 150114 Umlaute zerschießen hier alles! // GW 150114 $courseName = iconv('UTF-8', $encoding.'//TRANSLIT//IGNORE', $courseName); // GW 150119 $topLineY = 45; // Beginn der gesamten Ausgabe $topLineY = 95; // Set the background image $bgType = WPCW_arrays_getValue($this->settingsList, 'cert_background_type', 'use_default'); $bgImg = WPCW_arrays_getValue($this->settingsList, 'cert_background_custom_url'); // Disable auto-page-break $this->pdffile->SetAutoPageBreak(false, 0); // Use custom image if ($bgType == 'use_custom') { if ($bgImg) { $this->pdffile->Image($bgImg, 0, 0, $this->size_width, $this->size_height); } } else { $this->pdffile->Image(WPCW_plugin_getPluginDirPath() . 'img/certificates/certificate_bg.jpg', 0, 0, 297, 210, '', '', '', false, 300, '', false, false, 0); } // ...Certify... $this->pdffile->SetFont('Helvetica', 'B', 28); // GW 150114 ... war 30 $this->centerString(strtoupper(__('This is to certify that', 'wp_courseware')), $topLineY); // Name with a line underneath $this->pdffile->SetFont('ArchitectsDaughter', '', 16, false, false); // GW 150122 ... war $this->centerString($student, $topLineY + 20); // GW 150122 ... war $this->centerLine(120, $topLineY + 27); $this->centerString($student, $topLineY + 35); $this->centerLine(120, $topLineY + 42); // ...Completed... // GW 150119 $this->pdffile->SetFont('Helvetica','B', 28); $this->pdffile->SetFont('Helvetica', 'B', 16); // GW 150114 ... war 30 // GW 150122 ... war $this->centerString(strtoupper(__('has successfully completed', 'wp_courseware')), $topLineY + 50); $this->centerString(strtoupper(__('has successfully completed', 'wp_courseware')), $topLineY + 60); // Course $this->pdffile->SetFont('ArchitectsDaughter', '', 16); // GW 150122 ... $this->centerString($courseName, $topLineY + 70); // GW 150122 ... $this->centerLine(180, $topLineY + 77); $this->centerString($courseName, $topLineY + 85); $this->centerLine(180, $topLineY + 92); $this->footer_line_length = 60; // GW 150119 $this->footer_Y = 162; $this->footer_Y = 250; $footer_font_size = 15; $date_X = 40; $this->signature_X = $this->size_width - 100; $this->pdffile->SetFont('Helvetica', '', 14); // Date - field $this->pdffile->SetXY($date_X, $this->footer_Y + 8); $this->pdffile->Cell(0, 0, __('Date', 'wp_courseware'), false, false, 'L'); // Signature - field $this->pdffile->SetXY($this->signature_X, $this->footer_Y + 8); $this->pdffile->Cell(0, 0, __('Instructor', 'wp_courseware'), false, false, 'L'); // Lines - Date, Signature $this->pdffile->Line($date_X, $this->footer_Y + 7, $date_X + $this->footer_line_length, $this->footer_Y + 7); $this->pdffile->Line($this->signature_X, $this->footer_Y + 7, $this->signature_X + $this->footer_line_length, $this->footer_Y + 7); // Date - the date itself. Centre on the line $this->pdffile->SetFont('ArchitectsDaughter', '', $footer_font_size); // Use date of completion if available from certificate details $completeDate = false; if ($certificateDetails && $certificateDetails->cert_generated) { $completeDate = strtotime($certificateDetails->cert_generated); } // Use current date if not available. if ($completeDate <= 0) { $completeDate = current_time('timestamp'); } $date_localFormat = get_option('date_format'); $date_str = date_i18n($date_localFormat, $completeDate); $date_str_len = $this->pdffile->GetStringWidth($date_str); $this->pdffile->SetXY($date_X + ($this->footer_line_length - $date_str_len) / 2, $this->footer_Y); $this->pdffile->Cell(0, 0, $date_str, false, false); // Signature - signature itself $this->render_handleSignature(); // Logo - handle rendering a logo if one exists $this->render_handleLogo(); // Change output based on what's been specified as a parameter. if ('browser' == $showMode) { // GW 150120 - war: certificate.pdf (2x) $this->pdffile->Output('Teilnahme-Zertifikat.pdf', 'I'); } else { $this->pdffile->Output('Teilnahme-Zertifikat.pdf', 'D'); } }
/** * Generate the certificate PDF. * * @param String $student The name of the student. * @param String $courseName The name of the course. * @param String $certificateDetails The raw certificate details. * @param String $showMode What type of export to do. ('download' to force a download or 'browser' to do it inline.) */ function generatePDF($student, $courseName, $certificateDetails, $showMode = 'download') { // Do codepage conversions of text used in the certificate. $encoding = WPCW_arrays_getValue($this->settingsList, 'certificate_encoding', 'ISO-8859-1'); // GW 150217 Umlaute zerschießen hier alles! // GW 150217 $student = iconv('UTF-8', $encoding.'//TRANSLIT//IGNORE', $student); // GW 150114 Umlaute zerschießen hier alles! // GW 150114 $courseName = iconv('UTF-8', $encoding.'//TRANSLIT//IGNORE', $courseName); // GW 150119 $topLineY = 45; // Beginn der gesamten Ausgabe $topLineY = 35; // Set the background image $bgType = WPCW_arrays_getValue($this->settingsList, 'cert_background_type', 'use_default'); $bgImg = WPCW_arrays_getValue($this->settingsList, 'cert_background_custom_url'); // Disable auto-page-break $this->pdffile->SetAutoPageBreak(false, 0); // Use custom image if ($bgType == 'use_custom') { if ($bgImg) { $this->pdffile->Image($bgImg, 0, 0, $this->size_width, $this->size_height); } } else { $this->pdffile->Image(WPCW_plugin_getPluginDirPath() . 'img/certificates/certificate_bg.jpg', 0, 0, 297, 210, '', '', '', false, 300, '', false, false, 0); } $topLineY += 3; $this->pdffile->SetFont('Helvetica', '', 6); $this->pdffile->SetXY(145, $topLineY); $this->pdffile->Cell(0, 0, 'Urlaubs- und Lohnausgleichskasse der Bauwirtschaft', false, false); $topLineY += 2; $this->pdffile->SetXY(145, $topLineY); $this->pdffile->Cell(0, 0, 'Zusatzversorgungskasse des Baugewerbes AG', false, false); $topLineY += 8; // Ich habe an der ... teilgenommen $this->pdffile->SetFont('Helvetica', 'B', 16); $this->centerString('Ich habe an der Datenschutz-Schulung und dem', $topLineY); $topLineY += 6; $this->centerString('Verständnistest für Beschäftigte bei SOKA-BAU teilgenommen.', $topLineY); $topLineY += 27; // Date - the date itself. Centre on the line $this->pdffile->SetFont('Helvetica', '', 14); // Use date of completion if available from certificate details $completeDate = false; if ($certificateDetails && $certificateDetails->cert_generated) { $completeDate = strtotime($certificateDetails->cert_generated); } // Use current date if not available. if ($completeDate <= 0) { $completeDate = current_time('timestamp'); } $date_localFormat = get_option('date_format'); $date_str = date_i18n($date_localFormat, $completeDate); $date_str_kopie = $date_str; // GW 150225 Datum doch nich anzeigen $date_str = ", den " . $date_str; $date_str = ", den "; $date_str_len = $this->pdffile->GetStringWidth($date_str); $this->pdffile->SetXY(70, $topLineY); $this->pdffile->Cell(0, 0, $date_str, false, false); $topLineY += 6; // Ort, Datum, Unterschrift $three_line_length = 57; // Ort $ort_X = 10; $this->pdffile->SetFont('Helvetica', '', 12); $str_N = 'Ort'; $str_W = $this->pdffile->GetStringWidth($str_N); $new_X = $ort_X + $three_line_length / 2 - $str_W / 2; $new_X = round($new_X); $this->pdffile->SetXY($new_X, $topLineY); $this->pdffile->Cell(0, 0, $str_N, false, false, 'L'); $this->pdffile->Line($ort_X, $topLineY, $ort_X + $three_line_length, $topLineY); // Datum $datum_X = 77; $this->pdffile->SetFont('Helvetica', '', 12); $str_N = 'Datum'; $str_W = $this->pdffile->GetStringWidth($str_N); $new_X = $datum_X + $three_line_length / 2 - $str_W / 2; $new_X = round($new_X); $this->pdffile->SetXY($new_X, $topLineY); $this->pdffile->Cell(0, 0, $str_N, false, false, 'L'); $this->pdffile->Line($datum_X, $topLineY, $datum_X + $three_line_length, $topLineY); // Unterschrift $unterschrift_X = 145; $this->pdffile->SetFont('Helvetica', '', 12); $str_N = 'Unterschrift, Abteilungs-Nr.'; $str_W = $this->pdffile->GetStringWidth($str_N); $new_X = $unterschrift_X + $three_line_length / 2 - $str_W / 2; $new_X = round($new_X); $this->pdffile->SetXY($new_X, $topLineY); $this->pdffile->Cell(0, 0, $str_N, false, false, 'L'); $this->pdffile->Line($unterschrift_X, $topLineY, $unterschrift_X + $three_line_length, $topLineY); $topLineY += 18; // Teilnahme-Zertifikat $this->pdffile->SetFont('Helvetica', 'B', 36); $this->centerString('Teilnahme-Zertifikat', $topLineY); // Name des "Studenten" $this->pdffile->SetFont('Helvetica', 'B', 24); $topLineY += 26; //FullName + LoginName kommen in der Form "Gerd Weyhing|gweyhing|male", also auseinanderschneiden. $exp = explode("|", $student); $student = $exp[0]; $student_username = $exp[1]; $student_username = "******" . $student_username; $student_address = $exp[2]; if ($student_address != "") { $student = $student_address . " " . $student; } $this->centerString($student, $topLineY); $topLineY += 10; $this->pdffile->SetFont('Helvetica', 'B', 16); $this->centerString($student_username, $topLineY); $topLineY += 10; // ...Completed... $this->pdffile->SetFont('Helvetica', '', 16); $this->centerString('hat an der', $topLineY); $topLineY += 10; // Titel der Schulung $this->pdffile->SetFont('Helvetica', 'B', 16); $this->centerString($courseName, $topLineY); $topLineY += 10; // ...teilgenommen $this->pdffile->SetFont('Helvetica', '', 16); $this->centerString('teilgenommen', $topLineY); $topLineY += 10; $str = 'und den Verständnistest|erfolgreich|bestanden.'; $str_W = $this->pdffile->GetStringWidth($str); $str_exp = explode("|", $str); $this->pdffile->SetFont('Helvetica', '', 16); $this->pdffile->SetXY(42, $topLineY); $this->pdffile->Cell(0, 0, $str_exp[0], false, false); $this->pdffile->SetFont('Helvetica', 'B', 17); $this->pdffile->SetXY(105, $topLineY - 0.4); $this->pdffile->Cell(0, 0, $str_exp[1], false, false); $this->pdffile->SetFont('Helvetica', '', 16); $this->pdffile->SetXY(138, $topLineY); $this->pdffile->Cell(0, 0, $str_exp[2], false, false); $topLineY += 18; $this->centerString('Es wurden folgende Themenschwerpunkte behandelt:', $topLineY); $this->pdffile->SetFont('Helvetica', '', 14); $topLineY += 10; $topLineY += 6; $this->pdffile->SetXY(30, $topLineY); $this->pdffile->Cell(0, 0, '- Rechtsquellen des Datenschutzes', false, false); $topLineY += 6; $this->pdffile->SetXY(30, $topLineY); $this->pdffile->Cell(0, 0, '- datenschutzrechtliche Grundbegriffe', false, false); $topLineY += 6; $this->pdffile->SetXY(30, $topLineY); $this->pdffile->Cell(0, 0, '- datenschutzrelevante tarifvertragliche Regelungen', false, false); $topLineY += 6; $this->pdffile->SetXY(30, $topLineY); $this->pdffile->Cell(0, 0, '- Datenschutz bei ULAK und ZVK', false, false); $topLineY += 12; $this->pdffile->SetFont('Helvetica', '', 14); // Untere Zeile $topLineY += 12; $date_X = 17; $signature_X = 115; $two_line_length = 70; $str_W = $this->pdffile->GetStringWidth($date_str_kopie); $new_X = $date_X + $two_line_length / 2 - $str_W / 2; $new_X = round($new_X); $this->pdffile->SetXY($new_X, $topLineY); $this->pdffile->Cell(0, 0, $date_str_kopie, false, false, 'L'); // Datum links unten $topLineY += 6; $this->pdffile->SetFont('Helvetica', '', 12); $str_N = 'Datum'; $str_W = $this->pdffile->GetStringWidth($str_N); $new_X = $date_X + $two_line_length / 2 - $str_W / 2; $new_X = round($new_X); $this->pdffile->SetXY($new_X, $topLineY); $this->pdffile->Cell(0, 0, $str_N, false, false, 'L'); $this->pdffile->Line($date_X, $topLineY, $date_X + $two_line_length, $topLineY); // Unterschrift rechts unten $this->render_handleSignature(); $this->pdffile->SetFont('Helvetica', '', 12); $str_N = 'Referent'; $str_W = $this->pdffile->GetStringWidth($str_N); $new_X = $signature_X + $two_line_length / 2 - $str_W / 2; $new_X = round($new_X); $this->pdffile->SetXY($new_X, $topLineY); $this->pdffile->Cell(0, 0, $str_N, false, false, 'L'); $this->pdffile->Line($signature_X, $topLineY, $signature_X + $two_line_length, $topLineY); $topLineY += 5; //$this->pdffile->SetXY($date_X + (($this->footer_line_length - $date_str_len)/2), $topLineY); //$this->pdffile->Cell(0,0, $date_str, false, false); // Signature - signature itself // Logo - handle rendering a logo if one exists $this->render_handleLogo(); $topLineY += 5; // Date - field //$this->pdffile->SetXY($date_X, $topLineY); //$this->pdffile->Cell(0, 0, __('Date', 'wp_courseware'), false, false, 'L'); // Signature - field //$this->pdffile->SetXY($this->signature_X, $topLineY); //$this->pdffile->Cell(0,0, __('Instructor', 'wp_courseware'), false, false, 'L'); // Change output based on what's been specified as a parameter. if ('browser' == $showMode) { // GW 150120 - war: certificate.pdf (2x) $this->pdffile->Output('Teilnahme-Zertifikat.pdf', 'I'); } else { $this->pdffile->Output('Teilnahme-Zertifikat.pdf', 'D'); } }
/** * Convert page/post to a course unit */ function WPCW_showPage_ConvertPage() { require_once WPCW_plugin_getPluginDirPath() . 'pages/page_unit_convertpage.inc.php'; WPCW_showPage_ConvertPage_load(); }