Course.php: make group invitation work.

Bug430-Eden2
Lan Hui 2023-08-23 21:55:02 +08:00
parent b477edca1b
commit f2dfb5ddd6
2 changed files with 28 additions and 29 deletions

View File

@ -55,6 +55,19 @@ include 'Header.php';
?>
<?php
if (isset($_SESSION['info_general'])) {
echo '<div class="alert alert-warning">' . $_SESSION['info_general'] . '</div>';
$_SESSION['info_general'] = null;
}
if (isset($_SESSION['info_courses'])) {
echo '<div class="alert alert-warning">' . $_SESSION['info_courses'] . '</div>';
$_SESSION['info_courses'] = null;
}
?>
<?php
if( $_SESSION['user_type'] == "Student")
{
@ -64,19 +77,6 @@ include 'Header.php';
<div class="col-9">
<?php
if (isset($_SESSION['info_general'])) {
echo '<hr><div class="alert alert-info" role="alert" style="float:left;">' . $_SESSION['info_general'] . '</div>';
$_SESSION['info_general'] = null;
}
if (isset($_SESSION['info_courses'])) {
echo '<hr><div class="alert alert-info" role="alert" style="float:left;">' . $_SESSION['info_courses'] . '</div>';
$_SESSION['info_courses'] = null;
}
?>
<!-- Nav tabs -->
<ul class="nav nav-tabs" id="myTab">
@ -468,31 +468,25 @@ where Lab_Report_ID=$lab_repo_id and (lab_report_submissions.Student_id='$studen
$name = $row['Group_Name'];
$id = $row['Course_Group_id'];
$status = $row['Status'];
$extra = " - <a href='#' class='' onclick='invite($id)'> Invite Others</a></small>";
$extra = " <a href='#' class='' onclick='invite($id)'> Invite member </a></small>";
if($status == "Invited")
{
$extra2 = " <a href='#' class='' onclick='accept($id,1)'>Accept</a></small>";
$extra3 = " <a href='#' class='' onclick='accept($id,0)'>Decline</a></small>";
}
# Add "delete group" button and allow only group creator to delete it
$extra4 = "<button onclick='deleteGroup($id)' class='btn btn-sm btn-danger'>Delete group</button>";
echo "<ul class='list-group'>";
echo "<li class='list-group-item'><b>$name</b> ($status) $extra $extra2 $extra3" .
(($status == "Created")? "$extra4": "")
."</li>";
echo "<li class='list-group-item'><b>$name</b> ($id) <br> $extra <br> $extra2 <br> $extra3 </li>";
$rs2 = mysqli_query($con,"SELECT `ID`, `Course_Group_id`, course_group_members_table.Student_ID,
course_group_members_table.`Status`,users_table.Full_Name FROM `course_group_members_table`
INNER JOIN users_table on users_table.Student_ID=course_group_members_table.Student_ID
where course_group_members_table.Course_Group_id=$id");
$rs2 = mysqli_query($con,"SELECT Course_Group_id, users_table.Student_ID, course_group_members_table.Status, users_table.Full_Name
FROM course_group_members_table
INNER JOIN users_table ON users_table.Student_ID=course_group_members_table.Student_ID
WHERE course_group_members_table.Student_ID AND course_group_members_table.Course_Group_id=$id");
# Check whether the current user in session is the creator of the group
$rs3 = mysqli_query($con, "SELECT `Status` from course_group_members_table where Student_ID = $student_id");
$rs3 = mysqli_query($con, "SELECT Status from course_group_members_table where Student_ID = $student_id");
$flag = mysqli_fetch_assoc($rs3)['Status'] == "Created";
while ($row = mysqli_fetch_assoc($rs2)) {
@ -501,7 +495,7 @@ where course_group_members_table.Course_Group_id=$id");
$status = $row['Status'];
$Student_ID = $row['Student_ID'];
#Show group members + remove button next to each member except the creator of the group
# Show group members + Kick out button next to each member except the creator of the group
if ($flag) {
echo "<li class='list-group-item'>$name - $Student_ID ($status)&nbsp;".(($status != "Created")?"<button onclick='removeMember($Student_ID, $id)'
class='btn btn-sm btn-warning'>Kick out</button>":"")."</li>";
@ -509,6 +503,12 @@ where course_group_members_table.Course_Group_id=$id");
echo "<li class='list-group-item'><small> $name - $Student_ID ($status)</small>";
}
}
# Add "delete group" button and allow only group creator to delete it
if ($status == 'Created') {
echo "<li class='list-group-item'> <button onclick='deleteGroup($id)' class='btn btn-sm btn-danger'>Delete group</button> </li>";
}
echo "</ul>";
}
}
?>
@ -633,7 +633,6 @@ where course_group_members_table.Course_Group_id=$id");
function removeMember(student_id, group_id) {
try
{
$('<form id="frm" method="get" action="Script.php"><input type="hidden" name="removemember" value="true">\n\

View File

@ -815,7 +815,7 @@ if (!empty($_GET["acceptinvite"])) {
}
if ($con->query($sql) === TRUE) {
$_SESSION["info_general"] = " Group Invite Updated";
$_SESSION["info_general"] = " Group invitation status updated";
header("Location: Course.php?url=" . $url);
} else {
echo "Error: " . $sql . "<br>" . $con->error;