2 Revize

Autor SHA1 Zpráva Datum
  Gabriel Santiago Plaza 4331c0a5d8 final de features před 2 roky
  Gabriel Santiago Plaza 0a44bf0ba1 Feature de objectives před 2 roky

+ 16
- 11
app/controllers/CriteriaController.php Zobrazit soubor

@@ -257,7 +257,11 @@ class CriteriaController extends \BaseController
257 257
             ->where('criterion_id', $criteria_id)
258 258
             ->orderBy('position')
259 259
             ->get();
260
-        $criterion->program =  DB::table('program_criterion')->where('criterion_id', $criteria_id)->get();
260
+        $criterion->program =  DB::table('program_criterion_objective_outcome as poco')
261
+            ->join('criterion_objective_outcome as cobo', 'cobo.id', '=', 'poco.cri_obj_out_id')
262
+            ->where('criterion_id', $criteria_id)
263
+            ->select('poco.program_id')
264
+            ->distinct()->get();
261 265
         $criterion->activity_criterion = DB::table('assessments')
262 266
             ->join('activity_criterion', 'activity_criterion.id', '=', 'assessments.activity_criterion_id')
263 267
             ->where('activity_criterion.criterion_id', $criteria_id)
@@ -336,8 +340,9 @@ class CriteriaController extends \BaseController
336 340
 
337 341
 
338 342
         $saved_criterion = DB::table('criteria')
339
-            ->join('program_criterion', 'program_criterion.criterion_id', '=', 'criteria.id')
340 343
             ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
344
+            ->join('program_criterion_objective_outcome', 'program_criterion_objective_outcome.cri_obj_out_id', '=', 'criterion_objective_outcome.id')
345
+
341 346
             ->join('criterion_scale', 'criterion_scale.criterion_id', '=', 'criteria.id')
342 347
             ->whereIn('program_id', $input['program_id'])
343 348
             ->whereIn('objective_id', $objectives)
@@ -461,7 +466,7 @@ class CriteriaController extends \BaseController
461 466
      */
462 467
     public function create()
463 468
     {
464
-        $clean_input = $this->cleanInput();	
469
+        $clean_input = $this->cleanInput();
465 470
 
466 471
         Log::info(json_encode($clean_input));
467 472
 
@@ -489,7 +494,7 @@ class CriteriaController extends \BaseController
489 494
                     return Redirect::to('criteria')->withInput();
490 495
 
491 496
                 case 2:
492
-//                     Log::info(Input::all());
497
+                    //                     Log::info(Input::all());
493 498
                     return Redirect::to('school-criteria')->withInput();
494 499
 
495 500
                 case 3:
@@ -630,9 +635,9 @@ class CriteriaController extends \BaseController
630 635
                 }*/
631 636
 
632 637
 
633
-                foreach ($clean_input['program_id'] as $program_id) {
634
-                    DB::insert("insert into `program_criterion` (`criterion_id`, `program_id`) values({$criterionId},{$program_id})");
635
-                }
638
+                //foreach ($clean_input['program_id'] as $program_id) {
639
+                //    DB::insert("insert into `program_criterion` (`criterion_id`, `program_id`) values({$criterionId},{$program_id})");
640
+                //}
636 641
 
637 642
                 Session::flash('status', 'success');
638 643
                 Session::flash('message', 'Criterion created: "' . $criterion->name . '".');
@@ -873,7 +878,7 @@ class CriteriaController extends \BaseController
873 878
                 $criterionId = $criterion->id;
874 879
                 DB::table('criterion_objective_outcome as cobo')
875 880
                     ->join('program_criterion_objective_outcome as poco', 'poco.cri_obj_out_id', '=', 'cobo.id')
876
-                    ->where($criterionId)
881
+                    ->where('cobo.criterion_id', $criterionId)
877 882
                     ->delete();
878 883
                 // DB::delete("delete from `criterion_objective_outcome` where `criterion_id` ={$criterionId}");
879 884
                 DB::delete("delete from `program_criterion` where `criterion_id` ={$criterionId}");
@@ -964,9 +969,9 @@ class CriteriaController extends \BaseController
964 969
 
965 970
                         break;
966 971
                 }*/
967
-                foreach ($clean_input['program_id'] as $program_id) {
968
-                    DB::insert("insert into `program_criterion` (`criterion_id`, `program_id`) values({$criterionId},{$program_id})");
969
-                }
972
+                //foreach ($clean_input['program_id'] as $program_id) {
973
+                //    DB::insert("insert into `program_criterion` (`criterion_id`, `program_id`) values({$criterionId},{$program_id})");
974
+                //}
970 975
 
971 976
 
972 977
 

+ 2
- 2
app/controllers/Objective2Controller.php Zobrazit soubor

@@ -660,9 +660,9 @@ class Objective2Controller extends \BaseController
660 660
 				if ($clean_input['agreement']) {
661 661
 					DB::table('criterion_objective_outcome')
662 662
 						//QUE PONEMOS CORRADA
663
-						//->join('program_criterion_objective_outcome', 'criterion_objective_outcome.id', "=", 'program_criterion_objective_outcome.cri_obj_out_id')
663
+						->join('program_criterion_objective_outcome', 'criterion_objective_outcome.id', "=", 'program_criterion_objective_outcome.cri_obj_out_id')
664 664
 
665
-						->join('program_criterion', 'criterion_objective_outcome.criterion_id', "=", 'program_criterion.criterion_id')
665
+						//->join('program_criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', "=", 'program_criterion_objective_outcome.criterion_id')
666 666
 						->whereIn('program_id', $clean_input['program_id'])
667 667
 						->whereIn('outcome_id', $clean_input['outcome_id'])
668 668
 						->where('objective_id', '=', 0)

+ 10
- 5
app/controllers/ObjectivesController.php Zobrazit soubor

@@ -242,8 +242,8 @@ class ObjectivesController extends \BaseController
242 242
     }
243 243
 
244 244
     $criteria_scales = DB::table('criteria')
245
-      ->join('criterion_objective_outcome as cobo', 'criterion_id', '=', 'criteria.id')
246
-      ->join('program_criterion', 'cobo.criterion_id', '=', 'program_criterion.criterion_id')
245
+      ->join('criterion_objective_outcome as cobo', 'cobo.criterion_id', '=', 'criteria.id')
246
+      ->join('program_criterion_objective_outcome as poco', 'cobo.id', '=', 'poco.cri_obj_out_id')
247 247
       ->whereIn('program_id', $program_ids)
248 248
       ->where('objective_id', $objective->id)
