function get_accessable_courses()
 {
     $courses = $this->get_assigned_courses_ids();
     $new_course_array = array();
     foreach ($courses as $course) {
         $can_update = CoursePress_Capabilities::can_update_course($course->ID, $this->ID);
         $can_delete = CoursePress_Capabilities::can_delete_course($course->ID, $this->ID);
         $can_publish = CoursePress_Capabilities::can_change_course_status($course->ID, $this->ID);
         $can_view_unit = CoursePress_Capabilities::can_view_course_units($course->ID, $this->ID);
         $my_course = CoursePress_Capabilities::is_course_instructor($course->ID, $this->ID);
         $creator = CoursePress_Capabilities::is_course_creator($course->ID, $this->ID);
         if (!$my_course && !$creator && !$can_update && !$can_delete && !$can_publish && !$can_view_unit) {
             continue;
         } else {
             $new_course_array[] = $course;
         }
     }
     return $new_course_array;
 }
    ?>
</option>
										<?php 
}
?>
										<?php 
$args = array('post_type' => 'course', 'post_status' => 'any', 'posts_per_page' => -1);
$courses = get_posts($args);
$available_course_options = 0;
//coursepress_create_my_assigned_notification_cap
foreach ($courses as $course) {
    //if ( $notification_id == 0 ) {
    $instructor = new Instructor(get_current_user_id());
    $instructor_courses = $instructor->get_assigned_courses_ids();
    $my_course = in_array($course->ID, $instructor_courses);
    $my_course = CoursePress_Capabilities::is_course_instructor($course->ID);
    //}
    if ($notification_id == 0) {
        if (current_user_can('manage_options') || current_user_can('coursepress_create_notification_cap') || current_user_can('coursepress_create_my_notification_cap') && $course->post_author == get_current_user_ID() || current_user_can('coursepress_create_my_assigned_notification_cap') && $my_course) {
            ?>
													<option value="<?php 
            echo $course->ID;
            ?>
" <?php 
            selected($meta_course_id, $course->ID);
            ?>
><?php 
            echo $course->post_title;
            ?>
</option>
													<?php 
Пример #3
0
    $args = array('post_type' => 'course', 'post_status' => 'any', 'posts_per_page' => -1);
    $courses = get_posts($args);
    ?>
				<select name="course_id" id="dynamic_courses" class="chosen-select">

					<?php 
    $assessment_page = 1;
    $courses_with_students = 0;
    $course_num = 0;
    $first_course_id = 0;
    $count = 0;
    foreach ($courses as $course) {
        $show = false;
        $count = Unit_Module::get_ungraded_response_count($course->ID);
        // Only instructors can assess
        $can_assess = CoursePress_Capabilities::is_course_instructor($course->ID);
        if (!$can_assess) {
            continue;
        }
        $course_obj = new Course($course->ID);
        $course_object = $course_obj->get_course();
        $num_students = $course_obj->get_number_of_students();
        if ($course_obj->get_number_of_students() >= 1) {
            if (empty($first_course_id)) {
                $first_course_id = $course->ID;
            }
            $courses_with_students++;
            ?>
							<option value="<?php 
            echo $course->ID;
            ?>
 public static function get_ungraded_response_count($course_id = '')
 {
     $counter = 0;
     if ($course_id == '') {
         $args = array('post_type' => array('module_response', 'attachment'), 'post_status' => array('publish', 'inherit'), 'posts_per_page' => -1, 'meta_key' => 'course_id', 'meta_value' => $course_id, 'meta_query' => array('relation' => 'AND', array('key' => 'response_grade', 'compare' => 'NOT EXISTS', 'value' => '')));
         $ungraded_responses = get_posts($args);
         //Count only ungraded responses from STUDENTS!
         foreach ($ungraded_responses as $key => $ungraded_response) {
             // Only show count for courses an Instructor can actually assess
             $course_id = get_post_meta($ungraded_response->ID, 'course_id', true);
             if (!CoursePress_Capabilities::is_course_instructor($course_id)) {
                 continue;
             }
             if (get_post_meta($ungraded_response->post_parent, 'gradable_answer', true) != 'yes') {
                 unset($ungraded_responses[$key]);
                 continue;
             }
             if (get_user_option('role', $ungraded_response->post_author) !== 'student') {
                 unset($ungraded_responses[$key]);
                 continue;
             }
             $module = get_post($ungraded_response->post_parent);
             if ($module) {
                 $class_name = $module->module_type;
                 $response = call_user_func($class_name . '::get_response', $ungraded_response->post_author, $module->ID);
                 if (count($response) >= 1) {
                     $grade_data = Unit_Module::get_response_grade($response->ID);
                     if ($grade_data) {
                         // If there are more than one response submitted and it is already graded.
                         unset($ungraded_responses[$key]);
                         continue;
                     }
                 }
                 $unit = get_post($module->post_parent);
                 $course_id = $unit->post_parent;
                 // Count only answers from students that are still enrolled in the course.
                 if (!get_user_option('enrolled_course_date_' . $course_id, $ungraded_response->post_author)) {
                     unset($ungraded_responses[$key]);
                     continue;
                 }
             }
             $counter += 1;
         }
         return $counter;
     } else {
         $args = array('post_type' => array('module_response', 'attachment'), 'post_status' => array('publish', 'inherit'), 'posts_per_page' => -1, 'meta_query' => array('relation' => 'AND', array('key' => 'response_grade', 'compare' => 'NOT EXISTS', 'value' => ''), array('key' => 'course_id', 'value' => $course_id)));
         if (!CoursePress_Capabilities::is_course_instructor($course_id)) {
             return 0;
         }
         $ungraded_responses = get_posts($args);
         //Count only ungraded responses from STUDENTS!
         foreach ($ungraded_responses as $key => $ungraded_response) {
             if (get_post_meta($ungraded_response->post_parent, 'gradable_answer', true) != 'yes') {
                 unset($ungraded_responses[$key]);
                 continue;
             }
             if (get_user_option('role', $ungraded_response->post_author) !== 'student') {
                 unset($ungraded_responses[$key]);
                 continue;
             }
             $module = get_post($ungraded_response->post_parent);
             if ($module) {
                 $class_name = $module->module_type;
                 $response = call_user_func($class_name . '::get_response', $ungraded_response->post_author, $module->ID);
                 if (count($response) >= 1) {
                     $grade_data = Unit_Module::get_response_grade($response->ID);
                     if ($grade_data) {
                         // If there are more than one response submitted and it is already graded.
                         unset($ungraded_responses[$key]);
                         continue;
                     }
                 }
                 $unit = get_post($module->post_parent);
                 $course_id = $unit->post_parent;
                 // Count only answers from students that are still enrolled in the course.
                 if (!get_user_option('enrolled_course_date_' . $course_id, $ungraded_response->post_author)) {
                     unset($ungraded_responses[$key]);
                     continue;
                 }
             }
         }
         return count($ungraded_responses);
     }
 }