/** * Creates a box to show that a unit has been completed. * * @return String The HTML that renders this box. */ function render_completionBox_complete() { $html = false; // Work out if course completed. // Unit and course is complete, so show course complete message. if ($this->userProgress->isCourseCompleted()) { $certHTML = false; $certificateDetails = WPCW_certificate_getCertificateDetails($this->currentUserID, $this->parentData->course_id); // Generate certificate button if enabled and a certificate exists for this user. if ('use_certs' == $this->parentData->course_opt_use_certificate && $certificateDetails) { $certHTML = sprintf('<div class="wpcw_fe_progress_box_download"><a href="%s" class="fe_btn fe_btn_download">%s</a></div>', WPCW_certificate_generateLink($certificateDetails->cert_access_key), __('Download Certificate', 'wp_courseware')); } // Course completion message $html .= sprintf('<div class="wpcw_fe_progress_box_wrap"> <div class="wpcw_fe_progress_box wpcw_fe_progress_box_complete">%s%s</div> </div>', $certHTML, $this->parentData->course_message_course_complete); } else { $html = sprintf('<div class="wpcw_fe_progress_box_wrap"><div class="wpcw_fe_progress_box wpcw_fe_progress_box_complete">%s</div></div>', $this->parentData->course_message_unit_complete); } // Got any quiz status data to show? $quizMessageData = $this->render_completionBox_quizPassStatus(); // Got any custom feedback data to show? $customFeedbackMessages = $this->render_customFeedbackMessage_showResults(); return $html . $quizMessageData . $customFeedbackMessages; }
/** * Creates a box to show that a unit has been completed. * * @return String The HTML that renders this box. */ function render_completionBox_complete() { $html = false; // Work out if course completed. // Unit and course is complete, so show course complete message. if ($this->userProgress->isCourseCompleted()) { $certHTML = false; // GW 150130 echo "Course ".$this->parentData->course_id." of User ".$this->currentUserID. " is complete/d"; $certificateDetails = WPCW_certificate_getCertificateDetails($this->currentUserID, $this->parentData->course_id); // Generate certificate button if enabled and a certificate exists for this user. if ('use_certs' == $this->parentData->course_opt_use_certificate && $certificateDetails) { $certHTML = sprintf('<div class="wpcw_fe_progress_box_download"><a href="%s" class="fe_btn fe_btn_download">%s</a></div>', WPCW_certificate_generateLink($certificateDetails->cert_access_key), __('Download Certificate', 'wp_courseware')); } // Course completion message $html .= sprintf('<div class="wpcw_fe_progress_box_wrap"> <div class="wpcw_fe_progress_box wpcw_fe_progress_box_complete">%s%s</div> </div>', $certHTML, $this->parentData->course_message_course_complete); } else { $html = sprintf('<div class="wpcw_fe_progress_box_wrap"><div class="wpcw_fe_progress_box wpcw_fe_progress_box_complete">%s</div></div>', $this->parentData->course_message_unit_complete); } // Got any quiz status data to show? $quizMessageData = $this->render_completionBox_quizPassStatus(); // Got any custom feedback data to show? $customFeedbackMessages = $this->render_customFeedbackMessage_showResults(); // TODO WORKING HERE #3 - retake button // Allow non-blocking Quiz Retakes - (as unit is always complete for non-blocking quizzes). /* $messageToShow = false; printf('ERJOASCNLASKNXLKASNCLKAMSD'); if ($this->check_quizzes_NonBlockingQuizOffersRetakeButton()) { $messageToShow .= sprintf('<div class="wpcw_fe_quiz_retake"> <div class="wpcw_fe_submit_loader wpcw_loader"> <img src="%simg/ajax_loader.gif" /> </div> <a href="#" class="fe_btn fe_btn_completion btn_completion" data-wpcw_quiz="%d" data-wpcw_unit="%d">%s</a> </div>', WPCW_plugin_getPluginPath(), $this->unitQuizDetails->quiz_id, $this->unitPost->ID, __('Retake Quiz', 'wp_courseware')); } // Finally show the message to the user. $retakeButtonData = WPCW_UnitFrontend::message_createMessage_warning($messageToShow); */ return $html . $quizMessageData . $customFeedbackMessages . $retakeButtonData; }
/** * Creates a box to show that a unit has been completed. * * @return String The HTML that renders this box. */ function render_completionBox_complete() { $html = false; // Work out if course completed. // Unit and course is complete, so show course complete message. if ($this->userProgress->isCourseCompleted()) { $certHTML = false; $certificateDetails = WPCW_certificate_getCertificateDetails($this->currentUserID, $this->parentData->course_id); // Generate certificate button if enabled and a certificate exists for this user. if ('use_certs' == $this->parentData->course_opt_use_certificate && $certificateDetails) { $certHTML = sprintf('<div class="wpcw_fe_progress_box_download"><a href="%s" class="fe_btn fe_btn_download">%s</a></div>', WPCW_certificate_generateLink($certificateDetails->cert_access_key), __('Download Certificate', 'wp_courseware')); } // Course completion message $html .= sprintf('<div class="wpcw_fe_progress_box_wrap"> <div class="wpcw_fe_progress_box wpcw_fe_progress_box_complete">%s%s</div> </div>', $certHTML, $this->parentData->course_message_course_complete); } else { $html = sprintf('<div class="wpcw_fe_progress_box_wrap"><div class="wpcw_fe_progress_box wpcw_fe_progress_box_complete">%s</div></div>', $this->parentData->course_message_unit_complete); } // Got any quiz status data to show? $quizMessageData = $this->render_completionBox_quizPassStatus(); // Got any custom feedback data to show? $customFeedbackMessages = $this->render_customFeedbackMessage_showResults(); $html .= $quizMessageData . $customFeedbackMessages; // Allow non-blocking Quiz Retakes - (as unit is always complete for non-blocking quizzes). if ($this->check_quizzes_NonBlockingQuizOffersRetakeButton()) { $remainingAttempts = $this->fetch_quizzes_getRemainingAttempts(); if ($remainingAttempts != 0) { if ('quiz_noblock' == $this->unitQuizDetails->quiz_type) { // Show a message about the recommended score. $courseDetails = WPCW_courses_getCourseDetails($this->unitQuizDetails->parent_course_id); if ($this->unitQuizProgress->quiz_needs_marking != 0) { $messageToShow .= $courseDetails->course_message_quiz_open_grading_non_blocking; $showRetakeButton = false; } elseif ('retake_waiting' != $this->unitQuizProgress->quiz_next_step_type) { $messageToShow .= wpautop(sprintf(__('The recommended grade for this quiz is <b>%d%%</b> (and your grade is <b>%d%%</b>). The course instructor has allowed you to retake this quiz if you wish to improve your grade.', 'wp_courseware'), $this->unitQuizDetails->show_recommended_percentage, $this->unitQuizProgress->quiz_grade)); $showRetakeButton = true; } } } else { $showRetakeButton = false; $messageToShow .= wpautop(__('Unfortunately you have reached the maximum limit of attempts you are permitted for this quiz.', 'wp_courseware')); } // The retake button (if allowed) if ($showRetakeButton) { $messageToShow .= sprintf('<div class="wpcw_fe_quiz_retake"> <div class="wpcw_fe_submit_loader wpcw_loader"> <img src="%simg/ajax_loader.gif" /> </div> <a href="#" class="fe_btn fe_btn_completion btn_completion" data-wpcw_quiz="%d" data-wpcw_unit="%d">%s</a> </div>', WPCW_plugin_getPluginPath(), $this->unitQuizDetails->quiz_id, $this->unitPost->ID, __('Retake Quiz', 'wp_courseware')); $html .= WPCW_UnitFrontend::message_createMessage_warning($messageToShow); } // No quiz progress or we're ready for a retake, so show the quiz to be rendered for completion by the user. // Ensure that we render the quiz if we've not yet completed the quiz. if (!$this->check_quizzes_hasUserCompletedQuiz() || $this->check_quizzes_areWeWaitingForUserToRetakeQuiz()) { $html .= $this->render_quizzes_handleQuizRendering(); } } //. $quizMessageData . $customFeedbackMessages . $retakeButtonData return $html; }
/** * Function called when the user completes a unit * @param Integer $userID The ID of the user that's completed the unit. * @param Integer $unitID The ID of the unit that's been completed. * @param Object $unitParentData The object of parent data associated with the unit, such as module and course. */ function WPCW_actions_users_unitCompleted($userID, $unitID, $unitParentData) { if (!$userID || !$unitID || !$unitParentData) { return; } global $wpdb, $wpcwdb; $wpdb->show_errors(); // Update the user progress count. WPCW_users_updateUserUnitProgress($unitParentData->course_id, $userID, $unitParentData->course_unit_count); // Work out if module/course completed. $userProgress = new UserProgress($unitParentData->course_id, $userID); if ($userProgress->isModuleCompleted($unitID)) { do_action('wpcw_user_completed_module', $userID, $unitID, $unitParentData); } if ($userProgress->isCourseCompleted()) { do_action('wpcw_user_completed_course', $userID, $unitID, $unitParentData); } //error_log(''); //error_log('Module Completed?: ' . $unitID . ' - ' . ($userProgress->isModuleCompleted($unitID) ? 'yes' : 'no')); //error_log('Course Completed?: ' . $unitID . ' - ' . ($userProgress->isCourseCompleted() ? 'yes' : 'no')); }
function show_courses_topic() { include_once '../wp-content/plugins/wp-courseware/lib/common.inc.php'; include_once '../wp-content/plugins/wp-courseware/lib/constants.inc.php'; include_once '../wp-content/plugins/wp-courseware/lib/email_defaults.inc.php'; include_once '../wp-content/plugins/wp-courseware/lib/class_user_progress.inc.php'; $was_saved = 0; if ($_POST["topic_for_course"]) { foreach ($_POST["topic_for_course"] as $tfc_id => $tfc_value) { $tfc_value = explode("-", $tfc_value); //echo $tfc_value[0]."---".$tfc_value[1]."<br>"; $set_topic = EventDatabaseManager::setTopicForCourse($tfc_value[0], $tfc_value[1]); $was_saved = 1; } } $output_str = ""; $output_str .= "<form name=\"form1\" method=\"post\" action=\"" . $_SERVER['REQUEST_URI'] . "\">"; $topic_per_course = EventDatabaseManager::getTopicPerCourse(); // $topic_per_course_test_cert_date = EventDatabaseManager::getTopicPerCourse_test_CertDate(); //echo "<pre>";var_dump($topic_per_course); echo "</pre><br><br>"; $output_str .= "<h2>" . HEADER_TOPICS_PER_COURSE . "</h2>"; if ($was_saved == 1) { $output_str .= "<p>Gespeichert!</p>"; } $output_str .= "<table>"; $output_str .= "<tr>"; $output_str .= "<td style=\"padding: 1px 2px; border: 1px solid black; background:black; color:white;\">Course-ID</td>"; $output_str .= "<td style=\"padding: 1px 2px; border: 1px solid black; background:black; color:white;\">Course-Title</td>"; $output_str .= "<td style=\"padding: 1px 2px; border: 1px solid black; background:black; color:white;\">Topic-Title</td>"; $output_str .= "<td style=\"padding: 1px 2px; border: 1px solid black; background:black; color:white;\">User</td>"; $output_str .= "</tr>"; $topics = EventDatabaseManager::getAllTopics(); $output_str .= "<tr>"; $output_str .= "<td colspan=4 style=\"padding: 1px 2px; border: 1px solid black;\">Variante 1: Datum ist Topic Expiry Date</td>"; $output_str .= "</tr>"; foreach ($topic_per_course as $tpc => $course_value) { $topic_select = "<select name=\"topic_for_course[" . $course_value['course_id'] . "]\">"; $topic_select .= "<option value=\"" . $course_value['course_id'] . "-0\">---</option>"; foreach ($topics as $topic_id => $topic_value) { $selected = ""; if ($topic_id == $course_value['topic_id']) { $selected = " selected "; } $topic_select .= "<option " . $selected . " value=\"" . $course_value['course_id'] . "-" . $topic_id . "\">" . $topic_value . " (" . $topic_id . ")</option>"; } $topic_select .= "</select>"; $user_string = ""; //echo "tpc2:<br><pre>";var_dump($course_value['users']); echo "</pre>"; foreach ($course_value['users'] as $users => $user) { $user_string .= $user['name'] . " ("; $user_string .= $user['id'] . "): "; // $user_string .= date("d.m.Y",strtotime($user['topic_expiry_date'])); // wird doch gar nicht benutzt!!! $bla = new UserProgress($course_value['course_id'], $user['id']); //echo "<pre>";var_dump($bla); echo "</pre><br><br>"; if ($bla->isCourseCompleted()) { $user_string .= " <span style=\"background: orange; color: white;\">[completed (certificate)]</span>"; } // Datum in Weiß auf Orange ist cert_generated $active = EventDatabaseManager::isTopicForUserActive($user['id'], $course_value['topic_id']); $user_string .= $active; // $user_string .= "+" . $user['repetition_frequency_days']."="; //$repetition_date = strtotime($user['topic_expiry_date']." +".$user['repetition_frequency_days']." days")."="; //$user_string .= date("d.m.Y",(int)$repetition_date); // wenn repetition_frequency_days == 0 -> keine Wiedervorlage // topic_expiry_date durch creation_date ersetzen // sonst: $user_string .= "<br>"; } $output_str .= "<tr>"; $output_str .= "<td style=\"padding: 1px 2px; border: 1px solid black;\">" . $course_value['course_id'] . "</td>"; $output_str .= "<td style=\"padding: 1px 2px; border: 1px solid black;\">" . $course_value['course_title'] . "</td>"; $output_str .= "<td style=\"padding: 1px 2px; border: 1px solid black;\">" . $topic_select . "</td>"; $output_str .= "<td style=\"padding: 1px 2px; border: 1px solid black;\">[" . count($course_value['users']) . "]<br>" . rtrim($user_string, ",") . "</td>"; $output_str .= "</tr>"; } $output_str .= "<tr><td colspan=\"4\">"; $output_str .= " <span style=\"background: orange; color: white;\"> Course Completed und Datum der Zertifkatsgenerierung </span>"; $output_str .= " <span style=\"background: red; color: white;\"> V = Rep.Date ist Vergangenheit </span>"; $output_str .= " <span style=\"background: green; color: white;\"> Z = Rep.Date ist Heute oder Zukunft </span>"; $output_str .= " <span style=\"background: red; color: white;\"> K = kein Zertifikat </span>"; $output_str .= " <span style=\"background: #FFCC00; color: black;\"> WV am </span>"; $output_str .= " <span style=\"background: green; color: white;\"> 0 = keine WV </span>"; $output_str .= "</td></tr>"; $output_str .= "<tr>"; $output_str .= "<td colspan=4 style=\"padding: 1px 2px; border: 1px solid black;\">Variante 2: Datum ist Certificate Creation Date -> weniger Treffer (wieder verworfen)</td>"; $output_str .= "</tr>"; $output_str .= "</table>"; $output_str .= " <br>"; $output_str .= " <input type=\"submit\" value=\"Speichern\" />"; $output_str .= " <input name=\"action\" value=\"insert\" type=\"hidden\" />"; $output_str .= " </form>"; echo $output_str; }
/** * Creates a box to show that a unit has been completed. * * @param Object $parentData A copy of the parent course and module details for this unit. * @param Integer $unitID The ID of the unit that's been completed. * @param Integer $user_id The ID of the user who has just completed the unit. */ function WPCW_units_getCompletionBox_complete($parentData, $unitID, $user_id) { // Work out if course completed. $userProgress = new UserProgress($parentData->course_id, $user_id); $html = false; // Unit and course is complete, so show course complete message. if ($userProgress->isCourseCompleted()) { $certHTML = false; $certificateDetails = WPCW_certificate_getCertificateDetails($user_id, $parentData->course_id); // Generate certificate button if enabled and a certificate exists for this user. if ('use_certs' == $parentData->course_opt_use_certificate && $certificateDetails) { $certHTML = sprintf('<div class="wpcw_fe_progress_box_download"><a href="%s" class="fe_btn fe_btn_download">%s</a></div>', WPCW_certificate_generateLink($certificateDetails->cert_access_key), __('Download Certificate', 'wp_courseware')); } // Course completion message $html .= sprintf('<div class="wpcw_fe_progress_box_wrap"> <div class="wpcw_fe_progress_box wpcw_fe_progress_box_complete">%s%s</div> </div>', $certHTML, $parentData->course_message_course_complete); } else { $html = sprintf('<div class="wpcw_fe_progress_box_wrap"><div class="wpcw_fe_progress_box wpcw_fe_progress_box_complete">%s</div></div>', $parentData->course_message_unit_complete); } return $html; }