source: Dev/trunk/src/client/qed-client/model/widgets/SurveyRenderWidget.js @ 477

Last change on this file since 477 was 461, checked in by hendrikvanantwerpen, 12 years ago

Save answers, improved response page and question widgets.

  • Warn if _ComplexValueMixin is not pout on a form element, to prevent 'name' collisions. Changed all depending widgets to <form>'s.
  • Fixed names for question widgets to actually save answers.
  • Fixed and improved response page.
  • Fixed names in MultipleChoice? widget, which behaves different for radio and check.
File size: 1.4 KB
Line 
1define([
2    "../../widgets/_ComplexValueWidget",
3    "../classes/Survey",
4    "./questions/Factory",
5    "dojo/_base/array",
6    "dojo/_base/declare",
7    "dojo/dom-construct",
8    "dojo/text!./templates/SurveyRenderWidget.html"
9], function(_ComplexValueWidget, Survey, QuestionWidgetFactory, array, declare, domConstruct, template) {
10    return declare([_ComplexValueWidget],{
11        templateString: template,
12        survey: null,
13        startup: function() {
14            if ( this._started ) { return; }
15            this.inherited(arguments);
16            if ( this.survey ) {
17                this._setSurveyAttr(this.survey);
18            }
19        },
20        _setSurveyAttr: function(survey) {
21            domConstruct.empty(this.domNode);
22            this.survey = survey;
23            var f = new QuestionWidgetFactory();
24            array.forEach(Survey.Questions.get(this.survey),function(question,question_index){
25                array.forEach(question.content || [], function(item,item_index){
26                    // The dot causes values to be grouped in an object!
27                    var w = f.createViewWidget(item);
28                    if ( w !== null ) {
29                        w.name = question_index.toString()+'/'+question.code.toString()+'.'+item_index.toString();
30                        w.placeAt(this.domNode);
31                    }
32                },this);
33            },this);
34        }
35    });
36});
Note: See TracBrowser for help on using the repository browser.