public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/functions.php
/**
 * Marks a unit as complete for the specified user. No error checking is made to check that the user
 * is allowed to update the record, it's assumed that the permission checking has been done before this step.
 *
 * @since 1.0.0
 *
 * @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.
 */
Marks a unit as complete for the specified user. No error checking is made to check that the user
is allowed to update the record, it's assumed that the permission checking has been done before this step.



@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.
Marks a unit as complete for the specified user . No error checking is made to check that the user is allowed to update the record it ' s assumed that the permission checking has been done before this step . @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 .
function WPCW_units_saveUserProgress_Complete( $userID, $unitID ) {
	global $wpdb, $wpcwdb;
	$wpdb->show_errors();
	$keyColumns = array( 'user_id', 'unit_id' );
	$data                          = array();
	$data['unit_completed_status'] = 'complete';
	$data['unit_completed_date']   = current_time( 'mysql' );
	$data['user_id']               = $userID;
	$data['unit_id']               = $unitID;
	$progress = doesRecordExistAlready( $wpcwdb->user_progress, $keyColumns, array( $userID, $unitID ) );
	if ( $progress ) {
		if ( $progress->unit_completed_status == 'complete' ) {
			return false;
		}
		$SQL = arrayToSQLUpdate( $wpcwdb->user_progress, $data, $keyColumns );
	} else {
		$SQL = arrayToSQLInsert( $wpcwdb->user_progress, $data );
	}
	$wpdb->query( $SQL );
}
function WPCW_units_saveUserProgress_Complete ( $ userID , $ unitID ) { global $ wpdb , $ wpcwdb ; $ wpdb -> show_errors ( ) ; $ keyColumns = array ( 'user_id' , 'unit_id' ) ; $ data = array ( ) ; $ data [ 'unit_completed_status' ] = 'complete' ; $ data [ 'unit_completed_date' ] = current_time ( 'mysql' ) ; $ data [ 'user_id' ] = $ userID ; $ data [ 'unit_id' ] = $ unitID ; $ progress = doesRecordExistAlready ( $ wpcwdb -> user_progress , $ keyColumns , array ( $ userID , $ unitID ) ) ; if ( $ progress ) { if ( $ progress -> unit_completed_status == 'complete' ) { return false ; } $ SQL = arrayToSQLUpdate ( $ wpcwdb -> user_progress , $ data , $ keyColumns ) ; } else { $ SQL = arrayToSQLInsert ( $ wpcwdb -> user_progress , $ data ) ; } $ wpdb -> query ( $ SQL ) ; }
Marks a unit as complete for the specified user.
Marks a unit as complete for the specified user .
// Has it been marked as complete? If so, we don't want to do that again to preserve the date. // We generally shouldn't get here, but protect anyway.