249 249
       ->select('num_scales')
@@ -255,7 +255,7 @@ class ObjectivesController extends \BaseController
255 255
 
256 256
       $objective->criteria[$num_scales] = DB::table('criteria')
257 257
         ->join('criterion_objective_outcome as cobo', 'cobo.criterion_id', '=', 'criteria.id')
258
-        ->join('program_criterion', 'program_criterion.criterion_id', '=', 'criteria.id')
258
+        ->join('program_criterion_objective_outcome as poco', 'cobo.id', '=', 'poco.cri_obj_out_id')
259 259
         ->whereIn('program_id', $program_ids)
260 260
         ->where('objective_id', $objective->id)
261 261
         ->where('num_scales', $num_scales)
@@ -265,8 +265,13 @@ class ObjectivesController extends \BaseController
265 265
 
266 266
       foreach ($objective->criteria[$num_scales] as $criteria) {
267 267
         $criteria->programs = DB::table('programs')
268
-          ->join('program_criterion', 'programs.id', '=', 'program_criterion.program_id')
268
+          ->join('program_criterion_objective_outcome as poco', 'poco.program_id', '=', 'programs.id')
269
+          ->join('criterion_objective_outcome as cobo', 'cobo.id', '=', 'poco.cri_obj_out_id')
270
+
271
+
269 272
           ->where('criterion_id', $criteria->criterion_id)
273
+          ->select("programs.*")
274
+          ->distinct()
270 275
           ->get();
271 276
 
272 277
         $criteria->outcomes = DB::table('outcomes')
@@ -289,4 +294,4 @@ class ObjectivesController extends \BaseController
289 294
       'objective' => $objective
290 295
     );
291 296
   }
292
-}
297
+}

+ 78
- 134
app/controllers/OutcomesController.php Zobrazit soubor

@@ -14,7 +14,7 @@ class OutcomesController extends \BaseController
14 14
     {
15 15
         $title = "Learning Outcomes";
16 16
         $outcomes = Outcome::withTrashed()->orderBy('id', 'ASC')->get();
17
-//         $outcomes = Outcome::withTrashed()->orderBy('name', 'ASC')->get();
17
+        //         $outcomes = Outcome::withTrashed()->orderBy('name', 'ASC')->get();
18 18
         $schools = School::orderBy('name', 'ASC')->get();
19 19
         // $semesters_ids = Session::get('semesters_ids');
20 20
         // $semesters = Semester::whereIn('id',$semesters_ids)->get();
@@ -343,28 +343,26 @@ class OutcomesController extends \BaseController
343 343
     public function delete()
344 344
     {
345 345
         $outcomeArray = json_decode(Input::get('outcomeArray'), true);
346
-// 		Log::info("delete".json_encode($outcomeArray));
347
-		$outcome = Outcome::withTrashed()
348
-			->where('id', '=', $outcomeArray['id'])
349
-			->firstOrFail();
350
-// 		Log::info("delete2".json_encode($outcome));
351
-		$outcome->forceDelete();
352
-// 		Log::info("sal".json_encode($sal));
353
-// 		if($sal)
354
-		{
355
-			Session::flash('status', 'success');
356
-			Session::flash('message', 'Learning Outcome deleted.');
357
-			
358
-		}
359
-
360
-	}
361
-    
346
+        // 		Log::info("delete".json_encode($outcomeArray));
347
+        $outcome = Outcome::withTrashed()
348
+            ->where('id', '=', $outcomeArray['id'])
349
+            ->firstOrFail();
350
+        // 		Log::info("delete2".json_encode($outcome));
351
+        $outcome->forceDelete();
352
+        // 		Log::info("sal".json_encode($sal));
353
+        // 		if($sal)
354
+        {
355
+            Session::flash('status', 'success');
356
+            Session::flash('message', 'Learning Outcome deleted.');
357
+        }
358
+    }
359
+
362 360
     public function updateMore()
363 361
     {
364 362
         $outcomeArray = json_decode(Input::get('outcomeArray'), true);
365 363
         Session::flash('status', 'success');
366 364
         Session::flash('message', 'Learning Outcomes updated.');
367
-		Log::info("Ahora1".json_encode($outcomeArray));
365
+        Log::info("Ahora1" . json_encode($outcomeArray));
368 366
 
369 367
         foreach ($outcomeArray as $outcomeObject) {
370 368
 
@@ -375,9 +373,9 @@ class OutcomesController extends \BaseController
375 373
                     'definition' => $outcomeObject['definition'],
376 374
                     'expected_outcome' => $outcomeObject['expected_outcome'],
377 375
                     'activation_date' => $outcomeObject['activation_date'],
378
-//                     'deactivation_date' => (isset($outcomeObject['deactivation_date'])?$outcomeObject['deactivation_date']:NULL),
376
+                    //                     'deactivation_date' => (isset($outcomeObject['deactivation_date'])?$outcomeObject['deactivation_date']:NULL),
379 377
                     'level' => $outcomeObject['level'],
380
-//                     'new_outcome_id'=>$outcomeObject['new_outcome_id']
378
+                    //                     'new_outcome_id'=>$outcomeObject['new_outcome_id']
381 379
                     // TODO- validar los otros 3 valores
382 380
                 ),
383 381
                 array(
@@ -385,9 +383,9 @@ class OutcomesController extends \BaseController
385 383
                     'definition' => 'required',
386 384
                     'expected_outcome' => 'required|numeric',
387 385
                     'activation_date' => 'required|date',
388
-//                     'deactivation_date' => 'sometimes|required|date',
386
+                    //                     'deactivation_date' => 'sometimes|required|date',
389 387
                     'level' => 'required|numeric'
390
-//                     'new_outcome_id' => 'required|numeric'
388
+                    //                     'new_outcome_id' => 'required|numeric'
391 389
                     // TODO- los requisitos de los otros 3 valores
392 390
                 )
393 391
             );
@@ -401,18 +399,15 @@ class OutcomesController extends \BaseController
401 399
                     $outcome->definition = $outcomeObject['definition'];
402 400
                     $outcome->expected_outcome = $outcomeObject['expected_outcome'];
403 401
                     $outcome->activation_date = $outcomeObject['activation_date'];
