1 | <?php |
---|
2 | /* |
---|
3 | * To change this template, choose Tools | Templates |
---|
4 | * and open the template in the editor. |
---|
5 | */ |
---|
6 | |
---|
7 | /** |
---|
8 | * The PHP class that implements the survey editor interface |
---|
9 | * |
---|
10 | * @author Thijs Schipper |
---|
11 | */ |
---|
12 | class surveyEditorWidget { |
---|
13 | |
---|
14 | private $loadedSession; |
---|
15 | |
---|
16 | public function __construct() { |
---|
17 | // Set basic variables |
---|
18 | // Should probably include a default empty survey for the sake of safety |
---|
19 | } |
---|
20 | |
---|
21 | public function handlePost() { |
---|
22 | // Get POSTed data and store variables to class instance properties |
---|
23 | // Most important: loadedSession! |
---|
24 | |
---|
25 | //var_dump($_POST); |
---|
26 | |
---|
27 | $dbi = new DatabaseInterface(); |
---|
28 | if (isset($_POST['objectUid']) && !empty($_POST['objectUid'])) { |
---|
29 | $surveyResults = $dbi->get("Survey", array("uid" => $_POST['objectUid'])); |
---|
30 | if (count($surveyResults) > 0) { |
---|
31 | $this->loadedSurvey = $surveyResults[0]; |
---|
32 | } else { |
---|
33 | var_dump("No surveys found!"); |
---|
34 | } |
---|
35 | } else { |
---|
36 | var_dump("Incorrect or null uid passed!"); |
---|
37 | } |
---|
38 | } |
---|
39 | |
---|
40 | public function init() { |
---|
41 | // echo the HTML markup to display the editor on the screen |
---|
42 | ?> |
---|
43 | |
---|
44 | <div id="surveyEditor" class="largeFrame"> |
---|
45 | <div class="largeTitle"> |
---|
46 | Survey name |
---|
47 | </div> |
---|
48 | <div id="surveyEditorContent" class="innerLargeFrame"> |
---|
49 | |
---|
50 | <!-- |
---|
51 | <div id="questionUID" class="smallFrame"> |
---|
52 | <div class="smallTitle"><div class="listNumber">1</div>#QUESTION-IDENT-NO</div> |
---|
53 | <div class="content"> |
---|
54 | <p class="questionBody"> |
---|
55 | This is the question body text. This is what the user will read when he is answering the survey.This is the question body text. This is what the user will read when he is answering the survey.This is the question body text. This is what the user will read when he is answering the survey. |
---|
56 | </p> |
---|
57 | <div class="questionParamsView"> |
---|
58 | PARAMETERS GO HERE, probably in one line (Only answer type and identifier?) Tags? |
---|
59 | </div> |
---|
60 | </div> |
---|
61 | <div id="questionDisplayControls" class="controls"> |
---|
62 | <input type="button" value="Edit" onClick="javascript:alert('editing not yet supported');" class =" smallButton"/> |
---|
63 | <input type="button" value="Remove" onClick="javascript:alert('removing not yet supported');" class =" smallButton"/> |
---|
64 | </div> |
---|
65 | </div> |
---|
66 | --> |
---|
67 | |
---|
68 | </div> |
---|
69 | <div id="surveyEditorControls" class="controls"> |
---|
70 | <input type="button" value="Discard survey" onClick="javascript:alert('discard not yet supported');" class="smallButton" /> |
---|
71 | <input type="button" value="Save survey" onClick="javascript:alert('save not yet supported');" class="smallButton" /> |
---|
72 | </div> |
---|
73 | |
---|
74 | </div> |
---|
75 | |
---|
76 | |
---|
77 | <form name="hiddenFields"> |
---|
78 | <input type="hidden" id="surveyUid" value="<?php echo $this->loadedSurvey->uid; ?>" /> |
---|
79 | <input type="hidden" id="questionUids" value="<?php echo $this->loadedSurvey->questions; ?>" /> |
---|
80 | <input type="hidden" id="surveyTitle" value="<?php echo $this->loadedSurvey->title; ?>" /> |
---|
81 | <input type="hidden" id="numQuestions" value="<?php echo count($this->loadedSurvey->questions); ?>" /> |
---|
82 | <input type="hidden" id="surveyDescription" value="<?php echo $this->loadedSurvey->description; ?>" /> |
---|
83 | </form> |
---|
84 | |
---|
85 | |
---|
86 | <?php |
---|
87 | } |
---|
88 | |
---|
89 | public function javascript() { |
---|
90 | // output the javascript tags and needed functions in the head of the page |
---|
91 | ?> |
---|
92 | <script type="text/javascript" src="js/surveyEditorScripts.js"></script> |
---|
93 | <script type="text/javascript" src="js/jquery.js"></script> |
---|
94 | <script type="text/javascript"> |
---|
95 | $(document).ready(function() { |
---|
96 | loadSurvey(); |
---|
97 | }); |
---|
98 | </script> |
---|
99 | <?php |
---|
100 | } |
---|
101 | |
---|
102 | } |
---|
103 | ?> |
---|