/**
  * Can the user access this particular course (for this unit). 
  * @return Boolean True if yes, false otherwise.
  */
 function check_user_canUserAccessCourse()
 {
     return $this->userProgress && $this->userProgress->canUserAccessCourse();
 }
/**
 * Shows a detailed summary of the user progress.
 */
function WPCW_showPage_UserProgess_load()
{
    global $wpcwdb, $wpdb;
    $wpdb->show_errors();
    $page = new PageBuilder(false);
    $page->showPageHeader(__('Detailed User Progress Report', 'wp_courseware'), '75%', WPCW_icon_getPageIconURL());
    // Check passed user ID is valid
    $userID = WPCW_arrays_getValue($_GET, 'user_id');
    $userDetails = get_userdata($userID);
    if (!$userDetails) {
        $page->showMessage(__('Sorry, but that user could not be found.', 'wp_courseware'), true);
        $page->showPageFooter();
        return false;
    }
    printf(__('<p>Here you can see how well <b>%s</b> (Username: <b>%s</b>) is doing with your training courses.</p>', 'wp_courseware'), $userDetails->data->display_name, $userDetails->data->user_login);
    // #### 1 - Show a list of all training courses, and then list the units associated with that course.
    $SQL = "SELECT * \n\t\t\tFROM {$wpcwdb->courses}\n\t\t\tORDER BY course_title ASC \n\t\t\t";
    $courseCount = 0;
    $courses = $wpdb->get_results($SQL);
    if ($courses) {
        foreach ($courses as $course) {
            $up = new UserProgress($course->course_id, $userID);
            // Skip if user is not allowed to access the training course.
            if (!WPCW_courses_canUserAccessCourse($course->course_id, $userID)) {
                continue;
            }
            printf('<h3 class="wpcw_tbl_progress_course">%s</h3>', $course->course_title);
            printf('<table class="widefat wpcw_tbl wpcw_tbl_progress">');
            printf('<thead>');
            printf('<th>%s</th>', __('Unit', 'wp_courseware'));
            printf('<th class="wpcw_center">%s</th>', __('Completed', 'wp_courseware'));
            printf('<th class="wpcw_center wpcw_tbl_progress_quiz_name">%s</th>', __('Quiz Name', 'wp_courseware'));
            printf('<th class="wpcw_center">%s</th>', __('Quiz Status', 'wp_courseware'));
            printf('<th class="wpcw_center">%s</th>', __('Actions', 'wp_courseware'));
            printf('</thead><tbody>');
            // #### 2 - Fetch all associated modules
            $modules = WPCW_courses_getModuleDetailsList($course->course_id);
            if ($modules) {
                foreach ($modules as $module) {
                    // #### 3 - Render Modules as a heading.
                    printf('<tr class="wpcw_tbl_progress_module">');
                    printf('<td colspan="3">%s %d - %s</td>', __('Module', 'wp_courseware'), $module->module_number, $module->module_title);
                    // Blanks for Quiz Name and Actions.
                    printf('<td>&nbsp;</td>');
                    printf('<td>&nbsp;</td>');
                    printf('</tr>');
                    // #### 4. - Render the units for this module
                    $units = WPCW_units_getListOfUnits($module->module_id);
                    if ($units) {
                        foreach ($units as $unit) {
                            $showDetailLink = false;
                            printf('<tr class="wpcw_tbl_progress_unit">');
                            printf('<td class="wpcw_tbl_progress_unit_name">%s %d - %s</td>', __('Unit', 'wp_courseware'), $unit->unit_meta->unit_number, $unit->post_title);
                            // Has the unit been completed yet?
                            printf('<td class="wpcw_tbl_progress_completed">%s</td>', $up->isUnitCompleted($unit->ID) ? __('Completed', 'wp_courseware') : '');
                            // See if there's a quiz for this unit?
                            $quizDetails = WPCW_quizzes_getAssociatedQuizForUnit($unit->ID, false, $userID);
                            // Render the quiz details.
                            if ($quizDetails) {
                                // Title of quiz
                                printf('<td class="wpcw_tbl_progress_quiz_name">%s</td>', $quizDetails->quiz_title);
                                // No correct answers, so mark as complete.
                                if ('survey' == $quizDetails->quiz_type) {
                                    $quizResults = WPCW_quizzes_getUserResultsForQuiz($userID, $unit->ID, $quizDetails->quiz_id);
                                    if ($quizResults) {
                                        printf('<td class="wpcw_tbl_progress_completed">%s</td>', __('Completed', 'wp_courseware'));
                                        // Showing a link to view details
                                        $showDetailLink = true;
                                        printf('<td><a href="%s&user_id=%d&quiz_id=%d&unit_id=%d" class="button-secondary">%s</a></td>', admin_url('users.php?page=WPCW_showPage_UserProgess_quizAnswers'), $userID, $quizDetails->quiz_id, $unit->ID, __('View Survey Details', 'wp_courseware'));
                                    } else {
                                        printf('<td class="wpcw_center">%s</td>', __('Pending', 'wp_courseware'));
                                    }
                                } else {
                                    $quizResults = WPCW_quizzes_getUserResultsForQuiz($userID, $unit->ID, $quizDetails->quiz_id);
                                    // Show the admin how many questions were right.
                                    if ($quizResults) {
                                        // -1% means that the quiz is needing grading.
                                        if ($quizResults->quiz_grade < 0) {
                                            printf('<td class="wpcw_center">%s</td>', __('Awaiting Final Grading', 'wp_courseware'));
                                        } else {
                                            printf('<td class="wpcw_tbl_progress_completed">%d%%</td>', number_format($quizResults->quiz_grade, 1));
                                        }
                                        // Showing a link to view details
                                        $showDetailLink = true;
                                        printf('<td><a href="%s&user_id=%d&quiz_id=%d&unit_id=%d" class="button-secondary">%s</a></td>', admin_url('users.php?page=WPCW_showPage_UserProgess_quizAnswers'), $userID, $quizDetails->quiz_id, $unit->ID, __('View Quiz Details', 'wp_courseware'));
                                    } else {
                                        printf('<td class="wpcw_center">%s</td>', __('Pending', 'wp_courseware'));
                                    }
                                }
                                // end of if survey
                            } else {
                                printf('<td class="wpcw_center">-</td>');
                                printf('<td class="wpcw_center">-</td>');
                            }
                            // Quiz detail link
                            if (!$showDetailLink) {
                                printf('<td>&nbsp;</td>');
                            }
                            printf('</tr>');
                        }
                    }
                }
            }
            printf('</tbody></table>');
            // Track number of courses user can actually access
            $courseCount++;
        }
        // Course is not allowed to access any courses. So show a meaningful message.
        if ($courseCount == 0) {
            $page->showMessage(sprintf(__('User <b>%s</b> is not currently allowed to access any training courses.', 'wp_courseware'), $userDetails->data->display_name), true);
        }
    } else {
        printf('<p>%s</p>', __('There are currently no courses to show. Why not create one?', 'wp_courseware'));
    }
    $page->showPageFooter();
}
 /**
  * Remove associated UserProgress on delete.
  */
 function destroyUserProgress()
 {
     UserProgress::deleteBySQL('block_id = ?', array($this->id));
 }