404
-                    if($outcomeObject['deactivation_date']!="")
405
-                    {
406
-                    	$outcome->deactivation_date = $outcomeObject['deactivation_date'];
407
-	                    if(isset($outcomeObject['new_outcome_id']))$outcome->new_outcome_id = $outcomeObject['new_outcome_id'];
408
-                    }
409
-                    else 
410
-                    {
411
-                    	$outcome->deactivation_date = NULL;
412
-                    	$outcome->new_outcome_id=NULL;
402
+                    if ($outcomeObject['deactivation_date'] != "") {
403
+                        $outcome->deactivation_date = $outcomeObject['deactivation_date'];
404
+                        if (isset($outcomeObject['new_outcome_id'])) $outcome->new_outcome_id = $outcomeObject['new_outcome_id'];
405
+                    } else {
406
+                        $outcome->deactivation_date = NULL;
407
+                        $outcome->new_outcome_id = NULL;
413 408
                     }
414 409
                     $outcome->level = $outcomeObject['level'];
415
-		Log::info("Ahora2".json_encode($outcome));
410
+                    Log::info("Ahora2" . json_encode($outcome));
416 411
 
417 412
                     $outcome->save();
418 413
 
@@ -448,22 +443,24 @@ class OutcomesController extends \BaseController
448 443
 
449 444
     public function fetchCriteria()
450 445
     {
451
-        // 		var_dump((Input::get('filter')));
452
-        // 		exit();
446
+        $criteria_not_available = DB::table('criterion_objective_outcome')
447
+            ->where('objective_id', '=', 0)
448
+            ->lists('criterion_id');
449
+        $criteria = DB::table('criteria')
450
+            ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id');
453 451
         if (Input::get('filter')) {
454 452
             switch (Input::get('filter')) {
455 453
                 case 'all':
456
-                    $criteria = DB::table('criteria')
454
+                    /*$criteria = DB::table('criteria')
457 455
                         ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
458 456
                         ->where('criterion_objective_outcome.outcome_id', '=', Input::get('outcome_id'))
459 457
                         ->where('criterion_objective_outcome.objective_id', '=', Input::get('objective_id'))
460 458
                         ->where('criteria.num_scales', '=', Input::get('num_scales'))
461
-                        ->where('criteria.max_score', '=', Input::get('maximum'))
462
-                        ->select('criterion_id as id', 'name')
463
-                        ->orderBy('name', 'ASC')
464
-                        ->get();
459
+                        ->where('criteria.max_score', '=', Input::get('maximum'))*/
460
+
465 461
 
466
-                    foreach ($criteria as $criterion) {
462
+
463
+                    /*foreach ($criteria as $criterion) {
467 464
                         $criterion->program_ids = json_encode(DB::table('program_criterion')
468 465
                             ->where('criterion_id', $criterion->id)
469 466
                             ->lists('program_id'));
@@ -475,6 +472,7 @@ class OutcomesController extends \BaseController
475 472
                             ->lists('text');
476 473
                     }
477 474
                     return $criteria;
475
+                    break;*/
478 476
                     break;
479 477
 
480 478
                 case 'school':
@@ -483,17 +481,15 @@ class OutcomesController extends \BaseController
483 481
 
484 482
                         // Fetch all the programs whose school is the user's
485 483
                         $program_ids = DB::table('programs')->where('school_id', Auth::user()->school_id)->lists('id');
486
-                        $criteria = DB::table('criteria')
487
-                            ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
488
-                            ->join('program_criterion', 'program_criterion.criterion_id', '=', 'criteria.id')
489
-                            ->where('criterion_objective_outcome.outcome_id', '=', Input::get('outcome_id'))
490
-                            ->where('criterion_objective_outcome.objective_id', '=', Input::get('objective_id'))
491
-                            ->where('criteria.num_scales', '=', Input::get('num_scales'))
492
-                            ->where('criteria.max_score', '=', Input::get('maximum'))
493
-                            ->whereIn('program_criterion.program_id', $program_ids)
494
-                            ->select('criterion_id as id', 'name')
495
-                            ->orderBy('name', 'ASC')
496
-                            ->get();
484
+                    } else {
485
+                        $program_ids = DB::table('programs')->where('school_id', Auth::user()->programs[0]->school->id)->lists('id');
486
+                    }
487
+                    $criteria = $criteria
488
+                        ->join('program_criterion_objective_outcome as poco', 'poco.cri_obj_out_id', '=', 'criterion_objective_outcome.id')
489
+
490
+                        ->whereIn('poco.program_id', $program_ids);
491
+
492
+                    /*
497 493
                         foreach ($criteria as $criterion) {
498 494
                             $criterion->program_ids = json_encode(DB::table('program_criterion')
499 495
                                 ->where('criterion_id', $criterion->id)
@@ -506,57 +502,21 @@ class OutcomesController extends \BaseController
506 502
                                 ->lists('text'));
507 503
                         }
508 504
                         // Return all criteria belonging to any of those programs
509
-                        return $criteria;
510
-                    }
505
+                        return $criteria;*/
511 506
 
512
-                    // If pcoord
513
-                    else {
514 507
 
515
-                        // Fetch all the programs from the user's school;
516
-                        // Fetch all the programs from the user's school;
517
-                        $program_ids = DB::table('programs')->where('school_id', Auth::user()->programs[0]->school->id)->lists('id');
518 508
 
519
-                        $criteria = DB::table('criteria')
520
-                            ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
521
-                            ->join('program_criterion', 'program_criterion.criterion_id', '=', 'criteria.id')
522
-                            ->where('criterion_objective_outcome.outcome_id', '=', Input::get('outcome_id'))
523
-                            ->where('criterion_objective_outcome.objective_id', '=', Input::get('objective_id'))
524
-                            ->where('criteria.num_scales', '=', Input::get('num_scales'))
525
-                            ->where('criteria.max_score', '=', Input::get('maximum'))
526
-                            ->whereIn('program_criterion.program_id', $program_ids)
527
-                            ->select('criterion_id as id', 'name')
528
-                            ->orderBy('name', 'ASC')
529
-                            ->get();
530 509
 
531
-                        foreach ($criteria as $criterion) {
532
-                            $criterion->program_ids = json_encode(DB::table('program_criterion')
533
-                                ->where('criterion_id', $criterion->id)
534
-                                ->lists('program_id'));
535
-                            $criterion->objectives = json_encode(DB::table('criterion_objective_outcome')
536
-                                ->join('objectives', 'objectives.id', '=', 'criterion_objective_outcome.objective_id')
537
-                                ->where('criterion_id', $criterion->id)
538
-                                ->select('objectives.*')
539
-                                ->distinct()
540
-                                ->lists('text'));
541
-                        }
542
-                        return $criteria;
543
-                    }
544 510
 
545 511
                     break;
546 512
 
547 513
                 case 'program':
548
-                    $criteria = DB::table('criteria')
549
-                        ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
550
-                        ->join('program_criterion', 'program_criterion.criterion_id', '=', 'criteria.id')
551
-                        ->where('criterion_objective_outcome.outcome_id', '=', Input::get('outcome_id'))
552
-                        ->where('criterion_objective_outcome.objective_id', '=', Input::get('objective_id'))
553
-                        ->where('criteria.num_scales', '=', Input::get('num_scales'))
554
-                        ->where('criteria.max_score', '=', Input::get('maximum'))
555
-                        ->whereIn('program_criterion.program_id', Auth::user()->programs->lists('id'))
556
-                        ->select('criterion_id as id', 'name')
557
-                        ->orderBy('name', 'ASC')
558
-                        ->get();
559
-                    foreach ($criteria as $criterion) {
514
+
515
+                    $criteria = $criteria
516
+                        ->join('program_criterion_objective_outcome as poco', 'poco.cri_obj_out_id', '=', 'criterion_objective_outcome.id')
517
+
518
+                        ->whereIn('poco.program_id', Auth::user()->programs->lists('id'));
519
+                    /*foreach ($criteria as $criterion) {
560 520
                         $criterion->program_ids = json_encode(DB::table('program_criterion')
561 521
                             ->where('criterion_id', $criterion->id)
562 522
                             ->lists('program_id'));
@@ -567,21 +527,13 @@ class OutcomesController extends \BaseController
567 527
                             ->distinct()
568 528
                             ->lists('text'));
569 529
                     }
570
-                    return $criteria;
530
+                    return $criteria;*/
571 531
                     break;
572 532
 
573 533
                 default:
574
-                    $criteria = DB::table('criteria')
575
-                        ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
576
-                        ->where('criterion_objective_outcome.outcome_id', '=', Input::get('outcome_id'))
577
-                        ->where('criterion_objective_outcome.objective_id', '=', Input::get('objective_id'))
578
-                        ->where('criteria.num_scales', '=', Input::get('num_scales'))
579
-                        ->where('criteria.max_score', '=', Input::get('maximum'))
580
-                        ->select('criterion_id as id', 'name')
581
-                        ->orderBy('name', 'ASC')
582
-                        ->get();
583 534
 
584
-                    foreach ($criteria as $criterion) {
535
+
536
+                    /*foreach ($criteria as $criterion) {
585 537
                         $criterion->program_ids = json_encode(DB::table('program_criterion')
586 538
                             ->where('criterion_id', $criterion->id)
587 539
                             ->lists('program_id'));
@@ -592,33 +544,21 @@ class OutcomesController extends \BaseController
592 544
                             ->distinct()
593 545
                             ->lists('text'));
594 546
                     }
595
-                    return $criteria;
547
+                    return $criteria;*/
596 548
                     break;
597 549
             }
598
-        } else {
599
-            $criteria = DB::table('criteria')
600
-                ->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
601
-                ->where('criterion_objective_outcome.outcome_id', '=', Input::get('outcome_id'))
602
-                ->where('criterion_objective_outcome.objective_id', '=', Input::get('objective_id'))
603
-                ->where('criteria.num_scales', '=', Input::get('num_scales'))
604
-                ->where('criteria.max_score', '=', Input::get('maximum'))
605
-                ->select('criterion_id as id', 'name')
606
-                ->orderBy('name', 'ASC')
607
-                ->get();
608
-
609
-            foreach ($criteria as $criterion) {
610
-                $criterion->program_ids = json_encode(DB::table('program_criterion')
611
-                    ->where('criterion_id', $criterion->id)
612
-                    ->lists('program_id'));
613
-                $criterion->objectives = json_encode(DB::table('criterion_objective_outcome')
614
-                    ->join('objectives', 'objectives.id', '=', 'criterion_objective_outcome.objective_id')
615
-                    ->where('criterion_id', $criterion->id)
616
-                    ->select('objectives.*')
617
-                    ->distinct()
618
-                    ->lists('text'));
619
-            }
620
-            return $criteria;
621 550
         }
551
+
552
+        $criteria = $criteria
553
+            ->where('criterion_objective_outcome.outcome_id', '=', Input::get('outcome_id'))
554
+            ->where('criterion_objective_outcome.objective_id', '=', Input::get('objective_id'))
555
+            ->where('criteria.num_scales', '=', Input::get('num_scales'))
556
+            ->where('criteria.max_score', '=', Input::get('maximum'))
557
+            ->whereNotIn('criteria.id', $criteria_not_available)
558
+            ->select('criterion_id as id', 'name')
559
+            ->orderBy('name', 'ASC')
560
+            ->get();
561
+        return $criteria;
622 562
     }
623 563
 
624 564
     /**
@@ -715,7 +655,7 @@ class OutcomesController extends \BaseController
715 655
         $diferent_levels = DB::table('criterion_objective_outcome')
716 656
             ->join('criteria', 'criteria.id', '=', 'criterion_objective_outcome.criterion_id')
717 657
             // GASP, añadí programa, para que solo muestre niveles de criterios del programa
718
-            ->join('program_criterion', 'criteria.id', '=', 'program_criterion.criterion_id')
658
+            ->join('program_criterion_objective_outcome', 'criterion_objective_outcome.id', '=', 'program_criterion_objective_outcome.cri_obj_out_id')
719 659
             ->whereIn('program_id', $program_ids)
720 660
             ->where('criterion_objective_outcome.outcome_id', $id)
721 661
             ->distinct('criteria.num_scales')
@@ -739,8 +679,8 @@ class OutcomesController extends \BaseController
739 679
             //                 ->get();
740 680
             $outcome_criterias = DB::table('criterion_objective_outcome')
741 681
                 ->join('criteria', 'criteria.id', '=', 'criterion_objective_outcome.criterion_id')
742
-                ->join('program_criterion', 'program_criterion.criterion_id', '=', 'criteria.id')
743
-                ->whereIn('program_criterion.program_id', $program_ids)
682
+                ->join('program_criterion_objective_outcome', 'criterion_objective_outcome.id', '=', 'program_criterion_objective_outcome.cri_obj_out_id')
683
+                ->whereIn('program_criterion_objective_outcome.program_id', $program_ids)
744 684
                 ->where('criterion_objective_outcome.outcome_id', $id)
745 685
                 ->where('criteria.num_scales', $level)
746 686
                 ->select('criteria.id', 'criteria.name', 'criteria.deleted_at')
@@ -753,10 +693,14 @@ class OutcomesController extends \BaseController
753 693
                 $scales = DB::select("select * FROM scales INNER join `criterion_scale` on `criterion_scale`.`scale_id` = `scales`.`id` where criterion_scale.criterion_id ={$criteria_id->id} ORDER BY position");
754 694
 
755 695
                 $programs = DB::table('programs')
756
-                    ->join('program_criterion', 'program_criterion.program_id', '=', 'programs.id')
696
+                    ->join('program_criterion_objective_outcome', 'programs.id', '=', 'program_criterion_objective_outcome.program_id')
697
+                    ->join('criterion_objective_outcome as cobo', 'cobo.id', '=', 'program_criterion_objective_outcome.cri_obj_out_id')
698
+                    //->join('program_criterion', 'program_criterion.program_id', '=', 'programs.id')
757 699
                     ->where('criterion_id', $criteria_id->id)
700
+                    ->select('programs.*')
701
+                    ->distinct()
758 702
                     ->lists('programs.name');
759
-                Log::info($scales);
703
+                // Log::info($scales);
760 704
 
761 705
                 /* $scales =
762 706
                     DB::select(

+ 9
- 9
app/controllers/ProgramsController.php Zobrazit soubor

@@ -282,9 +282,9 @@ class ProgramsController extends \BaseController
282 282
       $domains = DB::table('outcomes')
283 283
         ->join('criterion_objective_outcome as cobo', 'cobo.outcome_id', '=', 'outcomes.id')
284 284
         ->join('criteria', 'criteria.id', '=', 'cobo.criterion_id')
285
-        ->join('program_criterion', 'criteria.id', '=', 'program_criterion.criterion_id')
286
-        ->join('courses', 'courses.program_id', '=', 'program_criterion.program_id')
287
-        ->where('program_criterion.program_id', $program->id)
285
+        ->join('program_criterion_objective_outcome', 'cobo.id', '=', 'program_criterion_objective_outcome.cri_obj_out_id')
286
+        ->join('courses', 'courses.program_id', '=', 'program_criterion_objective_outcome.program_id')
287
+        ->where('program_criterion_objective_outcome.program_id', $program->id)
288 288
         ->select('outcomes.name', 'outcomes.activation_date')
289 289
         ->distinct()
290 290
         ->orderBy('outcomes.name', 'asc')
@@ -306,9 +306,9 @@ class ProgramsController extends \BaseController
306 306
       $courses_used =  DB::table('outcomes')
307 307
         ->join('criterion_objective_outcome as cobo', 'cobo.outcome_id', '=', 'outcomes.id')
308 308
         ->join('criteria', 'criteria.id', '=', 'cobo.criterion_id')
309
-        ->join('program_criterion', 'criteria.id', '=', 'program_criterion.criterion_id')
310
-        ->join('courses', 'courses.program_id', '=', 'program_criterion.program_id')
311
-        ->where('program_criterion.program_id', $program->id)
309
+        ->join('program_criterion_objective_outcome', 'cobo.id', '=', 'program_criterion_objective_outcome.cri_obj_out_id')
310
+        ->join('courses', 'courses.program_id', '=', 'program_criterion_objective_outcome.program_id')
311
+        ->where('program_criterion_objective_outcome.program_id', $program->id)
312 312
         ->select('courses.number', 'outcomes.name as domain_name', 'courses.code')
313 313
         ->distinct()
314 314
         ->orderBy('courses.name', 'asc')
@@ -328,14 +328,14 @@ class ProgramsController extends \BaseController
328 328
       $transformative_actions = DB::table('outcomes')
329 329
         ->join('criterion_objective_outcome as cobo', 'cobo.outcome_id', '=', 'outcomes.id')
330 330
         ->join('criteria', 'criteria.id', '=', 'cobo.criterion_id')
331
-        ->join('program_criterion', 'criteria.id', '=', 'program_criterion.criterion_id')
332
-        ->join('courses', 'courses.program_id', '=', 'program_criterion.program_id')
331
+        ->join('program_criterion_objective_outcome', 'cobo.id', '=', 'program_criterion_objective_outcome.cri_obj_out_id')
332
+        ->join('courses', 'courses.program_id', '=', 'program_criterion_objective_outcome.program_id')
333 333
 
334 334
         ->join('activities', 'activities.course_id', '=', 'courses.id')
335 335
         ->join('activity_criterion', 'activity_criterion.activity_id', '=', 'activities.id')
336 336
         ->join('transformative_activity_criterion as taa', 'taa.activity_criterion_id', '=', 'activity_criterion.id')
337 337
         ->join('transformative_actions', 'transformative_actions.id', '=', 'taa.trans_action_id')
338
-        ->where('program_criterion.program_id', $program->id)
338
+        ->where('program_criterion_objective_outcome.program_id', $program->id)
339 339
         ->select('transformative_actions.description', 'outcomes.name as domain_name')
340 340
         ->distinct()
341 341
         ->orderBy('transformative_actions.description', 'asc')

+ 25
- 4
app/controllers/TemplatesController.php Zobrazit soubor

@@ -252,6 +252,8 @@ class TemplatesController extends \BaseController
252 252
 		// 			Log::info("aqui".(count($criteria)));
253 253
 		// 			Log::info(json_encode(count($criteria)));
254 254
 
255
+
256
+
255 257
 		$templates = Template::where('school_id', '=', $school_id_user)->orWhere('school_id', '=', NULL)
256 258
 			->orderBy('name', 'ASC')->get();
257 259
 		$criteria_ids = array();
@@ -274,6 +276,22 @@ class TemplatesController extends \BaseController
274 276
 		$templates_dentro = Template::whereNotIn('id', $templates_fuera_ids)
275 277
 			->orderBy('name', 'ASC')->get();
276 278
 
279
+		/*$templates_dentro = Template::join('template_criterion', 'template_criterion.template_id', '=', 'templates.id')
280
+			->join('criterion_objective_outcome as cobo', 'cobo.criterion_id', '=', 'template_criterion.criterion_id')
281
+			->where('objective_id', '<>', '0')
282
+
283
+			->where(function ($query) use ($school_id_user) {
284
+				$query->where('school_id', $school_id_user)
285
+					->orWhere('school_id', '=', NULL);
286
+			})
287
+
288
+			//			->orWhere('school_id', '=', NULL)
289
+
290
+			->orderBy('name', 'ASC')
291
+			->groupBy('templates.id')
292
+			->select("templates.*")
293
+			->get();*/
294
+
277 295
 		// 			if(!isset($templates_dentro))$templates_dentro=
278 296
 
279 297
 		// 			var_dump(json_encode($templates_dentro));
@@ -296,7 +314,7 @@ class TemplatesController extends \BaseController
296 314
 				return "NO pa";
297 315
 			}
298 316
 
299
-			$crit->all_objectives = Objective::join("criterion_objective_outcome", 'objectives.id', '=', 'criterion_objective_outcome.objective_id')
317
+			$crit->all_objectives = DB::table("objectives")->join("criterion_objective_outcome", 'objectives.id', '=', 'criterion_objective_outcome.objective_id')
300 318
 				->where('criterion_id', $crit->id)
301 319
 				->select('objectives.*')
302 320
 				->groupBy('objectives.id')
@@ -452,9 +470,12 @@ class TemplatesController extends \BaseController
452 470
 				->orderBy('position', 'ASC')
453 471
 				->get();
454 472
 
455
-			$temp_crit->program_ids = json_encode(DB::table('program_criterion')
456
-				->where('criterion_id', $temp_crit->id)
457
-				->lists('program_id'));
473
+			$temp_crit->program_ids = json_encode(DB::table('program_criterion_objective_outcome')
474
+				->join('criterion_objective_outcome', 'criterion_objective_outcome.id', '=', 'program_criterion_objective_outcome.cri_obj_out_id')
475
+				->where('criterion_objective_outcome.criterion_id', $temp_crit->id)
476
+				->select('program_criterion_objective_outcome.program_id')
477
+				->distinct()
478
+				->lists('program_criterion_objective_outcome.program_id'));
458 479
 
459 480
 			Log::info("ee" . json_encode($temp_crit->program_ids));
460 481
 

+ 88
- 2
app/controllers/ThreeYearPlanController.php Zobrazit soubor

@@ -321,8 +321,8 @@ class ThreeYearPlanController extends \BaseController
321 321
     $program_id = Input::get('program_id');
322 322
 
323 323
     // get program_id
324
-    $user_id = auth::user()->id;
325
-    Log::info(Input::all());
324
+    //$user_id = auth::user()->id;
325
+    //Log::info(Input::all());
326 326
 
327 327
     // get typ_program_id
328 328
     $result = DB::table('typ_program')
@@ -1070,4 +1070,90 @@ class ThreeYearPlanController extends \BaseController
1070 1070
       return $pdf->stream(basename($queryToPath->path_to_pdf));
1071 1071
   }
1072 1072
   */
1073
+
1074
+  ///////////////////
1075
+  //
1076
+  //Pair everything
1077
+  //
1078
+  ////////////////////
1079
+
1080
+  public function pairEveryObjective()
1081
+  {
1082
+    Log::info(Input::all());
1083
+    $selected_objectives = Input::get('selected_objectives');
1084
+    $typ_id = Input::get('typ_id');
1085
+    $program_id = Input::get('program_id');
1086
+    for ($i = 0; $i < count($selected_objectives); $i += 3) {
1087
+      Input::replace([
1088
+        'program_id' => $program_id,
1089
+        'new_objective_id' => $selected_objectives[$i + 2],
1090
+        'outcome_id' => $selected_objectives[$i],
1091
+        'semester_id' => $selected_objectives[$i + 1],
1092
+        'typ_id' => $typ_id,
1093
+        'previous_objective_id' => 'nothing_selected'
1094
+
1095
+
1096
+      ]);
1097
+      if ($this->section2_on_change() != 'update was succes')
1098
+        return 0;
1099
+    }
1100
+    return 200;
1101
+  }
1102
+
1103
+  public function pairEveryCourse()
1104
+  {
1105
+    Log::info(Input::all());
1106
+    $typ_id = Input::get('typ_id');
1107
+    $program_id = Input::get('program_id');
1108
+    $pairing_array = Input::get('pairing_array');
1109
+    $type_of_work = Input::get("type_of_work");
1110
+
1111
+    //$typ_id = Input::get('typ_id');
1112
+    //$outcome_id = Input::get('outcome_id');
1113
+    //$semester_id = Input::get('semester_id');
1114
+    //$objective_id = Input::get('objective_id');
1115
+    //$previous_course_id = Input::get('previous_course_id');
1116
+    //$new_course_id = Input::get('new_course_id');
1117
+
1118
+    // get program_id
1119
+    //$program_id = Input::get('program_id');
1120
+
1121
+
1122
+    if ($type_of_work == 'este_semestre') {
1123
+      foreach ($pairing_array as $course_array) {
1124
+        Input::replace([
1125
+          'outcome_id' => $course_array[0],
1126
+          'semester_id' => $course_array[1],
1127
+          'objective_id' => $course_array[2],
1128
+          'new_course_id' => $course_array[3],
1129
+          'typ_id' => $typ_id,
1130
+          'previous_course_id' => 'nothing_selected',
1131
+          'program_id' => $program_id,
1132
+
1133
+
1134
+        ]);
1135
+        if ($this->section3_on_change() != 'update succes?')
1136
+          return 0;
1137
+      }
1138
+    } else {
1139
+      foreach ($pairing_array as $semester_array) {
1140
+        foreach ($semester_array as $course_array) {
1141
+          Input::replace([
1142
+            'outcome_id' => $course_array[0],
1143
+            'semester_id' => $course_array[1],
1144
+            'objective_id' => $course_array[2],
1145
+            'new_course_id' => $course_array[3],
1146
+            'typ_id' => $typ_id,
1147
+            'previous_course_id' => 'nothing_selected',
1148
+            'program_id' => $program_id,
1149
+
1150
+
1151
+          ]);
1152
+          if ($this->section3_on_change() != 'update succes?')
1153
+            return 0;
1154
+        }
1155
+      }
1156
+    }
1157
+    return 200;
1158
+  }
1073 1159
 }

