瀏覽代碼

Bugs de rubrics y assessments

父節點
當前提交
17238e53b3

+ 40
- 5
app/controllers/ActivitiesController.php 查看文件

@@ -283,7 +283,7 @@ class ActivitiesController extends \BaseController
283 283
                         }
284 284
                     }
285 285
                     $activity_draft = Input::get('draft');
286
-
286
+                    Log::info(json_encode($weights));
287 287
                     foreach ($weights as $act_crit => $weigh) {
288 288
                         DB::update("update activity_criterion set weight = {$weigh} where id = {$act_crit}");
289 289
                     }
@@ -843,20 +843,55 @@ class ActivitiesController extends \BaseController
843 843
         $students = $course->students;
844 844
 
845 845
         // Get rubric contents
846
-        $rubric_contents = Rubric::select('contents')->where('id', '=', $activity->rubric_id)->get();
847
-        $rubric_contents = json_decode($rubric_contents['0']->contents);
846
+        $rubric = Rubric::find($activity->rubric[0]->id);
847
+        $rubric_contents = DB::table('criteria')
848
+            ->join("rubric_criterion", "rubric_criterion.criterion_id", "=", "criteria.id")
849
+            ->join("activity_criterion", "criteria.id", '=', 'activity_criterion.criterion_id')
850
+            ->where("activity_criterion.activity_id", '=', $activity->id)
851
+            ->where('rubric_criterion.rubric_id', '=', $rubric->id)
852
+            ->select('criteria.name', 'criteria.id as criterion_id', 'criteria.subcriteria')
853
+            ->addSelect('activity_criterion.activity_id', 'activity_criterion.weight', 'activity_criterion.id as activity_criterion_id')
854
+            ->addSelect('rubric_criterion.rubric_id', 'rubric_criterion.id as rubric_criterion_id')
855
+            ->get();
856
+
857
+        foreach ($rubric_contents as $index => $crit) {
858
+            $crit->scales = DB::table('scales')
859
+                ->join('criterion_scale', 'scales.id', '=', 'criterion_scale.scale_id')
860
+                ->where('criterion_id', $crit->criterion_id)
861
+                ->get();
862
+        }
863
+
864
+
848 865
 
849
-        $rubric = Rubric::find($activity->rubric_id);
850 866
 
851 867
         // Get results
852
-        $assessments = DB::table('assessments')->where('activity_id', '=', $activity->id)->orderBy('id', 'asc')->get();
868
+        /*$assessments = DB::table('assessments')->where('activity_id', '=', $activity->id)->orderBy('id', 'asc')->get();
853 869
 
854 870
         // Decode the scores (blade workaround)
855 871
         $scores_array = array();
856 872
         foreach ($assessments as $index => $assessment) {
857 873
             $scores_array[$assessment->id] = json_decode($assessment->scores, true);
874
+        }*/
875
+        // Get results
876
+        $activity_criterion_ids = DB::table('activity_criterion')->where("activity_id", '=', $activity->id)->lists('id');
877
+        Log::info($activity_criterion_ids);
878
+        $assessments = DB::table('assessments')
879
+            ->join('students', 'assessments.student_id', '=', 'students.id')
880
+            ->whereIn('activity_criterion_id', $activity_criterion_ids)
881
+            ->orderBy('assessments.id', 'asc')->get();
882
+        Log::info($assessments);
883
+        // Decode the scores (blade workaround)
884
+        $scores_array = array();
885
+
886
+        foreach ($assessments as $index => $assessment) {
887
+
888
+            $scores_array[$assessment->student_id][] = $assessment->score;
889
+            $scores_array[$assessment->student_id]['comments'] = DB::table('activity_student')->where('student_id', '=', $assessment->student_id)
890
+                ->where("activity_id", '=', $activity->id)
891
+                ->select('comments')->first()->comments;
858 892
         }
859 893
 
894
+
860 895
         return View::make('local.professors.print_assessment', compact('activity', 'title', 'students', 'course', 'rubric_contents', 'assessments', 'scores_array', 'rubric'));
861 896
     }
862 897
 }

