prepare($sql_course)) { // Bind variables to the prepared statement as parameters $stmt_course->bind_param("s", $param_courseID); // Set parameters $param_courseID = $courseID; // Attempt to execute the prepared statement if ($stmt_course->execute()) { // Get result $result = $stmt_course->get_result(); // Check if the course exists if ($result->num_rows == 1) { // Fetch result as an associative array $courseDetails = $result->fetch_assoc(); $coursename = $courseDetails['coursename']; $degree = $courseDetails['degree']; $startdate = $courseDetails['start']; $time = $courseDetails['time']; $room = $courseDetails['room']; $instructorID = $courseDetails['instructorID']; } else { // Course not found, handle the error as needed header('Location: /acb/login.html?error=Course not found'); exit(); } } else { echo "Oops! Something went wrong. Please try again later."; } // Close statement $stmt_course->close(); } // Create DateTime objects try { $startdateObj = new DateTime($startdate); $timeObj = new DateTime($time); } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; exit; } // Translate day of the week and time of day $dayOfWeek = translateDayOfWeek($startdateObj->format('l')); $timeOfDay = translateTimeOfDay((int)$timeObj->format('H')); // Format date and time $startdateFormatted = $startdateObj->format('d/m/Y'); $timeFormatted = $timeObj->format('H:i'); // Combine the time description $fullTimeDescription = $timeFormatted . ' (' . $dayOfWeek . ' ' . $timeOfDay . ')'; //echo $fullTimeDescription; // Fetch instructor's full name based on instructorID $instructor = 'Instructor not found'; $sql_instructor = "SELECT fullname FROM instructors WHERE instructorID = ?"; if ($stmt_instructor = $link->prepare($sql_instructor)) { // Bind variables to the prepared statement as parameters $stmt_instructor->bind_param("s", $param_instructorID); // Set parameters $param_instructorID = $instructorID; // Attempt to execute the prepared statement if ($stmt_instructor->execute()) { // Get result $result = $stmt_instructor->get_result(); // Check if the instructor exists if ($result->num_rows == 1) { // Fetch result as an associative array $instructorData = $result->fetch_assoc(); $instructor = $instructorData['fullname']; } else { // Instructor not found, handle the error as needed $instructor = 'Instructor not found'; } } else { echo "Oops! Something went wrong. Please try again later."; } // Close statement $stmt_instructor->close(); } // Fetch the bonus score from the student table $sql = "SELECT bonus, `group` FROM students WHERE studentID = ? AND courseID = ?"; $stmt = $link->prepare($sql); $stmt->bind_param("ss", $studentID, $courseID); $stmt->execute(); $result = $stmt->get_result(); // Fetch the results or set default values if ($row = $result->fetch_assoc()) { $bonusScore = $row['bonus'] !== null ? $row['bonus']/50 : 0; $groupID = !empty($row['group']) ? $row['group'] : "Not Assigned"; // Default to "Not Assigned" } else { $bonusScore = 0; $groupID = "Not Assigned"; // Default if no record found } // Get midterm scores $scores = getMidtermScore($studentID, $courseID, $link); // Check for errors if (isset($scores["error"])) { echo "

Error: " . htmlspecialchars($scores["error"]) . "

"; } else { // Scale Scores $midtermPresentScaled = ($scores["highestPresent"] > 0) ? round(($scores["midtermPresent"] / $scores["highestPresent"]) * 10, 1) : 0; $midtermDiscussScaled = ($scores["highestDiscuss"] > 0) ? round(($scores["midtermDiscuss"] / $scores["highestDiscuss"]) * 10, 1) : 0; // Earned Scores (scaled down if they haven't evaluated all 22 groups) $midtermPresentEarned = round($midtermPresentScaled * (($scores["evaluatedPresent"] + $scores["evaluatedDiscuss"])/ 22), 1); $midtermDiscussEarned = round($midtermDiscussScaled * (($scores["evaluatedDiscuss"] + $scores["evaluatedDiscuss"])/ 22), 1); $midtermTotalScaled = round((0.5 * $midtermPresentScaled) + (0.5 * $midtermDiscussScaled), 1); $midtermTotalEarned = round(($midtermTotalScaled * ($scores["evaluatedPresent"] + $scores["evaluatedDiscuss"]) / 22), 1); // Display the results //echo "

Midterm Presentation Score: " . htmlspecialchars($scores["midtermPresent"]) . "

"; //echo "

Number of Evaluations for Presentation: " . htmlspecialchars($scores["nPresent"]) . "

"; //echo "

Midterm Discussion Score: " . htmlspecialchars($scores["midtermDiscuss"]) . "

"; //echo "

Number of Evaluations for Discussion: " . htmlspecialchars($scores["nDiscuss"]) . "

"; //echo "

Highest Presentation Score: " . htmlspecialchars($scores["highestPresent"]) . "

"; //echo "

Highest Discussion Score: " . htmlspecialchars($scores["highestDiscuss"]) . "

"; //echo "

Evaluations Given for Presentations: " . htmlspecialchars($scores["evaluatedPresent"]) . "

"; //echo "

Evaluations Given for Discussions: " . htmlspecialchars($scores["evaluatedDiscuss"]) . "

"; // Display Scaled & Earned Scores //echo "
"; //echo "

Scaled Midterm Presentation Score: " . htmlspecialchars($midtermPresentScaled) . "

"; //echo "

Earned Midterm Presentation Score (adjusted for evaluations): " . htmlspecialchars($midtermPresentEarned) . "

"; //echo "

Scaled Midterm Discussion Score: " . htmlspecialchars($midtermDiscussScaled) . "

"; //echo "

Earned Midterm Discussion Score (adjusted for evaluations): " . htmlspecialchars($midtermDiscussEarned) . "

"; } // Step 1: Fetch the student's groupID $sql = "SELECT `group` FROM students WHERE studentID = ? AND courseID = ?"; $stmt = $link->prepare($sql); $stmt->bind_param("ss", $studentID, $courseID); $stmt->execute(); $result = $stmt->get_result(); if ($row = $result->fetch_assoc()) { $groupID = $row['group']; } else { $groupID = null; } $stmt->close(); // Step 2: Fetch the final exam score for this group $finalScore = 0; // Default value if no score found if ($groupID) { $sql = "SELECT score FROM final WHERE `group` = ? AND courseID = ?"; $stmt = $link->prepare($sql); $stmt->bind_param("ss", $groupID, $courseID); $stmt->execute(); $result = $stmt->get_result(); if ($row = $result->fetch_assoc()) { $finalScore = $row['score']; } } // Close database connection $stmt->close(); // Step 7: Compute Total Score $totalScore = round((0.5 * (is_numeric($finalScore) ? $finalScore : 0)) + (0.5 * $midtermTotalEarned), 1); $midtermTotalBonus = $midtermTotalEarned + $bonusScore; $finalScoreBonus = (is_numeric($finalScore) ? $finalScore : 0) + $bonusScore; $totalScoreBonus = $totalScore + $bonusScore; // Display the bonus score //echo "

Midterm total: " . htmlspecialchars($midtermTotalEarned) . "

"; //echo "

Final: " . htmlspecialchars($finalScore) . "

"; //echo "

Total: " . htmlspecialchars($totalScore) . "

"; //echo "

Bonus Score: " . htmlspecialchars($bonusScore) . "

"; //echo "

Group ID: " . htmlspecialchars($groupID) . "

"; // Check if the row exists $sql = "SELECT 1 FROM ACB.scores WHERE studentID = ? AND courseID = ?"; $stmt = $link->prepare($sql); $stmt->bind_param("ss", $studentID, $courseID); $stmt->execute(); $result = $stmt->get_result(); if ($result->num_rows > 0) { // Row exists – perform update $stmt->close(); $updateSql = "UPDATE ACB.scores SET midterm = ?, final = ?, total = ? WHERE studentID = ? AND courseID = ?"; $stmt = $link->prepare($updateSql); $stmt->bind_param("dddss", $midtermTotalBonus, $finalScoreBonus, $totalScoreBonus, $studentID, $courseID); $stmt->execute(); } else { // Row does not exist – perform insert $stmt->close(); $insertSql = "INSERT INTO ACB.scores (studentID, courseID, midterm, final, total) VALUES (?, ?, ?, ?, ?)"; $stmt = $link->prepare($insertSql); $stmt->bind_param("ssddd", $studentID, $courseID, $midtermTotalBonus, $finalScoreBonus, $totalScoreBonus); $stmt->execute(); } // Cleanup $stmt->close(); // Close the link $link->close(); ?> Scores - Microeconomic Analysis of Consumer Behavior

YOUR SCORES

This page displays your scores.
Note that your midterm score is scaled based on the highest group score and may change as new scores become available.

Your class participation

Bonus points for lecture participation:

Number of evaluations for presentation:

Number of evaluations for discussion:

Total evaluations given:

Total required evaluations is 22.


Presentation

Number of evaluations from your classmates:

Presentation score:

Highest presentation score in class:

Scaled presentation score:

(Scaled by the highest presentation score in class.)

Your score for presentation:

(Scaled by the number of evaluations you gave out of the required 22 evaluations)


Discussion

Number of evaluations from your classmates:

Discussion score:

Highest discussion score in Class:

Scaled discussion score:

(Scaled by the highest discussion score in class.)

Your score for discussion:

(Scaled by the number of evaluations you gave out of the required 22 evaluations)


Overall

Midterm total (50%):

Midterm total after bonus:

Team project score (50%):

Team project score after bonus (50%):

Total score:

Total score after bonus:

Note that the total score will not exceed 10.