forked from riprap/Survey-Ninja
-
Notifications
You must be signed in to change notification settings - Fork 0
/
list_surveys.php
71 lines (64 loc) · 1.98 KB
/
list_surveys.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
<?php
/*
File Name: list_surveys.php
Authors Name: Scott Montgomery and Nolan Knill
Web Site Name: Survey Site
File Description: The page that lists all of the active surveys and allows the user to take them.
*/
$page_name = "All Surveys";
include "functions/functions.php";
$surveys = get_active_surveys();
?>
<?php include 'partials/html_header.php'; ?>
<body>
<?php include 'partials/header.php'; ?>
<div class="row">
<div class="large-9 columns" role="content">
<h3><?php echo $page_name;?></h3>
<?php include 'partials/messages.php'; ?>
<?php
if (empty($surveys)) {?>
<h3>There are currently no active surveys.</h4>
<?php } else { ?>
<h5>To take a survey, click a survey's name.</h5>
<table>
<tr>
<th>Name</th>
<th>Survey Type</th>
<th>Number of Questions</th>
</tr>
<?php
foreach ($surveys as $survey):
$questions = get_questions($survey['id']);
?>
<tr>
<td>
<a href="survey.php?survey=<?php echo $survey['id']; ?>">
<?php echo htmlentities($survey['name']); ?>
</a>
</td>
<td>
<?php echo $survey['survey_type'];?>
</td>
<td>
<?php
if (!empty($questions)) :
echo count($questions);
else: ?>
<a href="add_questions.php?survey=<?php echo $survey['id']; ?>">
<?php echo count($questions); ?>
</a>
<?php
endif; //End the if statement to provide the url to add questions if the survey has no questions
?>
</td>
</tr>
<?php endforeach; //End of the foreach to loop through each of the surveys ?>
</table>
<?php } //End of if statement if there are surveys?>
</div>
<?php include 'partials/sidebar.php' ?>
</div>
<?php include 'partials/footer.php'; ?>
</body>
</html>