Browse Source

Update ThreeYearPlanController.php

Fixes  to queries
onielm 3 years ago
parent
commit
88f674311c
1 changed files with 8 additions and 16 deletions
  1. 8
    16
      app/controllers/ThreeYearPlanController.php

+ 8
- 16
app/controllers/ThreeYearPlanController.php View File

@@ -329,12 +329,12 @@ class ThreeYearPlanController extends \BaseController
329 329
           }
330 330
 
331 331
           // lookup available objectives
332
-          $result_objectives = DB::table('criterion_objective_outcome')
333
-              ->join('outcomes','outcomes.id','=','criterion_objective_outcome.outcome_id')
334
-              ->join('objectives','objectives.id','=','criterion_objective_outcome.objective_id')
332
+          $result_objectives = DB::table('objective_outcome')
333
+              ->join('outcomes','outcomes.id','=','objective_outcome.outcome_id')
334
+              ->join('objectives','objectives.id','=','objective_outcome.objective_id')
335 335
               ->join('objective_program','objective_program.objective_id','=','objectives.id')
336 336
               ->where('objective_program.program_id',$program_id)
337
-              ->where('criterion_objective_outcome.outcome_id',$outcome_id)
337
+              ->where('objective_outcome.outcome_id',$outcome_id)
338 338
               ->select('objectives.id','objectives.text','outcomes.name as outcome_name')
339 339
               ->orderBy('objectives.text', 'asc')
340 340
               ->get();
@@ -407,8 +407,6 @@ class ThreeYearPlanController extends \BaseController
407 407
         // buscar info sobre selected_semsters
408 408
         $outcome_->selected_semesters = array();
409 409
         foreach ($result_semesters as $semesters_) {
410
-          $semester_id = $semesters_->semester_id;
411
-
412 410
           $typ_semester_outcome_id = $semesters_->id;
413 411
           $result_objectives = DB::table('typ_semester_objectives')
414 412
               ->join('objectives','objectives.id','=','typ_semester_objectives.objective_id')
@@ -419,19 +417,13 @@ class ThreeYearPlanController extends \BaseController
419 417
 
420 418
           $semesters_->selected_objectives = array();
421 419
           foreach ($result_objectives as $objectives_) {
422
-            $objective_id = $objectives_->objective_id;
423
-            $program_id = $objectives_->program_id;
424
-            $result_courses = DB::table('objective_program')
425
-                ->join('objectives','objectives.id','=','objective_program.objective_id')
426
-                ->join('courses','courses.program_id','=','objective_program.program_id')
427
-                ->where('objective_program.objective_id', $objective_id)
428
-                ->where('objective_program.program_id', $program_id)
429
-                ->where('courses.semester_id', $semester_id)
430
-                ->distinct('courses.name','courses.code')
431
-                ->select('courses.id as course_id','courses.name','courses.code','objective_program.objective_id','objective_program.program_id')
420
+            $result_courses = DB::table('courses')
421
+                ->where('courses.program_id', $program_id)
422
+                ->select('courses.id as course_id','courses.name','courses.code','courses.program_id')
432 423
                 ->orderBy('courses.name', 'asc')
433 424
                 ->groupBy('courses.name','courses.code')
434 425
                 ->get();
426
+            #los cursos resultantes creo que deberian ser: todos los que se estan dando en mi programa
435 427
 
436 428
             $objectives_->available_courses = array();
437 429
             foreach ($result_courses as $courses_) {