source: Dev/branches/jos-branch/classes/widgets/SurveyEditorWidget.php @ 238

Last change on this file since 238 was 238, checked in by fpvanagthoven, 13 years ago

-selectObject is een algemene object selector. Kan gebruikt worden vanuit het mainmenu om in de verschillende editors te komen, en kan eventueel ook onder de "add existing" knop kopen te staan binnen die editors.

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