Example #4
0
/**
 * 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'));
}
Example #5
0
/**
 * Function that creates a list of units.
 * 
 * @param Integer $courseID The ID of the course to show.
 * @param Array $options The list of options to show.
 */
function WPCW_courses_renderCourseList($courseID, $options)
{
    extract(shortcode_atts(array('module' => 0, 'module_desc' => false, 'show_title' => false, 'show_desc' => false, 'widget_mode' => false, 'show_toggle_col' => false, 'show_modules_previous' => 'all', 'show_modules_next' => 'all', 'toggle_modules' => 'expand_all'), $options));
    // Check settings to to see if they are true
    $module_desc = $module_desc == 'true';
    $show_title = $show_title == 'true';
    $show_desc = $show_desc == 'true';
    $courseDetails = false;
    $parentData = false;
    global $post;
    // Show course based on current location for user. Use the currently shown post
    // to work out which course to show using the associated parent data.
    if ('current' == $courseID) {
        $parentData = WPCW_units_getAssociatedParentData($post->ID);
        if ($parentData) {
            $courseDetails = WPCW_courses_getCourseDetails($parentData->parent_course_id);
            $courseID = $parentData->parent_course_id;
        } else {
            return false;
        }
    } else {
        // Check course ID is valid
        $courseDetails = WPCW_courses_getCourseDetails($courseID);
        if (!$courseDetails) {
            return __('Unrecognised course ID.', 'wp_courseware');
        }
        // Course ID is fine, get associated parent data for
        // hiding aspects of the widget
        $parentData = WPCW_units_getAssociatedParentData($post->ID);
    }
    $moduleList = false;
    // Do we just want a single module?
    if ($module > 0) {
        // Get module by module number within course (not the module ID)
        $moduleDetailsSingle = WPCW_modules_getModuleDetails_byModuleNumber($courseDetails->course_id, $module);
        if (!$moduleDetailsSingle) {
            return __('Could not find module.', 'wp_courseware');
        }
        // Create module list of 1 using single module
        $moduleList[$moduleDetailsSingle->module_id] = $moduleDetailsSingle;
    } else {
        // Check there are modules
        $moduleList = WPCW_courses_getModuleDetailsList($courseID);
        if (!$moduleList) {
            return __('There are no modules in this training course.', 'wp_courseware');
        }
    }
    $html = false;
    // #### Show course title/description
    if ($show_title) {
        $html .= sprintf('<div class="wpcw_fe_course_title">%s</div>', $courseDetails->course_title);
    }
    if ($show_desc) {
        $html .= sprintf('<div class="wpcw_fe_course_desc">%s</div>', $courseDetails->course_desc);
    }
    $html .= '<table id="wpcw_fe_course" cellspacing="0" cellborder="0">';
    $showUnitLinks = false;
    // If true, show links to the units
    $colCount = 2;
    // Number of columns in the table
    // UP Object to determine what to show to the user.
    $userProgress = false;
    // Check user is logged in, and if they can access this course
    $user_id = get_current_user_id();
    if ($user_id != 0) {
        $userProgress = new UserProgress($courseID, $user_id);
        // Show links for user if they are allowed to access this course.
        if ($userProgress->canUserAccessCourse()) {
            // User is logged in and can do course, so show the stuff they can do.
            $showUnitLinks = true;
            // Got an extra column to show progress
            $colCount = 3;
        }
    }
    // If we're showing a widget, and we have the parent data based on the
    // currently viewed unit, then change what's in the widget in terms
    // of previous/next units.
    $hideList = array();
    if ($widget_mode && $module == 0 && $parentData) {
        // Build a list of the modules before and after the current
        // module, so that we can more easily control what's visible,
        // and what's not.
        $modulesBefore = array();
        $modulesAfter = array();
        $currentList =& $modulesBefore;
        foreach ($moduleList as $moduleID => $moduleObj) {
            // Switch lists, we've found the current module
            if ($moduleID == $parentData->parent_module_id) {
                $currentList =& $modulesAfter;
            } else {
                $currentList[] = $moduleID;
            }
        }
        // Handle showing previous modules
        switch ($show_modules_previous) {
            // All all items in the before list to be hidden
            case 'none':
                $hideList = array_merge($hideList, $modulesBefore);
                break;
            case 'all':
                break;
                // Keep a specific number of modules to show.
            // Keep a specific number of modules to show.
            default:
                $show_modules_previous += 0;
                $modulesToPickFrom = count($modulesBefore);
                // Remove the modules at the start of the list, leaving the right number of
                // $show_modules_previous modules in the list.
                if ($show_modules_previous > 0 && $modulesToPickFrom > $show_modules_previous) {
                    $hideList = array_merge($hideList, array_slice($modulesBefore, 0, $modulesToPickFrom - $show_modules_previous));
                }
                break;
        }
        // end switch
        // Handle showing the next modules.
        switch ($show_modules_next) {
            // All all items in the after list to be hidden
            case 'none':
                $hideList = array_merge($hideList, $modulesAfter);
                break;
            case 'all':
                break;
                // Keep a specific number of modules to show.
            // Keep a specific number of modules to show.
            default:
                $show_modules_next += 0;
                $modulesToPickFrom = count($modulesAfter);
                // Remove the modules at the start of the list, leaving the right number of
                // $show_modules_previous modules in the list.
                if ($show_modules_next > 0 && $modulesToPickFrom > $show_modules_next) {
                    $hideList = array_merge($hideList, array_slice($modulesAfter, $show_modules_next));
                }
                break;
        }
        // end switch
    }
    // Columns for marking item as being pending or complete.
    $progress_Complete = '<td class="wpcw_fe_unit_progress wpcw_fe_unit_progress_complete"><span>&nbsp;</span></td>';
    $progress_Pending = '<td class="wpcw_fe_unit_progress wpcw_fe_unit_progress_incomplete"><span>&nbsp;</span></td>';
    $progress_Blank = '<td class="wpcw_fe_unit_progress"><span>&nbsp;</span></td>';
    // Show modules
    foreach ($moduleList as $moduleID => $moduleObj) {
        // See if we're skipping this module
        if (in_array($moduleID, $hideList)) {
            continue;
        }
        // If $collapseTitleArea is set to true, then the module will be collapsed. So just check what to hide
        // based on the contents of $toggle_modules
        $collapseTitleArea = false;
        if ($widget_mode && $parentData) {
            switch ($toggle_modules) {
                case 'contract_all':
                    $collapseTitleArea = true;
                    break;
                    // See if the currently visible unit module is the one being rendered.
                // See if the currently visible unit module is the one being rendered.
                case 'contract_all_but_current':
                    $collapseTitleArea = $moduleID != $parentData->parent_module_id;
                    break;
                    // Default is not to collapse.
            }
        }
        // We're showing the toggle section, so add it.
        if ($show_toggle_col) {
            $moduleTitleArea = false;
            $moduleTitleArea = sprintf('<td>%s</td><td class="wpcw_fe_toggle">%s</td>', $moduleObj->module_title, $collapseTitleArea ? '+' : '-');
        } else {
            $moduleTitleArea = sprintf('<td colspan="%d">%s</td>', $colCount - 1, $moduleObj->module_title);
        }
        // Render final title bit
        $html .= sprintf('<tr class="wpcw_fe_module %s" id="wpcw_fe_module_group_%d">
							<td>%s %d</td>
							' . $moduleTitleArea . '			
						</tr>', $collapseTitleArea ? 'wpcw_fe_module_toggle_hide' : '', $moduleObj->module_number, __('Module', 'wp_courseware'), $moduleObj->module_number, $moduleTitleArea);
        // ### Showing the module descriptions?
        if ($module_desc) {
            $html .= sprintf('<tr class="wpcw_fe_module_des"><td colspan="%d">%s</td></tr>', $colCount, $moduleObj->module_desc);
        }
        // Add the class for the row that matches the parent module ID.
        $moduleRowClass = ' wpcw_fe_module_group_' . $moduleObj->module_number;
        // ### No Units Line
        $units = WPCW_units_getListOfUnits($moduleID);
        if (!$units) {
            $extraColSpan = 0;
            if ($show_toggle_col) {
                $extraColSpan = 1;
            }
            $html .= sprintf('<tr class="wpcw_fe_unit wpcw_fe_unit_none %s">
						<td colspan="%d">%s</td>
					  </tr>', $moduleRowClass, $colCount + $extraColSpan, __('There are no units in this module.', 'wp_courseware'));
        } else {
            // Render each unit
            foreach ($units as $unit) {
                $progressRow = false;
                $progressCol = false;
                // Show links for units
                if ($showUnitLinks) {
                    // Yes we are showing progress data... see what state we're at.
                    if ($userProgress) {
                        if ($userProgress->isUnitCompleted($unit->ID)) {
                            $progressCol = $progress_Complete;
                            $progressRow = 'wpcw_fe_unit_complete';
                        } else {
                            $progressCol = $progress_Pending;
                            $progressRow = 'wpcw_fe_unit_pending';
                        }
                        //$progressCol = ($userProgress->isUnitCompleted($unit->ID) ? $progress_Complete : $progress_Pending);
                    }
                    // See if the user is allowed to access this unit or not.
                    if ($userProgress->canUserAccessUnit($unit->ID)) {
                        // Main unit title, link and unit number
                        $html .= sprintf('
							<tr class="wpcw_fe_unit ' . $progressRow . $moduleRowClass . '">
								<td>%s %d</td>
								<td class="wpcw_fe_unit"><a href="%s">%s</a></td>
								' . $progressCol . '
							</tr>', __('Unit', 'wp_courseware'), $unit->unit_meta->unit_number, get_permalink($unit->ID), $unit->post_title);
                    } else {
                        // If we're not allowed to access the unit, then it's always marked as pending.
                        $html .= sprintf('
							<tr class="wpcw_fe_unit ' . $progressRow . $moduleRowClass . '">
								<td>%s %d</td>
								<td class="wpcw_fe_unit">%s</td>
								' . $progress_Pending . '
							</tr>', __('Unit', 'wp_courseware'), $unit->unit_meta->unit_number, $unit->post_title);
                    }
                } else {
                    $colspan = 1;
                    if ($show_toggle_col) {
                        $colspan = 2;
                    }
                    $html .= sprintf('
					<tr class="wpcw_fe_unit ' . $progressRow . $moduleRowClass . '">
						<td>%s %d</td>
						<td colspan="%d" class="wpcw_fe_unit">%s</td>
					</tr>', __('Unit', 'wp_courseware'), $unit->unit_meta->unit_number, $colspan, $unit->post_title);
                }
            }
        }
        // end show units
    }
    $html .= '</table>';
    // Add powered by link
    $settings = TidySettings_getSettings(WPCW_DATABASE_SETTINGS_KEY);
    $html .= WPCW_generatedPoweredByLink($settings);
    return $html;
}
Example #6
0
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'] . "&nbsp;(";
            $user_string .= $user['id'] . "):&nbsp;";
            // $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;
}
Example #7
0
/**
 * 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;
}