Browse Source

Arreglos y migrations

parent
commit
71ac151280

+ 15
- 5
app/controllers/ActivitiesController.php View File

204
             ->addSelect('activity_criterion.activity_id', 'activity_criterion.weight', 'activity_criterion.id as activity_criterion_id')
204
             ->addSelect('activity_criterion.activity_id', 'activity_criterion.weight', 'activity_criterion.id as activity_criterion_id')
205
             ->addSelect('rubric_criterion.rubric_id', 'rubric_criterion.id as rubric_criterion_id')
205
             ->addSelect('rubric_criterion.rubric_id', 'rubric_criterion.id as rubric_criterion_id')
206
             ->get();
206
             ->get();
207
+        Log::info("EN mi cuarto o o o");
207
         Log::info($rubric_criterion);
208
         Log::info($rubric_criterion);
208
         foreach ($rubric_criterion as $index => $singleCR) {
209
         foreach ($rubric_criterion as $index => $singleCR) {
209
             $singleCR->scales = json_encode(DB::table('scales')
210
             $singleCR->scales = json_encode(DB::table('scales')
232
         $scores_array = array();
233
         $scores_array = array();
233
 
234
 
234
         foreach ($assessments as $index => $assessment) {
235
         foreach ($assessments as $index => $assessment) {
235
-            $scores_array[$assessment->student_id][] = $assessment->score;
236
+            $scores_array[$assessment->student_id][$assessment->activity_criterion_id] = $assessment->score;
236
             $scores_array[$assessment->student_id]['comments'] = DB::table('activity_student')->where('student_id', '=', $assessment->student_id)
237
             $scores_array[$assessment->student_id]['comments'] = DB::table('activity_student')->where('student_id', '=', $assessment->student_id)
237
                 ->where("activity_id", '=', $activity->id)
238
                 ->where("activity_id", '=', $activity->id)
238
                 ->select('comments')->first()->comments;
239
                 ->select('comments')->first()->comments;
239
         }
240
         }
240
-
241
+        Log::info($assessments);
241
         Log::info($scores_array);
242
         Log::info($scores_array);
242
 
243
 
243
 
244
 
774
         // Get rubric contents
775
         // Get rubric contents
775
         $rubric = Rubric::find($activity->rubric[0]->id);
776
         $rubric = Rubric::find($activity->rubric[0]->id);
776
 
777
 
778
+
777
         $rubric->titles = DB::table('titles')
779
         $rubric->titles = DB::table('titles')
778
             ->join('rubric_title', 'rubric_title.title_id', '=', 'titles.id')
780
             ->join('rubric_title', 'rubric_title.title_id', '=', 'titles.id')
779
             ->where('rubric_id', $rubric->id)
781
             ->where('rubric_id', $rubric->id)
780
-            ->get();
781
-
782
+            ->orderBy("position", 'ASC')
783
+            ->lists('text');
782
         //$rubric_contents = Rubric::select('contents')->where('id', '=', $activity->rubric_id)->get();
784
         //$rubric_contents = Rubric::select('contents')->where('id', '=', $activity->rubric_id)->get();
783
         //$rubric_contents = json_decode($rubric_contents['0']->contents);
785
         //$rubric_contents = json_decode($rubric_contents['0']->contents);
784
 
786
 
792
             ->addSelect('activity_criterion.activity_id', 'activity_criterion.weight', 'activity_criterion.id as activity_criterion_id')
794
             ->addSelect('activity_criterion.activity_id', 'activity_criterion.weight', 'activity_criterion.id as activity_criterion_id')
793
             ->addSelect('rubric_criterion.rubric_id', 'rubric_criterion.id as rubric_criterion_id')
795
             ->addSelect('rubric_criterion.rubric_id', 'rubric_criterion.id as rubric_criterion_id')
794
             ->get();
796
             ->get();
797
+        Log::info("EN mi cuarto o o o");
798
+        Log::info($rubric_criterion);
795
 
799
 
796
         foreach ($rubric_criterion as $index => $crit) {
800
         foreach ($rubric_criterion as $index => $crit) {
797
             $crit->scales = DB::table('scales')
801
             $crit->scales = DB::table('scales')
815
         $scores_array = array();
819
         $scores_array = array();
816
 
820
 
817
         foreach ($assessments as $index => $assessment) {
821
         foreach ($assessments as $index => $assessment) {
818
-            $scores_array[$assessment->student_id][] = $assessment->score;
822
+            $scores_array[$assessment->student_id][$assessment->activity_criterion_id][] = $assessment->score;
819
             $scores_array[$assessment->student_id]['comments'] = DB::table('activity_student')->where('student_id', '=', $assessment->student_id)
823
             $scores_array[$assessment->student_id]['comments'] = DB::table('activity_student')->where('student_id', '=', $assessment->student_id)
820
                 ->where("activity_id", '=', $activity->id)
824
                 ->where("activity_id", '=', $activity->id)
821
                 ->select('comments')->first()->comments;
825
                 ->select('comments')->first()->comments;
853
             ->addSelect('activity_criterion.activity_id', 'activity_criterion.weight', 'activity_criterion.id as activity_criterion_id')
857
             ->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')
858
             ->addSelect('rubric_criterion.rubric_id', 'rubric_criterion.id as rubric_criterion_id')
855
             ->get();
859
             ->get();
860
+        $rubric->titles = DB::table('titles')
861
+            ->join('rubric_title', 'rubric_title.titles_id', '=', 'titles.id')
862
+            ->where('rubric_id', $rubric->id)
863
+            ->orderBy("position", 'ASC')
864
+            ->lists('text');
865
+
856
 
866
 
857
         foreach ($rubric_contents as $index => $crit) {
867
         foreach ($rubric_contents as $index => $crit) {
858
             $crit->scales = DB::table('scales')
868
             $crit->scales = DB::table('scales')

+ 1
- 0
app/controllers/RubricsController.php View File

443
 
443
 
444
     public function fetchRubricCriterion()
444
     public function fetchRubricCriterion()
445
     {
445
     {
446
+        Log::info(Input::all());
446
         $rubric = DB::table("criterion_scale")
447
         $rubric = DB::table("criterion_scale")
447
             ->join('scales', 'scales.id', '=', 'criterion_scale.scale_id')
448
             ->join('scales', 'scales.id', '=', 'criterion_scale.scale_id')
448
             ->where("criterion_id", '=', Input::get('criterion_id'))
449
             ->where("criterion_id", '=', Input::get('criterion_id'))

+ 25
- 1
app/controllers/TemplatesController.php View File

389
 	{
389
 	{
390
 		try {
390
 		try {
391
 			$template = Template::find($id);
391
 			$template = Template::find($id);
392
+			$template->titles = DB::table('titles')
393
+				->join('template_title', 'template_title.title_id', '=', 'titles.id')
394
+				->where("template_id", $template->id)
395
+				->orderBy('position', 'ASC')
396
+				->lists('text');
397
+			$template_criterion = DB::table('template_criterion')
398
+				->join('criteria', 'criteria.id', '=', 'template_criterion.criterion_id')
399
+				->where('template_id', $template->id)
400
+				->orderBy('position', 'ASC')
401
+				->get();
402
+
403
+			foreach ($template_criterion as $single_crit) {
404
+				$single_crit->scales = DB::table('criterion_scale')
405
+					->join('scales', 'criterion_scale.scale_id', '=', 'scales.id')
406
+					->where('criterion_id', $single_crit->id)
407
+					->orderBy('position')
408
+					->lists('description');
409
+				$single_crit->outcomes = DB::table('outcomes')
410
+					->join('criterion_objective_outcome', 'criterion_objective_outcome.outcome_id', '=', 'outcomes.id')
411
+					->where('criterion_id', $single_crit->id)
412
+					->select('name')
413
+					->distinct()
414
+					->lists('name');
415
+			}
392
 
416
 
393
 			$title = $template->name;
417
 			$title = $template->name;
394
 
418
 
402
 			else
426
 			else
403
 				$program = 'All Programs';
427
 				$program = 'All Programs';
404
 
428
 
405
-			return View::make('local.managers.shared.print_rubric', compact('title', 'template', 'school', 'program'));
429
+			return View::make('local.managers.shared.print_rubric', compact('title', 'template_criterion', 'template', 'school', 'program'));
406
 		} catch (Exception $e) {
430
 		} catch (Exception $e) {
407
 			Session::flash('status', 'danger');
431
 			Session::flash('status', 'danger');
408
 			Session::flash('message', $e->getMessage());
432
 			Session::flash('message', $e->getMessage());

+ 39
- 0
app/database/migrations/2021_08_27_142254_add_level_modality_gender_student.php View File

1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+use Illuminate\Support\Facades\Schema;
6
+
7
+class AddLevelModalityGenderStudent extends Migration
8
+{
9
+
10
+	/**
11
+	 * Run the migrations.
12
+	 *
13
+	 * @return void
14
+	 */
15
+	public function up()
16
+	{
17
+		Schema::table('students', function (Blueprint $table) {
18
+
19
+			$table->integer('level')->unsigned();
20
+			$table->char("modality", 1);
21
+			$table->char('gender', 4);
22
+		});
23
+	}
24
+
25
+	/**
26
+	 * Reverse the migrations.
27
+	 *
28
+	 * @return void
29
+	 */
30
+	public function down()
31
+	{
32
+		Schema::table('students', function (Blueprint $table) {
33
+
34
+			$table->dropColumn("level");
35
+			$table->dropColumn('modality');
36
+			$table->dropColumn('gender');
37
+		});
38
+	}
39
+}

+ 35
- 0
app/database/migrations/2021_08_27_142509_add_degree_to_programs.php View File

1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+use Illuminate\Support\Facades\Schema;
6
+
7
+class AddDegreeToPrograms extends Migration
8
+{
9
+
10
+	/**
11
+	 * Run the migrations.
12
+	 *
13
+	 * @return void
14
+	 */
15
+	public function up()
16
+	{
17
+		Schema::table('programs', function (Blueprint $table) {
18
+
19
+			$table->char('degree', 3);
20
+		});
21
+	}
22
+
23
+	/**
24
+	 * Reverse the migrations.
25
+	 *
26
+	 * @return void
27
+	 */
28
+	public function down()
29
+	{
30
+		Schema::table('programs', function (Blueprint $table) {
31
+
32
+			$table->dropColumn("degree");
33
+		});
34
+	}
35
+}

+ 33
- 0
app/database/migrations/2021_08_27_142937_add_modality_to_course.php View File

1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+use Illuminate\Support\Facades\Schema;
6
+
7
+class AddModalityToCourse extends Migration
8
+{
9
+
10
+	/**
11
+	 * Run the migrations.
12
+	 *
13
+	 * @return void
14
+	 */
15
+	public function up()
16
+	{
17
+		Schema::table('courses', function (Blueprint $table) {
18
+			$table->char('modality', 1);
19
+		});
20
+	}
21
+
22
+	/**
23
+	 * Reverse the migrations.
24
+	 *
25
+	 * @return void
26
+	 */
27
+	public function down()
28
+	{
29
+		Schema::table('courses', function (Blueprint $table) {
30
+			$table->dropColumn('modality');
31
+		});
32
+	}
33
+}

+ 18
- 12
app/views/local/managers/shared/print_rubric.blade.php View File

121
     <tr>
121
     <tr>
122
       <th></th>
122
       <th></th>
123
       <th>Criterion</th>
123
       <th>Criterion</th>
124
-      <th>Beginning (1-2)</th>
125
-      <th>In Progress (3-4)</th>
126
-      <th>Good (5-6)</th>
127
-      <th>Excellent (7-8)</th>
124
+      @foreach($template->titles as $i=>$title)
125
+      <th>{{$title}} ({{1+($i*($template->max_score/$template->num_scales))}}-{{(1+$i)*($template->max_score/$template->num_scales)}})</th>
126
+      @endforeach
128
       <th>Learning Outcome</th>
127
       <th>Learning Outcome</th>
129
       <th>Copyright</th>
128
       <th>Copyright</th>
130
       <th>Notes</th>
129
       <th>Notes</th>
131
     </tr>
130
     </tr>
132
   </thead>
131
   </thead>
133
   <tbody>
132
   <tbody>
134
-  @foreach(json_decode($template->contents) as $index => $criterion)
133
+  @foreach($template_criterion as $index => $criterion)
135
     <tr>
134
     <tr>
136
       <td>{{ $index + 1 }}.</td>
135
       <td>{{ $index + 1 }}.</td>
137
       <td>
136
       <td>
139
 
138
 
140
         @if(property_exists($criterion, 'subcriteria'))
139
         @if(property_exists($criterion, 'subcriteria'))
141
           <ul class="list-unstyled">
140
           <ul class="list-unstyled">
142
-            @foreach($criterion->subcriteria as $subcriterion)
141
+            @foreach(json_decode($criterion->subcriteria) as $subcriterion)
143
                 <li>{{ $subcriterion }}</li>
142
                 <li>{{ $subcriterion }}</li>
144
             @endforeach
143
             @endforeach
145
           </ol>
144
           </ol>
146
         @endif
145
         @endif
147
       </td>
146
       </td>
148
-      <td>{{{ $criterion->description12 }}}</td>
149
-      <td>{{{ $criterion->description34 }}}</td>
150
-      <td>{{{ $criterion->description56 }}}</td>
151
-      <td>{{{ $criterion->description78 }}}</td>
152
-      <td>{{{ Outcome::where('id', $criterion->outcome_id)->first()->name }}}</td>
147
+      @foreach($criterion->scales as $index=>$description)
148
+      <td>{{{ $description }}}</td>
149
+      @endforeach
150
+      
151
+      <td>
152
+        <ol>
153
+        @foreach($criterion->outcomes as $outcome)
154
+        <li>{{$outcome}}</li>
155
+
156
+        @endforeach
157
+        </ol>
158
+      </td>
153
       <td>
159
       <td>
154
       @if($criterion->copyright)
160
       @if($criterion->copyright)
155
         {{{ $criterion->copyright }}}
161
         {{{ $criterion->copyright }}}
166
 </table>
172
 </table>
167
 
173
 
168
 
174
 
169
-<?
175
+<?php
170
 
176
 
171
 echo '</body>';
177
 echo '</body>';
172
 echo '</html>';
178
 echo '</html>';

+ 24
- 16
app/views/local/managers/shared/rubrics.blade.php View File

316
     </div>
316
     </div>
317
 </div>
317
 </div>
318
 <script>
318
 <script>
319
-    // --------------------------------------------------------------------------
319
+  
320
+    </script>
321
+@stop
322
+
323
+@section('included-js')
324
+
325
+<!-- jQuery Sortable Tables -->
326
+<script src="{{ asset('vendor/jQuerySortable/jquery-sortable-min.js') }}"></script>
327
+
328
+<!-- X-Editable js -->
329
+<script src="{{ asset('vendor/xeditable/bootstrap-editable.min.js') }}"></script>
330
+
331
+@stop
332
+
333
+@section('javascript')
334
+// --------------------------------------------------------------------------
320
 // Functions
335
 // Functions
321
 // --------------------------------------------------------------------------
336
 // --------------------------------------------------------------------------
322
 
337
 
742
             $('#expected_percentage').val(data.template.expected_percentage);
757
             $('#expected_percentage').val(data.template.expected_percentage);
743
             
758
             
744
             $('#expected_points').val(data.template.expected_points);
759
             $('#expected_points').val(data.template.expected_points);
760
+            
745
             $('#number_of_scales').val(data.template.num_scales);
761
             $('#number_of_scales').val(data.template.num_scales);
746
             refreshSelects();
762
             refreshSelects();
747
             changeTable();
763
             changeTable();
913
         // Enable print button
929
         // Enable print button
914
         $('#button-print-rubric').prop('disabled', false);
930
         $('#button-print-rubric').prop('disabled', false);
915
 
931
 
932
+        fetchCriteria($('#select-outcome'), $('#select-objective'));
933
+
934
+
916
         }, 
935
         }, 
917
         'json',
936
         'json',
918
     );
937
     );
1118
 })
1137
 })
1119
 $('#number_of_scales').on('change', function(){
1138
 $('#number_of_scales').on('change', function(){
1120
     changeTable();
1139
     changeTable();
1140
+    $('#rubric-container').hide();
1141
+    $('#rubric-name').val('');
1142
+    $('tbody').empty();
1143
+
1121
 })
1144
 })
1122
 // When a learning outcome changes, update its criteria
1145
 // When a learning outcome changes, update its criteria
1123
 /*$('#select-outcome, input[name=criteria-filter]').on('change', function()
1146
 /*$('#select-outcome, input[name=criteria-filter]').on('change', function()
1311
 
1334
 
1312
 });
1335
 });
1313
 
1336
 
1314
-    </script>
1315
-@stop
1316
-
1317
-@section('included-js')
1318
-
1319
-<!-- jQuery Sortable Tables -->
1320
-<script src="{{ asset('vendor/jQuerySortable/jquery-sortable-min.js') }}"></script>
1321
-
1322
-<!-- X-Editable js -->
1323
-<script src="{{ asset('vendor/xeditable/bootstrap-editable.min.js') }}"></script>
1324
-
1325
-@stop
1326
-
1327
-@section('javascript')
1328
-
1329
 // --------------------------------------------------------------------------
1337
 // --------------------------------------------------------------------------
1330
 // Page load
1338
 // Page load
1331
 // --------------------------------------------------------------------------
1339
 // --------------------------------------------------------------------------

+ 3
- 5
app/views/local/professors/assessment.blade.php View File

144
                                 
144
                                 
145
                                 @for ($j=0; $j<=$rubric->max_score; $j++)
145
                                 @for ($j=0; $j<=$rubric->max_score; $j++)
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 the decoded scores with index as the assessment id and second index as criterion id equals the loop index, mark it as selected -->
147
-                                    <?php
148
-                                    Log::info($scores_array);
149
-                                    ?>
150
-                                    @if(array_key_exists($student->id, $scores_array) && $j ==  $scores_array[$student->id][$i])
147
+
148
+                                    @if(array_key_exists($student->id, $scores_array) && isset($scores_array[$student->id][$rubric_criterion[$i]->activity_criterion_id]) && $j ==  $scores_array[$student->id][$rubric_criterion[$i]->activity_criterion_id])
151
                                         <option value="{{$j}}" selected="selected">{{ $j }}</option>
149
                                         <option value="{{$j}}" selected="selected">{{ $j }}</option>
152
                                     @else
150
                                     @else
153
                                         <option value="{{$j}}">{{ $j }}</option>
151
                                         <option value="{{$j}}">{{ $j }}</option>
155
                                 @endfor
153
                                 @endfor
156
 
154
 
157
                                 <!-- N/A option -->
155
                                 <!-- N/A option -->
158
-                                @if( !array_key_exists($student->id, $scores_array)|| isset($scores_array[$student->id][$i]))
156
+                                @if( !array_key_exists($student->id, $scores_array)|| !isset($scores_array[$student->id][$rubric_criterion[$i]->activity_criterion_id]))
159
                                     <option value="N/A" selected="selected">N/A</option>
157
                                     <option value="N/A" selected="selected">N/A</option>
160
                                 @else
158
                                 @else
161
                                     <option value="N/A">N/A</option>
159
                                     <option value="N/A">N/A</option>

+ 5
- 5
app/views/local/professors/print_assessment.blade.php View File

131
             <!-- If the activity was assessed, load the assessment.-->
131
             <!-- If the activity was assessed, load the assessment.-->
132
             @if(sizeof($assessments)!=0)
132
             @if(sizeof($assessments)!=0)
133
                 <!-- For each assessment -->
133
                 <!-- For each assessment -->
134
-                @foreach ($assessments as $assessment)
134
+                @foreach ($students as $student)
135
                     <tr class="student-row">
135
                     <tr class="student-row">
136
                         <!-- Fetch student name -->
136
                         <!-- Fetch student name -->
137
-                        <td class="student-field" data-student-id="{{ $assessment->student_id }}">
138
-                            {{{ Student::find($assessment->student_id)->name }}}
137
+                        <td class="student-field" data-student-id="{{ $student->id }}">
138
+                            {{{ $student->name }}}
139
                         </td>
139
                         </td>
140
 
140
 
141
                         <!-- For each criterion in the rubric, there's a score field -->
141
                         <!-- For each criterion in the rubric, there's a score field -->
142
                         @for ($i = 0; $i<sizeof($rubric_contents); $i++)
142
                         @for ($i = 0; $i<sizeof($rubric_contents); $i++)
143
                             <td class="score-field">
143
                             <td class="score-field">
144
-                                @if(array_key_exists($assessment->student_id, $scores_array)&& isset($scores_array[$assessment->student_id][$i]))
145
-                                {{ $scores_array[$assessment->student_id][$i] }}
144
+                                @if(array_key_exists($student->id, $scores_array)&& isset($scores_array[$student->id][$i]))
145
+                                {{ $scores_array[$student->id][$i] }}
146
                                 @else
146
                                 @else
147
                                 N/A
147
                                 N/A
148
                                 @endif
148
                                 @endif

+ 15
- 14
app/views/local/professors/view_assessment.blade.php View File

24
             <div class="modal-body">
24
             <div class="modal-body">
25
                 <table class="table table-bordered">
25
                 <table class="table table-bordered">
26
                     <thead>
26
                     <thead>
27
-                        <th>Beginning (1-2)</th>
28
-                        <th>In Progress (3-4)</th>
29
-                        <th>Good (5-6)</th>
30
-                        <th>Excellent (7-8)</th>
27
+                        @foreach($rubric->titles as $i=>$title)
28
+                        <th>{{$title}} ({{1+($i*($rubric->max_score/$rubric->num_scales))}}-{{(1+$i)*($rubric->max_score/$rubric->num_scales)}})</th>
29
+                        @endforeach
30
+                        
31
                         <th>Notes</th>
31
                         <th>Notes</th>
32
                     </thead>
32
                     </thead>
33
                     <tbody>
33
                     <tbody>
297
 {
297
 {
298
     $.ajax({
298
     $.ajax({
299
         type: 'POST',
299
         type: 'POST',
300
-        url: "{{ URL::action('CriteriaController@fetchCriterionWithTrashed') }}",
301
-        data: { id: $(this).data('criterion-id') },
300
+        url: "{{ URL::action('RubricsController@fetchRubricCriterion') }}",
301
+        data: { criterion_id: $(this).data('criterion-id') },
302
         success: function(data)
302
         success: function(data)
303
         {
303
         {
304
-            $('.modal-title').html(data.name);
305
-
304
+            data = JSON.parse(data);
305
+            $('.modal-title').html(data.criteria.name);
306
+            descriptions = '';
306
             $('.modal-body tbody tr').empty();
307
             $('.modal-body tbody tr').empty();
308
+            for(i =0; i<{{$rubric->num_scales}}; i++){
309
+                descriptions += '<td>'+data[i].description+'</td>'
310
+            }
307
             $('.modal-body tbody tr').append
311
             $('.modal-body tbody tr').append
308
             (
312
             (
309
-                '<td>'+data.description12+'</td>'
310
-                +'<td>'+data.description34+'</td>'
311
-                +'<td>'+data.description56+'</td>'
312
-                +'<td>'+data.description78+'</td>'
313
+                descriptions
313
             );
314
             );
314
 
315
 
315
-            if(data.notes!=null)
316
-                $('.modal-body tbody tr').append('<td>'+data.notes+'</td>');
316
+            if(data.criteria.notes!=null)
317
+                $('.modal-body tbody tr').append('<td>'+data.criteria.notes+'</td>');
317
             else
318
             else
318
                 $('.modal-body tbody tr').append('<td></td>');
319
                 $('.modal-body tbody tr').append('<td></td>');
319
 
320