Ignore:
Timestamp:
12/15/11 17:09:49 (13 years ago)
Author:
fpvanagthoven
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/classes/surveyEditorWidget.php

    r182 r185  
    1212class surveyEditorWidget {
    1313
    14     private $loadedSession;
     14    private $loadedSurvey;
     15    private $dbi;
    1516
    1617    public function __construct() {
    1718        // Set basic variables
    1819        // Should probably include a default empty survey for the sake of safety
     20        $dbi = new DatabaseInterface();
    1921    }
    2022
    2123    public function handlePost() {
    2224        // Get POSTed data and store variables to class instance properties
    23         // Most important: loadedSession!
    24 
    25         //var_dump($_POST);
    26 
    2725        $dbi = new DatabaseInterface();
    2826        if (isset($_POST['objectUid']) && !empty($_POST['objectUid'])) {
    2927            $surveyResults = $dbi->get("Survey", array("uid" => $_POST['objectUid']));
    30             if (count($surveyResults) > 0) {
    31                 $this->loadedSurvey = $surveyResults[0];
     28            if (!empty($surveyResults)) {
     29                (is_array($surveyResults)) ? $this->loadedSurvey = $surveyResults[0] : $this->loadedSurvey = $surveyResults;
    3230            } else {
    33                 var_dump("No surveys found!");
     31                die("No surveys found!");
    3432            }
    3533        } else {
    36             var_dump("Incorrect or null uid passed!");
     34            die("Incorrect or null uid passed!");
    3735        }
    3836    }
    3937
    4038    public function init() {
     39        $questionString = "";
     40        foreach ($this->loadedSurvey->questions as $question) {
     41            $questionString .= $question->uid . ",";
     42        }
    4143        // echo the HTML markup to display the editor on the screen
    4244        ?>
    4345
    4446        <div id="surveyEditor" class="largeFrame">
    45             <div class="largeTitle">
    46                 Survey name
     47            <div class="largeTitle" id="surveyTitle">
     48                <?php echo $this->loadedSurvey->title; ?>
    4749            </div>
    48             <div id="surveyEditorContent" class="innerLargeFrame">
     50            <div id="seqContent" class="innerLargeFrame">
     51                <div id="seqContentWrapper">
    4952
    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>
    6553                </div>
    66                 -->
    67 
     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" />
     61                </div>
     62                <input type="button" id="vertControls_Add" class="bigButton vertical" value="+" onClick="addQuestion_Click();" />
    6863            </div>
    6964            <div id="surveyEditorControls" class="controls">
     65                <div id="pageControls">
     66                    <input type="button" value="<<" id="pageControls_first" onClick="" />
     67                    <input type="button" value="<" id="pageControls_previous" onClick="" />
     68                    Page <input type="text" value="1" id="pageControls_current" onChange="" class="smallTextField" /> of 5
     69                    <input type="button" value=">" id="pageControls_next" onClick="" />
     70                    <input type="button" value=">>" id="pageControls_last" onClick="" />
     71                </div>
     72
    7073                <input type="button" value="Discard survey" onClick="javascript:alert('discard not yet supported');" class="smallButton" />
    7174                <input type="button" value="Save survey" onClick="javascript:alert('save not yet supported');" class="smallButton" />
     
    7578
    7679
    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; ?>" />
     80        <form id="hiddenInputs">
     81            <input type="hidden" id="surveyUidField" value="<?php echo $this->loadedSurvey->uid; ?>" />
     82            <input type="hidden" id="questionUidsField" value="<?php echo $questionString ?>" />
     83            <input type="hidden" id="surveyTitleField" value="<?php echo $this->loadedSurvey->title; ?>" />
     84            <input type="hidden" id="numQuestionsField" value="<?php echo count($this->loadedSurvey->questions); ?>" />
     85            <input type="hidden" id="surveyDescriptionField" value="<?php echo $this->loadedSurvey->description; ?>" />
    8386        </form>
    8487
     
    9093        // output the javascript tags and needed functions in the head of the page
    9194        ?>
    92         <script type="text/javascript" src="js/surveyEditorScripts.js"></script>
     95        <script type="text/javascript" src="js/sequencerScripts.js"></script>
     96        <script type="text/javascript" src="js/generalscripts.js"></script>
    9397        <script type="text/javascript" src="js/jquery.js"></script>
    9498        <script type="text/javascript">
    9599            $(document).ready(function() {
    96                 loadSurvey();
     100                loadSequencer();
    97101            });
    98102        </script>
Note: See TracChangeset for help on using the changeset viewer.