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 $loadedSurvey; |
---|
15 | private $dbi; |
---|
16 | |
---|
17 | public function __construct() { |
---|
18 | // Set basic variables |
---|
19 | // Should probably include a default empty survey for the sake of safety |
---|
20 | $dbi = new DatabaseInterface(); |
---|
21 | } |
---|
22 | |
---|
23 | public function handlePost() { |
---|
24 | // Get POSTed data and store variables to class instance properties |
---|
25 | $dbi = new DatabaseInterface(); |
---|
26 | if (isset($_POST['objectUid']) && !empty($_POST['objectUid'])) { |
---|
27 | $surveyResults = $dbi->get("Survey", array("uid" => $_POST['objectUid'])); |
---|
28 | if (!empty($surveyResults)) { |
---|
29 | $this->loadedSurvey = $surveyResults[0]; |
---|
30 | } else { |
---|
31 | die("No surveys found!"); |
---|
32 | } |
---|
33 | } else { |
---|
34 | die("Incorrect or null uid passed!"); |
---|
35 | } |
---|
36 | } |
---|
37 | |
---|
38 | public function init() { |
---|
39 | $questionString = ""; |
---|
40 | foreach ($this->loadedSurvey->questions as $question) { |
---|
41 | $questionString .= $question->code . ","; |
---|
42 | } |
---|
43 | // echo the HTML markup to display the editor on the screen |
---|
44 | ?> |
---|
45 | |
---|
46 | <div id="surveyEditor" class="largeFrame"> |
---|
47 | <div class="largeTitle" id="surveyTitle"> |
---|
48 | <?php echo $this->loadedSurvey->title; ?> |
---|
49 | </div> |
---|
50 | <div id="seqContent" class="innerLargeFrame"> |
---|
51 | <div id="seqContentWrapper"> |
---|
52 | |
---|
53 | </div> |
---|
54 | </div> |
---|
55 | <div id="surveyEditorVertControls" class="vertControls"> |
---|
56 | <div class="segment"> |
---|
57 | <label>Move</label> |
---|
58 | <input type="button" id="vertControls_MoveUp" class="bigButton vertical" value="Ë" /> |
---|
59 | <input type="button" id="vertControls_MoveDown" class="bigButton vertical" value="Ë
" /> |
---|
60 | </div> |
---|
61 | <input type="button" id="vertControls_Add" class="bigButton vertical" value="+" onClick="addQuestion_Click();" /> |
---|
62 | </div> |
---|
63 | <div id="surveyEditorControls" class="controls"> |
---|
64 | <div id="pageControls"> |
---|
65 | <input type="button" value="<<" id="pageControls_first" onClick="" /> |
---|
66 | <input type="button" value="<" id="pageControls_previous" onClick="" /> |
---|
67 | Page <input type="text" value="1" id="pageControls_current" onChange="" class="smallTextField" /> of 5 |
---|
68 | <input type="button" value=">" id="pageControls_next" onClick="" /> |
---|
69 | <input type="button" value=">>" id="pageControls_last" onClick="" /> |
---|
70 | </div> |
---|
71 | |
---|
72 | <input type="button" value="Discard survey" onClick="javascript:alert('discard not yet supported');" class="smallButton" /> |
---|
73 | <input type="button" value="Save survey" onClick="saveSurvey(true);" class="smallButton" /> |
---|
74 | </div> |
---|
75 | |
---|
76 | </div> |
---|
77 | |
---|
78 | |
---|
79 | <form id="hiddenInputs"> |
---|
80 | <input type="hidden" id="surveyUidField" value="<?php echo $this->loadedSurvey->uid; ?>" /> |
---|
81 | <input type="hidden" id="questionUidsField" value="<?php echo $questionString ?>" /> |
---|
82 | <input type="hidden" id="surveyTitleField" value="<?php echo $this->loadedSurvey->title; ?>" /> |
---|
83 | <input type="hidden" id="numQuestionsField" value="<?php echo count($this->loadedSurvey->questions); ?>" /> |
---|
84 | <input type="hidden" id="surveyDescriptionField" value="<?php echo $this->loadedSurvey->description; ?>" /> |
---|
85 | </form> |
---|
86 | |
---|
87 | |
---|
88 | <?php |
---|
89 | } |
---|
90 | |
---|
91 | public function javascript() { |
---|
92 | // output the javascript tags and needed functions in the head of the page |
---|
93 | ?> |
---|
94 | <script type="text/javascript" src="js/sequencerScripts.js"></script> |
---|
95 | <script type="text/javascript" src="js/generalscripts.js"></script> |
---|
96 | <script type="text/javascript" src="js/questionEditorScripts.js"></script> |
---|
97 | <script type="text/javascript" src="js/jquery.js"></script> |
---|
98 | <script type="text/javascript"> |
---|
99 | $(document).ready(function() { |
---|
100 | loadSequencer(); |
---|
101 | }); |
---|
102 | </script> |
---|
103 | <?php |
---|
104 | } |
---|
105 | |
---|
106 | } |
---|
107 | ?> |
---|