-
Notifications
You must be signed in to change notification settings - Fork 3
/
quiz.php
86 lines (83 loc) · 4.34 KB
/
quiz.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
<link rel="stylesheet" href="/QUIZ/style.css">
<title>QuizX</title>
</head>
<body>
<?php include 'partials/_header.php'?>
<?php
if(isset($_GET['quizDeleted']) && $_GET['quizDeleted'] == 'true'){
echo '<div class="alert alert-success alert-dismissible fade show my-0" role="alert">
<strong>Success!</strong> The quiz has been deleted.
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>';
unset($_GET['quizDeleted']);
}
?>
<div class="container my-3">
<div class="row mb-2">
<h3 class="text-light">Available Quizes</h3>
</div>
<?php
include 'partials/_dbconnect.php';
$sql = "SELECT * FROM `quizes`";
$result = mysqli_query($conn, $sql);
echo '<div class="row">';
while($row = mysqli_fetch_assoc($result)){
$qname = $row['qname'];
$_SESSION['subject'] = $qname;
$qtotal = $row['qtotal'];
$qright = $row['qright'];
$qwrong = $row['qwrong'];
$eid = $row['eid'];
echo'<div class="col-sm-12 col-md-3 mb-5">
<div class="card card-product" style="width: 18rem;">
<div class="card-body">
<h5 class="card-title">'.$qname.'</h5>
<p>Total Questions : '.$qtotal.' </p>
<p>Correct Answer : '.$qright.' </p>
<p>Marks : '.$qright * $qtotal.'</p>
<p>Negative Marking : '.$qwrong.' </p>';
if(isset($_SESSION['role']) && $_SESSION['role'] == 'teacher'){
echo '<a href="/QUIZ/partials/_viewquiz.php?subject='.$qname.'&eid='.$eid.'" class="btn btn-success mb-2 mx-2">View
Quiz</a>';
}
else if(isset($_SESSION['role']) && $_SESSION['role'] == 'student'){
$email = $_SESSION['email'];
$sql1 = "SELECT * FROM `history` where email = '$email' and eid = '$eid'";
$result1 = mysqli_query($conn, $sql1);
$numRows = mysqli_num_rows($result1);
if($numRows > 0){
echo '<a href="/QUIZ/partials/_takequiz.php?subject='.$qname.'&eid='.$eid.'&n=1&t='.$qtotal.'&retake=1" class="btn btn-danger mb-2">Retake
this Quiz</a>';
}
else{
echo '<a href="/QUIZ/partials/_takequiz.php?subject='.$qname.'&eid='.$eid.'&n=1&t='.$qtotal.'" class="btn btn-danger mb-2">Take
Quiz</a>';
}
}
if(isset($_SESSION['role']) && $_SESSION['role'] == 'teacher') {
/*echo '<a href="/QUIZ/partials/_modifyquiz.php?subject='.$qname.'" class="btn btn-warning mb-2">Modify
Quiz</a>*/
echo ' <a href="/QUIZ/partials/_deletequiz.php?op=delete&subject='.$qname.'&eid='.$eid.'" class="btn btn-danger mb-2">Delete
Quiz</a>';
}
echo'</div>
</div>
</div>';
}
echo '</div>';
?>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf" crossorigin="anonymous">
</script>
</body>
</html>