Esempio n. 1
0
    global $connection;
    global $version_name;
    global $current_username;
    $query_record = "UPDATE students SET {$version_name}={$new_high_score} WHERE username='******'";
    $recorded_score = mysqli_query($connection, $query_record);
    confirm_query($recorded_score);
    if ($recorded_score) {
        echo "Score updated.";
    } else {
        die("Database query failed.");
    }
}
if ($new_high_score > $store_score) {
    $last_quiz_message = "Congratulations! You earned your personal best on the " . $version_name . " quiz!";
    $last_quiz_report = "You answered " . $new_high_score . " questions correctly.";
    record_high_score($new_high_score, $current_username);
} else {
    $last_quiz_message = "You answered " . $new_high_score . " questions correctly.";
    $last_quiz_report = "Your best score on this quiz is " . $store_score . " correct answers.";
}
a:
unset($_SESSION['quiz_count']);
unset($_SESSION['already_answered']);
unset($_SESSION['score']);
if ($_SESSION["context"] == "student") {
    $menu_message = "Student Base";
    $menu_link = "student_base.php";
} else {
    if ($_SESSION["context"] == "teacher") {
        $menu_message = "Teacher Base";
        $menu_link = "teacher_base.php";
Esempio n. 2
0
 function record_high_score($recent_score, $current_username)
 {
     global $connection;
     global $version_name;
     $query_record = "UPDATE students SET {$version_name}={$recent_score} WHERE username='******'";
     $recorded_score = mysqli_query($connection, $query_record);
     confirm_query($recorded_score);
     if (!$recorded_score) {
         die("Database query failed.");
     }
 }
 /* compares your recent score to the stored score. If new score is higher, it records it. */
 if ($recent_score > $store_score) {
     $results_message = "Congratulations! You earned your personal best on the " . $quiz_name . " quiz!";
     $score_message = "You answered " . $recent_score . " questions correctly.";
     record_high_score($recent_score, $current_username);
 } else {
     $results_message = "You answered " . $recent_score . " questions correctly.";
     $score_message = "Your best score on the " . $quiz_name . " Quiz is " . $store_score . " correct answers.";
 }
 /*$query_record = "UPDATE students SET $version_name={$_SESSION['score']} WHERE username='******'student_username']}'";*/
 /*	$query_record = "UPDATE students SET hawaii_score=1 WHERE username='******'"; */
 /*Here's where I try to set up a badge system */
 /* I need this query to find out if they have already earned the badge */
 $query_badge = "SELECT {$badge_version} FROM students WHERE username = '******'student_username']}' ";
 $result_badges = mysqli_query($connection, $query_badge);
 if (!$result_badges) {
     die("Database query failed.");
 }
 $badges_earned = mysqli_fetch_assoc($result_badges);
 function record_badge_earned($badge_version)