public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/functions.php
/**
 * Update the quiz results in the database.
 *
 * Assume that the data exists when doing this update.
 *
 * @since 1.0.0
 *
 * @param object $quizResultsSoFar The updated list of results data.
 */
Update the quiz results in the database.
Assume that the data exists when doing this update.



@param object $quizResultsSoFar The updated list of results data.
Update the quiz results in the database . Assume that the data exists when doing this update . @param object $quizResultsSoFar The updated list of results data .
function WPCW_quizzes_updateQuizResults( $quizResultsSoFar ) {
	global $wpcwdb, $wpdb;
	$wpdb->show_errors();
	$markinglistCount = 0;
	$markinglist      = false;
	$needsMarkingList = $quizResultsSoFar->quiz_needs_marking_list;
	$newQuizData      = $quizResultsSoFar->quiz_data;
	if ( ! empty( $needsMarkingList ) ) {
		$markinglist      = maybe_serialize( $needsMarkingList );
		$markinglistCount = count( $needsMarkingList );
	}
	$dataToUpdate = array(
		'user_id'                 => $quizResultsSoFar->user_id,
		'unit_id'                 => $quizResultsSoFar->unit_id,
		'quiz_id'                 => $quizResultsSoFar->quiz_id,
		'quiz_needs_marking_list' => $markinglist,
		'quiz_needs_marking'      => $markinglistCount,
		'quiz_data'               => maybe_serialize( $newQuizData ),
		'quiz_grade'              => - 1,
		'quiz_attempt_id'         => $quizResultsSoFar->quiz_attempt_id,
	);
	$dataToUpdate['quiz_grade'] = WPCW_quizzes_calculateGradeForQuiz( $newQuizData, $markinglistCount );
	$SQL = arrayToSQLUpdate( $wpcwdb->user_progress_quiz, $dataToUpdate, array( 'user_id', 'unit_id', 'quiz_id', 'quiz_attempt_id' ) );
	$wpdb->query( $SQL );
}
function WPCW_quizzes_updateQuizResults ( $ quizResultsSoFar ) { global $ wpcwdb , $ wpdb ; $ wpdb -> show_errors ( ) ; $ markinglistCount = 0 ; $ markinglist = false ; $ needsMarkingList = $ quizResultsSoFar -> quiz_needs_marking_list ; $ newQuizData = $ quizResultsSoFar -> quiz_data ; if ( ! empty ( $ needsMarkingList ) ) { $ markinglist = maybe_serialize ( $ needsMarkingList ) ; $ markinglistCount = count ( $ needsMarkingList ) ; } $ dataToUpdate = array ( 'user_id' => $ quizResultsSoFar -> user_id , 'unit_id' => $ quizResultsSoFar -> unit_id , 'quiz_id' => $ quizResultsSoFar -> quiz_id , 'quiz_needs_marking_list' => $ markinglist , 'quiz_needs_marking' => $ markinglistCount , 'quiz_data' => maybe_serialize ( $ newQuizData ) , 'quiz_grade' => - 1 , 'quiz_attempt_id' => $ quizResultsSoFar -> quiz_attempt_id , ) ; $ dataToUpdate [ 'quiz_grade' ] = WPCW_quizzes_calculateGradeForQuiz ( $ newQuizData , $ markinglistCount ) ; $ SQL = arrayToSQLUpdate ( $ wpcwdb -> user_progress_quiz , $ dataToUpdate , array ( 'user_id' , 'unit_id' , 'quiz_id' , 'quiz_attempt_id' ) ) ; $ wpdb -> query ( $ SQL ) ; }
Update the quiz results in the database.
Update the quiz results in the database .
// Relabel variables for clarity. // Got items that need marking. // Update with the quiz grade