| Current Path : /var/www/cesa.co.za/cceconvenors/ |
| Current File : /var/www/cesa.co.za/cceconvenors/exams.php |
<?php
session_start(); // Initialize Session data
ob_start(); // Turn on output buffering
$Questionnaire_ID = intval($_REQUEST["qid"]);
?>
<?php include "ewcfg7.php" ?>
<?php include "ewmysql7.php" ?>
<?php include "phpfn7.php" ?>
<?php include "userfn7.php" ?>
<?php
if (!isset($_SESSION[EW_SESSION_STATUS]) || ($_SESSION[EW_SESSION_STATUS] != "login")) {
header("Location: " . "http" . ($_SERVER["HTTPS"] == "on" ? "s" : "") . "://" . $_SERVER["HTTP_HOST"] . "/cceconvenors/login.php");
die();
}
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
$conni = mysqli_connect(EW_CONN_HOST, EW_CONN_USER, EW_CONN_PASS, EW_CONN_DB);
include_once($_SERVER['DOCUMENT_ROOT'] . "/cesanet/inc_shared.php");
$sql = "SELECT CCEExams.Questionnaire_Name, CCEExams.Score, CCEExams.MarkerUser, COUNT(CCEExamQuestions.Question_ID) AS NumQuestions
FROM CCEExams JOIN CCEExamQuestions USING (Questionnaire_ID)
WHERE CCEExams.Questionnaire_ID='" . $Questionnaire_ID . "'
GROUP BY Questionnaire_Name, Score, MarkerUser";
//echo $sql;
$rec = mysqli_query($conni, $sql);
if ($row = mysqli_fetch_assoc($rec)) {
extract($row);
} else {
die();
}
mysqli_free_result($rec);
$bUserCanMark = CCEConvenorAuth::canMarkExam($MarkerUser, $Questionnaire_ID);
$bUserCanMark = true;
//echo $_SESSION[EW_SESSION_USER_NAME];
$sql = "SELECT CCEStudents.CCEStudentID, CCEStudents.KnownAs, CCEStudents.FirstName, CCEStudents.Surname, SUM(CCEExamMarks.Question_Score) AS TotalScore,
COUNT(CCEExamMarks.Question_ID) AS NumMarked, MAX(CCEExamMarks.DateMarked) AS DateMarked, CCEExamTiming.TimeStarted,
CCEExamTiming.CCEExamTimingID,
(SELECT COUNT(CCEExamStudentAnswers.AnonAnswerID) FROM CCEExamStudentAnswers
WHERE CCEExamStudentAnswers.ExamTimingID = CCEExamTiming.CCEExamTimingID) AS NumAnswered
FROM CCEStudents
INNER JOIN CCEStudentCourses USING (CCEStudentID)
INNER JOIN CCEExamTiming ON (CCEExamTiming.CCEStudentID=CCEStudents.CCEStudentID)
LEFT JOIN CCEExamMarks ON (CCEStudents.CCEStudentID=CCEExamMarks.CCEStudentID
AND CCEExamMarks.Questionnaire_ID=CCEExamTiming.Questionnaire_ID AND CCEExamTiming.CCEExamTimingID = CCEExamMarks.ExamTimingID)
WHERE CCEExamTiming.Questionnaire_ID=" . $Questionnaire_ID . "
AND CCEStudents.CCEStudentID NOT IN (" . implode(',', getTestStudentIDs()) . ")
GROUP BY CCEStudents.CCEStudentID, CCEStudents.KnownAs, CCEStudents.FirstName, CCEStudents.Surname, CCEExamTiming.TimeStarted,
CCEExamTiming.CCEExamTimingID
ORDER BY CCEExamTiming.TimeStarted DESC, " . CCEStudentDisplayOrder::sqlOrderByDisplayName('CCEStudents');
// echo 'Please ignore debug info: ' . $sql . '<br />';
$rec = mysqli_query($conni, $sql);
$dates = array();
$dateSelected = null;
$rows = array();
if (isset($_REQUEST['selectedDate']) && strlen($_REQUEST['selectedDate']) > 0) {
$dateSelected = new DateTime($_REQUEST['selectedDate']);
}
while ($row = mysqli_fetch_assoc($rec)) {
// echo $row['TimeStarted'] . '<br />';
$date = new DateTime($row['TimeStarted']);
$rows[] = $row;
if (!in_array($date->format('d-M-Y'), $dates)) {
$dates[] = $date->format('d-M-Y');
}
if (is_null($dateSelected)) {
$dateSelected = $date;
}
}
?>
<?php include "header.php" ?>
<h1><?php echo htmlspecialchars($Questionnaire_Name); ?></h1>
<table border=1 cellspacing=0 cellpadding=5 width="95%">
<tr>
<th colspan="5">
<h4>Exam View Screen</h4>
</th>
</tr>
<tr><td bgcolor="#EEEEEE"><b>Student</b></td><td bgcolor="#EEEEEE"><b>Overall Mark</b></td>
<td bgcolor="#EEEEEE"><b>Date Marked</b></td><td bgcolor="#EEEEEE"><b>All Questions Marked?</b></td>
<td bgcolor="#EEEEEE">
<b>Select Exam Date:</b>
<select name="examDate" id="examDate" onchange="window.location = 'exams.php?qid=<?php echo $Questionnaire_ID; ?>&selectedDate=' + document.getElementById('examDate').value;">
<?php
foreach ($dates as $oneDate) {
?><option value="<?php echo $oneDate ?>"<?php
if ($dateSelected->format('d-M-Y') == $oneDate) {
echo ' selected';
}
?>><?php echo $oneDate ?></option>
<?php
}
?>
</select>
</td></tr>
<?php
$iClassTotal = 0;
$iNumClass = 0;
foreach ($rows as $row) {
$date = new DateTime($row['TimeStarted']);
if ($date->format('d-M-Y') != $dateSelected->format('d-M-Y')) {
continue;
}
?>
<tr><td><?php echo $row["FirstName"] . " " . $row["Surname"]; ?></td>
<td><?php
if (!empty($row["DateMarked"])) {
echo round($row["TotalScore"] / $Score * 100, 1) . "%";
$iClassTotal += $row["TotalScore"];
$iNumClass++;
}
?></td>
<td>
<?php echo (empty($row["DateMarked"]) ? "Not marked" : date("Y-m-d", strtotime($row["DateMarked"]))); ?>
</td>
<td>
<?php
if ($row["NumMarked"] < $row['NumAnswered']) {
echo "No";
} else {
echo "Yes";
}
?>
</td>
<td>
<?php if ($bUserCanMark) { ?>
<a href="markexam.php?qid=<?php echo $Questionnaire_ID; ?>&st=<?php
echo $row["CCEStudentID"];
?>&CCEExamTimingID=<?php echo $row['CCEExamTimingID'] ?>"><b>Mark Exam</b></a>
<?php } ?>
<a href="viewexam.php?qid=<?php echo $Questionnaire_ID; ?>&st=<?php echo $row["CCEStudentID"];
?>&CCEExamTimingID=<?php echo $row['CCEExamTimingID'] ?>"><b>View Exam</b></a>
</td>
</tr>
<?php
}
if ($iNumClass > 0) {
?>
<tr>
<td bgcolor="#EEEEEE"><b>Average</b></td><td colspan="4"
bgcolor="#EEEEEE"><?php echo round($iClassTotal / $iNumClass / $Score * 100, 1); ?>%</td>
</tr>
<?php
}
?>
</table>
<?php include "footer.php" ?>