| 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 | */ |
|---|
| 6 | function Evaluation(type, data) |
|---|
| 7 | { |
|---|
| 8 | //========== private static members ==========// |
|---|
| 9 | Evaluation.id = (typeof Evaluation.id == 'undefined') ? 0 : ++Evaluation.id; |
|---|
| 10 | |
|---|
| 11 | //========== public constants ==========// |
|---|
| 12 | this.ratingQualities = ["", "Worst","Poor","Average","Good","Best"]; |
|---|
| 13 | this.id = Evaluation.id; |
|---|
| 14 | this.ratingGroupName = "evaluationGroup" + this.id; |
|---|
| 15 | this.textID = "evaluationText" + this.id; |
|---|
| 16 | this.type = type; |
|---|
| 17 | this.data = data; |
|---|
| 18 | |
|---|
| 19 | //========== public read-only members ==========// |
|---|
| 20 | this.text = ""; |
|---|
| 21 | this.rating = -1; |
|---|
| 22 | |
|---|
| 23 | //========== public methods ==========// |
|---|
| 24 | this.html = html; |
|---|
| 25 | this.recordText = recordText; |
|---|
| 26 | this.recordRating = recordRating; |
|---|
| 27 | |
|---|
| 28 | //========== private methods ==========// |
|---|
| 29 | this.smallScaleForm = smallScaleForm; |
|---|
| 30 | this.evaluationForm = evaluationForm; |
|---|
| 31 | |
|---|
| 32 | //========== function definitions ==========// |
|---|
| 33 | /** |
|---|
| 34 | * @return The html representation of this evaluation. |
|---|
| 35 | */ |
|---|
| 36 | function html() |
|---|
| 37 | { |
|---|
| 38 | var text = "<table class='evaluation'>" + |
|---|
| 39 | "<tr>" + |
|---|
| 40 | "<th class='evaluationType' colspan='2'>" + type + " Evaluation</th>" + |
|---|
| 41 | "</tr>" + |
|---|
| 42 | "<tr>" + |
|---|
| 43 | "<td><table class='evaluationInner2'>"; |
|---|
| 44 | |
|---|
| 45 | for (i = 0; i < this.data.length; i += 2) |
|---|
| 46 | { |
|---|
| 47 | text += "<tr>" + |
|---|
| 48 | "<td class='evaluationLabel'>" + this.data[i] + "</td>" + |
|---|
| 49 | "<td class='evaluationCriteria'>" + this.data[i+1] + "</td>" + |
|---|
| 50 | "</tr>"; |
|---|
| 51 | } |
|---|
| 52 | /* Displays the comment input field |
|---|
| 53 | text += "<tr><td colspan='2' class='evaluationResponse'>" + |
|---|
| 54 | "<input onchange='events.getEvaluation(" + this.id + ").recordText();'" + |
|---|
| 55 | " id='" + this.textID + "' type='text' value='" + this.text + "'" + |
|---|
| 56 | " class='evaluationResponseText' />" |
|---|
| 57 | + "</td>"; |
|---|
| 58 | */ |
|---|
| 59 | text += "</table>"; |
|---|
| 60 | /* Displays the ranking bubbles */ |
|---|
| 61 | text += "</td>" + |
|---|
| 62 | "<td class='evaluationScale'>" + this.evaluationForm() + "</td>" + |
|---|
| 63 | "</tr>"; |
|---|
| 64 | |
|---|
| 65 | text += "</table>"; |
|---|
| 66 | |
|---|
| 67 | |
|---|
| 68 | return text; |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | /** |
|---|
| 72 | * Stores the rating given by the evaluation scale radio button form. |
|---|
| 73 | */ |
|---|
| 74 | function recordRating(givenRating) |
|---|
| 75 | { |
|---|
| 76 | |
|---|
| 77 | this.rating = givenRating; |
|---|
| 78 | //console.log(this.ratingGroupName + " recordRating of " + this.rating ) |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | /** |
|---|
| 82 | * Stores the text in the written response text box. |
|---|
| 83 | */ |
|---|
| 84 | function recordText() |
|---|
| 85 | { |
|---|
| 86 | this.text = events.doc.getElementById(this.textID).value; |
|---|
| 87 | } |
|---|
| 88 | |
|---|
| 89 | /** |
|---|
| 90 | * @return The html for appropriate evaluation form for grading. |
|---|
| 91 | */ |
|---|
| 92 | function evaluationForm() |
|---|
| 93 | { |
|---|
| 94 | return this.smallScaleForm(); |
|---|
| 95 | } |
|---|
| 96 | |
|---|
| 97 | /** |
|---|
| 98 | * @return The html for a 1-5 grading scale. |
|---|
| 99 | */ |
|---|
| 100 | function smallScaleForm() |
|---|
| 101 | { |
|---|
| 102 | return "<form>" + |
|---|
| 103 | "<table align='right' class='evaluationScale'>" + |
|---|
| 104 | "<tr>" + |
|---|
| 105 | "<td class='eventRadioButtonSmallScale'>"+this.ratingQualities[5]+"</td>" + |
|---|
| 106 | "<td class='eventRadioButtonSmallScale'>"+this.ratingQualities[4]+"</td>" + |
|---|
| 107 | "<td class='eventRadioButtonSmallScale'>"+this.ratingQualities[3]+"</td>" + |
|---|
| 108 | "<td class='eventRadioButtonSmallScale'>"+this.ratingQualities[2]+"</td>" + |
|---|
| 109 | "<td class='eventRadioButtonSmallScale'>"+this.ratingQualities[1]+"</td>" + |
|---|
| 110 | "</tr>" + |
|---|
| 111 | "<tr>" + |
|---|
| 112 | "<td align='center'><input type='radio' " + |
|---|
| 113 | (this.rating == 5 ? "checked='true'" : "") + |
|---|
| 114 | " onchange='events.getEvaluation(" + this.id + |
|---|
| 115 | ").recordRating(5)' name='" + this.ratingGroupName + |
|---|
| 116 | "' value='1'></td>" + |
|---|
| 117 | "<td align='center'><input type='radio' " + |
|---|
| 118 | (this.rating == 4 ? "checked='true'" : "") + |
|---|
| 119 | " onchange='events.getEvaluation(" + this.id + |
|---|
| 120 | ").recordRating(4)' name='" + this.ratingGroupName + |
|---|
| 121 | "' value='2'></td>" + |
|---|
| 122 | "<td align='center'><input type='radio' " + |
|---|
| 123 | (this.rating == 3 ? "checked='true'" : "") + |
|---|
| 124 | " onchange='events.getEvaluation(" + this.id + |
|---|
| 125 | ").recordRating(3)' name='" + this.ratingGroupName + |
|---|
| 126 | "' value='3'></td>" + |
|---|
| 127 | "<td align='center'><input type='radio' " + |
|---|
| 128 | (this.rating == 2 ? "checked='true'" : "") + |
|---|
| 129 | " onchange='events.getEvaluation(" + this.id + |
|---|
| 130 | ").recordRating(2)' name='" + this.ratingGroupName + |
|---|
| 131 | "' value='4'></td>" + |
|---|
| 132 | "<td align='center'><input type='radio' " + |
|---|
| 133 | (this.rating == 1 ? "checked='true'" : "") + |
|---|
| 134 | " onchange='events.getEvaluation(" + this.id + |
|---|
| 135 | ").recordRating(1)' name='" + this.ratingGroupName + |
|---|
| 136 | "' value='5'></td>" + |
|---|
| 137 | "</tr>" + |
|---|
| 138 | "</table>" + |
|---|
| 139 | "</form>"; |
|---|
| 140 | } |
|---|
| 141 | } |
|---|