Fixed Bug418
parent
244af4c11b
commit
7b68043060
20
Script.php
20
Script.php
|
@ -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"]);
|
||||||
|
|
||||||
|
// 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')";
|
$sql = "INSERT INTO `course_ta`(`Course_ID`, `TA`) VALUES ('$id','$ta')";
|
||||||
|
|
||||||
if ($con->query($sql) === TRUE) {
|
if ($con->query($sql) === TRUE) {
|
||||||
|
|
||||||
$_SESSION["info_Admin_Courses"] = $type . " Course TA Assigned ";
|
$_SESSION["info_Admin_Courses"] = $type . " Course TA Assigned ";
|
||||||
header("Location: Admin.php");
|
header("Location: Admin.php");
|
||||||
} else {
|
} else {
|
||||||
echo "Error: " . $sql . "<br>" . $con->error;
|
echo "<script>
|
||||||
|
alert('You must select a TA first!.');
|
||||||
|
window.location.href='Admin.php';
|
||||||
|
</script>";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue