Merge branch 'Bug418-YAAQOB-MPIANA' of http://118.25.96.118:3000/mrlan/LRR into Bug418-YAAQOB-MPIANA

Bug418-YAAQOB-MPIANA^2
Lan Hui 2023-11-28 19:07:21 +08:00
commit ff407da550
1 changed files with 21 additions and 7 deletions

View File

@ -913,18 +913,32 @@ if (!empty($_GET["ignoreremarking"])) {
#Assign TA #Assign TA
if (!empty($_GET["assignTA"])) { if (!empty($_GET["assignTA"])) {
$id = mysqli_real_escape_string($con, $_GET["id"]); $id = mysqli_real_escape_string($con, $_GET["id"]);
$ta = mysqli_real_escape_string($con, $_GET["ta"]); $ta = mysqli_real_escape_string($con, $_GET["ta"]);
$sql = "INSERT INTO `course_ta`(`Course_ID`, `TA`) VALUES ('$id','$ta')"; // Check if the TA is already assigned to the course
$check_sql = "SELECT * FROM `course_ta` WHERE `Course_ID`='$id' AND `TA`='$ta'";
$check_result = $con->query($check_sql);
if ($con->query($sql) === TRUE) { if ($check_result->num_rows > 0) {
// Alert user about the duplicate assignment
$_SESSION["info_Admin_Courses"] = $type . " Course TA Assigned "; echo "<script>
header("Location: Admin.php"); alert('The selected TA is already assigned to this course.');
window.location.href='Admin.php';
</script>";
} else { } else {
echo "Error: " . $sql . "<br>" . $con->error; // Proceed with the TA assignment
$sql = "INSERT INTO `course_ta`(`Course_ID`, `TA`) VALUES ('$id','$ta')";
if ($con->query($sql) === TRUE) {
$_SESSION["info_Admin_Courses"] = $type . " Course TA Assigned ";
header("Location: Admin.php");
} else {
echo "<script>
alert('You must select a TA first!.');
window.location.href='Admin.php';
</script>";
}
} }
} }