示例#1
0
			<?php 
}
?>
			</tbody>
		</table>

		<div class="tablenav">
			<div class="alignleft actions">
				<select name="units" class="chosen-select">
					<option value=""><?php 
_e('All Units', 'cp');
?>
</option>
					<?php 
$course = new Course($current_course_id);
$course_units = $course->get_units();
foreach ($course_units as $course_unit) {
    ?>
						<option value="<?php 
    echo $course_unit->ID;
    ?>
"><?php 
    echo $course_unit->post_title;
    ?>
</option>
					<?php 
}
?>

				</select>
				<?php 
 function course_units($atts)
 {
     global $wp, $coursepress;
     $content = '';
     extract(shortcode_atts(array('course_id' => $course_id), $atts));
     if (!empty($course_id)) {
         $course_id = (int) $course_id;
     }
     if (empty($course_id)) {
         if (array_key_exists('coursename', $wp->query_vars)) {
             $course_id = Course::get_course_id_by_name($wp->query_vars['coursename']);
         } else {
             $course_id = 0;
         }
     }
     $course = new Course($course_id);
     $units = $course->get_units($course_id, 'publish');
     $user_id = get_current_user_id();
     $student = new Student($user_id);
     //redirect to the parent course page if not enrolled
     if (!current_user_can('manage_options')) {
         //If current user is not admin, check if he can access to the units
         if ($course->details->post_author != get_current_user_id()) {
             //check if user is an author of a course ( probably instructor )
             if (!current_user_can('coursepress_view_all_units_cap')) {
                 //check if the instructor, even if it's not the author of the course, maybe has a capability given by the admin
                 //if it's not an instructor who made the course, check if he is enrolled to course
                 // Added 3rd parameter to deal with legacy meta data
                 if (!$student->user_enrolled_in_course($course_id, $user_id, 'update_meta')) {
                     // if( defined('DOING_AJAX') && DOING_AJAX ) { cp_write_log('doing ajax'); }
                     //ob_start();
                     wp_redirect(get_permalink($course_id));
                     //if not, redirect him to the course page so he may enroll it if the enrollment is available
                     exit;
                 }
             }
         }
     }
     $content .= '<ol>';
     $last_unit_url = '';
     foreach ($units as $unit) {
         //				$unit_details	 = new Unit( $unit->ID );
         $content .= '<li><a href="' . Unit::get_permalink($unit->ID, $course_id) . '">' . $unit->post_title . '</a></li>';
         $last_unit_url = Unit::get_permalink($unit->ID, $course_id);
     }
     $content .= '</ol>';
     if (count($units) >= 1) {
         $content .= do_shortcode('[course_discussion]');
     }
     if (count($units) == 0) {
         $content = __('0 course units prepared yet. Please check back later.', 'cp');
     }
     if (count($units) == 1) {
         //ob_start();
         // if( defined('DOING_AJAX') && DOING_AJAX ) { cp_write_log('doing ajax'); }
         wp_redirect($last_unit_url);
         exit;
     }
     return $content;
 }
 public static function calculate_course_completion($student_id, $course_id, $update = true)
 {
     if (empty($course_id)) {
         return false;
     }
     $cache_key = __METHOD__ . '-' . $student_id . '-' . $course_id;
     if (CoursePress_Cache::cp_cache_get($cache_key)) {
         return CoursePress_Cache::cp_cache_get($cache_key);
     }
     $data = self::get_completion_data($student_id, $course_id);
     $course = new Course($course_id);
     $total_units = $course->get_units($course_id, 'publish', true);
     // No units or no units published
     if (empty($total_units)) {
         CoursePress_Cache::cp_cache_set($cache_key, 0);
         return 0;
     }
     $progress = 0.0;
     if (isset($data['unit']) && is_array($data['unit'])) {
         foreach ($data['unit'] as $unit_id => $unit) {
             if ('publish' == get_post_status($unit_id)) {
                 $progress += self::calculate_unit_completion($student_id, $course_id, $unit_id, $update, $data);
             }
         }
         $progress = $progress / $total_units;
         $progress = $progress > 100 ? 100 : $progress;
         $data['course_progress'] = $progress;
     }
     if ($update) {
         self::update_completion_data($student_id, $course_id, $data);
     }
     if (100 == (int) $progress) {
         do_action('coursepress_set_course_completed', $student_id, $course_id);
     }
     CoursePress_Cache::cp_cache_set($cache_key, $progress);
     return $progress;
 }
    ?>
											</select>
											<?php 
    $current_course_id = 0;
    if (isset($_GET['course_id'])) {
        $current_course_id = (int) $_GET['course_id'];
    } else {
        $current_course_id = $first_course_id;
    }
    ?>

											<?php 
    if ($current_course_id !== 0) {
        //courses exists, at least one
        $course = new Course($current_course_id);
        $course_units = $course->get_units($current_course_id, 'publish');
        if (count($course_units) >= 1) {
            ?>

													<label class="ungraded"><?php 
            _e('Ungraded Elements Only', 'cp');
            ?>
														<?php 
            if (isset($_GET['ungraded']) && $_GET['ungraded'] == 'yes') {
                $ungraded_filter = 'yes';
            } else {
                $ungraded_filter = 'no';
            }
            ?>
														<input type="checkbox" id="ungraded" name="ungraded" value="yes" <?php 
            checked($ungraded_filter, 'yes', true);
示例#5
0
        ?>
" alt="<?php 
        echo esc_attr($course_object->post_title);
        ?>
" /></div> -->
							<div class="course_excerpt"><?php 
        echo cp_get_the_course_excerpt($course_object->ID, apply_filters('course_admin_excerpt_length', 55));
        ?>
</div>
							<div class="column-course-units visible-small visible-extra-small">
								<strong><?php 
        _e('Units', 'cp');
        ?>
:</strong>
								<?php 
        echo $course_obj->get_units('', 'any', true);
        ?>
 <?php 
        _e('Units', 'cp');
        ?>
,
								<?php 
        echo $course_obj->get_units('', 'publish', true);
        ?>
 Published
							</div>
							<div class="column-course-students visible-small visible-extra-small">
								<strong><?php 
        _e('Students', 'cp');
        ?>
:</strong>
        $currentUser->set_class_request($row['class_request']);
        $currentUser->set_recommend($row['recommend']);
        //Add the object to correct array
        $taArray[] = $currentUser;
    }
    $dbh = null;
} catch (PDOException $e) {
    print "Error!:" . $e->getMessage() . "<br/>";
    die;
}
/*
 * Now that all of the information has been gathered from the database, we can use it to generate some html.
 *
 */
