CoursePress - Show student overview on front end.

Now that coursepress pro version 2.0 displays the students progress within their workbook, is there any chance that student specific shortcodes can be generated/created so I can allow a students manager to view their course progress.

Ideally I'm trying to create a page whereby I can list the students names and their course progress or is there a report I can run for all students?

I don't want the student manager to be able to login to the backend of wordpress though.
I just want them to be able to see their learners progress overall. So if they have 8 students in XYZ course they can get a snapshot overview of where they are all up to.

It's also important that they are not able to change anything within the course, just view student progress.

  • Ivan

    Hi EVOLOGY !

    You can try to create MU plugin as (wordpress_folder)/wp-content/mu-plugins/wpmu_workbooks_shortcode.php file via FTP and add the following code to this file

    <?php
    
    function wpmu_workbooks_shortcode( $atts ) {
        $return = '';
        if ( !class_exists( 'CoursePress_Helper_Utility' ) ) {
            return $return;
        }
        $current_user_id = get_current_user_id();
    
        $course_ids = array_merge(
                CoursePress_Data_Facilitator::get_facilitated_courses( $current_user_id, array( 'publish' ), true ),
                CoursePress_Data_Instructor::get_assigned_courses_ids( $current_user_id )
        );
    
        if ( $course_ids ) {
            foreach ( $course_ids as $course_id ) {
                CoursePress_Helper_Utility::set_the_course( $course_id );
                $course = CoursePress_Data_Course::get_course( $course_id );
                $return .= '<br><br><br>' . sprintf( __( 'COURSE TITLE - %s' ), $course->post_title );
    
                $students = CoursePress_Data_Course::get_students( $course_id );
    
                foreach ( $students as $student ) {
                    $new_user = wp_set_current_user( $student->ID );
                    if ( !empty( $new_user->ID ) ) {
                        $return .= '<br><br>' . sprintf( __( 'WORKBOOK OF %s' ), $new_user->data->user_nicename );
                        $return .= CoursePress_Data_Shortcode_Student::student_workbook_table( array() );
                    }
    
                }
            }
        } else {
            $return .= __( 'COURSE NOT FOUND' );
        }
        wp_set_current_user( $current_user_id );
    
        return $return;
    }
    add_shortcode( 'wpmu_workbooks_shortcode', 'wpmu_workbooks_shortcode' );

    Then you can use [wpmu_workbooks_shortcode] for displaying all workbooks of students for all courses where the current user is Facilitator or Instructor.

    Best regards,
    Ivan.

  • Valentijn L

    Hi
    Looks great but how to make a workbook overview with direct links for the students
    based on Members Pro membership selections?

    I guess matching active members of their relevant group :

    How to correct this for each active student (want an extra link on top showing at the end all workbook of all courses and modules clickable)

    foreach ( $students as $student ) {
    $new_user = wp_set_current_user( $student->ID );
    if ( !empty( $new_user->ID ) ) {
    $return .= '

    ' . sprintf( __( 'WORKBOOK OF %s' ), $new_user->data->user_nicename );
    $return .= CoursePress_Data_Shortcode_Student::student_workbook_table( array() );
    }

    }

    Now students have to go inside an active course and press on workbook

  • Ivan

    Hi Valentijn L !

    If I correctly understood you - you want to show a link to the workbook of a current course. If yes - you should change your provided part of the code to

    $workbook_is_active = CoursePress_Helper_Utility::checked( CoursePress_Data_Course::get_setting( $course_id, 'allow_workbook', false ) );
    if ( $workbook_is_active ) {
    	$workbook_url = CoursePress_Data_Student::get_workbook_url( $course_id );
    } else {
    	$workbook_url = '';
    }
    
    foreach ( $students as $student ) {
    	$new_user = wp_set_current_user( $student->ID );
    	if ( !empty( $new_user->ID ) ) {
    		$return .= $workbook_url ? '<br><br><a href="' . $workbook_url . '">' . __( 'WORKBOOK LINK' ) . '</a>' : '';
    		$return .= '<br><br>' . sprintf( __( 'WORKBOOK OF %s' ), $new_user->data->user_nicename );
    		$return .= CoursePress_Data_Shortcode_Student::student_workbook_table( array() );
    	}
    }

    If I incorrectly understood you - please, provide me an example of the link which you want to show.

    Best,
    Ivan.

  • Ivan

    Hi Valentijn L !

    For showing workbooks links of enrolled courses for current user in separate shortcode - You could try adding the following snippet in a MU plugin ( more info about MU plugins is here )

    function wpmu_student_workbooks_shortcode(  ) {
        $return = '';
        $current_user_id = get_current_user_id();
    	if ( class_exists( 'CoursePress_Data_Student' ) && $current_user_id ) {
    		$student_courses = CoursePress_Data_Student::get_enrolled_courses_ids( $current_user_id );
    		foreach ( $student_courses as $course_id ) {
    			$workbook_is_active = CoursePress_Helper_Utility::checked( CoursePress_Data_Course::get_setting( $course_id, 'allow_workbook', false ) );
    			if ( $workbook_is_active ) {
    				$workbook_url = CoursePress_Data_Student::get_workbook_url( $course_id );
    				$course = CoursePress_Data_Course::get_course( $course_id );
    				$return .= '<a href="' . $workbook_url . '">' . $course->post_title . '</a><br>';
    			}
    		}
    	}
        return $return;
    }
    add_shortcode( 'wpmu_student_workbooks_shortcode', 'wpmu_student_workbooks_shortcode' );

    Then you can use [wpmu_student_workbooks_shortcode] for it.

    Best,
    Ivan.

  • Valentijn L

    Hi
    Did a bit of tweaking using arrays now :

    //* cp show workbook */
    
    function wpmu_student_workbooks_shortcode(  ) {
        $return = '';
        $current_user_id = get_current_user_id();
        $workbooks = array();
    	if ( class_exists( 'CoursePress_Data_Student' ) && $current_user_id ) {
    		$student_courses = CoursePress_Data_Student::get_enrolled_courses_ids( $current_user_id );
    		foreach ( $student_courses as $course_id ) {
    			$workbook_is_active = CoursePress_Helper_Utility::checked( CoursePress_Data_Course::get_setting( $course_id, 'allow_workbook', false ) );
    			if ( $workbook_is_active ) {
    				$workbook_url = CoursePress_Data_Student::get_workbook_url( $course_id );
    				$course = CoursePress_Data_Course::get_course( $course_id );
    				$return = '<a href="' . $workbook_url . '" target="blank" description="open this workbook" title="open this workbook">' . $course->post_title . '</a>';
    				//$return .= '<a href="' . $workbook_url . '" target="blank" description="open deze werkboek" title="open deze werkboek">' . $course->post_title . '</a><br>';
    				array_push($workbooks, $return);
    			}
    		}
    	}
    
    	sort($workbooks);
    	//var_dump($workbooks);
    		foreach($workbooks as $key => $value)
    		{
    		  echo $value.'<br>';
    		}
    
    }
    add_shortcode( 'wpmu_student_workbooks_shortcode', 'wpmu_student_workbooks_shortcode' );
  • Ivan

    Hi Valentijn L !

    how to output also in one page instead of delivering of list of links to the workbooks.

    Do you mean the output of workbooks? if yes - did you try to use the MU which described in the first my reply of this thread?

    Now my students have to click 5 links to have an overview. Any suggestions?

    Do you mean the overview of Courses? If yes - you can use the main coursepress's page for that. By default, it's {your_domain}/courses or you can change this slug on WP Dashboard -> Coursepress Pro -> Settings page.

    Best,
    Ivan.