Browse Source

arreglos sobre todo relacionados con rubricas, criterios y objetivos

parent
commit
ebe45e0ab4

+ 2
- 2
app/config/app.php View File

@@ -15,8 +15,8 @@ return array(
15 15
 
16 16
 	//'debug' => $_ENV['APP_DEBUG'] ?: false,
17 17
 
18
-	'debug' => true,
19
-	//'debug' => false,
18
+// 	'debug' => true,
19
+	'debug' => false,
20 20
 	/*
21 21
 	|--------------------------------------------------------------------------
22 22
 	| Application URL

+ 10
- 2
app/controllers/ActivitiesController.php View File

@@ -283,7 +283,8 @@ class ActivitiesController extends \BaseController
283 283
                     foreach ($student_data as $index => $student_dict) {
284 284
                         $student_id = $student_dict->studentId;
285 285
                         foreach ($student_dict->activity_crit_id as $act_crit_id => $score) {
286
-                            if (DB::table('assessments')->where('student_id', '=', $student_id)
286
+                     	 	  Log::info(json_encode($score));
287
+                          if (DB::table('assessments')->where('student_id', '=', $student_id)
287 288
                                 ->where('activity_criterion_id', '=', $act_crit_id)
288 289
                                 ->first()
289 290
                             ) {
@@ -291,7 +292,14 @@ class ActivitiesController extends \BaseController
291 292
                                     ->where('activity_criterion_id', '=', $act_crit_id)
292 293
                                     ->update(array('score' => $score));
293 294
                             } else {
294
-                                DB::insert("insert into assessments (`activity_criterion_id`, `student_id`, `score`) values ({$act_crit_id}, {$student_id}, {$score})");
295
+                            	if($score==null)
296
+                            	{
297
+	                                DB::insert("insert into assessments (`activity_criterion_id`, `student_id`) values ({$act_crit_id}, {$student_id})");
298
+    							}
299
+    							else
300
+    							{	
301
+    	                            DB::insert("insert into assessments (`activity_criterion_id`, `student_id`, `score`) values ({$act_crit_id}, {$student_id}, {$score})");
302
+                            	}
295 303
                             }
296 304
                         }
297 305
                         if (DB::table('activity_student')

+ 3
- 3
app/controllers/AuthController.php View File

@@ -28,9 +28,9 @@ class AuthController extends \BaseController
28 28
 
29 29
 		if (!$validator->fails()) {
30 30
 			//			TODO: Remove this for production environment
31
-			if (App::environment('local', 'staging')) {
32
-				return $this->processLogin();
33
-			}
31
+// 			if (App::environment('local', 'staging')) {
32
+// 				return $this->processLogin();
33
+// 			}
34 34
 			try {
35 35
 				// User input
36 36
 				$username = str_replace('@upr.edu', '', Input::get('email'));

+ 46
- 21
app/controllers/CoursesController.php View File

@@ -716,16 +716,22 @@ CoursesController extends \BaseController
716 716
             //             	->join('students', 'assessments.student_id', '=', 'students.id')
717 717
             //             	->where('activity_id', '=', $activity->id)->orderBy('assessments.id', 'asc')->get();
718 718
 
719
-            $assessments = DB::table('assessments')
720
-                ->join('students', 'assessments.student_id', '=', 'students.id')
721
-                ->join('activity_criterion', 'assessments.activity_criterion_id', '=', 'activity_criterion.id')
722
-                ->where('activity_criterion.activity_id', '=', $activity->id)->orderBy('assessments.id', 'asc')->get();
723
-
719
+//             $assessments = DB::table('assessments')
720
+//                 ->join('students', 'assessments.student_id', '=', 'students.id')
721
+//                 ->join('activity_criterion', 'assessments.activity_criterion_id', '=', 'activity_criterion.id')
722
+//                 ->where('activity_criterion.activity_id', '=', $activity->id)->orderBy('assessments.id', 'asc')->get();
723
+//             $assessments = DB::table('assessments')
724
+//                 ->join('students', 'assessments.student_id', '=', 'students.id')
725
+//                 ->join('activity_criterion', 'assessments.activity_criterion_id', '=', 'activity_criterion.id')
726
+//                 ->where('activity_criterion.activity_id', '=', $activity->id)->orderBy('assessments.id', 'asc')->get();
727
+// print json_encode($assessments);exit();
724 728
             // Get rubric contents
725
-            $rubric_contents = json_decode($activity->rubric->contents);
726
-
729
+//             $rubric_contents = json_decode($activity->rubric->contents);
730
+			$rubric_contents = $activity->allActivityCriterionInfo();
727 731
             $criterion_list = array('#', 'Name', 'School', 'Major');
728
-
732
+			$students=$activity->assessed_students();
733
+// print json_encode($students);exit();
734
+			
729 735
             // Set criterion names
730 736
             foreach ($rubric_contents as $criterion) {
731 737
                 $criterion_list[] = $criterion->name;
@@ -739,18 +745,37 @@ CoursesController extends \BaseController
739 745
             fputcsv($file, $criterion_list);
740 746
 
741 747
             // Set student info and scores for each criterion
742
-            foreach ($assessments as $assessment) {
743
-                $student = Student::find($assessment->student_id);
744
-                $scores = json_decode($assessment->scores, true);
745
-                fputcsv($file, array_merge(
746
-                    array($student->number, $student->name, $student->school_code, $student->conc_code),
748
+//             foreach ($assessments as $assessment) {
749
+//                 $student = Student::find($assessment->student_id);
750
+//                 $scores = json_decode($assessment->scores, true);
751
+//                 fputcsv($file, array_merge(
752
+//                     array($student->number, $student->name, $student->school_code, $student->conc_code),
753
+//                     $scores,
754
+//                     array($assessment->percentage, $assessment->comments)
755
+//                 ));
756
+//             }
757
+            foreach ($students as $student) {
758
+//                 $student = Student::find($assessment->student_id);
759
+//                 $scores = json_decode($assessment->scores, true);
760
+                $scores = $activity->student_scores($student->id);
761
+                $comm=$activity->student_comments($student->id);
762
+//                 print json_encode($activity->student_percentage($student->id));//exit();
763
+//                  var_dump($activity->student_percentage($student->id)[0]->percentage);//exit();
764
+				$resul= array_merge(
765
+                    array($student->id, $student->name, $student->school_code, $student->conc_code),
747 766
                     $scores,
748
-                    array($assessment->percentage, $assessment->comments)
749
-                ));
767
+                    array($activity->student_percentage($student->id))
768
+                    ,
769
+                    array($activity->student_comments($student->id)->comments)
770
+                );
771
+//                     print json_encode($resul);//exit();
772
+//                      var_dump($resul);//exit();
773
+            
774
+                fputcsv($file,$resul);
750 775
             }
751 776
             fputcsv($file, $empty_line);
752 777
         }
753
-
778
+// exit();
754 779
         // Table with all activities and grades
755 780
 
756 781
         // Set headers for table
@@ -775,12 +800,12 @@ CoursesController extends \BaseController
775 800
             $assessed_activities = $course->assessedActivities;
776 801
             // Iterate over activities, get percentages and add them to the record array
777 802
             foreach ($assessed_activities as $activity) {
778
-                $percentage = DB::table('assessments')
779
-                    ->select('percentage')
780
-                    ->where('student_id', '=', $student->id)
781
-                    ->where('activity_id', '=', $activity->id)->first();
803
+//                 $percentage = DB::table('assessments')
804
+//                     ->select('percentage')
805
+//                     ->where('student_id', '=', $student->id)
806
+//                     ->where('activity_id', '=', $activity->id)->first();
782 807
 
783
-                $student_record[] = $percentage->percentage;
808
+                $student_record[] = $activity->student_percentage($student->id);
784 809
             }
785 810
 
786 811
             // Average

+ 13
- 10
app/controllers/CriteriaController.php View File

@@ -888,12 +888,12 @@ class CriteriaController extends \BaseController
888 888
             $parentesis = array('(', ')');
889 889
             if ($criterion->save()) {
890 890
                 $criterionId = $criterion->id;
891
-                DB::table('criterion_objective_outcome as cobo')
892
-                    ->join('program_criterion_objective_outcome as poco', 'poco.cri_obj_out_id', '=', 'cobo.id')
893
-                    ->where('cobo.criterion_id', $criterionId)
891
+                DB::table('criterion_objective_outcome')
892
+                    ->join('program_criterion_objective_outcome', 'program_criterion_objective_outcome.cri_obj_out_id', '=', 'criterion_objective_outcome.id')
893
+                    ->where('criterion_objective_outcome.criterion_id', $criterionId)
894 894
                     ->delete();
895 895
                 // DB::delete("delete from `criterion_objective_outcome` where `criterion_id` ={$criterionId}");
896
-                DB::delete("delete from `program_criterion` where `criterion_id` ={$criterionId}");
896
+//                 DB::delete("delete from `program_criterion` where `criterion_id` ={$criterionId}");
897 897
 
898 898
                 foreach ($clean_input['objective_id'] as $objective_id) {
899 899
 
@@ -1202,7 +1202,7 @@ class CriteriaController extends \BaseController
1202 1202
     {
1203 1203
 
1204 1204
         $role = Auth::user()->role;
1205
-
1205
+// Log::info("fdsdff".json_encode($role));
1206 1206
         $criterion_id = Input::get('criterion_id');
1207 1207
 
1208 1208
         switch ($role) {
@@ -1212,20 +1212,23 @@ class CriteriaController extends \BaseController
1212 1212
             case 2:
1213 1213
                 $program_ids = Program::where("school_id", Auth::user()->school_id)->lists('id');
1214 1214
                 break;
1215
-
1216 1215
             case 3:
1216
+                $program_ids = Auth::user()->programs->lists('id');
1217
+                break;
1217 1218
             case 4:
1218 1219
                 $program_ids = Program::whereIn('id', Auth::user()->programs->lists('id'));
1219 1220
                 break;
1220 1221
         }
1221
-        $outcomes_paired_ids = DB::table('criterion_objective_outcome as cobo')
1222
-            ->join('program_criterion_objective_outcome as poco', 'poco.cri_obj_out_id', '=', 'cobo.id')
1222
+
1223
+       $outcomes_paired_ids = DB::table('criterion_objective_outcome')
1224
+            ->join('program_criterion_objective_outcome', 'program_criterion_objective_outcome.cri_obj_out_id', '=', 'criterion_objective_outcome.id')
1223 1225
             ->whereIn("program_id", $program_ids)
1224 1226
             ->where('criterion_id', $criterion_id)
1225
-            ->select('cobo.outcome_id')
1227
+            ->select('criterion_objective_outcome.outcome_id')
1226 1228
             ->distinct()
1227
-            ->lists('cobo.outcome_id');
1229
+            ->lists('criterion_objective_outcome.outcome_id');
1228 1230
 
1231
+// Log::info($outcomes_paired_ids);
1229 1232
 
1230 1233
         $json = [];
1231 1234
         $json['outcomes'] = $outcomes_paired_ids;

+ 6
- 4
app/controllers/TemplatesController.php View File

@@ -172,7 +172,7 @@ class TemplatesController extends \BaseController
172 172
 				break;
173 173
 		}
174 174
 
175
-
175
+Log::info(json_encode($user->programs->lists('id')));
176 176
 		return View::make('local.managers.admins.view_template', compact('template', 'title', 'can_edit'));
177 177
 	}
178 178
 
@@ -304,7 +304,7 @@ class TemplatesController extends \BaseController
304 304
 				->lists('criteria.id');
305 305
 		}
306 306
 		// 			Log::info("aqui".(count($criteria)));
307
-					Log::info(json_encode(($criteria)));
307
+// 					Log::info(json_encode(($criteria)));
308 308
 
309 309
 
310 310
 
@@ -402,7 +402,7 @@ class TemplatesController extends \BaseController
402 402
 					->where('school_id', $template->school_id)->lists('programs.id');
403 403
 			} else {
404 404
 				$program_ids = DB::table('programs')
405
-					->where('program_id', $template->program_id)->lists('programs.id');
405
+					->where('id', $template->program_id)->lists('programs.id');
406 406
 			}
407 407
 		} else {
408 408
 			$role = Auth::user()->role;
@@ -510,6 +510,7 @@ class TemplatesController extends \BaseController
510 510
 
511 511
 		$template->num_scales = count($titles);
512 512
 		$template->max_score = $max_score;
513
+		$template->user_id = Auth::user()->id;
513 514
 
514 515
 		if ($template->save()) {
515 516
 
@@ -585,7 +586,8 @@ class TemplatesController extends \BaseController
585 586
 			->join('template_criterion', 'template_criterion.criterion_id', '=', 'criteria.id')
586 587
 			->where("template_criterion.template_id", '=', Input::get('id'))
587 588
 			->get();
588
-		Log::info(json_encode($template_info['criterion']));
589
+		Log::info(json_encode($template_info['template']));
590
+		//Log::info(json_encode($template_info['criterion']));
589 591
 		// 				Log::info(($temp_crit->program_ids));
590 592
 		foreach ($template_info['criterion'] as $temp_crit) {
591 593
 			$temp_crit->scales = DB::table('scales')

+ 72
- 1
app/models/Activity.php View File

@@ -19,10 +19,80 @@ class Activity extends Eloquent
19 19
     return $this->belongsTo('Course');
20 20
   }
21 21
 
22
+//   public function assessed_students()
23
+//   {
24
+//     return $this->belongsToMany('Student', 'assessments')->withPivot('scores', 'percentage')->withTimestamps();
25
+//   }
22 26
   public function assessed_students()
23 27
   {
24
-    return $this->belongsToMany('Student', 'assessments')->withPivot('scores', 'percentage')->withTimestamps();
28
+    return  DB::table('students')
29
+    	-> join('assessments','assessments.student_id','=','students.id')    
30
+    	-> join('activity_criterion','assessments.activity_criterion_id','=','activity_criterion.id')
31
+      ->where('activity_criterion.activity_id', '=', $this->id)
32
+      ->select('students.*')
33
+      ->distinct()
34
+      ->get();;
35
+  }
36
+  
37
+  public function student_scores($student_id)
38
+  {
39
+//       $assessments=DB::table('activity_criterion')
40
+//     	-> leftJoin('assessments','assessments.activity_criterion_id','=','activity_criterion.id')
41
+//       ->where('activity_criterion.activity_id', '=', $this->id)
42
+//       ->where('assessments.student_id', '=', $student_id)
43
+//       ->select('activity_criterion.id','score')
44
+//       ->orderBy('criterion_ids')
45
+//       ->get();
46
+//       $assessments=DB::table('assessments')
47
+//     	-> join('activity_criterion','assessments.activity_criterion_id','=','activity_criterion.id')
48
+//       ->where('activity_criterion.activity_id', '=', $this->id)
49
+//       ->where('assessments.student_id', '=', $student_id)
50
+//       ->select('activity_criterion.id','score')
51
+//       ->orderBy('criterion_id')
52
+//       ->get();
53
+    $activity_id=$this->id;
54
+    $assessments=DB::select(DB::raw("select id,  COALESCE(score,0) score from 
55
+    	(select activity_criterion_id, score from`assessments` where student_id= $student_id) a right OUTER join 
56
+    	(select id from `activity_criterion` where `activity_criterion`.`activity_id` = $activity_id) b on a.activity_criterion_id = b.id"));
57
+  
58
+    
59
+    $scores=array();
60
+    foreach($assessments as $assess)
61
+    {
62
+    	$scores[$assess->id]=$assess->score;
63
+    }
64
+    return  $scores;
65
+  }
66
+  
67
+  public function student_comments($student_id)
68
+  {
69
+      $comments=DB::table('activity_student')
70
+      ->where('activity_id', '=', $this->id)
71
+      ->where('student_id', '=', $student_id)
72
+      ->select('comments')
73
+      ->first();
74
+    
75
+    return  $comments;
76
+  }
77
+  
78
+   public function student_percentage($student_id)
79
+  {
80
+ //      $scores=DB::table('assessments')
81
+//     	-> join('activity_criterion','assessments.activity_criterion_id','=','activity_criterion.id')
82
+//       ->where('activity_criterion.activity_id', '=', $this->id)
83
+//       ->where('assessments.student_id', '=', $student_id)
84
+//       ->select('criterion_id','score')
85
+//       ->get();
86
+      //rubrics->expected_points
87
+    $activity_id=$this->id;
88
+ $percentage=DB::select(DB::raw("select COALESCE(ROUND(100*sum(score*weight)/sum(max_score*weight),2),0) percentage from (select activity_criterion_id, score from`assessments` where
89
+  student_id= $student_id) a right OUTER join 
90
+  (select id, weight, activity_id from `activity_criterion` where `activity_criterion`.`activity_id` = $activity_id) b on a.activity_criterion_id = b.id join 
91
+  rubric_activity on rubric_activity.activity_id=b.activity_id join rubrics on rubrics.id=rubric_activity.rubric_id"));
92
+    
93
+    return $percentage[0]->percentage;
25 94
   }
95
+ 
26 96
   public function amount_of_assessed_students()
27 97
   {
28 98
 
@@ -137,6 +207,7 @@ class Activity extends Eloquent
137 207
       ->where('activity_id', $this->id)
138 208
       ->select('activity_criterion.activity_id', 'activity_criterion.criterion_id', 'criteria.*')
139 209
       ->distinct()
210
+      ->orderBy('criteria.id')
140 211
       ->get();
141 212
 
142 213
 

+ 5
- 1
app/models/User.php View File

@@ -82,6 +82,10 @@ class User extends Eloquent implements UserInterface, RemindableInterface
82 82
 	// return the programs the user is a pcoord of
83 83
 	public function programs()
84 84
 	{
85
-		return $this->belongsToMany('Program')->select('programs.id', 'programs.name', 'programs.school_id', 'programs.is_graduate');
85
+// 		return $this->hasManyThrough('Program','Program_user')->select('programs.id', 'programs.name', 'programs.school_id', 'programs.is_graduate');
86
+// 		$sal= $this->belongsToMany('Program')->select('programs.id', 'programs.name', 'programs.school_id', 'programs.is_graduate');
87
+		$sal= $this->belongsToMany('Program')->select('programs.id', 'programs.name', 'programs.school_id', 'programs.is_graduate');
88
+		Log::info(json_encode($sal));
89
+		return $sal;
86 90
 	}
87 91
 }

+ 44
- 38
app/views/local/managers/shared/rubrics_new.blade.php View File

@@ -524,7 +524,7 @@
524 524
             annual_plan_id:$(select).val()
525 525
         },
526 526
         function(semesters){
527
-            console.log(semesters);
527
+            //console.log(semesters);
528 528
 
529 529
             options_for_semesters = makeOptionsForSemesters(semesters);
530 530
             $("#select-semester-plans").html(options_for_semesters);
@@ -552,7 +552,7 @@
552 552
                 semester_id:$(semesters).val()
553 553
             },
554 554
             function(courses){
555
-                console.log(courses);
555
+                //console.log(courses);
556 556
                 options = makeOptionsForCourses(courses);
557 557
                 $("#select-courses-plans").html(options);
558 558
                 $('.selectpicker').selectpicker('refresh');
@@ -582,7 +582,7 @@
582 582
                 number_of_scales:$(number_of_scales).val()
583 583
             },
584 584
             function(criteria){
585
-                console.log(criteria);
585
+                //console.log(criteria);
586 586
                 options_criteria = makeOptionsForCriteria(criteria)
587 587
                 
588 588
                 $('#select-criteria-plans').html(options);
@@ -666,7 +666,7 @@
666 666
             annual_plan_id:annual_plan_id
667 667
         },
668 668
         function(outcomes){
669
-            console.log(outcomes);
669
+            //console.log(outcomes);
670 670
 
671 671
             options_for_select = makeOptionsForOutcomes(outcomes);
672 672
             $("#select-outcomes-plans").html(options_for_select);
@@ -679,11 +679,11 @@
679 679
 
680 680
 
681 681
 function fetchObjectives(select_outcome){
682
-    console.log($(select_outcome).find('option:selected').html())
682
+    //console.log($(select_outcome).find('option:selected').html())
683 683
     option_selected = $(select_outcome).find('option:selected');
684
-    console.log($(select_outcome).find('option:selected').data('objectives'))
685
-    console.log($(select_outcome).val())
686
-    console.log(option_selected.val())
684
+    //console.log($(select_outcome).find('option:selected').data('objectives'))
685
+    //console.log($(select_outcome).val())
686
+    //console.log(option_selected.val())
687 687
     $.post(
688 688
         "{{URL::action('AnnualPlansController@fetchObjectivesFromPlan')}}",
689 689
         {
@@ -700,7 +700,7 @@ function fetchObjectives(select_outcome){
700 700
     }
701 701
 
702 702
     function makeOptionsForObjectives(objectives){
703
-        console.log(objectives);
703
+        //console.log(objectives);
704 704
 
705 705
         option_selected = '';
706 706
         
@@ -787,8 +787,8 @@ function saveTemplate(){
787 787
     }
788 788
     else
789 789
     {
790
-        console.log('school', $('#select-school').find(':selected').data('school-id') );
791
-        console.log('program', $('#select-program').find(':selected').data('program-id') );
790
+        //console.log('school', $('#select-school').find(':selected').data('school-id') );
791
+        //console.log('program', $('#select-program').find(':selected').data('program-id') );
792 792
 
793 793
         // Update database
794 794
         $.post
@@ -911,7 +911,7 @@ function addCriterion(select)
911 911
         
912 912
 
913 913
             str +='<th><span class="glyphicon glyphicon-remove icon-btn" aria-hidden="true"></span></th></tr>';
914
-	console.log(str);
914
+	//console.log(str);
915 915
 
916 916
             $('table tbody').append(str);
917 917
 
@@ -962,7 +962,7 @@ function buildCopyrightList()
962 962
 
963 963
                         copyrightNumber = Number.parseInt($(this).find('sup').text());
964 964
 
965
-                        console.log('a: '+copyrightNumber);
965
+                        //console.log('a: '+copyrightNumber);
966 966
 
967 967
                         criterion.children('td:nth-child(2)').find('sup').text(copyrightNumber);
968 968
                         found =true;
@@ -978,8 +978,8 @@ function buildCopyrightList()
978 978
                 {
979 979
                     var copyrightNumber = $('#copyright-list li').length+1;
980 980
 
981
-                    console.log('b: '+copyrightNumber);
982
-                    console.log(criterion.children('td:nth-child(2)').find('sup').length);
981
+                    //console.log('b: '+copyrightNumber);
982
+                    //console.log(criterion.children('td:nth-child(2)').find('sup').length);
983 983
 
984 984
                     criterion.children('td:nth-child(2)').find('sup').text(copyrightNumber);
985 985
                     $('#copyright-list').append('<li><sup>'+copyrightNumber+' </sup><span>'+copyright+'<span></li>');
@@ -1058,7 +1058,7 @@ function fetchCriteria(outcome, objective)
1058 1058
         function(data)
1059 1059
         {
1060 1060
             $('#select-criterion').empty();
1061
-		console.log(data);
1061
+		//console.log(data);
1062 1062
             // Append criteria
1063 1063
             data.forEach( function (arrayItem)
1064 1064
             {
@@ -1137,7 +1137,7 @@ function fetchCriterion(criterion)
1137 1137
 
1138 1138
                         copyrightNumber = Number.parseInt($(this).find('sup').text());
1139 1139
 
1140
-                        console.log('a: '+copyrightNumber);
1140
+                        //console.log('a: '+copyrightNumber);
1141 1141
 
1142 1142
                         criterion.children('td:nth-child(2)').find('sup').text(copyrightNumber);
1143 1143
                         found =true;
@@ -1153,8 +1153,8 @@ function fetchCriterion(criterion)
1153 1153
                 {
1154 1154
                     var copyrightNumber = $('#copyright-list li').length+1;
1155 1155
 
1156
-                    console.log('b: '+copyrightNumber);
1157
-                    console.log(criterion.children('td:nth-child(2)').find('sup').length);
1156
+                    //console.log('b: '+copyrightNumber);
1157
+                    //console.log(criterion.children('td:nth-child(2)').find('sup').length);
1158 1158
 
1159 1159
                     criterion.children('td:nth-child(2)').find('sup').text(copyrightNumber);
1160 1160
                     $('#copyright-list').append('<li><sup>'+copyrightNumber+' </sup><span>'+copyright+'<span></li>');
@@ -1195,6 +1195,7 @@ function refreshSelects()
1195 1195
 // Fetch programs associated to a specific school
1196 1196
 function fetchPrograms(school)
1197 1197
 {
1198
+	//console.log(school.find(':selected'));
1198 1199
     $.ajax({
1199 1200
         type: 'POST',
1200 1201
         url: "{{ URL::action('ProgramsController@fetch') }}",
@@ -1238,25 +1239,27 @@ function loadTemplate()
1238 1239
             //Set the name of the rubric
1239 1240
             $('#rubric-name').val(data.template.name);
1240 1241
 
1241
-console.log(data.template.school_id);
1242
-console.log($('#select-school'));
1242
+//console.log($('#select-school'));
1243 1243
             // Set school id to 0, then to the saved value if it exists
1244 1244
             $('#select-school option[data-school-id="0"]').prop('selected', true);
1245 1245
             $('#select-school option[data-school-id="'+data.template.school_id+'"]').prop('selected', true);
1246
-console.log($('#select-school'));
1246
+console.log("name"+data.template.name);
1247
+console.log("school"+data.template.school_id);
1248
+console.log("name"+data.template.name);
1247 1249
 
1248 1250
             // Fetch programs associated to that school
1249 1251
             fetchPrograms($('#select-school'));
1252
+           // fetchPrograms(data.template.school_id);
1250 1253
 
1251 1254
             // Set program id to 0, then to the saved value if it exists
1252 1255
             $('#select-program option[data-program-id="0"]').prop('selected', true);
1253 1256
             $('#select-program option[data-program-id="'+data.template.program_id+'"]').prop('selected', true);
1254 1257
 
1255 1258
             // Set expected values
1256
-            console.log(data.template.expected_percentage);
1259
+         //   console.log(data.template.expected_percentage);
1257 1260
 
1258
-            console.log(data.template.expected_points);
1259
-            console.log(data.template.max_score);
1261
+      //      console.log(data.template.expected_points);
1262
+        //    console.log(data.template.max_score);
1260 1263
         
1261 1264
         $('#max_score').val(data.template.max_score);
1262 1265
           
@@ -1271,28 +1274,30 @@ console.log($('#select-school'));
1271 1274
             changeTable();
1272 1275
             // Set visibility
1273 1276
             var is_visible = data.template.is_visible;
1274
-            if(is_visible)
1277
+            console.log("is_visible",is_visible);
1278
+            if(is_visible==1)
1275 1279
             {
1280
+            	console.log("entro?")
1276 1281
                 $('#is_visible0').prop('checked', false);
1277 1282
                 $('#is_visible1').prop('checked', true);
1278 1283
             }
1279 1284
             else
1280 1285
             {
1281
-                $('#is_visible1').prop('checked', false);
1282 1286
                 $('#is_visible0').prop('checked', true);
1287
+                $('#is_visible1').prop('checked', false);
1283 1288
             }
1284 1289
 
1285 1290
 
1286 1291
             // Set the contents of the rubric
1287 1292
             var temp_criterion = data.criterion;
1288
-               console.log(temp_criterion);
1293
+       //        console.log(temp_criterion);
1289 1294
             for(temp_c in temp_criterion){
1290 1295
                 current_criterion = temp_criterion[temp_c]
1291
-               console.log(current_criterion.program_ids);
1296
+       //        console.log(current_criterion.program_ids);
1292 1297
                 objectives = JSON.stringify(current_criterion.objectives);
1293 1298
                 //var str = '<tr data-assoc-objectives= '+"'"+objectives+"'"+' data-program_ids = "'+current_criterion.program_ids+'" data-criterion-name = "'+current_criterion.name+'" data-criterion-id="'+temp_criterion[temp_c].criterion_id+'" data-criterion-copyright="'+temp_criterion[temp_c].copyright+'" data-criterion-notes="'+temp_criterion[temp_c].notes+'" data-outcomes = "'+temp_criterion[temp_c].outcomes+'"><th><span class="glyphicon glyphicon-move"></span></th><td>';
1294 1299
                 var str = "<tr  data-program_ids = '"+current_criterion.program_ids+"' data-criterion-name = '"+current_criterion.name+"' data-criterion-id='"+temp_criterion[temp_c].criterion_id+"' data-criterion-copyright='"+temp_criterion[temp_c].copyright+"' data-criterion-notes='"+temp_criterion[temp_c].notes+"' data-outcomes = '"+temp_criterion[temp_c].outcomes+"'><th><span class='glyphicon glyphicon-move'></span></th><td>";
1295
-                console.log(str);
1300
+           //     console.log(str);
1296 1301
 
1297 1302
                 var subcriteria ='';
1298 1303
                 if(current_criterion.subcriteria){
@@ -1323,7 +1328,7 @@ console.log($('#select-school'));
1323 1328
                 str+= '<td>'+current_criterion.outcomes+'</td>'
1324 1329
   
1325 1330
                 str+='<th><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></th></tr>';
1326
-                console.log(str);
1331
+           //     console.log(str);
1327 1332
 
1328 1333
     $('table tbody').append(str);
1329 1334
 
@@ -1421,14 +1426,13 @@ console.log($('#select-school'));
1421 1426
         
1422 1427
             var template_program = selected.data('template-program-id');
1423 1428
          //   console.log(selected.data('template-program-id'));
1424
-          //  console.log(programs.includes(selected.data('template-program-id').toString()));
1429
+            console.log("**"+programs.indexOf(selected.data('template-program-id').toString()));
1425 1430
         
1426 1431
         if(
1427 1432
             {{ Auth::user()->role }}==1
1428 1433
             || ({{ Auth::user()->role }}==2 && selected.data('admin')!=1)
1429 1434
             || ({{ Auth::user()->role }}==3
1430
-                && programs.includes(selected.data('template-program-id'))
1431
-
1435
+                && programs.indexOf(selected.data('template-program-id'))
1432 1436
                 && selected.data('admin')!=1
1433 1437
             )
1434 1438
         )
@@ -1543,7 +1547,6 @@ $('#select-template').on('change', function()
1543 1547
         $('#button-confirm-update-rubric').prop('disabled', true);
1544 1548
         $('#button-print-rubric').prop('disabled', true);
1545 1549
     }
1546
-
1547 1550
     // Otherwise, load the selected template
1548 1551
     else
1549 1552
     {
@@ -1556,13 +1559,16 @@ $('#select-template').on('change', function()
1556 1559
         
1557 1560
         var template_program = selected.data('template-program-id');
1558 1561
 <!--         var dataset = selected.dataSet.templateProgramId; -->
1562
+//            console.log("***"+({{ Auth::user()->role }}==3
1563
+  //              && programs.indexOf(selected.data('template-program-id'))
1564
+    //            && selected.data('admin')!=1
1565
+      //      )+programs+template_program+{{ json_encode(Auth::user()->programs->lists('id')) }});
1559 1566
 
1560 1567
         if(
1561 1568
             {{ Auth::user()->role }}==1
1562 1569
             || ({{ Auth::user()->role }}==2 && selected.data('admin')!=1)
1563 1570
             || ({{ Auth::user()->role }}==3
1564
-                && programs.includes(selected.data('template-program-id'))
1565
-
1571
+                && programs.indexOf(selected.data('template-program-id'))
1566 1572
                 && selected.data('admin')!=1
1567 1573
             )
1568 1574
         )
@@ -1798,7 +1804,7 @@ $('.save').on('click', function(e)
1798 1804
             console.log(program_ids);
1799 1805
 			
1800 1806
            // program_ids = $(this).data('program_ids')
1801
-            if(!program_ids.includes(program_id) ){
1807
+            if(!program_ids.indexOf(program_id) ){
1802 1808
                 title = "<h6>The following criteria and objectives will be matched with this program</h6>"
1803 1809
                 htmlString += "<ol style='list-style-position: inside'>"
1804 1810
         

+ 7
- 1
app/views/local/professors/assessment.blade.php View File

@@ -289,7 +289,13 @@ $('#button-submit-assessment, #button-draft-assessment, #button-diagnostic-asses
289 289
             activity_criterion_id = $('.criterion-field').eq(index2).data('activity-criterion-id');
290 290
             score = scoreField.children('select').find(':selected').val();
291 291
             if(score != "N/A")
292
-            student_info[index].activity_crit_id[activity_criterion_id] = score;
292
+            {
293
+	            student_info[index].activity_crit_id[activity_criterion_id] = score;
294
+    		}
295
+    		else
296
+    		{
297
+    			student_info[index].activity_crit_id[activity_criterion_id] = null;
298
+    		}
293 299
             // Score in the cell
294 300
             //var score = scoreField.children('select').find(':selected').val();
295 301