-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchooseQuiz.php
53 lines (47 loc) · 1.64 KB
/
chooseQuiz.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
<?php
include("cas.php");
include("database_connect.php");
$title = "QuizSplash: Choose a Quiz";
// PREPARE THE TEMPLATE
$template = file_get_contents('./template.html');
// REPLACE THE TITLE
$template = str_replace('<!--XXXTITLEXXX-->', $title, $template);
// REPLACE INSTANCES OF USERNAME
$username = $_SESSION['user'];
$template = str_replace('<!--XXXUSERNAMEXXX-->', $username, $template);
// ADD ADMINISTRATION LINK TO TOPNAV IF ADMINISTRATOR
$sql_adminCheck = "SELECT *
FROM classes
WHERE (instructor = '".$username."')
OR (assistant = '".$username."');";
$res_adminCheck = mysql_query($sql_adminCheck);
$cnt_adminCheck = mysql_num_rows($res_adminCheck);
$adminLink = "<li><a href =\"./classAdmin.php\">Administer My Classes</a></li>";
if ($cnt_adminCheck > 0) {
$template = str_replace('<!--XXXADMINISTRATIONXXX-->', $adminLink, $template);
}
// FIND THE SPLITPOINT
$splitpoint = strpos($template,'<!--XXXSPLITPOINTXXX-->');
// ECHO THE TOP BUN
echo substr($template, 0, $splitpoint);
?>
<h2>Choose a Quiz</h2>
<h4>Example Course</h4>
<ul>
<li>Example Quiz [0 questions in pool]
<ul>
<li>Average quiz score in this pool: 85%</li>
<li>Take a quiz from this pool:
<ul>
<li><a href="./takeQuiz.php">Ten random questions</a></li>
<li><a href="./takeQuiz.php">Questions I've gotten wrong</a></li>
<li><a href="./takeQuiz.php">The best 10 questions</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<?php
// ECHO THE BOTTOM BUN
echo substr($template, $splitpoint);
?>