Selaa lähdekoodia

Merge branch 'Merge_gabriel_mayo' of https://git.ccom.uprrp.edu/CDCC/OLAS into Merge_gabriel_mayo

Para ajustar ultimos cambios
Carlos J Corrada Bravo 3 vuotta sitten
vanhempi
commit
bef46d1998

+ 21
- 3
app/controllers/CriteriaController.php Näytä tiedosto

@@ -738,16 +738,21 @@ class CriteriaController extends \BaseController
738 738
     {
739 739
         if (Auth::user()->role == 1) {
740 740
             //buscar todos los objetivos
741
-            $objectives = DB::table('program_user')
741
+            /*$objectives = DB::table('program_user')
742 742
                 ->join('objective_program', 'objective_program.program_id', '=', 'program_user.program_id')
743 743
                 ->join('objectives', 'objectives.id', '=', 'objective_program.objective_id')
744 744
                 ->join('programs', 'programs.id', '=', 'program_user.program_id')
745 745
                 ->select('objectives.id', 'objectives.text', 'programs.name')
746 746
                 ->orderBy('objectives.text', 'asc')
747
+                ->get();*/
748
+
749
+            $objectives = DB::table('objectives')
750
+                ->where('objectives.active', 1)
751
+                ->orderBy('objectives.text', 'asc')
747 752
                 ->get();
748 753
         } elseif (Auth::user()->role == 2) {
749 754
             //buscar los objetivos de la departamento (school)
750
-            $objectives = DB::table('program_user')
755
+            /*$objectives = DB::table('program_user')
751 756
                 ->join('objective_program', 'objective_program.program_id', '=', 'program_user.program_id')
752 757
                 ->join('objectives', 'objectives.id', '=', 'objective_program.objective_id')
753 758
                 ->join('programs', 'programs.id', '=', 'program_user.program_id')
@@ -755,6 +760,16 @@ class CriteriaController extends \BaseController
755 760
                 ->select('objectives.id', 'objectives.text', 'programs.name')
756 761
                 ->orderBy('objectives.text', 'asc')
757 762
                 ->get();
763
+                */
764
+            $objectives = DB::table('objectives')
765
+                ->join('objective_program', 'objective_program.objective_id', '=', 'objectives.id')
766
+                ->join('programs', 'programs.id', '=', 'objective_program.program_id')
767
+                ->where('program.school_id', Auth::user()->school_id)
768
+                ->where('objectives.active', 1)
769
+                ->orderBy('objectives.text', 'asc')
770
+                ->select('objectives.id', 'objectives.text')
771
+                ->distinct()
772
+                ->get();
758 773
         } elseif ((Auth::user()->role == 3) || (Auth::user()->role == 4)) {
759 774
             //buscar los objetivos de los programas cuales el profesor esta
760 775
             $objectives = DB::table('program_user')
@@ -762,7 +777,10 @@ class CriteriaController extends \BaseController
762 777
                 ->join('objectives', 'objectives.id', '=', 'objective_program.objective_id')
763 778
                 ->join('programs', 'programs.id', '=', 'program_user.program_id')
764 779
                 ->where('program_user.user_id', Auth::user()->id)
765
-                ->select('objectives.id', 'objectives.text', 'programs.name')
780
+                ->where('objectives.active', 1)
781
+                ->select('objectives.id', 'objectives.text')
782
+                ->distinct()
783
+
766 784
                 ->orderBy('objectives.text', 'asc')
767 785
                 ->get();
768 786
         }

+ 65
- 1
app/controllers/ObjectivesController.php Näytä tiedosto

@@ -214,8 +214,72 @@ class ObjectivesController extends \BaseController
214 214
   {
215 215
     $id = Input::get('id');
216 216
 
217
-    $objective = Objective::find($id);
217
+    //$objective = Objective::find($id);
218
+    $objective = DB::table('objectives')
219
+      ->where('id', $id)
220
+      ->first();
218 221
 
222
+    $role = Auth::user()->role;
223
+
224
+    switch ($role) {
225
+      case 1:
226
+        $program_ids = DB::table('programs')->lists('id');
227
+        # code...
228
+        break;
229
+      case 2:
230
+        $program_ids = DB::table('programs')
231
+          ->where('school_id', Auth::user()->school_id)
232
+          ->lists('id');
233
+        break;
234
+      case 3:
235
+      case 4:
236
+        $program_ids = DB::table('program_user')
237
+          ->where('user_id', Auth::user()->id)
238
+          ->lists('program_id');
239
+
240
+
241
+        break;
242
+    }
243
+
244
+    $criteria_scales = DB::table('criteria')
245
+      ->join('criterion_objective_outcome as cobo', 'criterion_id', '=', 'criteria.id')
246
+      ->where('objective_id', $objective->id)
247
+      ->select('num_scales')
248
+      ->orderBy('num_scales', 'DESC')
249
+      ->distinct()
250
+      ->lists('num_scales');
251
+    $objective->criteria = [];
252
+    foreach ($criteria_scales as $i => $num_scales) {
253
+
254
+      $objective->criteria[$num_scales] = DB::table('criteria')
255
+        ->join('criterion_objective_outcome as cobo', 'cobo.criterion_id', '=', 'criteria.id')
256
+        ->join('program_criterion', 'program_criterion.criterion_id', '=', 'criteria.id')
257
+        ->whereIn('program_id', $program_ids)
258
+        ->where('objective_id', $objective->id)
259
+        ->where('num_scales', $num_scales)
260
+        ->select('criteria.*', 'cobo.criterion_id')
261
+        ->distinct()
262
+        ->get();
263
+
264
+      foreach ($objective->criteria[$num_scales] as $criteria) {
265
+        $criteria->programs = DB::table('programs')
266
+          ->join('program_criterion', 'programs.id', '=', 'program_criterion.program_id')
267
+          ->where('criterion_id', $criteria->criterion_id)
268
+          ->get();
269
+
270
+        $criteria->outcomes = DB::table('outcomes')
271
+          ->join('criterion_objective_outcome', 'outcomes.id', '=', 'criterion_objective_outcome.outcome_id')
272
+          ->where('objective_id', $objective->id)
273
+          ->where('criterion_id', $criteria->criterion_id)
274
+          ->select('outcomes.*')
275
+          ->get();
276
+        $criteria->scales = DB::table('criterion_scale')
277
+          ->join('scales', 'criterion_scale.scale_id', '=', 'scales.id')
278
+          ->where('criterion_id', $criteria->criterion_id)
279
+          ->orderBy('position', 'asc')
280
+          ->get();
281
+      }
282
+    }
219 283
     //$objective->program;
220 284
     //$objective->criteria;
221 285
 

+ 6
- 2
app/controllers/OutcomesController.php Näytä tiedosto

@@ -582,6 +582,7 @@ class OutcomesController extends \BaseController
582 582
         // switch para el query, dependiendo del usuario
583 583
 
584 584
         $role = Auth::user()['role'];
585
+        $semesters = Session::get('sesemster_ids');
585 586
 
586 587
         switch ($role) {
587 588
             case 1:
@@ -594,6 +595,9 @@ class OutcomesController extends \BaseController
594 595
             case 3:
595 596
                 $program_ids = DB::table('program_user')->where('user_id', Auth::user()['id'])->lists('program_id');
596 597
                 break;
598
+            case 4:
599
+                $program_ids = DB::table('program_user')->where('user_id', Auth::user()['id'])->lists('program_id');
600
+                break;
597 601
         }
598 602
 
599 603
         $outcome->criteria = array();
@@ -709,7 +713,7 @@ class OutcomesController extends \BaseController
709 713
                     ->with(array('courses' => function ($query2) use ($outcome_id) {
710 714
                         $query2
711 715
                             ->has('activities')
712
-//                             ->whereNotNull('outcomes_attempted')
716
+                            //                             ->whereNotNull('outcomes_attempted')
713 717
                             // ->where('outcomes_attempted', 'NOT LIKE', '%"'.$outcome_id.'":0%')
714 718
                             ->whereIn('semester_id', Session::get('semesters_ids'))
715 719
                             ->groupBy(array('code', 'number'));
@@ -810,7 +814,7 @@ class OutcomesController extends \BaseController
810 814
                     ->with(array('courses' => function ($query2) use ($outcome_id) {
811 815
                         $query2
812 816
                             ->has('activities')
813
-//                             ->whereNotNull('outcomes_attempted')
817
+                            //                             ->whereNotNull('outcomes_attempted')
814 818
                             // ->where('outcomes_attempted', 'NOT LIKE', '%"'.$outcome_id.'":0%')
815 819
                             ->whereIn('semester_id', Session::get('semesters_ids'))
816 820
                             ->groupBy(array('code', 'number'));

+ 28
- 10
app/controllers/ProfessorsController.php Näytä tiedosto

@@ -80,23 +80,41 @@ class ProfessorsController extends \BaseController
80 80
         $program =  Auth::user()->programs[0];
81 81
         $title = 'Your Program: ' . $program->name;
82 82
         $program_courses = Course::where('program_id', '=', $program->id)->whereIn('semester_id', Session::get('semesters_ids'))->get();
83
-        $outcomes = Outcome::orderBy('name', 'asc')->get();
84
-        $outcomeCount = Outcome::all()->count();
83
+        $semesters = Session::get('semesters_ids');
84
+        $semesters = DB::table('semesters')->whereIn('id', $semesters)->orderBy('start', 'ASC')->first();
85
+
86
+        $outcomes = Outcome::select(array('id', 'name', 'expected_outcome'))
87
+            ->whereNull('deleted_at')
88
+            ->whereRaw("(deactivation_date IS NULL or deactivation_date >= '{$semesters->start}')")
89
+            ->orderBy('name', 'ASC')->get();
90
+        $outcomeCount = count($outcomes);
91
+        $outcomes_achieved = [];
92
+        $outcomes_attempted = [];
93
+
94
+        Log::info($program_courses);
85 95
 
86
-        $outcomes_achieved = array_fill(1, $outcomeCount, 0);
87
-        $outcomes_attempted = array_fill(1, $outcomeCount, 0);
88 96
 
89 97
         foreach ($program_courses as $course) {
90
-            if ($course->outcomes_achieved != NULL) {
91
-                $course_outcomes_achieved = json_decode($course->outcomes_achieved, true);
92
-                $course_outcomes_attempted = json_decode($course->outcomes_attempted, true);
93
-                for ($i = 1; $i <= count($outcomes_attempted); $i++) {
94
-                    $outcomes_achieved[$i] += $course_outcomes_achieved[$i];
95
-                    $outcomes_attempted[$i] += $course_outcomes_attempted[$i];
98
+
99
+
100
+            if ($course->outcomes_ach()) {
101
+
102
+                $course_outcomes_achieved = $course->outcomes_ach();
103
+                $course_outcomes_attempted = $course->outcomes_att();
104
+                foreach ($course_outcomes_achieved as $outcome => $score) {
105
+                    if (array_key_exists($outcome, $outcomes_achieved))
106
+                        $outcomes_achieved[$outcome] += $score;
107
+                    else $outcomes_achieved[$outcome] = $score;
108
+                }
109
+                foreach ($course_outcomes_attempted as $outcome => $score) {
110
+                    if (array_key_exists($outcome, $outcomes_attempted))
111
+                        $outcomes_attempted[$outcome] += $score;
112
+                    else $outcomes_attempted[$outcome] = $score;
96 113
                 }
97 114
             }
98 115
         }
99 116
 
117
+
100 118
         // Program contact information
101 119
         $scoords = User::where('school_id', $program->school_id)
102 120
             ->where('role', 2)

+ 51
- 0
app/database/migrations/2021_09_24_211312_create_semester_program_student.php Näytä tiedosto

@@ -0,0 +1,51 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+use Illuminate\Support\Facades\Schema;
6
+
7
+class CreateSemesterProgramStudent extends Migration
8
+{
9
+
10
+	/**
11
+	 * Run the migrations.
12
+	 *
13
+	 * @return void
14
+	 */
15
+	public function up()
16
+	{
17
+		Schema::create('program_student_semester', function (Blueprint $table) {
18
+			$table->increments('id');
19
+			$table->integer('student_id')->unsigned();
20
+			$table->integer('program_id')->unsigned();
21
+			$table->integer('semester_id')->unsigned();
22
+			$table->foreign('semester_id')
23
+				->references('id')
24
+				->on('semesters')
25
+				->onDelete('cascade')
26
+				->onUpdate('cascade');
27
+			$table
28
+				->foreign('student_id')
29
+				->references('id')
30
+				->on('students')
31
+				->onDelete('cascade')
32
+				->onUpdate('cascade');
33
+
34
+			$table->foreign('program_id')
35
+				->references('id')
36
+				->on('programs')
37
+				->onDelete('cascade')
38
+				->onUpdate('cascade');
39
+		});
40
+	}
41
+
42
+	/**
43
+	 * Reverse the migrations.
44
+	 *
45
+	 * @return void
46
+	 */
47
+	public function down()
48
+	{
49
+		Schema::drop('program_student_semester');
50
+	}
51
+}

+ 1
- 1
app/routes.php Näytä tiedosto

@@ -180,7 +180,7 @@ Route::group(array('before' => 'auth|has_access'), function () {
180 180
     ));
181 181
     Route::get('printThreeYear/{program_id}/{typ}', array(
182 182
         'as' => 'printThreeYear/{program_id}/{typ}',
183
-        'uses' => 'ThreeYearPlanController@print'
183
+        'uses' => 'ThreeYearPlanController@printPlan'
184 184
     ));
185 185
     // Fetch all criteria associated to an outcome
186 186
     Route::post('fetchInfo', array(

+ 28
- 0
app/views/global/view-learning-outcomes-criteria.blade.php Näytä tiedosto

@@ -278,13 +278,41 @@ $(document).ready(function()
278 278
                   //var cell_text = description;
279 279
                   row.push(description);
280 280
               });
281
+              howManyPrograms = 0;
281 282
               $.each(criterion_programs, function(index, program){
282 283
 
283 284
               program_html += (index+1) +'. '+program+'<br>\n';
285
+              howManyPrograms++;
284 286
               });
285 287
               row.push(program_html);
288
+              role = {{{Auth::user()->role}}};
289
+              
290
+              switch (role) {
291
+                case 1:
292
+                if(!criterion.deleted_at) row.push('<a onclick = "statusClick(this)" data-criterion-id="'+criterion.id+'" href="#" class = "status">Active</a>');
293
+              else row.push('<a href="#" onclick = "statusClick(this)" data-criterion-id="'+criterion.id+'" class = "status">Deactivated</a>');
294
+                  break;
295
+                case 2:
296
+                if(!criterion.deleted_at) row.push('<a onclick = "statusClick(this)" data-criterion-id="'+criterion.id+'" href="#" class = "status">Active</a>');
297
+              else row.push('<a href="#" onclick = "statusClick(this)" data-criterion-id="'+criterion.id+'" class = "status">Deactivated</a>');
298
+              break;
299
+              case 3:
300
+                if(howManyPrograms<=1){
286 301
               if(!criterion.deleted_at) row.push('<a onclick = "statusClick(this)" data-criterion-id="'+criterion.id+'" href="#" class = "status">Active</a>');
287 302
               else row.push('<a href="#" onclick = "statusClick(this)" data-criterion-id="'+criterion.id+'" class = "status">Deactivated</a>');
303
+                }
304
+
305
+                else{
306
+                  if(!criterion.deleted_at) row.push('<p>Active</p>');
307
+              else row.push('<p>Deactivated</p>');
308
+                }
309
+                break;
310
+                case 4:
311
+                if(!criterion.deleted_at) row.push('<p>Active</p>');
312
+              else row.push('<p>Deactivated</p>');
313
+                  break;
314
+              }
315
+  
288 316
               if(criterion_scales.length < criterions_levels){
289 317
                 var i = criterion_scales.length;
290 318
                 while (i < criterions_levels){

+ 251
- 33
app/views/global/view-objectives-criteria.blade.php
File diff suppressed because it is too large
Näytä tiedosto


+ 1
- 1
app/views/global/view-three-year-plan.blade.php Näytä tiedosto

@@ -400,7 +400,7 @@ $('.go-to-temp').on('click', function(){
400 400
       var id = $(this).data('cycle-id');
401 401
       $('#table-cycles').data('typ-id',id);
402 402
       $('#print_button').show();
403
-      $('#print_button').attr("href", "{{URL::action('ThreeYearPlanController@print', [$program_id])}}"+
403
+      $('#print_button').attr("href", "{{URL::action('ThreeYearPlanController@printPlan', [$program_id])}}"+
404 404
       '/'+ $(this).data('cycle-id'));
405 405
       $('#section1').show();
406 406
       $('#section2').hide();