public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/admin/functions.php
/**
 * Generate a course list for resetting the progress for a user.
 *
 * @since 1.0.0
 *
 * @param string $fieldName The name to use for the name attribute for this dropdown.
 * @param array  $courseIDList If specified, this is a list of IDs to determine which courses to use in the reset box.
 * @param string $blankMessage the message to show if there are no courses.
 * @param string $addBlank Use this string as the first item in the dropdown.
 * @param string $cssID The CSS ID to use for the select box.
 * @param string $cssClass The CSS class to use for the select box.
 *
 * @return string The course reset dropdown box.
 */
Generate a course list for resetting the progress for a user.

@param string $fieldName The name to use for the name attribute for this dropdown.
@param array  $courseIDList If specified, this is a list of IDs to determine which courses to use in the reset box.
@param string $blankMessage the message to show if there are no courses.
@param string $addBlank Use this string as the first item in the dropdown.
@param string $cssID The CSS ID to use for the select box.
@param string $cssClass The CSS class to use for the select box.

@return string The course reset dropdown box.
Generate a course list for resetting the progress for a user . @param string $fieldName The name to use for the name attribute for this dropdown . @param array $courseIDList If specified this is a list of IDs to determine which courses to use in the reset box . @param string $blankMessage the message to show if there are no courses . @param string $addBlank Use this string as the first item in the dropdown . @param string $cssID The CSS ID to use for the select box . @param string $cssClass The CSS class to use for the select box . @return string The course reset dropdown box .
function WPCW_courses_getCourseResetDropdown( $fieldName, $courseIDList = false, $blankMessage, $addBlank, $cssID, $cssClass ) {
	$selectDetails = array( '' => $addBlank );
	$courseList = WPCW_courses_getCourseList();
	if ( ! empty( $courseList ) ) {
		$blankCount = 2;
		foreach ( $courseList as $courseID => $aCourse ) {
			if ( is_array( $courseIDList ) && ! in_array( $courseID, $courseIDList ) ) {
				continue;
			}
			$selectDetails[ 'course_' . $courseID ] = $aCourse;
			$moduleList = WPCW_courses_getModuleDetailsList( $courseID );
			if ( ! empty( $moduleList ) ) {
				foreach ( $moduleList as $moduleID => $moduleDetails ) {
					$units = WPCW_units_getListOfUnits( $moduleID );
					if ( ! empty( $units ) ) {
						$selectDetails[ 'module_' . $moduleID ] = sprintf( '&nbsp;&nbsp;- %s %d: %s',
							__( 'Module', 'wp-courseware' ),
							$moduleDetails->module_number,
							$moduleDetails->module_title
						);
						foreach ( $units as $unitID => $unitDetails ) {
							$selectDetails[ 'unit_' . $unitID ] = sprintf( '&nbsp;&nbsp;-- %s %d: %s',
								__( 'Unit', 'wp-courseware' ),
								$unitDetails->unit_meta->unit_number,
								$unitDetails->post_title
							);
						}
					}
				}
			}
			$paddingKey                   = str_pad( false, $blankCount ++, ' ' );
			$selectDetails[ $paddingKey ] = '&nbsp';
		}
	}
	if ( count( $selectDetails ) == 1 ) {
		$selectDetails[' '] = $blankMessage;
	}
	return WPCW_forms_createDropdown( $fieldName, $selectDetails, false, $cssID, $cssClass );
}
function WPCW_courses_getCourseResetDropdown ( $ fieldName , $ courseIDList = false , $ blankMessage , $ addBlank , $ cssID , $ cssClass ) { $ selectDetails = array ( '' => $ addBlank ) ; $ courseList = WPCW_courses_getCourseList ( ) ; if ( ! empty ( $ courseList ) ) { $ blankCount = 2 ; foreach ( $ courseList as $ courseID => $ aCourse ) { if ( is_array ( $ courseIDList ) && ! in_array ( $ courseID , $ courseIDList ) ) { continue ; } $ selectDetails [ 'course_' . $ courseID ] = $ aCourse ; $ moduleList = WPCW_courses_getModuleDetailsList ( $ courseID ) ; if ( ! empty ( $ moduleList ) ) { foreach ( $ moduleList as $ moduleID => $ moduleDetails ) { $ units = WPCW_units_getListOfUnits ( $ moduleID ) ; if ( ! empty ( $ units ) ) { $ selectDetails [ 'module_' . $ moduleID ] = sprintf ( '&nbsp;&nbsp;- %s %d: %s' , __ ( 'Module' , 'wp-courseware' ) , $ moduleDetails -> module_number , $ moduleDetails -> module_title ) ; foreach ( $ units as $ unitID => $ unitDetails ) { $ selectDetails [ 'unit_' . $ unitID ] = sprintf ( '&nbsp;&nbsp;-- %s %d: %s' , __ ( 'Unit' , 'wp-courseware' ) , $ unitDetails -> unit_meta -> unit_number , $ unitDetails -> post_title ) ; } } } } $ paddingKey = str_pad ( false , $ blankCount ++ , ' ' ) ; $ selectDetails [ $ paddingKey ] = '&nbsp' ; } } if ( count ( $ selectDetails ) == 1 ) { $ selectDetails [ ' ' ] = $ blankMessage ; } return WPCW_forms_createDropdown ( $ fieldName , $ selectDetails , false , $ cssID , $ cssClass ) ; }
Generate a course list for resetting the progress for a user.
Generate a course list for resetting the progress for a user .
// Need all courses // Filter out unwanted courses. // Have sentinel of course_ to identify a course. // Now we add the modules for this course // Now we add the units for this course // Only add a module if it has units, to make resetting easier. // Add a blank sentinel to space out courses. // No courses... show meaningful message to the trainer. // Generate the select box. Use the $cssID as the name of the field too.