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']; $deadline = $courseDetails['deadline']; } 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(); } //echo $deadline; $now = new DateTime(); $deadlineTime = $deadline ? new DateTime($deadline) : null; $isBeforeDeadline = $now <= $deadlineTime; $deadlineFormatted = $deadline ? date('l, d M Y \a\t H:i', strtotime($deadline)) : 'not set'; // 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(); } // IDENTIFY TEAM MEMBERS // Step 1: Fetch the student's group $sql = "SELECT `group`, `lead` FROM students WHERE courseID = ? AND studentID = ?"; $stmt = $link->prepare($sql); $stmt->bind_param("ss", $courseID, $studentID); $stmt->execute(); $result = $stmt->get_result(); if ($row = $result->fetch_assoc()) { $studentIDgroup = $row['group']; $lead = $row['lead']; } else { $studentIDgroup = null; } $stmt->close(); // Step 2: Fetch all teammates' names (except the student), mark team leader $teamMembers = []; if ($studentIDgroup !== null) { $sql = " SELECT lastname, firstname, `lead` FROM students WHERE courseID = ? AND `group` = ? AND studentID != ? "; $stmt = $link->prepare($sql); $stmt->bind_param("sss", $courseID, $studentIDgroup, $studentID); $stmt->execute(); $result = $stmt->get_result(); while ($row = $result->fetch_assoc()) { $name = $row['lastname'] . " " . $row['firstname']; if ((int)$row['lead'] === 1) { $name .= " (team leader)"; } $teamMembers[] = $name; } $stmt->close(); } // Initialize an empty array to store topics $topics = []; try { // Prepare an SQL query to select all papers and store them in an array $allPapers = []; $allPapersSql = "SELECT id, paper FROM papers"; if ($result = $link->query($allPapersSql)) { while ($row = $result->fetch_assoc()) { $allPapers[$row['id']] = $row['paper']; // Store paper reference with ID as key } $result->free(); } // Prepare an SQL query to select id, name, and items from the topics table $sql = "SELECT id, name, items FROM topics"; // Execute the query to fetch topics if ($result = $link->query($sql)) { // Fetch each topic row while ($row = $result->fetch_assoc()) { $topicID = $row['id']; // Fetch all required reading papers related to this topic $paperSql = "SELECT paper FROM papers WHERE topic = ?"; $paperStmt = $link->prepare($paperSql); $paperStmt->bind_param("i", $topicID); $paperStmt->execute(); $paperResult = $paperStmt->get_result(); // Initialize an array to store required reading papers $papers = []; while ($paperRow = $paperResult->fetch_assoc()) { $papers[] = $paperRow['paper']; // Store each paper reference } // Fetch course information for the given courseID $courseSql = "SELECT * FROM courses WHERE courseID = ?"; $courseStmt = $link->prepare($courseSql); $courseStmt->bind_param("s", $courseID); $courseStmt->execute(); $courseResult = $courseStmt->get_result(); $courseInfo = $courseResult->fetch_assoc(); // Fetch the course row // Initialize an array to store session details $sessionDetails = []; for ($i = 1; $i <= 6; $i++) { foreach (['A', 'B'] as $session) { $dayKey = "{$i}{$session}day"; $paperKey = "{$i}{$session}paper"; $presentKey = "{$i}{$session}present"; $discussKey = "{$i}{$session}discuss"; $activationKey = "{$i}{$session}"; // Column name for activation (e.g., 1A, 2B, etc.) // Check if the current session's day matches the topic ID if (isset($courseInfo[$dayKey]) && $courseInfo[$dayKey] == $topicID) { $paperID = $courseInfo[$paperKey]; $paperReference = $allPapers[$paperID] ?? 'Unknown Paper'; $sessionDetails[] = [ 'sessionID' => "{$i}{$session}", 'activated' => $courseInfo[$activationKey] ?? 0, 'paper' => $paperReference, 'present' => $courseInfo[$presentKey] ?? 'To be determined', 'discuss' => $courseInfo[$discussKey] ?? 'To be determined' ]; } } } // Store the topic, required reading papers, and session details in the $topics array $topics[] = [ 'id' => $topicID, 'name' => $row['name'], 'items' => $row['items'], 'papers' => $papers, // Store required reading papers 'sessions' => $sessionDetails // Store session details ]; // Free the result sets $paperResult->free(); $courseResult->free(); } } // Free result set for topics $result->free(); } catch (Exception $e) { // Handle errors (optional) echo "Error fetching topics or papers: " . $e->getMessage(); } //echo '
';
//print_r($topics);
//echo '
'; $link->close(); ?> Class home - Microeconomic Analysis of Consumer Behavior

TOPICS

This page displays all topics covered in this course.
Each topic includes key content, slides, related materials, and class activities.

Download the course outline here.

'; } ?>

Your Team

Your Group:

You are team leader"; ?>

You have no teammates in this course.

📄 Check the guidelines for the team project.

$deadlineFormatted.
"; } else { echo "⏰ The submission deadline has passed."; } echo " Submit or check submitted files here."; } else { // Team member if ($isBeforeDeadline) { echo "🧑‍🤝‍🧑 Your team leader can submit the team project files before $deadlineFormatted.
"; } else { echo "⏰ The submission deadline has passed."; } echo " You can check the submitted files here."; $reportfilepath = $_SERVER['DOCUMENT_ROOT'] . '/acb/reports/' . $courseID . '_' . $studentIDgroup . '.pdf'; $reporturl = '/acb/reports/' . $courseID . '_' . $studentIDgroup . '.pdf'; if (file_exists($reportfilepath)) { echo '

View evaluation report on your team project.

'; } } ?>


Key content:
', '
    ', $topic['items']); ?>

    Download slides here.

    Slides will be available soon.


    Related papers:
      $paper): ?>

    Class activities:

    Check the guidelines for group evaluation here.

    • Session ID:
      Paper:
      Presenting Group: (This is your group) Evaluate
      Discussing Group: (This is your group) Evaluate