//Add the additional course information in its own divs
$html = "<div id='extra_info_{$courseNum}'>\n            <div class='adminBottom'>\n                <p class='admin_bot_item_1'>Enrollment Cap: {$thisCourse->get_enroll_cap()}</p>\n                <p class='admin_bot_item_2'>Currently Enrolled: {$thisCourse->get_curr_enroll()}</p>\n                <p class='admin_bot_item_2'>Seats Available: {$thisCourse->get_seats_avail()}</p>\n            </div>\n            <div class='adminBottom'>\n                <p class='admin_bot_item_3'>Units: {$thisCourse->get_units()}</p>\n                <p class='admin_bot_item_2'>Location: {$thisCourse->get_location()}</p>\n                <p class='admin_bot_item_4'>Time: {$thisCourse->get_time()}</p>\n            </div>";
//Now, add the prospective TAs for this course, if there are any
if (count($taArray) > 0) {
    //Each TA gets their own div with their UID, name, and a select list with their recommend level and other possible levels
    foreach ($taArray as $ta) {
        $uid = $ta->get_uid();
        $recLevel = $ta->get_recommend();
        $selectID = "select_" . $uid . "_" . $courseNum;
        //Create the string that will be used as the arguments for the updateRecommend function
        $arguments = "\"" . $semester . "\", \"" . $year . "\", \"" . $uid . "\", \"" . $courseNum . "\"";
        $html .= "<div class='adminBottom'>\n                    <p class='admin_bot_item_6'>UID: {$uid}</p>\n                    <p class='admin_bot_item_5'>Name: {$ta->get_full_name()} </p>\n                    <select class='admin_bot_item_6' id={$selectID}\n                    onchange='updateRecommend({$arguments});'>";
        for ($i = 0; $i < 5; $i++) {
            $recommend = get_recommendation($i);
            if (option_selected($i, $recLevel)) {
                $html .= "<option value={$i} selected>{$recommend}</option>";
            } else {