source: Dev/trunk/classes/surveyEditorWidget.php @ 191

Last change on this file since 191 was 191, checked in by fpvanagthoven, 13 years ago
  • Clean up van bestanden die niet meer gebruikt worden/niet nodig zijn/zijn gemerged met bestaande files.
  • Daarnaast question/survey editor nu grotendeels werkend (min save functie...)
  • Inloggen werkt nu op userUid ipv naam, werkt beter met het aanmaken van creators.
  • Bug in returnObjectDisplay gefixt, er stond nog een var_dump tussen de echoes. JSON houdt niet van HTML tags.
File size: 4.1 KB
RevLine 
[178]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
[185]14    private $loadedSurvey;
15    private $dbi;
[178]16
17    public function __construct() {
18        // Set basic variables
19        // Should probably include a default empty survey for the sake of safety
[185]20        $dbi = new DatabaseInterface();
[178]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']));
[185]28            if (!empty($surveyResults)) {
[191]29                $this->loadedSurvey = $surveyResults[0];
[178]30            } else {
[185]31                die("No surveys found!");
[178]32            }
33        } else {
[185]34            die("Incorrect or null uid passed!");
[178]35        }
36    }
37
38    public function init() {
[185]39        $questionString = "";
40        foreach ($this->loadedSurvey->questions as $question) {
[191]41            $questionString .= $question->code . ",";
[185]42        }
[178]43        // echo the HTML markup to display the editor on the screen
44        ?>
45
46        <div id="surveyEditor" class="largeFrame">
[185]47            <div class="largeTitle" id="surveyTitle">
48                <?php echo $this->loadedSurvey->title; ?>
[178]49            </div>
[185]50            <div id="seqContent" class="innerLargeFrame">
51                <div id="seqContentWrapper">
[178]52
53                </div>
54            </div>
[185]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>
[178]63            <div id="surveyEditorControls" class="controls">
[185]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
[178]72                <input type="button" value="Discard survey" onClick="javascript:alert('discard not yet supported');" class="smallButton" />
[191]73                <input type="button" value="Save survey" onClick="saveSurvey(true);" class="smallButton" />
[178]74            </div>
75
76        </div>
77
78
[185]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; ?>" />
[178]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        ?>
[185]94        <script type="text/javascript" src="js/sequencerScripts.js"></script>
95        <script type="text/javascript" src="js/generalscripts.js"></script>
[178]96        <script type="text/javascript" src="js/jquery.js"></script>
97        <script type="text/javascript">
98            $(document).ready(function() {
[185]99                loadSequencer();
[178]100            });
101        </script>
102        <?php
103    }
104
105}
106?>
Note: See TracBrowser for help on using the repository browser.