-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsurvey_view.php
55 lines (46 loc) · 1.66 KB
/
survey_view.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
/**
* survey_view.php is a page to demonstrate the proof of concept of the
* initial SurveySez objects.
*
* Objects in this version are the Survey, Question & Answer objects
*
* @package SurveySez
* @author William Newman
* @version 2.12 2015/06/04
* @link http://newmanix.com/
* @license http://www.apache.org/licenses/LICENSE-2.0
* @see Question.php
* @see Answer.php
* @see Response.php
* @see Choice.php
*/
require '../inc_0700/config_inc.php'; #provides configuration, pathing, error handling, db credentials
spl_autoload_register('MyAutoLoader::NamespaceLoader');//required to load SurveySez namespace objects
$config->metaRobots = 'no index, no follow';#never index survey pages
# check variable of item passed in - if invalid data, forcibly redirect back to demo_list.php page
if(isset($_GET['id']) && (int)$_GET['id'] > 0){#proper data must be on querystring
$myID = (int)$_GET['id']; #Convert to integer, will equate to zero if fails
}else{
myRedirect(VIRTUAL_PATH . "surveys/index.php");
}
$mySurvey = new SurveySez\Survey($myID); //MY_Survey extends survey class so methods can be added
if($mySurvey->isValid)
{
$config->titleTag = "'" . $mySurvey->Title . "' Survey!";
}else{
$config->titleTag = smartTitle(); //use constant
}
#END CONFIG AREA ----------------------------------------------------------
get_header(); #defaults to theme header or header_inc.php
?>
<h3><?=$mySurvey->Title;?></h3>
<?php
if($mySurvey->isValid)
{ #check to see if we have a valid SurveyID
echo '<p>' . $mySurvey->Description . '</p>';
echo $mySurvey->showQuestions();
}else{
echo "Sorry, no such survey!";
}
get_footer(); #defaults to theme footer or footer_inc.php