Compare commits
No commits in common. "21918cf883ceb25f83bf065d7f7dadff34a4e944" and "44aa38be7648df2e9378779150107cc2d5066b67" have entirely different histories.
21918cf883
...
44aa38be76
42
Admin.php
42
Admin.php
|
@ -30,7 +30,7 @@ if ($_SESSION['user_type'] != "Lecturer" && $_SESSION['user_type'] != "Admin") {
|
||||||
<ul class="nav nav-tabs" id="myTab">
|
<ul class="nav nav-tabs" id="myTab">
|
||||||
|
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link active" href="#tab-student-accounts" id="batch_tab">Enter student numbers</a>
|
<a class="nav-link active" href="#tab-student-accounts" id="batch_tab">Create student accounts</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
|
@ -66,7 +66,7 @@ if ($_SESSION['user_type'] != "Lecturer" && $_SESSION['user_type'] != "Admin") {
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<form method="post" action="Script.php" id="create_account_form">
|
<form method="post" action="Script.php" id="create_account_form">
|
||||||
<input type="hidden" name="form_createlecturer" value="true" required="" />
|
<input type="hidden" name="form_createlecturrer" value="true" required="" />
|
||||||
Full name
|
Full name
|
||||||
<input type="text" name="fullname" placeholder="Full Name" class="form-control" required=""> <br>
|
<input type="text" name="fullname" placeholder="Full Name" class="form-control" required=""> <br>
|
||||||
Email
|
Email
|
||||||
|
@ -93,6 +93,10 @@ if ($_SESSION['user_type'] != "Lecturer" && $_SESSION['user_type'] != "Admin") {
|
||||||
echo '<hr><div class="alert alert-warning" role="alert">' . $_SESSION['info_Admin_Users'] . '</div>';
|
echo '<hr><div class="alert alert-warning" role="alert">' . $_SESSION['info_Admin_Users'] . '</div>';
|
||||||
$_SESSION['info_Admin_Users'] = null;
|
$_SESSION['info_Admin_Users'] = null;
|
||||||
}
|
}
|
||||||
|
if (isset($_SESSION['info_Admin_Users'])) {
|
||||||
|
echo '<hr><div class="alert alert-warning" role="alert">' . $_SESSION['info_Admin_Users'] . '</div>';
|
||||||
|
$_SESSION['info_Admin_Users'] = null;
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
@ -113,21 +117,10 @@ if ($_SESSION['user_type'] != "Lecturer" && $_SESSION['user_type'] != "Admin") {
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if ($_SESSION['user_type'] == "Lecturer") {
|
if ($_SESSION['user_type'] == "Lecturer") {
|
||||||
$user_id = $_SESSION['user_id'];
|
|
||||||
echo "<script>console.log('here {$user_id}');</script>"; // debug trick
|
|
||||||
// find the TAs in the courses taught by this instructor
|
|
||||||
$ta_result = mysqli_query(
|
|
||||||
$con,
|
|
||||||
"SELECT TA FROM course_ta INNER JOIN courses_table ON course_ta.Course_ID=courses_table.Course_ID WHERE courses_table.Lecturer_User_ID=$user_id"
|
|
||||||
);
|
|
||||||
$ta_ids = array(-1); // -1 is non-existent ID
|
|
||||||
while ($row = mysqli_fetch_assoc($ta_result)) {
|
|
||||||
array_push($ta_ids, $row['TA']);
|
|
||||||
}
|
|
||||||
$ta_ids2 = implode(', ', $ta_ids);
|
|
||||||
$result = mysqli_query(
|
$result = mysqli_query(
|
||||||
$con,
|
$con,
|
||||||
"SELECT * FROM users_table WHERE UserType in ('TA') and User_ID in ($ta_ids2)"
|
"SELECT * FROM users_table WHERE UserType in ('TA')"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +131,6 @@ if ($_SESSION['user_type'] != "Lecturer" && $_SESSION['user_type'] != "Admin") {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$num_rows = 0;
|
|
||||||
while ($row = mysqli_fetch_assoc($result)) {
|
while ($row = mysqli_fetch_assoc($result)) {
|
||||||
$pass = $row['Password'];
|
$pass = $row['Password'];
|
||||||
$btn = "<button class='btn btn-warning' onclick=\"updatePassword(" . $row['User_ID'] . ",'$pass')\">Reset</button>";
|
$btn = "<button class='btn btn-warning' onclick=\"updatePassword(" . $row['User_ID'] . ",'$pass')\">Reset</button>";
|
||||||
|
@ -151,10 +143,6 @@ if ($_SESSION['user_type'] != "Lecturer" && $_SESSION['user_type'] != "Admin") {
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "<tr><td>" . $row['User_ID'] . "</td><td>" . $row['Full_Name'] . "</td><td>" . $row['Email'] . "</td><td>$btn</td><td>$btnBlock</td></tr>";
|
echo "<tr><td>" . $row['User_ID'] . "</td><td>" . $row['Full_Name'] . "</td><td>" . $row['Email'] . "</td><td>$btn</td><td>$btnBlock</td></tr>";
|
||||||
$num_rows += 1;
|
|
||||||
}
|
|
||||||
if ($num_rows == 0) {
|
|
||||||
echo "<p>No TA</p>";
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</table>
|
</table>
|
||||||
|
@ -239,22 +227,8 @@ if ($_SESSION['user_type'] != "Lecturer" && $_SESSION['user_type'] != "Admin") {
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<?php include 'Footer.php';?>
|
<?php include 'Footer.php';?>
|
||||||
|
|
||||||
<script>
|
|
||||||
/** After creating a TA account, stay on the same tab "Create instructor account"
|
|
||||||
Side effect: ?tacreated will be appended on the URL
|
|
||||||
*/
|
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
|
||||||
const url = new URL(window.location.href);
|
|
||||||
if (url.searchParams.has('tacreated')) {
|
|
||||||
const elem = document.querySelector('#tab_ins_accounts');
|
|
||||||
elem.click();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function updatePassword(id, pass) {
|
function updatePassword(id, pass) {
|
||||||
if (!confirm('Are you sure to reset user password?')) {
|
if (!confirm('Are you sure to reset user password?')) {
|
||||||
|
|
24
Course.php
24
Course.php
|
@ -152,7 +152,7 @@ include 'Header.php';
|
||||||
$att3 = $row['Attachment_link_3'];
|
$att3 = $row['Attachment_link_3'];
|
||||||
$att4 = $row['Attachment_link_4'];
|
$att4 = $row['Attachment_link_4'];
|
||||||
$labid = $row['Lab_Report_ID'];
|
$labid = $row['Lab_Report_ID'];
|
||||||
$days_remaining = "Days remaining: ".date_diff(date_create($deadline), date_create())->format('%a days, %h hours, %i minutes');
|
$days_remaining = date_diff(date_create($deadline), date_create())->format('%a days, %h hours, %i minutes');
|
||||||
$full_link = "<a href='~\..\Download.php?file=$att1'>$att1</a>";
|
$full_link = "<a href='~\..\Download.php?file=$att1'>$att1</a>";
|
||||||
|
|
||||||
if($att2 != "") {
|
if($att2 != "") {
|
||||||
|
@ -165,11 +165,6 @@ include 'Header.php';
|
||||||
$full_link = $full_link."| <a href='~\..\Download.php?file=$att4'>$att4</a>";
|
$full_link = $full_link."| <a href='~\..\Download.php?file=$att4'>$att4</a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if the student has already submitted the assignment
|
|
||||||
$query_result = mysqli_query($con, "SELECT * FROM lab_report_submissions WHERE Student_id=$student_id AND Lab_Report_ID=$labid");
|
|
||||||
if (mysqli_num_rows($query_result) > 0)
|
|
||||||
$days_remaining = 'You have already submitted this assignment.';
|
|
||||||
|
|
||||||
echo "<div class='card mt-md-2' style='word-wrap: break-word;'>
|
echo "<div class='card mt-md-2' style='word-wrap: break-word;'>
|
||||||
<div class='card-body'>
|
<div class='card-body'>
|
||||||
<h5 class='card-title'>$title</h5>
|
<h5 class='card-title'>$title</h5>
|
||||||
|
@ -177,7 +172,7 @@ include 'Header.php';
|
||||||
<p class='card-text'> $ins </p>
|
<p class='card-text'> $ins </p>
|
||||||
<p> <small>Attachments</small>: $full_link </p>
|
<p> <small>Attachments</small>: $full_link </p>
|
||||||
<p class='card-text'> <small> Posted: $posted Deadline: $deadline </small> </p>
|
<p class='card-text'> <small> Posted: $posted Deadline: $deadline </small> </p>
|
||||||
<div class='alert alert-warning'>$days_remaining</div>
|
<div class='alert alert-warning'>Time left: $days_remaining</div>
|
||||||
<p><a href='~\..\SubmitLab.php?id=$labid&url=$url' class='btn btn-primary'>Submit</a></p>
|
<p><a href='~\..\SubmitLab.php?id=$labid&url=$url' class='btn btn-primary'>Submit</a></p>
|
||||||
</div>
|
</div>
|
||||||
</div>";
|
</div>";
|
||||||
|
@ -329,10 +324,10 @@ include 'Header.php';
|
||||||
$att2 = $row['Attachment2'];
|
$att2 = $row['Attachment2'];
|
||||||
$att3 = $row['Attachment3'];
|
$att3 = $row['Attachment3'];
|
||||||
$att4 = $row['Attachment4'];
|
$att4 = $row['Attachment4'];
|
||||||
$base_att1 = basename(rawurldecode($att1));
|
$base_att1 = basename($att1);
|
||||||
$base_att2 = basename(rawurldecode($att2));
|
$base_att2 = basename($att2);
|
||||||
$base_att3 = basename(rawurldecode($att3));
|
$base_att3 = basename($att3);
|
||||||
$base_att4 = basename(rawurldecode($att4));
|
$base_att4 = basename($att4);
|
||||||
|
|
||||||
$full_link = "<a href='~\..\Download.php?file=$att1&attachment=1'>$base_att1</a>"; // prevent students from directly accessing their classmates' submissions
|
$full_link = "<a href='~\..\Download.php?file=$att1&attachment=1'>$base_att1</a>"; // prevent students from directly accessing their classmates' submissions
|
||||||
|
|
||||||
|
@ -652,12 +647,11 @@ include 'Header.php';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function remarking(url)
|
function remarking(data)
|
||||||
{
|
{
|
||||||
const details = prompt("Please enter your remarking reasons","");
|
const details = prompt("Please enter your remarking reasons","");
|
||||||
if (details != null) {
|
|
||||||
window.location.href = url+"&details="+details;
|
window.location.href = data+"&details="+details;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -324,7 +324,7 @@ include 'Header.php';
|
||||||
}
|
}
|
||||||
echo "</div>";
|
echo "</div>";
|
||||||
|
|
||||||
$resultx1 = mysqli_query($con, "SELECT DISTINCT course_students_table.Student_ID, users_table.Full_Name
|
$resultx1 = mysqli_query($con, "SELECT course_students_table.Student_ID, users_table.Full_Name
|
||||||
FROM course_students_table
|
FROM course_students_table
|
||||||
INNER JOIN users_table on users_table.Student_ID=course_students_table.Student_ID
|
INNER JOIN users_table on users_table.Student_ID=course_students_table.Student_ID
|
||||||
WHERE Course_ID=$course_id");
|
WHERE Course_ID=$course_id");
|
||||||
|
@ -538,7 +538,7 @@ include 'Header.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mysqli_num_rows($result) == 0) {
|
if (mysqli_num_rows($result) == 0) {
|
||||||
echo "No such course offered in this academic year. Please check that your have entered the correct course code.<hr>";
|
echo "No results. <hr>";
|
||||||
} else {
|
} else {
|
||||||
while($row = mysqli_fetch_assoc($result)) {
|
while($row = mysqli_fetch_assoc($result)) {
|
||||||
$name = $row['Course_Name'];
|
$name = $row['Course_Name'];
|
||||||
|
|
|
@ -4,16 +4,11 @@ error_reporting(0);
|
||||||
date_default_timezone_set('Asia/Shanghai');
|
date_default_timezone_set('Asia/Shanghai');
|
||||||
|
|
||||||
include "get_mysql_credentials.php";
|
include "get_mysql_credentials.php";
|
||||||
try {
|
$con = mysqli_connect("localhost", $mysql_username, $mysql_password, "lrr");
|
||||||
$con = mysqli_connect("localhost", $mysql_username, $mysql_password, "lrr");
|
|
||||||
} catch (mysqli_sql_exception $e) {
|
|
||||||
echo $e->getMessage();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check database connection
|
// Check database connection
|
||||||
if (mysqli_connect_errno()) {
|
if (mysqli_connect_errno()) {
|
||||||
echo " Error number: ".mysqli_connect_errno();
|
echo "Failed to connect to MySQL: " . mysqli_connect_error();
|
||||||
exit();
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
49
Script.php
49
Script.php
|
@ -290,8 +290,53 @@ if (!empty($_POST["form_recover_password"])) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ################################ RESET Password #####################################
|
||||||
|
|
||||||
|
if (!empty($_POST["form_reset_password"])) {
|
||||||
|
$password = mysqli_real_escape_string($con, $_POST["password"]);
|
||||||
|
$token = mysqli_real_escape_string($con, $_POST["token"]);
|
||||||
|
$email = mysqli_real_escape_string($con, $_POST["email"]);
|
||||||
|
$result = mysqli_query(
|
||||||
|
$con,
|
||||||
|
"SELECT * FROM Users_Table WHERE email='$email'"
|
||||||
|
);
|
||||||
|
if (mysqli_num_rows($result) == 0) {
|
||||||
|
|
||||||
|
echo "invalid email";
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
while ($row = mysqli_fetch_assoc($result)) {
|
||||||
|
|
||||||
|
$userid = $row['User_ID'];
|
||||||
|
|
||||||
|
$email = $row['Email'];
|
||||||
|
$id = $row['Student_ID'];
|
||||||
|
|
||||||
|
$user_token = $userid * $userid * $userid + $userid * 0.00343;
|
||||||
|
if ($user_token == $token) {
|
||||||
|
// Password Update
|
||||||
|
|
||||||
|
// Password Update
|
||||||
|
$hashed_password = hash('sha512', $password);
|
||||||
|
$sql = "UPDATE users_table set HashPassword='$hashed_password' where User_ID='$userid';";
|
||||||
|
if ($con->query($sql) === TRUE) {
|
||||||
|
|
||||||
|
error_reporting(0);
|
||||||
|
|
||||||
|
$_SESSION["info_login"] = " Password changed successfully , you can login now with your new password ";
|
||||||
|
header("Location: index.php");
|
||||||
|
} else {
|
||||||
|
echo "Error: " . $sql . "<br>" . $con->error;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo "Invalid Token ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ############################### CREATE Lecturer/TA USER ##################################
|
// ############################### CREATE Lecturer/TA USER ##################################
|
||||||
if (!empty($_POST["form_createlecturer"])){
|
if (!empty($_POST["form_createlecturrer"])){
|
||||||
$email = mysqli_real_escape_string($con, $_POST["email"]);
|
$email = mysqli_real_escape_string($con, $_POST["email"]);
|
||||||
$fullname = mysqli_real_escape_string($con, $_POST["fullname"]);
|
$fullname = mysqli_real_escape_string($con, $_POST["fullname"]);
|
||||||
$type = mysqli_real_escape_string($con, $_POST["type"]);
|
$type = mysqli_real_escape_string($con, $_POST["type"]);
|
||||||
|
@ -316,7 +361,7 @@ if (!empty($_POST["form_createlecturer"])){
|
||||||
try {
|
try {
|
||||||
$result = mysqli_query($con, $sql);
|
$result = mysqli_query($con, $sql);
|
||||||
$_SESSION["info_Admin_Users"] = $type . " user created successfully. Use email " . $email . " as account name and ". $password ." as password.";
|
$_SESSION["info_Admin_Users"] = $type . " user created successfully. Use email " . $email . " as account name and ". $password ." as password.";
|
||||||
header("Location: Admin.php?tacreated");
|
header("Location: Admin.php");
|
||||||
} catch (Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
echo "$ex";
|
echo "$ex";
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,10 +151,10 @@ echo "<div><a href='Courses.php?course=$url'> $header </a></div>";
|
||||||
$submitted_by = "$student_name ($submitter_student_number) for group $groupname ";
|
$submitted_by = "$student_name ($submitter_student_number) for group $groupname ";
|
||||||
}
|
}
|
||||||
|
|
||||||
$base_att1 = basename(rawurldecode($att1));
|
$base_att1 = basename($att1);
|
||||||
$base_att2 = basename(rawurldecode($att2));
|
$base_att2 = basename($att2);
|
||||||
$base_att3 = basename(rawurldecode($att3));
|
$base_att3 = basename($att3);
|
||||||
$base_att4 = basename(rawurldecode($att4));
|
$base_att4 = basename($att4);
|
||||||
|
|
||||||
$full_link = "<a href='~\..\Download.php?file=$att1&attachment=1'>$base_att1</a>"; // prevent students from directly accessing their classmates' submissions
|
$full_link = "<a href='~\..\Download.php?file=$att1&attachment=1'>$base_att1</a>"; // prevent students from directly accessing their classmates' submissions
|
||||||
|
|
||||||
|
|
|
@ -136,7 +136,7 @@ INSERT INTO `course_students_table` (`Course_ID`, `Student_ID`, `ID`, `Status`)
|
||||||
(10, '201825800050', 13, 'Joined'),
|
(10, '201825800050', 13, 'Joined'),
|
||||||
(10, '201825800054', 14, 'Joined'),
|
(10, '201825800054', 14, 'Joined'),
|
||||||
(12, '201632120150', 15, 'Joined'),
|
(12, '201632120150', 15, 'Joined'),
|
||||||
(12, '201632120150', 16, 'Joined'),
|
(12, '2016321201502', 16, 'Joined'),
|
||||||
(12, '201825800050', 17, 'Joined');
|
(12, '201825800050', 17, 'Joined');
|
||||||
|
|
||||||
-- --------------------------------------------------------
|
-- --------------------------------------------------------
|
||||||
|
@ -200,7 +200,7 @@ CREATE TABLE `lab_reports_table` (
|
||||||
|
|
||||||
INSERT INTO `lab_reports_table` (`Lab_Report_ID`, `Course_ID`, `Posted_Date`, `Deadline`, `Instructions`, `Title`, `Attachment_link_1`, `Attachment_link_2`, `Attachment_link_3`, `Attachment_link_4`, `Marks`, `Type`) VALUES
|
INSERT INTO `lab_reports_table` (`Lab_Report_ID`, `Course_ID`, `Posted_Date`, `Deadline`, `Instructions`, `Title`, `Attachment_link_1`, `Attachment_link_2`, `Attachment_link_3`, `Attachment_link_4`, `Marks`, `Type`) VALUES
|
||||||
(1, 10, '2019-01-11 16:52', '2019-02-11 17:00', 'Description of the lab....', 'Reading 1', '700IMPORTANT WORDS.txt', '', '', '', '4', 'Individual'),
|
(1, 10, '2019-01-11 16:52', '2019-02-11 17:00', 'Description of the lab....', 'Reading 1', '700IMPORTANT WORDS.txt', '', '', '', '4', 'Individual'),
|
||||||
(2, 10, '2024-09-29 11:12', '2025-07-30 23:59', 'Read this paper http://sunnyday.mit.edu/16.355/budgen-david.pdf', 'Reading 2', '586LRR-Test-caseS.pdf', '', '', '', '6', 'Individual'),
|
(2, 10, '2019-01-17 11:12', '2019-01-25 23:59', 'Read this paper http://sunnyday.mit.edu/16.355/budgen-david.pdf', 'Reading 2', '586LRR-Test-caseS.pdf', '', '', '', '6', 'Individual'),
|
||||||
(3, 12, '2020-04-05 02:48', '2020-04-12 ', 'Do this assignment in time for testing', 'First Assignment Testing', '', '', '', '', '3', 'Group'),
|
(3, 12, '2020-04-05 02:48', '2020-04-12 ', 'Do this assignment in time for testing', 'First Assignment Testing', '', '', '', '', '3', 'Group'),
|
||||||
(4, 12, '2020-04-05 05:36', '2020-04-06 ', 'We are testing to see if the instructor can be able to modify the work', 'Second Assignment Testing', '', '', '', '', '3', 'Individual'),
|
(4, 12, '2020-04-05 05:36', '2020-04-06 ', 'We are testing to see if the instructor can be able to modify the work', 'Second Assignment Testing', '', '', '', '', '3', 'Individual'),
|
||||||
(5, 12, '2020-04-05 05:51', '2020-04-08 ', 'ASQDASDASCDD', 'Third Assignment Testingas', '', '', '', '', '3', 'Individual'),
|
(5, 12, '2020-04-05 05:51', '2020-04-08 ', 'ASQDASDASCDD', 'Third Assignment Testingas', '', '', '', '', '3', 'Individual'),
|
||||||
|
@ -235,7 +235,7 @@ CREATE TABLE `lab_report_submissions` (
|
||||||
--
|
--
|
||||||
|
|
||||||
INSERT INTO `lab_report_submissions` (`Submission_ID`, `Submission_Date`, `Lab_Report_ID`, `Student_id`, `Course_Group_id`, `Attachment1`, `Notes`, `Attachment2`, `Attachment3`, `Attachment4`, `Marks`, `Status`, `Title`, `Visibility`, `Remarking_Reason`) VALUES
|
INSERT INTO `lab_report_submissions` (`Submission_ID`, `Submission_Date`, `Lab_Report_ID`, `Student_id`, `Course_Group_id`, `Attachment1`, `Notes`, `Attachment2`, `Attachment3`, `Attachment4`, `Marks`, `Status`, `Title`, `Visibility`, `Remarking_Reason`) VALUES
|
||||||
(1, '2019-01-17 00:00:00', 1, '201825800050', 0, 'Reading list.txt', '-', '', '', '', NULL, 'Pending', 'Reading 1 submission', 'Public', ''),
|
(1, '2019-01-17 00:00:00', 1, '201825800050', 0, 'Reading list.txt', '-', '', '', '', 5, 'Marked', 'Reading 1 submission', 'Public', ''),
|
||||||
(5, '2019-01-21 08:31:00', 2, '201825800050', 0, 'Trial Balance.txt', ' - @2019-01-21 09:35 : Sorry I missed some details from your report', 'Boorka.jpg', '', '', 6, 'Marked', 'Submission x', 'Private', ''),
|
(5, '2019-01-21 08:31:00', 2, '201825800050', 0, 'Trial Balance.txt', ' - @2019-01-21 09:35 : Sorry I missed some details from your report', 'Boorka.jpg', '', '', 6, 'Marked', 'Submission x', 'Private', ''),
|
||||||
(30, '2020-04-06 23:18:00', 3, '0', 31, '/2016321201502/First Assignment Testing/UR Diagram.pdf', '<br>@2020-04-06 23:19 : ', '', '', '', 3, 'Marked', 'First Assignment Testing', 'Private', '');
|
(30, '2020-04-06 23:18:00', 3, '0', 31, '/2016321201502/First Assignment Testing/UR Diagram.pdf', '<br>@2020-04-06 23:19 : ', '', '', '', 3, 'Marked', 'First Assignment Testing', 'Private', '');
|
||||||
|
|
||||||
|
@ -286,7 +286,6 @@ CREATE TABLE `users_table` (
|
||||||
|
|
||||||
INSERT INTO `users_table` (`User_ID`, `Email`, `Password`, `HashPassword`, `Full_Name`, `UserType`, `Student_ID`, `Passport_Number`, `Status`) VALUES
|
INSERT INTO `users_table` (`User_ID`, `Email`, `Password`, `HashPassword`, `Full_Name`, `UserType`, `Student_ID`, `Passport_Number`, `Status`) VALUES
|
||||||
(3, 'admin@qq.com', '$2y$10$8GCG6lTo1LFRD3bOkAyKYeOMOrFSBUgrTxaPLS5ynWN1bYDHf89pO', '', 'Kamal', 'Admin', '0', NULL, 'Active'),
|
(3, 'admin@qq.com', '$2y$10$8GCG6lTo1LFRD3bOkAyKYeOMOrFSBUgrTxaPLS5ynWN1bYDHf89pO', '', 'Kamal', 'Admin', '0', NULL, 'Active'),
|
||||||
(7, 'peter@qq.com', '$2y$10$8GCG6lTo1LFRD3bOkAyKYeOMOrFSBUgrTxaPLS5ynWN1bYDHf89pO', '', 'Peter', 'Lecturer', NULL, '123', 'Active'),
|
|
||||||
(8, 'lanhui@qq.com', '$2y$10$8GCG6lTo1LFRD3bOkAyKYeOMOrFSBUgrTxaPLS5ynWN1bYDHf89pO', '', 'Lanhui', 'Lecturer', NULL, '123', 'Active'),
|
(8, 'lanhui@qq.com', '$2y$10$8GCG6lTo1LFRD3bOkAyKYeOMOrFSBUgrTxaPLS5ynWN1bYDHf89pO', '', 'Lanhui', 'Lecturer', NULL, '123', 'Active'),
|
||||||
(9, 'mohamed@qq.com', '$2y$10$8GCG6lTo1LFRD3bOkAyKYeOMOrFSBUgrTxaPLS5ynWN1bYDHf89pO', '', 'Mohamed', 'Student', '201825800050', 'P00581929', 'Active'),
|
(9, 'mohamed@qq.com', '$2y$10$8GCG6lTo1LFRD3bOkAyKYeOMOrFSBUgrTxaPLS5ynWN1bYDHf89pO', '', 'Mohamed', 'Student', '201825800050', 'P00581929', 'Active'),
|
||||||
(10, 'mark@qq.com', '123', '', 'Mark ', 'TA', NULL, '123', 'Active'),
|
(10, 'mark@qq.com', '123', '', 'Mark ', 'TA', NULL, '123', 'Active'),
|
||||||
|
|
|
@ -68,10 +68,8 @@ def test_lecturer_can_post_assignment(driver, url, restore_database):
|
||||||
login(driver, url, 'lanhui@qq.com', '123')
|
login(driver, url, 'lanhui@qq.com', '123')
|
||||||
|
|
||||||
# Create an assignment called Take-home quiz 1 for course (CSC1111) - Project Management
|
# Create an assignment called Take-home quiz 1 for course (CSC1111) - Project Management
|
||||||
elem = WebDriverWait(driver, 10).until(
|
elems = driver.find_elements(By.CLASS_NAME, 'btn-default')
|
||||||
EC.element_to_be_clickable((By.XPATH, '//div[@class="col-md-8"]/a[1]/div'))
|
elems[1].click()
|
||||||
)
|
|
||||||
elem.click()
|
|
||||||
elem = driver.find_element(By.NAME, 'deadlinedate')
|
elem = driver.find_element(By.NAME, 'deadlinedate')
|
||||||
elem.send_keys('002024/12/30')
|
elem.send_keys('002024/12/30')
|
||||||
elem = driver.find_element(By.NAME, 'deadlinetime')
|
elem = driver.find_element(By.NAME, 'deadlinetime')
|
||||||
|
@ -194,33 +192,6 @@ def test_student_with_invalid_student_number_cannot_sign_up(driver, url, restore
|
||||||
driver.quit()
|
driver.quit()
|
||||||
|
|
||||||
|
|
||||||
def test_student_with_weak_password_cannot_sign_up(driver, url, restore_database):
|
|
||||||
driver.get(url)
|
|
||||||
driver.maximize_window()
|
|
||||||
weak_password = '123Abc'
|
|
||||||
elem = driver.find_element(By.ID, 'signup_link')
|
|
||||||
elem.click()
|
|
||||||
elem = driver.find_element(By.NAME, 'fullname')
|
|
||||||
elem.send_keys('Good Student')
|
|
||||||
elem = driver.find_element(By.NAME, 'user_student_id')
|
|
||||||
elem.send_keys('202400000001')
|
|
||||||
elem = driver.find_element(By.NAME, 'email')
|
|
||||||
elem.send_keys('goodstudent@qq.com')
|
|
||||||
elem = driver.find_element(By.NAME, 'password')
|
|
||||||
elem.send_keys(weak_password)
|
|
||||||
elem = driver.find_element(By.NAME, 'confirmpassword')
|
|
||||||
elem.send_keys(weak_password)
|
|
||||||
elem = driver.find_element(By.ID, 'signup_btn')
|
|
||||||
elem.click()
|
|
||||||
|
|
||||||
# Log in Student account
|
|
||||||
login(driver, url, '202400000001', weak_password)
|
|
||||||
elems = driver.find_elements(By.CLASS_NAME, 'nav-link')
|
|
||||||
assert not 'Student ID' in elems[0].text
|
|
||||||
assert not 'Good Student' in elems[0].text
|
|
||||||
driver.quit()
|
|
||||||
|
|
||||||
|
|
||||||
def test_student_can_join_course(driver, url, restore_database):
|
def test_student_can_join_course(driver, url, restore_database):
|
||||||
# Student can join (CSC1111) - Project Management
|
# Student can join (CSC1111) - Project Management
|
||||||
login(driver, url, '201825800050', '123')
|
login(driver, url, '201825800050', '123')
|
||||||
|
@ -247,106 +218,7 @@ def test_student_can_join_course(driver, url, restore_database):
|
||||||
assert 'Joined' in elems[0].text
|
assert 'Joined' in elems[0].text
|
||||||
|
|
||||||
|
|
||||||
def test_student_can_submit_assignment(driver, url, restore_database):
|
@pytest.mark.skip()
|
||||||
''' Note: Make sure the fields Posted_Date and Deadline in the second row of lab_reports_table are in the current year'''
|
def test_student_can_submit_assignment():
|
||||||
# Student can submit assignment for CSC1111
|
# Student can submit Take-home quiz 1 for CSC1001
|
||||||
login(driver, url, '201825800050', '123')
|
assert True
|
||||||
driver.maximize_window()
|
|
||||||
|
|
||||||
# Enter into the course and the find the assignment
|
|
||||||
elems = driver.find_elements(By.CLASS_NAME, 'btn-default')
|
|
||||||
elems[1].click()
|
|
||||||
|
|
||||||
elem = driver.find_element(By.XPATH, '//div[@id="menu1"]/div/div/p/a[text()="Submit"]') # find the submit button
|
|
||||||
elem.click()
|
|
||||||
|
|
||||||
# Fill submission title, attach file, and submit
|
|
||||||
elem = driver.find_element(By.NAME, 'title')
|
|
||||||
elem.send_keys('Assignment submission from Mohamed')
|
|
||||||
elem = driver.find_element(By.NAME, 'attachment1')
|
|
||||||
elem.send_keys('/home/mrlan/Downloads/test/SeleniumHui/helper.py') # attach a file
|
|
||||||
elem = driver.find_element(By.XPATH, '//form/button')
|
|
||||||
elem.click()
|
|
||||||
|
|
||||||
# Go the Submitted tab
|
|
||||||
elem = driver.find_element(By.ID, 'myTab')
|
|
||||||
elems = elem.find_elements(By.CLASS_NAME, 'nav-link')
|
|
||||||
elems[2].click()
|
|
||||||
|
|
||||||
elem = driver.find_element(By.XPATH, '//div[@id="menu3"]/div')
|
|
||||||
assert 'Reading 2 (6 Marks)' in elem.text
|
|
||||||
assert 'SUBMITTED' in elem.text
|
|
||||||
assert 'helper.py' in elem.text
|
|
||||||
|
|
||||||
|
|
||||||
def test_student_can_request_remarking(driver, url, restore_database):
|
|
||||||
# Student logs in
|
|
||||||
login(driver, url, '201825800050', '123')
|
|
||||||
driver.maximize_window()
|
|
||||||
|
|
||||||
# Enter into the course
|
|
||||||
elems = driver.find_elements(By.CLASS_NAME, 'btn-default')
|
|
||||||
elems[1].click()
|
|
||||||
|
|
||||||
# Go the Marked tab
|
|
||||||
elem = driver.find_element(By.ID, 'myTab')
|
|
||||||
elems = elem.find_elements(By.CLASS_NAME, 'nav-link')
|
|
||||||
elems[3].click()
|
|
||||||
|
|
||||||
# Send remarking request
|
|
||||||
remarking_buttons = driver.find_elements(By.CLASS_NAME, 'btn-light')
|
|
||||||
remarking_buttons[0].click()
|
|
||||||
alert = driver.switch_to.alert
|
|
||||||
alert.send_keys('I need higher marks, teacher.')
|
|
||||||
alert.accept()
|
|
||||||
|
|
||||||
elem = driver.find_element(By.XPATH, '//div[@id="menu4"]/div/div/p/span')
|
|
||||||
assert 'Remarking request sent' == elem.text
|
|
||||||
|
|
||||||
|
|
||||||
def test_lecturer_can_mark_assignment(driver, url, restore_database):
|
|
||||||
# Lecturer lanhui@qq.com logs in
|
|
||||||
driver.maximize_window()
|
|
||||||
login(driver, url, 'lanhui@qq.com', '123')
|
|
||||||
|
|
||||||
# Enter into the course and the find the assignment
|
|
||||||
elem = driver.find_element(By.XPATH, '//div[1]/a[3]/div') # course Software Engineering
|
|
||||||
elem.click()
|
|
||||||
|
|
||||||
elem = driver.find_element(By.XPATH, '//div[2]/div[2]/div/a[2]') # View link
|
|
||||||
elem.click()
|
|
||||||
|
|
||||||
elem = driver.find_element(By.CLASS_NAME, 'btn-primary') # Blue Mark button
|
|
||||||
elem.click()
|
|
||||||
|
|
||||||
# Submit mark and comment
|
|
||||||
elem = driver.find_element(By.NAME, 'marks')
|
|
||||||
elem.send_keys('1')
|
|
||||||
elem = driver.find_element(By.NAME, 'feedback')
|
|
||||||
elem.send_keys('Inadequate')
|
|
||||||
form = driver.find_element(By.ID, 'submit-form')
|
|
||||||
form.submit()
|
|
||||||
|
|
||||||
elem = driver.find_element(By.ID, 'myTab')
|
|
||||||
elems = elem.find_elements(By.CLASS_NAME, 'nav-link')
|
|
||||||
assert 'Marked submissions (1)' == elems[1].text
|
|
||||||
elems[1].click()
|
|
||||||
elem = driver.find_element(By.XPATH, "//div[@id='menu2']/div/b")
|
|
||||||
assert 'Reading 1 submission' in elem.text
|
|
||||||
|
|
||||||
|
|
||||||
def test_lecturer_cannot_see_tas_not_from_his_course(driver, url, restore_database):
|
|
||||||
# Lecturer lanhui@qq.com logs in
|
|
||||||
driver.maximize_window()
|
|
||||||
login(driver, url, 'peter@qq.com', '123')
|
|
||||||
|
|
||||||
elem = driver.find_element(By.ID, 'admin_tab')
|
|
||||||
elem.click()
|
|
||||||
tab = driver.find_element(By.ID, 'existing_accounts_tab')
|
|
||||||
tab.click()
|
|
||||||
elem = driver.find_element(By.ID, 'tab-existing-accounts')
|
|
||||||
assert 'No TA' in elem.text
|
|
||||||
|
|
||||||
# Logout
|
|
||||||
logout(driver)
|
|
||||||
driver.quit()
|
|
||||||
|
|
Loading…
Reference in New Issue