+ 7
- 1
app/controllers/OutcomesController.php 查看文件

@@ -806,7 +806,13 @@ class OutcomesController extends \BaseController
806 806
 
807 807
     public function professorAssessmentReports()
808 808
     {
809
-        $outcomes = Outcome::select(array('id', 'name', 'expected_outcome'))->orderBy('name', 'ASC')->get();
809
+        $semesters = Session::get('semesters_ids');
810
+        $semesters = DB::table('semesters')->whereIn('id', $semesters)->orderBy('start', 'ASC')->first();
811
+        Log::info($semesters->start);
812
+        $outcomes = Outcome::select(array('id', 'name', 'expected_outcome'))
813
+            ->where('deleted_at', '=', NULL)
814
+            ->whereRaw("(deactivation_date = NULL or deactivation_date >= '{$semesters->start}')")
815
+            ->orderBy('name', 'ASC')->get();
810 816
         $title = "My Courses' Assessment Reports";
811 817
 
812 818
         return View::make('local.professors.assessment_reports', compact('title', 'outcomes'));

+ 45
- 3
app/controllers/RubricsController.php 查看文件

@@ -380,8 +380,28 @@ class RubricsController extends \BaseController
380 380
             App::abort('403', 'Access Forbidden');
381 381
 
382 382
         $rubric = Rubric::where('id', '=', $activity->rubric_id)->firstOrFail();
383
+        $rubric_criterion = DB::table('criteria')
384
+            ->join('rubric_criterion', 'rubric_criterion.criterion_id', '=', 'criteria.id')
385
+            ->where('rubric_criterion.rubric_id', '=', $activity->rubric[0]->id)
386
+            ->get();
387
+        $rubric->titles = DB::table('titles')
388
+            ->join('rubric_title', 'rubric_title.title_id', '=', 'titles.id')
389
+            ->where('rubric_title.rubric_id', $rubric->id)
390
+            ->orderBy('position')
391
+            ->lists('text');
392
+
393
+        foreach ($rubric_criterion as $single_cr) {
394
+            $single_cr->scales = json_encode(DB::table('scales')
395
+                ->join('criterion_scale', 'criterion_scale.scale_id', '=', 'scales.id')
396
+                ->where('criterion_scale.criterion_id', '=', $single_cr->criterion_id)
397
+                ->orderBy('position')
398
+                ->lists('description'));
399
+            $single_cr->outcomes = json_encode(DB::table('outcomes')
400
+                ->join('criterion_objective_outcome', 'outcomes.id', '=', 'criterion_objective_outcome.outcome_id')
401
+                ->where('criterion_objective_outcome.criterion_id', '=', $single_cr->criterion_id)->lists('name'));
402
+        }
383 403
         $title = $activity->name . ': ' . $rubric->name;
384
-        return View::make('local.professors.downloadrubric', compact('rubric', 'activity', 'title', 'course'));
404
+        return View::make('local.professors.downloadrubric', compact('rubric', 'rubric_criterion', 'activity', 'title', 'course'));
385 405
     }
386 406
 
387 407
     public function printview($activity_id, $rubric_id)
@@ -394,9 +414,31 @@ class RubricsController extends \BaseController
394 414
         if ($course->user_id != Auth::id())
395 415
             App::abort('403', 'Access Forbidden');
396 416
 
