Fixed Bug418

Bug418-YAAQOB-MPIANA
YAAQOB ABDULSATTAR HAMID ABDULQADER 2023-11-27 10:40:35 +08:00
parent 244af4c11b
commit 7b68043060
1 changed files with 21 additions and 7 deletions

View File

@ -913,18 +913,32 @@ if (!empty($_GET["ignoreremarking"])) {
#Assign TA
if (!empty($_GET["assignTA"])) {
$id = mysqli_real_escape_string($con, $_GET["id"]);
$ta = mysqli_real_escape_string($con, $_GET["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 ($check_result->num_rows > 0) {
// Alert user about the duplicate assignment
echo "<script>
alert('The selected TA is already assigned to this course.');
window.location.href='Admin.php';
</script>";
} else {
// 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 "Error: " . $sql . "<br>" . $con->error;
echo "<script>
alert('You must select a TA first!.');
window.location.href='Admin.php';
</script>";
}
}
}