+ 2
- 2
app/models/Criterion.php Zobrazit soubor

@@ -39,13 +39,13 @@ class Criterion extends Eloquent
39 39
 	}
40 40
 
41 41
 
42
-	public function scopeFromProgram($query, $programs)
42
+	/*public function scopeFromProgram($query, $programs)
43 43
 	{
44 44
 
45 45
 		return $query->join('program_criterion', 'program_criterion.criterion_id', '=', 'criteria.id')
46 46
 			->whereIn("program_id", "programs")
47 47
 			->select('criteria.*');
48
-	}
48
+	}*/
49 49
 
50 50
 	/**
51 51
 	 * Return the program that the criterion belongs to

+ 9
- 0
app/routes.php Zobrazit soubor

@@ -246,6 +246,15 @@ Route::group(array('before' => 'auth|has_access'), function () {
246 246
     Route::get("downloadThreeYearPlanPDF/{path_id}", "ThreeYearPlanController@showHTML");
247 247
     Route::get("findHTMLlinksTYP/{path_id}", 'ThreeYearPlanController@findHTML');
248 248
 
249
+    /////////////////////////////////////////
250
+    // 
251
+    //  pairing everything in three year
252
+    //
253
+    /////////////////////////////////////////
254
+
255
+
256
+    Route::post('pairEveryObjective', "ThreeYearPlanController@pairEveryObjective");
257
+    Route::post('pairEveryCourse', "ThreeYearPlanController@pairEveryCourse");
249 258
     //View annual plans and report
250 259
 
251 260
     Route::get('{annual_report_or_plan}/show/{program_id}', "AnnualPlansController@annualPlansShow");

+ 211
- 3
app/views/global/view-three-year-plan.blade.php Zobrazit soubor

@@ -252,16 +252,19 @@
252 252
                                 <div class="select-course-selection-0" style="margin-left:30px;">
253 253
                                     <div class="objective-selector-0">
254 254
                                         <label for="">OBJECTIVE TEMP</label>
255
-                                        <select class="select-0" name="" style="width:100%;max-width:55%;">
255
+                                        <select class="select-0"  name="" style="width:100%;max-width:55%;">
256 256
                                             <option class="default-option" value="nothing_selected">Select a course</option>
257 257
                                         </select>
258 258
                                         <button class="btn btn-md btn-primary delete-selection-0"
259 259
                                             style="margin:5px; "><span></span> X</button>
260 260
                                     </div>
261 261
                                     <div class="clone-objective-course-select-0">
262
+                                        <div class = 'btn-group'>
262 263
                                         <button class="btn btn-md btn-secondary add-objective-course"
263 264
                                             style="margin:5px;"><span class="glyphicon glyphicon-plus"></span> Choose more
264 265
                                             Courses</button>
266
+                                        <button class = 'btn btn-md btn-secondary copy-objective-button'  onclick="showParingObjectiveModal(this)" style="margin:5px;">Copy Courses to each Objective</button>
267
+                                        </div>
265 268
                                     </div>
266 269
                                 </div>
267 270
                             </div>
@@ -326,9 +329,206 @@
326 329
                 </div>
327 330
             </div>
328 331
         </div>
332
+        <div id="pairingModal" class="modal fade" tabindex="-1" data-criterion-id="0">
333
+            <div class="modal-dialog">
334
+                <div class="modal-content">
335
+                    <div class="modal-header" >
336
+                        <h5 class="modal-title" id = "pairingModalTitle">Would you like to pair this </h5>
337
+                        <button type="button" class="close" data-dismiss="modal">&times;</button>
338
+                    </div>
339
+                    <div class="modal-body"  id = 'pairingModalBody'>
340
+                    
341
+
342
+                    </div>
343
+                    <div class="modal-footer">
344
+                       
345
+                        <button type="button" class="btn btn-secondary" data-dismiss="modal" >cancel</button>
346
+                        <button type="button" id='pairingModalSubmitButton' class="btn btn-primary" data-dismiss="modal" onclick = 'pairEverything()' >Ok</button>
347
+                        
348
+                    </div>
349
+                </div>
350
+            </div>
351
+        </div>
329 352
 
330 353
     </div>
354
+
331 355
     <script>
356
+
357
+        function fetchPairingArraysForCourses(select_semester_selector, out_sem_obj_course_array, course_ids, outcome_id){
358
+
359
+            dict_to_send = {};
360
+            //always the same
361
+            
362
+
363
+            
364
+
365
+            dict_to_send['este_semestre']=  returnArrayReadyPerSelector(select_semester_selector, outcome_id, course_ids);
366
+
367
+            //array_por_semestre = [];
368
+            dict_to_send['por_semestre'] =[];
369
+
370
+
371
+            select_semester_selector.parent().children('.semester-course-selection').each(function(ind, div){
372
+                dict_to_send['por_semestre'].push(returnArrayReadyPerSelector(div, outcome_id, course_ids));
373
+            });
374
+
375
+            //dict_to_send['por_semestre'] = array_por_semestre;
376
+            return JSON.stringify(dict_to_send) ;
377
+
378
+        }
379
+        function returnArrayReadyPerSelector(selector, outcome_id, course_ids){
380
+                array_to_return =[];
381
+                semester_id = $(selector).data('semester-id');
382
+                $(selector).children("div.select-course-selection").each(function(ind, div){
383
+                    var objective_id = $(div).data('objective-id');
384
+                    $.each(course_ids, function(ind, course_id){
385
+                        array_to_return.push([outcome_id,semester_id,objective_id, course_id ])
386
+                    })
387
+                });
388
+            
389
+                return array_to_return;
390
+            }
391
+  
392
+        
393
+
394
+        function showParingObjectiveModal(button){
395
+            modal = "#pairingModal"
396
+
397
+            
398
+
399
+ 
400
+            is_obj = false;
401
+            if($(button).html()=="Copy Courses to each Objective"){
402
+                $(modal+'Title').html("Would you like to pair these Courses to each Objective in this Outcome");
403
+                $(modal+'Body').html(
404
+                "<label> Please select if you would like to pair these courses on this semester only or on each semester of this Outcome</label>"
405
+                );
406
+                select_semester = $("<select>",{
407
+                    'class':'selectpicker form-control',
408
+                    'id':'selectPorSemestre'
409
+                });
410
+                option = $("<option>", {
411
+                    'value': 'por_semestre'
412
+                }).html("For each Semester and Objective in this Outcome")
413
+
414
+                select_semester.append(option);
415
+                option = $("<option>", {
416
+                    'value': 'este_semestre'
417
+                }).html("For each Objective in this Semester and Outcome");
418
+                select_semester.append(option);
419
+                
420
+                $(modal+'Body').append(select_semester);
421
+                $('.selectpicker').selectpicker('refresh');
422
+               
423
+                }
424
+            else{
425
+                $(modal+'Title').html("Would you like to pair these Objective to each Semester in this Outcome");
426
+                $(modal+'Body').html("This action will pair these Objectives to each Semester of this Outcome.<br> This action is reversable")
427
+
428
+                is_obj = true;
429
+
430
+            }
431
+            select_course_selector = $(button).parent().parent().parent();
432
+            objective_selectors= select_course_selector.find("div:not([style*='display: none'])");
433
+            selects = objective_selectors.find('select');
434
+            
435
+
436
+            array_to_send = [];
437
+
438
+            var semester_id;
439
+            var outcome_id;
440
+            var objectives_ids = [];
441
+            var course_ids = [];
442
+            $.each(selects, function(ind, select){
443
+                splited = $(select).val().split('-');
444
+                semester_id = splited[1];
445
+                outcome_id = splited[0];
446
+                objectives_ids.push(splited[2]);
447
+                if(!is_obj){
448
+                    course_ids.push(splited[3]);
449
+                }
450
+
451
+                array_to_send.push(splited);
452
+            })
453
+
454
+            if(!is_obj){
455
+
456
+                two_possible_arrays = fetchPairingArraysForCourses(select_course_selector.parent(), array_to_send, course_ids, outcome_id);
457
+
458
+
459
+            }
460
+
461
+            else{
462
+                whole_outcome_div = select_course_selector.parent().parent();
463
+            whole_outcome_div.children('div.semester-course-selection').each(function(ind, div){
464
+                if($(div).data('semester-id')== semester_id){
465
+                    return;
466
+                }
467
+                
468
+                    div_semester = $(div).data('semester-id');
469
+                $.each(objectives_ids, function(ind, obj){
470
+                    array_to_send.push([outcome_id, div_semester, obj]);
471
+                })
472
+                
473
+                
474
+            })
475
+
476
+            }
477
+
478
+            if($(button).html()=="Copy Courses to each Objective"){
479
+                $(modal+"SubmitButton").attr('onclick', 'pairEveryCourse('+two_possible_arrays+')');
480
+       
481
+            }
482
+            else{
483
+                $(modal+"SubmitButton").attr('onclick', 'pairEveryObjective(['+array_to_send.toString()+'])')
484
+       
485
+            }
486
+
487
+            
488
+
489
+
490
+            $(modal).modal('show');
491
+
492
+        }
493
+
494
+        function pairEveryCourse(two_possible_arrays){
495
+           // two_possible_arrays = JSON.parse(two_possible_arrays);
496
+
497
+            pair_array = two_possible_arrays[$('#selectPorSemestre').val()];
498
+
499
+            var typ_id = $('#table-cycles').data('typ-id');
500
+            $.post(
501
+                "{{URL::action('ThreeYearPlanController@pairEveryCourse')}}", {
502
+                    pairing_array:pair_array,
503
+                    typ_id:typ_id,
504
+                    program_id:{{$program_id}},
505
+                    type_of_work: $('#selectPorSemestre').val()
506
+                },
507
+                function(data){
508
+                    if(data==200)
509
+                    $(".go-to-3").trigger('click');
510
+                }
511
+            )
512
+        }
513
+        function pairEveryObjective(selected_objectives){
514
+
515
+            var typ_id = $('#table-cycles').data('typ-id');
516
+            $.post(
517
+                "{{URL::action('ThreeYearPlanController@pairEveryObjective')}}",
518
+                {
519
+                    selected_objectives:selected_objectives,
520
+                    typ_id: typ_id,
521
+                    program_id:{{$program_id}}
522
+                },
523
+                function(data){
524
+                    if(data ==200){
525
+                        $(".go-to-2").trigger('click');
526
+                    }
527
+                   
528
+
529
+                }
530
+            )
531
+        }
332 532
         $(document).ready(function() {
333 533
             // --------------------------------------------------------------------------
334 534
             // Page load
@@ -656,6 +856,7 @@
656 856
             window.scrollTo(0, 0);
657 857
             $(".panel-body").hide();
658 858
             $("#section2").show();
859
+            
659 860
         });
660 861
 
661 862
 
@@ -716,6 +917,7 @@
716 917
 
717 918
                             var select_area = $('.semester-course-selection-0').clone(true);
718 919
                             select_area.attr('class', 'semester-course-selection');
920
+                            select_area.attr('data-semester-id', semester_id);
719 921
                             select_area.attr('style', ' ');
720 922
                             select_area.find('.semester-label-course-selection-0').html(
721 923
                                 semester_name + "'s Objectives");
@@ -725,6 +927,8 @@
725 927
                             select_area.find('.add-objective-course').html(
726 928
                                 '<span class="glyphicon glyphicon-plus"></span> Choose more Objectives'
727 929
                             );
930
+                            select_area.find('.copy-objective-button').html('Copy Objectives to each Semester in Outcome');
931
+
728 932
 
729 933
                             if (semester.available_objectives.length != 0) {
730 934
                                 select_area.find('.objective-selector-0 label').hide();
@@ -807,16 +1011,17 @@
807 1011
 
808 1012
         // in section 2 and 3, add selects for choosing more objectives and courses, respectively
809 1013
         $('.add-objective-course').on('click', function(e) {
810
-            var new_select = $(this).parent().parent().find('.objective-selector-0').clone(true);
1014
+            var new_select = $(this).parent().parent().parent().find('.objective-selector-0').clone(true);
811 1015
             new_select.attr('class', 'objective-selector');
812 1016
             new_select.show();
813 1017
             $(this).parent().before(new_select);
1018
+            //$('.selectpicker').selectpicker('refresh')
814 1019
         });
815 1020
 
816 1021
 
817 1022
         // go to section 3
818 1023
         $('.go-to-3').on('click', function(e) {
819
-            window.scrollTo(0, 0);
1024
+            //window.scrollTo(0, 0);
820 1025
             $(".panel-body").hide();;
821 1026
             $("#section3").show();;
822 1027
 
@@ -853,6 +1058,7 @@
853 1058
 
854 1059
                             var select_area = $('.semester-course-selection-0').clone(true);
855 1060
                             select_area.attr('class', 'semester-course-selection');
1061
+                            select_area.attr('data-semester-id', semester_id);
856 1062
                             select_area.attr('style', ' ');
857 1063
                             select_area.find('.semester-label-course-selection-0').html(
858 1064
                                 semester_name);
@@ -864,6 +1070,7 @@
864 1070
                                 var new_select = select_area.find(
865 1071
                                     '.select-course-selection-0').clone(true);
866 1072
                                 new_select.attr('class', 'select-course-selection');
1073
+                                new_select.attr('data-objective-id', objective_id);
867 1074
                                 new_select.find('label').html('');
868 1075
                                 new_select.find('.objective-selector-0').before(
869 1076
                                     '<p>Objective: <b>' + objective_text +
@@ -945,6 +1152,7 @@
945 1152
                         $('.courses-section').append(area);
946 1153
 
947 1154
                     });
1155
+                    //$('.selectpicker').selectpicker('refresh');
948 1156
                     //$('.objective-selector').children('.delete-selection-0').css("margin:5px; display:block;");
949 1157
                 }
950 1158
             );