397
-        $rubric = Rubric::where('id', '=', $activity->rubric_id)->firstOrFail();
417
+        $rubric = Rubric::where('id', '=', $activity->rubric[0]->id)->firstOrFail();
418
+        $rubric_criterion = DB::table('criteria')
419
+            ->join('rubric_criterion', 'rubric_criterion.criterion_id', '=', 'criteria.id')
420
+            ->where('rubric_criterion.rubric_id', '=', $activity->rubric[0]->id)
421
+            ->get();
422
+        $rubric->titles = DB::table('titles')
423
+            ->join('rubric_title', 'rubric_title.title_id', '=', 'titles.id')
424
+            ->where('rubric_title.rubric_id', $rubric->id)
425
+            ->orderBy('position')
426
+            ->lists('text');
427
+
428
+        foreach ($rubric_criterion as $single_cr) {
429
+            $single_cr->scales = json_encode(DB::table('scales')
430
+                ->join('criterion_scale', 'criterion_scale.scale_id', '=', 'scales.id')
431
+                ->where('criterion_scale.criterion_id', '=', $single_cr->criterion_id)
432
+                ->orderBy('position')
433
+                ->lists('description'));
434
+
435
+
436
+            $single_cr->outcomes = json_encode(DB::table('outcomes')
437
+                ->join('criterion_objective_outcome', 'outcomes.id', '=', 'criterion_objective_outcome.outcome_id')
438
+                ->where('criterion_objective_outcome.criterion_id', '=', $single_cr->criterion_id)->lists('name'));
439
+        }
398 440
         $title = $activity->name . ': ' . $rubric->name;
399
-        return View::make('local.professors.printrubric', compact('rubric', 'activity', 'title', 'course'));
441
+        return View::make('local.professors.printrubric', compact('rubric', 'rubric_criterion', 'activity', 'title', 'course'));
400 442
     }
401 443
 
402 444
     public function fetchRubricCriterion()

+ 12
- 0
app/models/Activity.php 查看文件

@@ -191,6 +191,18 @@ class Activity extends Eloquent
191 191
   }
192 192
 
193 193
   // o_att_array
194
+  public function is_assessed()
195
+  {
196
+    $all_criterion = DB::table('activity_criterion')
197
+      ->where('activity_criterion.activity_id', '=', $this->id)
198
+      ->lists('id');
199
+
200
+    $assessments = DB::table('assessments')
201
+      ->whereIn('activity_criterion_id', $all_criterion)
202
+      ->lists('id');
203
+
204
+    return boolval(count($assessments));
205
+  }
194 206
   public function getOAttArrayAttribute()
