Ignore:
Timestamp:
12/16/12 20:07:35 (12 years ago)
Author:
hendrikvanantwerpen
Message:

We can store answers for surveys now!

Introduces SurveyRun?, which can be edited. Workflow not quite clear yet. A
running survey can be accessed to leave a response. When the response
has an ID, it is loaded (used for closed surveys and continuations). A
researcher cannot create responses yet. He should also be able to add
comments to responses (that he creates).

Introduced caching of store requests.

Factored out path matching and formatting.

Put object creation in separate classes, to localize model/storage
dependency. Not consistent at the moment.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/branches/rest-dojo-ui/client/qed/pages/question.js

    r418 r420  
    11define([
    22    'dojo/_base/declare',
    3     'dojo/_base/Deferred',
    43    'dojo/_base/event',
    54    'dojo/_base/lang',
     5    'dojo/when',
    66    '../store',
    77    '../app/Content',
    88    '../app/Router',
    99    '../app/Page',
     10    '../model/classes/Question',
    1011    '../model/widgets/QuestionEditorPreview',
    1112    '../model/widgets/QuestionEditorToolkit',
    1213    'dojo/text!./templates/question.html'
    13 ],function(declare, Deferred, event, lang, store, Content, Router, Page, QuestionEditorPreview, QuestionEditorToolkit, template){
     14],function(declare, event, lang, when, store, Content, Router, Page, Question, QuestionEditorPreview, QuestionEditorToolkit, template){
    1415    return declare([Page], {
    1516        templateString: template,
     
    2627            this._setupEditor();
    2728            if (this.questionId === "new") {
    28                 this.question = { type: 'Question' };
     29                this.question = Question.create();
    2930                this._refresh();
    3031            } else {
    31                 Deferred.when(store.get(this.questionId))
     32                when(store.get(this.questionId))
    3233                .then(lang.hitch(this, function(obj) {
    3334                    this.question = obj;
     
    4041        },
    4142        _refresh: function () {
    42             this.titleNode.innerHTML = this.question.title || "";
     43            this.titleNode.innerHTML = Question.DisplayTitle.get(this.question);
    4344            this._toolkit.set('value',this.question);
    44             this._preview.appendItems(this.question.content || []);
     45            this._preview.appendItems(Question.Content.get(this.question));
    4546        },
    4647        _onSave: function(evt) {
    4748            lang.mixin(this.question, this._toolkit.get('value'));
    48             this.question.content = this._preview.getItems();
     49            Question.Content.set(this.question, this._preview.getItems());
    4950            store.put(this.question)
    5051            .then(function() {
Note: See TracChangeset for help on using the changeset viewer.