Warning: Can't use blame annotator:
svn blame failed on trunk/webapps/EInotebook/scripts/Evaluation.js: ("Can't find a temporary directory: Internal error", 20014)

source: tmcsimulator/trunk/webapps/EInotebook/scripts/Evaluation.js @ 359

Revision 359, 4.4 KB checked in by jdalbey, 7 years ago (diff)

Add EINotebook source

  • Property svn:executable set to *
RevLine 
1/**
2 * Represents an evaluation (e.g., a "CMS evaluation").
3 * @param type {String} Ex: "CMS" or "ATMS" ...
4 * @param data Array(label1, text1, label2, text2, ...)
5 */
6function Evaluation(type, data)
7{
8        //========== private static members ==========//
9        Evaluation.id = (typeof Evaluation.id == 'undefined') ? 0 : ++Evaluation.id;
10       
11        //========== public constants ==========//
12        this.id = Evaluation.id;
13        this.ratingGroupName = "evaluationGroup" + this.id;     
14        this.textID = "evaluationText" + this.id;
15        this.type = type;
16        this.data = data;
17       
18        //========== public read-only members ==========//
19        this.text = "";
20        this.rating = -1;
21       
22        //========== public methods ==========//
23        this.html = html;
24        this.recordText = recordText; 
25        this.recordRating = recordRating;
26       
27        //========== private methods ==========//
28        this.smallScaleForm = smallScaleForm;
29        this.evaluationForm = evaluationForm;
30       
31        //========== function definitions ==========//
32        /**
33         * @return The html representation of this evaluation.
34         */
35        function html()
36        {
37                var text = "<table class='evaluation'>" +
38                                   "<tr>" +
39                                   "<th class='evaluationType' colspan='2'>" + type + " Evalution</th>" +
40                                   "</tr>" +
41                                   "<tr>" +
42                                   "<td><table class='evaluationInner2'>";
43               
44                for (i = 0; i < this.data.length; i += 2)
45                {
46                        text += "<tr>" +
47                                   "<td class='evaluationLabel'>" + this.data[i] + "</td>" +
48                                   "<td class='evaluationCriteria'>" + this.data[i+1] + "</td>" +
49                                   "</tr>";
50                }
51               
52                text += "<tr><td colspan='2' class='evaluationResponse'>" +
53                        "<input onchange='events.getEvaluation(" + this.id + ").recordText();'" +
54                        " id='" + this.textID + "' type='text' value='" + this.text + "'" +
55                        " class='evaluationResponseText' />" 
56                        + "</td>";
57               
58                text += "</table></td>" +
59                                "<td class='evaluationScale'>" + this.evaluationForm() + "</td>" +
60                            "</tr>" +
61                                "</table>";
62               
63                return text;
64        }
65       
66        /**
67         * Stores the rating given by the evaluation scale radio button form.
68         */
69        function recordRating() 
70        { 
71                // list of radio buttons
72                var radioButtons;
73               
74                // get list of radio buttons
75                radioButtons = events.doc.getElementsByName(this.ratingGroupName);
76               
77                // FOR each radio button
78                for (var i = 0; i < radioButtons.length; i++)
79                {
80                        // IF the radio button is checked THEN
81                        if (radioButtons[i].checked)
82                        {
83                                // save rating
84                                this.rating = radioButtons[i].value;
85                        }
86                }
87        }
88
89        /**
90         * Stores the text in the written response text box.
91         */
92        function recordText() 
93        { 
94                this.text = events.doc.getElementById(this.textID).value; 
95        }
96       
97        /**
98         * @return The html for appropriate evaluation form for grading.
99         */
100        function evaluationForm()
101        {
102                return this.smallScaleForm();
103        }
104       
105        /**
106         * @return The html for a 1-5 grading scale.
107         */
108        function smallScaleForm()
109        {
110                return "<form>" +
111                           "<table align='right' class='evaluationScale'>" +
112                           "<tr>" +
113                           "<td class='eventRadioButtonSmallScale'>Best</td>" +
114                           "<td class='eventRadioButtonSmallScale'>Good</td>" +
115                           "<td class='eventRadioButtonSmallScale'>Average</td>" +
116                           "<td class='eventRadioButtonSmallScale'>Poor</td>" +
117                           "<td class='eventRadioButtonSmallScale'>Worst</td>" +
118                           "</tr>" +
119                           "<tr>" +
120                           "<td align='center'><input type='radio' " + 
121                                        (this.rating == 1 ? "checked='true'" : "") + 
122                                        " onchange='events.getEvaluation(" + this.id + 
123                                        ").recordRating()' name='" + this.ratingGroupName + 
124                                        "' value='1'></td>" +
125                           "<td align='center'><input type='radio' " + 
126                                        (this.rating == 2 ? "checked='true'" : "") + 
127                                        " onchange='events.getEvaluation(" + this.id + 
128                                        ").recordRating()' name='" + this.ratingGroupName + 
129                                        "' value='2'></td>" +
130                           "<td align='center'><input type='radio' " + 
131                                        (this.rating == 3 ? "checked='true'" : "") + 
132                                        " onchange='events.getEvaluation(" + this.id + 
133                                        ").recordRating()' name='" + this.ratingGroupName + 
134                                        "' value='3'></td>" +
135                           "<td align='center'><input type='radio' " + 
136                                        (this.rating == 4 ? "checked='true'" : "") + 
137                                        " onchange='events.getEvaluation(" + this.id + 
138                                        ").recordRating()' name='" + this.ratingGroupName + 
139                                        "' value='4'></td>" +
140                           "<td align='center'><input type='radio' " + 
141                                        (this.rating == 5 ? "checked='true'" : "") + 
142                                        " onchange='events.getEvaluation(" + this.id + 
143                                        ").recordRating()' name='" + this.ratingGroupName + 
144                                        "' value='5'></td>" +
145                           "</tr>" +
146                           "</table>"  +
147                           "</form>";
148        }
149}
Note: See TracBrowser for help on using the repository browser.