Changeset 240 for Dev/branches


Ignore:
Timestamp:
01/18/12 17:13:25 (13 years ago)
Author:
fpvanagthoven
Message:
 
Location:
Dev/branches/jos-branch
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • Dev/branches/jos-branch/js/questionEditorScripts.js

    r238 r240  
    2424    // Properties   
    2525    this.uid = null;    // The uid of the question contained in this editor
    26     this.saved = false; // Whether or not the question displayed in the editor has been saved already.
    2726    var me = this;      // Retarded self-reference because: Javascript
    2827    this.element = null;    // The parent div element containing the questionEditor
     
    7271        }
    7372    }
    74     this.init = function() {
     73    this.init = function(uid) {
    7574        // Outer div
    7675        this.saved = false;
     
    7877        me.element.className = "smallFrame questionEditor";
    7978        me.element.id = sequencer.state.selectedObject.uid;
    80         me.uid = sequencer.state.selectedObject.uid;
     79        me.uid = uid;
    8180        // Header
    8281        var titleDiv = ce("div");
     
    176175            "title": ge("qeTitleField").innerHTML,
    177176            "code": ge("qeCodeField").value,
    178             "description": ge("qeBodyTextField").value
     177            "description": ge("qeBodyTextField").value,
     178            "uid": me.uid
    179179        }
    180180       
     
    221221            // Then add the returned uid, if existing, to the sequencer.survey.questions array and set it for update
    222222            debugger;
     223            console.log(result.responseText);
    223224            var response = JSON.parse(result.responseText);
    224225            console.log(response);
     
    250251    }
    251252    this.discard = function() {
    252             debugger;
    253             me.element.parentNode.removeChild(me.element);
    254             me.init();
    255             sequencer.state.loaded = true;
    256             sequencer.state.editing = false;
    257             sequencer.survey.questions.upToDate[sequencer.survey.questions.uids.indexOf(me.uid)] = false;
    258             updateSequencer();
     253        debugger;
     254        me.element.parentNode.removeChild(me.element);
     255        sequencer.state.loaded = true;
     256        sequencer.state.editing = false;
     257        sequencer.survey.questions.upToDate[sequencer.survey.questions.uids.indexOf(me.uid)] = false;
     258        updateSequencer();
    259259       
    260260    }
     
    476476            uid: uid
    477477        });
    478         me.init();
     478        me.init(uid);
    479479        var oldElement = ge(uid);
    480480        if (oldElement) {
     
    494494        sequencer.state.editing = true;
    495495   
    496         me.reset();
     496        me.init(null);
    497497        var container = ge("seqContentWrapper");
    498498        container.appendChild(me.element);
  • Dev/branches/jos-branch/js/sequencerScripts.js

    r238 r240  
    178178
    179179    /*
    180          * Description:
    181          * This function updates the visual elements in the sequencer content view to match the current state of the sequencer.session.pipeline property.
    182          * It queries the database for object properties via AJAX (returnStep/Display/.php), then inserts divider div's in between where needed.
    183          */
     180     * Description:
     181     * This function updates the visual elements in the sequencer content view to match the current state of the sequencer.session.pipeline property.
     182     * It queries the database for object properties via AJAX (returnStep/Display/.php), then inserts divider div's in between where needed.
     183     */
    184184       
    185185    switch (sequencer.settings.content.contentType.toLowerCase()) {
     
    262262        }
    263263        updateDividers();
    264     // End optional
     264        // End optional
    265265    }
    266266}
     
    325325       
    326326        // Optional bit with the loading GIF
    327         for (var i = 0; i < needsUpdating.length; i++) {
    328             var loadingDiv = ce("div");
    329             loadingDiv.className = "displayStep loading";
    330             loadingDiv.innerHTML = "<img src='images/ui/ajax-loader-round.gif' />";
    331             if (needsUpdating[i][0] > sequencer.state.numSteps-1) {
    332                 content.appendChild(loadingDiv);
    333                 sequencer.state.numSteps++;
    334             }
    335             else {
    336                 content.replaceChild(loadingDiv, content.childNodes[i][0]*2);
     327        if (sequencer.settings.content.contentType.toLowerCase() != "survey"){
     328            for (var i = 0; i < needsUpdating.length; i++) {
     329                var loadingDiv = ce("div");
     330                loadingDiv.className = "displayStep loading";
     331                loadingDiv.innerHTML = "<img src='images/ui/ajax-loader-round.gif' />";
     332                if (needsUpdating[i][0] > sequencer.state.numSteps-1) {
     333                    content.appendChild(loadingDiv);
     334                    sequencer.state.numSteps++;
     335                }
     336                else {
     337                    content.replaceChild(loadingDiv, content.childNodes[i][0]*2);
     338                }
    337339            }
    338340        }
    339341        updateDividers();
    340     // End optional
     342        // End optional
    341343       
    342344    }
     
    441443function insertNewSteps(response, needsUpdating) {
    442444    /*
    443          * This is a function displaying how to handle the visual object representation in solely javascript.
    444          * Communication of relevant variables between PHP and JS happens in JSON format.
    445          * PHP returns a JSON array of objects to be created by JS
    446          * JS then loops through this array and creates DIVS to be inserted into the sequencer.
    447          * These are inserted at the position needsUpdating gives us.
    448          */
     445     * This is a function displaying how to handle the visual object representation in solely javascript.
     446     * Communication of relevant variables between PHP and JS happens in JSON format.
     447     * PHP returns a JSON array of objects to be created by JS
     448     * JS then loops through this array and creates DIVS to be inserted into the sequencer.
     449     * These are inserted at the position needsUpdating gives us.
     450     */
    449451    if (!response || !response.length > 0) return;
    450452    //console.log(response);
     
    760762    newAjaxRequest(requestString, "savesession.php", function(result){
    761763        console.log(result.responseText);
    762         }, true);
     764    }, true);
    763765}
    764766
     
    838840   
    839841     
    840 // The alternative is to use event bubbling to capture the event on a higher level.
    841 // Basically, we bind a super-structure onclick event that uses e.target|| event.srcElement to determine which element to move and select.
    842 // http://stackoverflow.com/questions/29624/how-to-maintain-correct-javascript-event-after-using-clonenodetrue
    843 // Pro: clean implementation, less events binded.
    844 // Con: Difficult, this already works fine, probably tougher to use in conjunction with multifunctionality (sessions, surveys, questionsets, etc in one kind of editor)
     842    // The alternative is to use event bubbling to capture the event on a higher level.
     843    // Basically, we bind a super-structure onclick event that uses e.target|| event.srcElement to determine which element to move and select.
     844    // http://stackoverflow.com/questions/29624/how-to-maintain-correct-javascript-event-after-using-clonenodetrue
     845    // Pro: clean implementation, less events binded.
     846    // Con: Difficult, this already works fine, probably tougher to use in conjunction with multifunctionality (sessions, surveys, questionsets, etc in one kind of editor)
    845847     
    846848}
     
    864866    // Derp, natuurlijk werkt de addQuestion call niet twee keer. Hij creeert twee keer exact hetzelfde object. Bottom line: het werkt. Nu de editing code voor deze questions gaan schrijven!
    865867    var response = [{
    866         uid: "1234567890testuid",
    867         title: "dummyQuestion",
    868         description: "This is a dummy question, not a real one!",
    869         type: "question"
    870     }];
     868            uid: "1234567890testuid",
     869            title: "dummyQuestion",
     870            description: "This is a dummy question, not a real one!",
     871            type: "question"
     872        }];
    871873   
    872874    var needsUpdating = [[
    873     0,
    874     "1234567890testuid",
    875     "question"
    876     ]];
     875            0,
     876            "1234567890testuid",
     877            "question"
     878        ]];
    877879   
    878880    insertNewQuestions(response, needsUpdating);
  • Dev/branches/jos-branch/setQuestion.php

    r237 r240  
    1313    $question_results = Question::get(array("uid" => $input->uid));
    1414    if (!empty($question_results)) {
    15         $question = $questions[0];
     15        $question = $question_results[0];
    1616    } else {
    1717        die("Error: attempt to edit a non-existing database object!");
     
    2222    if ($input->title) $question->title = $input->title;
    2323    if ($input->description) $question->description = $input->description;
    24     if ($input->category ) $question->category = null;
    25     if ($input->answers) $question->answers = null;
     24    if (isset($input->category) ) $question->category = null;
     25    if (isset($input->answers)) $question->answers = null;
    2626    $question->save();
    2727    $outputArray = array("created"=>false, "uid"=>$question->uid);
Note: See TracChangeset for help on using the changeset viewer.