195 207
   {
196 208
 

+ 12
- 5
app/views/local/professors/activity.blade.php 查看文件

@@ -197,7 +197,7 @@
197 197
             <!-- If no rubric is assigned and the semester is active -->
198 198
             @if(count($activity->rubric) == 0 && in_array($course->semester->id, $active_semesters))
199 199
                 {{ HTML::linkAction('RubricsController@newRubric', 'Assign Rubric', array($activity->id), array('class'=>'btn btn-primary btn-sm btn-block')) }}
200
-                {{ HTML::linkAction('RubricsController@newOtherMethod', 'Assign Other Assessment Method', array($activity->id), array('class'=>'btn btn-primary btn-sm btn-block')) }}
200
+                <!--{{ HTML::linkAction('RubricsController@newOtherMethod', 'Assign Other Assessment Method', array($activity->id), array('class'=>'btn btn-primary btn-sm btn-block')) }}-->
201 201
             @else
202 202
 
203 203
                 {{ HTML::linkAction('RubricsController@show', 'View Rubric', array($activity->id), array('class'=>'btn btn-primary btn-sm btn-block')) }}
@@ -208,7 +208,7 @@
208 208
                 @endif
209 209
 
210 210
                 <!-- If there is no assessment and the semester is active -->
211
-                @if($activity->o_att_array == NULL && in_array($course->semester->id, $active_semesters))
211
+                @if(!$activity->is_assessed() && in_array($course->semester->id, $active_semesters))
212 212
                     {{ HTML::linkAction('ActivitiesController@assess', 'Assess', array($activity->id), array('class'=>'btn btn-primary btn-sm btn-block')) }}
213 213
                 @else
214 214
                     {{ HTML::linkAction('ActivitiesController@viewAssessment', 'View Assessment Sheet', array($activity->id), array('class'=>'btn btn-primary btn-sm btn-block')) }}
@@ -353,14 +353,21 @@ $(function () {
353 353
     $('#criteriaGraph').highcharts({
354 354
         chart: {
355 355
             type: 'bar',
356
-            height: {{{ count($activity->criteria_achieved() )*22+225 }}},
356
+            height: 
357
+            @if($activity->is_assessed())
358
+            
359
+                {{ count($activity->criteria_achieved() )*22+225 }}
360
+            @else
361
+                {{22+225}}
362
+            @endif
363
+            ,
357 364
         },
358 365
         title: {
359 366
             text: 'Criteria Achievement',
360 367
         },
361 368
         xAxis: {
362 369
             categories: [
363
-                @if($activity->cap_array!=NULL)
370
+                @if($activity->is_assessed())
364 371
                     @foreach($activity->criteria_achieved() as $id=>$value)
365 372
                         "{{{ Criterion::withTrashed()->find($id)->name }}}",
366 373
                     @endforeach
@@ -436,7 +443,7 @@ $(function () {
436 443
                 y:-1
437 444
             },
438 445
             data:[
439
-                @if($activity->cap_array!=NULL)
446
+                @if($activity->is_assessed())
440 447
                     @foreach($activity->cap_array as $id=>$crit)
441 448
 
442 449
                         //This conditional is to ignore criteria that weren't assessed. These would have a value of null.

+ 22
- 5
app/views/local/professors/assessment.blade.php 查看文件

@@ -141,9 +141,13 @@
141 141
                             <td class="score-field">
142 142
                                 <select name="" id="" class="form-control" data-toggle="tooltip" data-placement="right" title="{{{ $student->name }}}">
143 143
                                 <!-- Option from 0-8 -->
144
+                                
144 145
                                 @for ($j=0; $j<=$rubric->max_score; $j++)
145 146
                                     <!-- If the decoded scores with index as the assessment id and second index as criterion id equals the loop index, mark it as selected -->
146
-                                    @if( $j ==  $scores_array[$student->id][$i])
147
+                                    <?php
148
+                                    Log::info($scores_array);
149
+                                    ?>
150
+                                    @if(array_key_exists($student->id, $scores_array) && $j ==  $scores_array[$student->id][$i])
147 151
                                         <option value="{{$j}}" selected="selected">{{ $j }}</option>
148 152
                                     @else
149 153
                                         <option value="{{$j}}">{{ $j }}</option>
@@ -151,7 +155,7 @@
151 155
                                 @endfor
152 156
 
153 157
                                 <!-- N/A option -->
154
-                                @if( $scores_array[$student->id][$i]=="N/A")
158
+                                @if( !array_key_exists($student->id, $scores_array)|| isset($scores_array[$student->id][$i]))
155 159
                                     <option value="N/A" selected="selected">N/A</option>
156 160
                                 @else
157 161
                                     <option value="N/A">N/A</option>
@@ -162,7 +166,12 @@
162 166
                         <td class="percentage"></td>
163 167
                         <td class="percentage-per-weight"></td>
164 168
                         <td class="">
165
-                            <textarea class="comments full-textarea" placeholder="Max. 255 characters" maxLength="255" >{{ $scores_array[$student->id]["comments"] }}</textarea>
169
+                            <textarea class="comments full-textarea" placeholder="Max. 255 characters" maxLength="255" >
170
+                            
171
+                                @if(array_key_exists($student->id, $scores_array))
172
+                                {{ $scores_array[$student->id]["comments"] }}
173
+                                @endif
174
+                            </textarea>
166 175
                         </td>
167 176
                      </tr>
168 177
                 @endforeach
@@ -209,6 +218,7 @@
209 218
     </div>
210 219
 </div>
211 220
 <script>
221
+
212 222
 $('#button-submit-assessment, #button-draft-assessment').on('click', function(e)
213 223
 {
214 224
 
@@ -265,8 +275,9 @@ $('#button-submit-assessment, #button-draft-assessment').on('click', function(e)
265 275
 
266 276
             // Criterion being evaluated in current iteration
267 277
             activity_criterion_id = $('.criterion-field').eq(index2).data('activity-criterion-id');
268
-            student_info[index].activity_crit_id[activity_criterion_id] = scoreField.children('select').find(':selected').val();
269
-
278
+            score = scoreField.children('select').find(':selected').val();
279
+            if(score != "N/A")
280
+            student_info[index].activity_crit_id[activity_criterion_id] = score;
270 281
             // Score in the cell
271 282
             //var score = scoreField.children('select').find(':selected').val();
272 283
 
@@ -600,4 +611,10 @@ $('.criterion-field').on('click', function()
600 611
 });
601 612
 
602 613
 
614
+$(window).load(function(){
615
+    $(".tableFloatingHeader").each(function(){
616
+        $(this).remove();
617
+    })
618
+});
619
+
603 620
 @stop

+ 21
- 5
app/views/local/professors/print_assessment.blade.php 查看文件

@@ -118,10 +118,12 @@ echo
118 118
             <thead>
119 119
                     <tr>
120 120
                         <th>Student</th>
121
-                        @foreach ($rubric_contents as $criterion)
122
-                            <th class="criterion-field" data-criterion-id="{{{ $criterion->id }}}">{{ $criterion->name}}</th>
121
+                        @foreach ($rubric_contents as $index=>$criterion)
122
+                            <th class="criterion-field" data-criterion-id="{{{ $criterion->criterion_id }}}">{{ $criterion->name}}</th>
123
+                            <input type="hidden" id="weight-{{$index}}" val = "{{$criterion->weight}}">
123 124
                         @endforeach
124 125
                         <th>Student Percentage</th>
126
+                        <th>Student % per Weight<th>
125 127
                     </tr>
126 128
             </thead>
127 129
             <tbody>
@@ -139,10 +141,15 @@ echo
139 141
                         <!-- For each criterion in the rubric, there's a score field -->
140 142
                         @for ($i = 0; $i<sizeof($rubric_contents); $i++)
141 143
                             <td class="score-field">
142
-                                {{ $scores_array[$assessment->id][$rubric_contents[$i]->id] }}
144
+                                @if(array_key_exists($assessment->student_id, $scores_array)&& isset($scores_array[$assessment->student_id][$i]))
145
+                                {{ $scores_array[$assessment->student_id][$i] }}
146
+                                @else
147
+                                N/A
148
+                                @endif
143 149
                             </td>
144 150
                         @endfor
145
-                        <td class="percentage">{{{ $assessment->percentage }}}</td>
151
+                        <td class="percentage"></td>
152
+                        <td class="percentage-per-weight"></td>
146 153
                      </tr>
147 154
                 @endforeach
148 155
             @endif
@@ -239,6 +246,9 @@ echo '</html>';
239 246
         var sum = 0 ;
240 247
         var total = 0;
241 248
         var percentage = 0;
249
+        var max_score = {{$rubric->max_score}};
250
+        var per_of_weight =0;
251
+        var sum_of_weight =0;
242 252
 
243 253
         row.find('td.score-field').each(function(index)
244 254
         {
@@ -247,16 +257,22 @@ echo '</html>';
247 257
             {
248 258
                 sum += val;
249 259
                 total+=1;
260
+                per_of_weight += val * parseInt($('#weight-'+index).val()); 
261
+            sum_of_weight += parseInt($('#weight-'+index).val());
250 262
             }
251 263
         });
264
+        percentage_per_weight = (100 *(per_of_weight/(max_score*sum_of_weight))).toFixed(2);
252 265
 
253
-        percentage =((sum/(total*8))*100).toFixed(2);
266
+        percentage =((sum/(total*max_score))*100).toFixed(2);
254 267
 
255 268
         //If percentage is not a number, set it to 0.
256 269
         if(isNaN(percentage))
257 270
             percentage="0.00";
271
+        if(isNaN(percentage_per_weight))
272
+        percentage_per_weight ="0.00";
258 273
 
259 274
         row.find('.percentage').html('<strong>'+percentage+'%</strong>');
275
+        row.find('.percentage-per-weight').html('<strong>'+percentage+'%</strong>');
260 276
 
261 277
     }
262 278
   });

+ 22
- 13
app/views/local/professors/printrubric.blade.php 查看文件

@@ -118,17 +118,17 @@ echo '<style type="text/css" media="print">
118 118
     <tr>
119 119
       <th></th>
120 120
       <th>Criterion</th>
121
-      <th>Beginning (1-2)</th>
122
-      <th>In Progress (3-4)</th>
123
-      <th>Good (5-6)</th>
124
-      <th>Excellent (7-8)</th>
121
+      @foreach($rubric->titles as $position => $text)
122
+      <th>{{$text}} ({{1+ ($position*($rubric->max_score/$rubric->num_scales))}}-{{(1+$position)*($rubric->max_score/$rubric->num_scales)}})</th>
123
+      @endforeach
124
+     
125 125
       <th>Learning Outcome</th>
126 126
       <th>Copyright</th>
127 127
       <th>Notes</th>
128 128
     </tr>
129 129
   </thead>
130 130
   <tbody>
131
-  @foreach(json_decode($rubric->contents) as $index => $criterion)
131
+    @foreach($rubric_criterion as $index=> $criterion)
132 132
     <tr>
133 133
       <td>{{ $index + 1 }}.</td>
134 134
       <td>
@@ -136,17 +136,25 @@ echo '<style type="text/css" media="print">
136 136
 
137 137
         @if(property_exists($criterion, 'subcriteria'))
138 138
           <ul class="list-unstyled">
139
-            @foreach($criterion->subcriteria as $subcriterion)
139
+            @foreach(json_decode($criterion->subcriteria) as $subcriterion)
140 140
                 <li>{{ $subcriterion }}</li>
141 141
             @endforeach
142 142
           </ul>
143 143
         @endif
144 144
       </td>
145
-      <td>{{ nl2br($criterion->description12) }}</td>
146
-      <td>{{ nl2br($criterion->description34) }}</td>
147
-      <td>{{ nl2br($criterion->description56) }}</td>
148
-      <td>{{ nl2br($criterion->description78) }}</td>
149
-      <td>{{ Outcome::where('id', $criterion->outcome_id)->first()->name }}</td>
145
+      @foreach(json_decode($criterion->scales) as $index2 => $description)
146
+      <td>{{  nl2br($description) }}</td>
147
+      @endforeach
148
+      
149
+      <td>
150
+        <ol>
151
+        @foreach(json_decode($criterion->outcomes) as $outcome)
152
+        
153
+<li>{{$outcome}}</li>
154
+        
155
+        @endforeach
156
+      </ol>
157
+      </td>
150 158
       <td>
151 159
       @if($criterion->copyright)
152 160
         {{{ $criterion->copyright }}}
@@ -157,8 +165,9 @@ echo '<style type="text/css" media="print">
157 165
         {{{ $criterion->notes }}}
158 166
       @endif
159 167
       </td>
160
-    </tr>
161
-  @endforeach
168
+    </tr>     
169
+    @endforeach
170
+
162 171
   </tbody>
163 172
 </table>
164 173
 

+ 9
- 1
app/views/local/professors/view_assessment.blade.php 查看文件

@@ -99,14 +99,22 @@
99 99
                     <!-- For each criterion in the rubric, there's a score field -->
100 100
                     @for ($i = 0; $i<sizeof($rubric_criterion); $i++)
101 101
                         <td class="score-field text-center">
102
+                            @if(array_key_exists($student->id, $scores_array) && isset($scores_array[$student->id][$i]))
102 103
                             {{$scores_array[$student->id][$i]}}
104
+                            @else
105
+                            N/A
106
+                            @endif
103 107
                         </td>
104 108
                             
105 109
                     @endfor
106 110
                     <td class="percentage text-center"></td>
107 111
                     <td class="percentage-per-weight text-center"></td>
108 112
                     <td class="">
109
-                        <textarea class="comments full-textarea" placeholder="Max. 255 characters" maxLength="255" disabled >{{ $scores_array[$student->id]["comments"] }}</textarea>
113
+                        <textarea class="comments full-textarea" placeholder="Max. 255 characters" maxLength="255" disabled >
114
+                            @if(array_key_exists($student->id, $scores_array))
115
+                            {{ $scores_array[$student->id]["comments"] }}
116
+                            @endif
117
+                        </textarea>
110 118
                     </td>
111 119
                  </tr>
112 120
             @endforeach