18 Commits

Autor SHA1 Mensagem Data
  onielm ce35d2425d Fixes for Transformative Action page 3 anos atrás
  onielm ad0fd1aea2 Migrations fixes 3 anos atrás
  onielm af26bd8660 Created Three Years Plan page 3 anos atrás
  onielm 46736f4660 Created Transformative Action page 3 anos atrás
  onielm b74b618bdd Merge branch 'gabriel_branch' into oniel-progreso 3 anos atrás
  onielm c9e797a3f2 Update .gitignore 3 anos atrás
  onielm 459ece87af para cambiar de branch 3 anos atrás
  Gabriel Santiago Plaza 10627d0e72 DONE 3 anos atrás
  Gabriel Santiago Plaza 64ad8ea783 Edit de backup 3 anos atrás
  Gabriel Santiago Plaza ebb1b8d6fa Merge branch 'adaptar_a_bd_nueva' into gabriel_branch 3 anos atrás
  Jose Quinones 52e7eeadda Quitando backupprovider 3 anos atrás
  Gabriel Santiago Plaza bdb822cb33 Merge branch 'adaptar_a_bd_nueva' into gabriel_branch 3 anos atrás
  Gabriel Santiago Plaza 685b1a7209 Merge branch 'oniel-progreso' into gabriel_branch 3 anos atrás
  Gabriel Santiago Plaza 5abdadd370 Los cambios mas recientes unidos con oniel 3 anos atrás
  Gabriel Santiago Plaza 7e6b827510 Create Documentacion.docx 3 anos atrás
  Gabriel Santiago Plaza 76cc344e47 Final Work 3 anos atrás
  Jose Quinones 3c621aaf63 todo hasta 2020-11-18 para adaptar a la nueva estructura de la bd. Falta manejar rubricas y assessment 4 anos atrás
  Gabriel Santiago Plaza fc142f4fe2 Gabriel, trabajo hasta 11/17 4 anos atrás
100 arquivos alterados com 12488 adições e 2407 exclusões
  1. 2
    0
      .gitignore
  2. BIN
      Documentacion.docx
  3. 8
    5
      app/config/app.php
  4. 6
    5
      app/config/database.php
  5. 73
    0
      app/config/packages/cornford/backup/config.php
  6. 172
    262
      app/controllers/ActivitiesController.php
  7. 273
    174
      app/controllers/AdministratorsController.php
  8. 76
    27
      app/controllers/CoursesController.php
  9. 442
    168
      app/controllers/CriteriaController.php
  10. 465
    0
      app/controllers/Objective2Controller.php
  11. 86
    0
      app/controllers/Objective_OutcomeController.php
  12. 336
    264
      app/controllers/OutcomesController.php
  13. 146
    23
      app/controllers/ProgramsController.php
  14. 70
    66
      app/controllers/RubricsController.php
  15. 555
    0
      app/controllers/ThreeYearPlanController.php
  16. 928
    0
      app/controllers/TransformativeActionsController.php
  17. 360
    358
      app/controllers/UsersController.php
  18. 12
    13
      app/database/migrations/2018_08_28_140328_remove_outcome_id_from_objectives_table.php
  19. 9
    10
      app/database/migrations/2020_04_04_005817_add_outcome_id_to_objectives_table.php
  20. 0
    43
      app/database/migrations/2020_04_22_122910_add_criteria_id_to_assessments_table.php
  21. 47
    0
      app/database/migrations/2020_10_04_142756_create_new_assessments_table.php
  22. 52
    0
      app/database/migrations/2020_10_05_124915_create_activity_criterion_table.php
  23. 35
    0
      app/database/migrations/2020_10_05_130252_add_max_score_num_scales_new_criteria_table.php
  24. 35
    0
      app/database/migrations/2020_10_05_142424_create_scales_table.php
  25. 47
    0
      app/database/migrations/2020_10_05_142912_create_criterion_scale_table.php
  26. 34
    0
      app/database/migrations/2020_10_05_232429_add_assessment_comments_to_activity_criterion.php
  27. 36
    0
      app/database/migrations/2020_10_09_131800_add_level_activation_date_to_outcomes.php
  28. 53
    0
      app/database/migrations/2020_10_16_190923_create_criterion_objective_outcome_table.php
  29. 57
    0
      app/database/migrations/2020_10_18_145108_create_outcome_performance_table.php
  30. 30
    0
      app/database/migrations/2020_10_29_122332_MakeOutcomeNullable.php
  31. 30
    0
      app/database/migrations/2020_10_29_195413_MakeObjectiveNullable.php
  32. 30
    0
      app/database/migrations/2020_10_29_224846_Make_criterion_objective_outcome_changeForeignKey.php
  33. 35
    0
      app/database/migrations/2020_11_06_011242_changeCriteriaObjOutcome.php
  34. 35
    0
      app/database/migrations/2020_12_04_111708_dropDescriptionInCriteria.php
  35. 44
    0
      app/database/migrations/2020_12_10_175517_createProgramCriterion2.php
  36. 34
    0
      app/database/migrations/2020_12_10_223135_addMinMaxInScales.php
  37. 47
    0
      app/database/migrations/2021_01_28_160558_ObjectiveProgramMigrate.php
  38. 33
    0
      app/database/migrations/2021_01_28_174905_fixObjectivesTable.php
  39. 33
    0
      app/database/migrations/2021_01_31_165057_fix_objectives_table_2.php
  40. 31
    0
      app/database/migrations/2021_01_31_171210_fix_criterion_scale.php
  41. 39
    0
      app/database/migrations/2021_02_16_142747_create_cycles_table.php
  42. 50
    0
      app/database/migrations/2021_02_16_142832_create_cycles_semesters_table.php
  43. 39
    0
      app/database/migrations/2021_02_17_205601_create_cycles_table.php
  44. 50
    0
      app/database/migrations/2021_02_17_205659_create_cycles_semesters_table.php
  45. 50
    0
      app/database/migrations/2021_02_17_205734_create_three_year_plans_table.php
  46. 48
    0
      app/database/migrations/2021_02_17_205809_create_typ_parts_table.php
  47. 63
    0
      app/database/migrations/2021_02_17_205850_create_typ_part_outcomes_table.php
  48. 33
    0
      app/database/migrations/2021_02_25_180526_three_year_plan.php
  49. 50
    0
      app/database/migrations/2021_02_25_181424_typ_semesters.php
  50. 43
    0
      app/database/migrations/2021_02_25_181544_typ_program.php
  51. 50
    0
      app/database/migrations/2021_02_25_181623_typ_semester_outcome.php
  52. 46
    0
      app/database/migrations/2021_02_25_181644_typ_semester_objectives.php
  53. 49
    0
      app/database/migrations/2021_02_25_181655_typ_semester_courses.php
  54. 51
    0
      app/database/migrations/2021_03_29_151147_create_Transformative_Actions.php
  55. 52
    0
      app/database/migrations/2021_03_29_151507_create_transformative_objective_program.php
  56. 51
    0
      app/database/migrations/2021_03_29_151542_create_annual_report_transformative.php
  57. 42
    0
      app/database/migrations/2021_03_29_154844_create_annual_plan_transformative.php
  58. 44
    0
      app/database/migrations/2021_04_25_194120_create_ta_course_table.php
  59. 30
    0
      app/database/migrations/emails/feedback-email-copy.blade.php
  60. 125
    0
      app/database/seeds/FillNewAssessmentActivityCriterion.php
  61. 94
    0
      app/database/seeds/FillNewCriterionRubric.php
  62. 59
    0
      app/database/seeds/FillScalesCriteria.php
  63. 43
    0
      app/database/unusedMigrations/2018_08_28_140328_remove_outcome_id_from_objectives_table.php
  64. 39
    0
      app/database/unusedMigrations/2020_04_04_005817_add_outcome_id_to_objectives_table.php
  65. 46
    0
      app/database/unusedMigrations/2020_10_04_141759_create_activity_criterion_table.php
  66. 52
    0
      app/database/unusedMigrations/2020_10_05_124915_create_activity_criterion_table.php
  67. 35
    0
      app/database/unusedMigrations/2020_10_05_130252_add_max_score_num_scales_new_criteria_table.php
  68. 35
    0
      app/database/unusedMigrations/2020_10_05_142424_create_scales_table.php
  69. 47
    0
      app/database/unusedMigrations/2020_10_05_142912_create_criterion_scale_table.php
  70. 34
    0
      app/database/unusedMigrations/2020_10_05_232429_add_assessment_comments_to_activity_criterion.php
  71. 36
    0
      app/database/unusedMigrations/2020_10_08_203557_create_new_criteria_table2.php
  72. 33
    0
      app/database/unusedMigrations/2020_10_08_215013_drop_objective_id_new_criteria.php
  73. 34
    0
      app/database/unusedMigrations/2020_10_09_085334_add_activities_rubric_id.php
  74. 35
    0
      app/database/unusedMigrations/2020_10_09_092810_drop_assessment_criteria.php
  75. 35
    0
      app/database/unusedMigrations/2020_10_09_094503_add_criterion_to_assessment.php
  76. 29
    0
      app/database/unusedMigrations/2020_10_09_095246_drop_foreign_assesment_criterion.php
  77. 36
    0
      app/database/unusedMigrations/2020_10_09_131800_add_level_activation_date_to_outcomes.php
  78. 30
    55
      app/filters.php
  79. 2
    1
      app/models/Activity.php
  80. 52
    0
      app/models/Course.php
  81. 56
    0
      app/models/Criterion.php
  82. 29
    26
      app/models/Objective.php
  83. 38
    0
      app/models/Objective_Outcome.php
  84. 315
    0
      app/models/Outcome.php
  85. 210
    0
      app/models/Program.php
  86. 17
    0
      app/models/Scale.php
  87. 13
    12
      app/models/User.php
  88. 178
    123
      app/routes.php
  89. 803
    0
      app/views/global/view-three-year-plan.blade.php
  90. 21
    19
      app/views/local/managers/admins/_navigation.blade.php
  91. 16
    1
      app/views/local/managers/admins/assessment_report.blade.php
  92. 1040
    266
      app/views/local/managers/admins/criteria.blade.php
  93. 101
    0
      app/views/local/managers/admins/learning-outcome_new.blade.php
  94. 90
    0
      app/views/local/managers/admins/learning-outcomes_new.blade.php
  95. 1044
    0
      app/views/local/managers/admins/new_criteria.blade.php
  96. 529
    0
      app/views/local/managers/admins/objectives.blade.php
  97. 471
    471
      app/views/local/managers/admins/overview.blade.php
  98. 891
    0
      app/views/local/managers/admins/transformativeAction.blade.php
  99. 18
    15
      app/views/local/managers/pCoords/_navigation.blade.php
  100. 0
    0
      app/views/local/managers/pCoords/criteria.blade.php

+ 2
- 0
.gitignore Ver arquivo

@@ -8,3 +8,5 @@ composer.lock
8 8
 Thumbs.db
9 9
 app/database/csv/*
10 10
 app/config/local/*
11
+app/config/app.php
12
+app/config/database.php

BIN
Documentacion.docx Ver arquivo


+ 8
- 5
app/config/app.php Ver arquivo

@@ -13,8 +13,9 @@ return array(
13 13
 	|
14 14
 	*/
15 15
 
16
-	'debug' => $_ENV['APP_DEBUG'] ?: false,
16
+	//'debug' => $_ENV['APP_DEBUG'] ?: false,
17 17
 
18
+	'debug' => true,
18 19
 	/*
19 20
 	|--------------------------------------------------------------------------
20 21
 	| Application URL
@@ -24,9 +25,9 @@ return array(
24 25
 	| the Artisan command line tool. You should set this to the root of
25 26
 	| your application so that it is used when running Artisan tasks.
26 27
 	|
27
-	*/
28
+	*/ //$_ENV['APP_URL'] ?:
28 29
 
29
-	'url' => $_ENV['APP_URL'] ?: 'http://localhost',
30
+	'url' =>  'http://localhost',
30 31
 
31 32
 	/*
32 33
 	|--------------------------------------------------------------------------
@@ -124,6 +125,7 @@ return array(
124 125
 		'Illuminate\Workbench\WorkbenchServiceProvider',
125 126
 		'Way\Generators\GeneratorsServiceProvider',
126 127
 		'Barryvdh\DomPDF\ServiceProvider',
128
+		// 'Cornford\Backup\Providers\BackupServiceProvider',
127 129
 		'Zizaco\Entrust\EntrustServiceProvider'
128 130
 
129 131
 	),
@@ -139,7 +141,7 @@ return array(
139 141
 	|
140 142
 	*/
141 143
 
142
-	'manifest' => storage_path().'/meta',
144
+	'manifest' => storage_path() . '/meta',
143 145
 
144 146
 	/*
145 147
 	|--------------------------------------------------------------------------
@@ -157,6 +159,7 @@ return array(
157 159
 		'App'               => 'Illuminate\Support\Facades\App',
158 160
 		'Artisan'           => 'Illuminate\Support\Facades\Artisan',
159 161
 		'Auth'              => 'Illuminate\Support\Facades\Auth',
162
+		//'Backup'	        => 'Cornford\Backup\Facades\Backup',
160 163
 		'Blade'             => 'Illuminate\Support\Facades\Blade',
161 164
 		'Cache'             => 'Illuminate\Support\Facades\Cache',
162 165
 		'ClassLoader'       => 'Illuminate\Support\ClassLoader',
@@ -193,7 +196,7 @@ return array(
193 196
 		'Validator'         => 'Illuminate\Support\Facades\Validator',
194 197
 		'View'              => 'Illuminate\Support\Facades\View',
195 198
 		'PDF'				=> 'Barryvdh\DomPDF\Facade',
196
-        'Entrust' => 'Zizaco\Entrust\EntrustFacade'
199
+		'Entrust' => 'Zizaco\Entrust\EntrustFacade'
197 200
 
198 201
 
199 202
 	),

+ 6
- 5
app/config/database.php Ver arquivo

@@ -47,15 +47,16 @@ return array(
47 47
 	'connections' => array(
48 48
 
49 49
 		'mysql' => array(
50
+
50 51
 			'driver'    => 'mysql',
51
-			'host'      => $_ENV['MYSQL_HOST'] ?: 'localhost',
52
-			'database'  => $_ENV['MYSQL_DATABASE'] ?: 'laravel',
53
-			'username'  => $_ENV['MYSQL_USERNAME'] ?: 'root',
54
-			'password'  => $_ENV['MYSQL_PASSWORD'] ?: '',
52
+			'host'      =>  '127.0.0.1',
53
+			'database'  =>  'trabajoolas5',
54
+			'username'  =>  'root',
55
+			'password'  =>  '',
55 56
 			'charset'   => 'utf8',
56 57
 			'collation' => 'utf8_unicode_ci',
57 58
 			'prefix'    => '',
58
-            'engine'    => 'InnoDB',
59
+			'engine'    => 'InnoDB',
59 60
 		),
60 61
 	),
61 62
 

+ 73
- 0
app/config/packages/cornford/backup/config.php Ver arquivo

@@ -0,0 +1,73 @@
1
+<?php
2
+
3
+return array(
4
+
5
+	/*
6
+	|--------------------------------------------------------------------------
7
+	| Enable Backup
8
+	|--------------------------------------------------------------------------
9
+	|
10
+	| Enable database backup.
11
+	|
12
+	*/
13
+	'enabled' => true,
14
+
15
+	/*
16
+	|--------------------------------------------------------------------------
17
+	| Path
18
+	|--------------------------------------------------------------------------
19
+	|
20
+	| A database backup path, absolute path, or path relative from public
21
+	| directory, a trailing slash is required.
22
+	|
23
+	*/
24
+	'path' => '../app/storage/backup/',
25
+
26
+	/*
27
+	|--------------------------------------------------------------------------
28
+	| Filename
29
+	|--------------------------------------------------------------------------
30
+	|
31
+	| A database export filename to use when exporting databases.
32
+	|
33
+	*/
34
+	'filename' => 'backup-' . date('Ymd-His'),
35
+
36
+	/*
37
+	|--------------------------------------------------------------------------
38
+	| Enable Compression
39
+	|--------------------------------------------------------------------------
40
+	|
41
+	| Enable backup compression using gzip. Requires gzencode/gzdecode.
42
+	|
43
+	*/
44
+	'compress' => true,
45
+
46
+	/*
47
+	|--------------------------------------------------------------------------
48
+	| Database Engine Processors
49
+	|--------------------------------------------------------------------------
50
+	|
51
+	| Set the database engines processor location, trailing slash is required.
52
+	|
53
+	*/
54
+	'processors' => array(
55
+		'mysql' => array(
56
+			'export' => '/usr/bin/',
57
+			'restore' => '/usr/bin/'
58
+		),
59
+		'pqsql' => array(
60
+			'export' => '/usr/bin/',
61
+			'restore' => '/usr/bin/'
62
+		),
63
+		'sqlite' => array(
64
+			'export' => null,
65
+			'restore' => null
66
+		),
67
+		'sqlsrv' => array(
68
+			'export' => '/usr/bin/',
69
+			'restore' => '/usr/bin/'
70
+		),
71
+	),
72
+
73
+);

+ 172
- 262
app/controllers/ActivitiesController.php Ver arquivo

@@ -2,7 +2,8 @@
2 2
 
3 3
 use Illuminate\Database\Eloquent\Collection;
4 4
 
5
-class ActivitiesController extends \BaseController {
5
+class ActivitiesController extends \BaseController
6
+{
6 7
 
7 8
     /**
8 9
      * Save a new activity
@@ -13,55 +14,51 @@ class ActivitiesController extends \BaseController {
13 14
     public function create($id)
14 15
     {
15 16
         /** Validation rules */
17
+
16 18
         $validator = Validator::make(
17 19
             array(
18 20
                 'name' => Input::get('name'),
19 21
                 'description' => Input::get('description')
20 22
             ),
21 23
             array(
22
-                'name' => 'required|unique:activities,course_id,'.$id,
24
+                'name' => 'required|unique:activities,course_id,' . $id,
23 25
                 'description' => 'required|min:10'
24 26
             )
25 27
         );
26 28
 
29
+
27 30
         /** If validation fails */
28
-        if ($validator->fails())
29
-        {
31
+        if ($validator->fails()) {
30 32
             /** Prepare error message */
31 33
             $message = 'Error(s) creating a new Activity<ul>';
32 34
 
33
-            foreach ($validator->messages()->all('<li>:message</li>') as $validationError)
34
-            {
35
-                $message.=$validationError;
35
+            foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
36
+                $message .= $validationError;
36 37
             }
37 38
 
38
-            $message.='</ul>';
39
+            $message .= '</ul>';
39 40
 
40 41
             /** Send error message and old data */
41 42
             Session::flash('status', 'danger');
42 43
             Session::flash('message', $message);
43 44
             return Redirect::back()->withInput();
44
-        }
45
-        else
46
-        {
45
+        } else {
47 46
             /** Instantiate new activity */
48 47
             $activity = new Activity;
49
-            $activity->name= Input::get('name');
48
+            $activity->name = Input::get('name');
50 49
             $activity->description = Input::get('description');
51 50
             $activity->course_id = $id;
52 51
             $activity->date = date('Y-m-d');
53 52
 
54 53
             /** If activity is saved, send success message */
55
-            if($activity->save())
56
-            {
54
+            if ($activity->save()) {
57 55
                 Session::flash('status', 'success');
58 56
                 Session::flash('message', 'Activity created.');
59 57
                 return Redirect::action('ActivitiesController@show', array($activity->id));
60 58
             }
61 59
 
62 60
             /** If saving fails, send error message and old data */
63
-            else
64
-            {
61
+            else {
65 62
                 Session::flash('status', 'warning');
66 63
                 Session::flash('message', 'Error adding Activity. Please try again later.');
67 64
                 return Redirect::back()->withInput();
@@ -76,24 +73,25 @@ class ActivitiesController extends \BaseController {
76 73
         $instruments = Rubric::all();
77 74
         $courses = Course::where('user_id', Auth::user()->id)->get();
78 75
         $outcomes = Outcome::with('objectives')->get();
79
-//        var_dump($outcomes[0]->objectives);
76
+        //        var_dump($outcomes[0]->objectives);
80 77
         $objectives_by_outcome = Collection::make([]);
81
-        $outcomes->each(function($outcome) use (&$objectives_by_outcome) {
82
-//            var_dump($outcome->objectives);
78
+        $outcomes->each(function ($outcome) use (&$objectives_by_outcome) {
79
+            //            var_dump($outcome->objectives);
83 80
             $objectives_by_outcome->put($outcome->id, $outcome->objectives);
84
-//            var_dump($objectives);
81
+            //            var_dump($objectives);
85 82
         });
86 83
         $criteria_by_objective = Collection::make([]);
87
-        $objectives_by_outcome->each(function($objectives) use (&$criteria_by_objective) {
88
-            $objectives->each(function($objective) use (&$criteria_by_objective) {
84
+        $objectives_by_outcome->each(function ($objectives) use (&$criteria_by_objective) {
85
+            $objectives->each(function ($objective) use (&$criteria_by_objective) {
89 86
                 $criteria_by_objective->put($objective->id, $objective->criteria);
90 87
             });
91 88
         });
92 89
         $transforming_actions = [];
93 90
         $course = Course::find($course_id);
94
-//        var_dump($criteria_by_objective);
95
-//        return $objectives->toJson();
96
-        return View::make('local.managers.admins.new-activity-create',
91
+        //        var_dump($criteria_by_objective);
92
+        //        return $objectives->toJson();
93
+        return View::make(
94
+            'local.managers.admins.new-activity-create',
97 95
             compact(
98 96
                 'title',
99 97
                 'course',
@@ -116,27 +114,25 @@ class ActivitiesController extends \BaseController {
116 114
         $activity = Activity::find($id);
117 115
 
118 116
         // If activity does not exist, display 404
119
-        if(!$activity)
117
+        if (!$activity)
120 118
             App::abort('404');
121 119
 
122 120
         // Get activity's course
123 121
         $course = Course::where('id', '=', $activity->course_id)->firstOrFail();
124 122
 
125 123
         // If activity does not belong to the requesting user, display 403
126
-        if ($course->user_id != Auth::id())
124
+        if ($course->user_id != Auth::id() and Auth::user()->role==4)
127 125
             App::abort('403', 'Access Forbidden');
128 126
 
129 127
         // Get active semesters
130
-        $active_semesters= array();
128
+        $active_semesters = array();
131 129
         $active_semesters_collection = Semester::select('id')->where('is_visible', 1)->where('start', '<=', date('Y-m-d H:i:s'))->where('end', '>=', date('Y-m-d H:i:s'))->get();
132
-        foreach ($active_semesters_collection as $active_semester)
133
-        {
134
-            $active_semesters[]=$active_semester->id;
130
+        foreach ($active_semesters_collection as $active_semester) {
131
+            $active_semesters[] = $active_semester->id;
135 132
         }
136
-            // Added the function htmlspecialchars to activity name string because it was corrupting Jquery code while using quotes on page rendering. - Carlos R Caraballo 1/18/2019
137
-        $title = $course->code.$course->number.'-'.$course->section.': '.htmlspecialchars($activity->name, ENT_QUOTES).' <span class="small attention">('.$course->semester->code.')</span>';
138
-        //$outcomes = Outcome::orderBy('name', 'asc')->get();
139
-        $outcomes = Outcome::active();
133
+        // Added the function htmlspecialchars to activity name string because it was corrupting Jquery code while using quotes on page rendering. - Carlos R Caraballo 1/18/2019
134
+        $title = $course->code . $course->number . '-' . $course->section . ': ' . htmlspecialchars($activity->name, ENT_QUOTES) . ' <span class="small attention">(' . $course->semester->code . ')</span>';
135
+        $outcomes = Outcome::orderBy('name', 'asc')->get();
140 136
         $outcomes_achieved = json_decode($activity->outcomes_achieved, true);
141 137
         $outcomes_attempted = json_decode($activity->outcomes_attempted, true);
142 138
 
@@ -149,7 +145,7 @@ class ActivitiesController extends \BaseController {
149 145
         $activity = Activity::find($id);
150 146
 
151 147
         // If activity does not exist, display 404
152
-        if(!$activity)
148
+        if (!$activity)
153 149
             App::abort('404');
154 150
 
155 151
         // Get activity's course
@@ -167,12 +163,11 @@ class ActivitiesController extends \BaseController {
167 163
         $rubric_contents = json_decode($rubric->contents);
168 164
 
169 165
         // Get results
170
-        $assessments = DB::table('assessments')->join('students', 'assessments.student_id','=','students.id')->where('activity_id', '=', $activity->id)->orderBy('assessments.id', 'asc')->get();
166
+        $assessments = DB::table('assessments')->join('students', 'assessments.student_id', '=', 'students.id')->where('activity_id', '=', $activity->id)->orderBy('assessments.id', 'asc')->get();
171 167
 
172 168
         // Decode the scores (blade workaround)
173 169
         $scores_array = array();
174
-        foreach ($assessments as $index=>$assessment)
175
-        {
170
+        foreach ($assessments as $index => $assessment) {
176 171
             $scores_array[$assessment->id] = json_decode($assessment->scores, true);
177 172
         }
178 173
 
@@ -181,12 +176,9 @@ class ActivitiesController extends \BaseController {
181 176
 
182 177
     public function saveAssessment()
183 178
     {
184
-        try
185
-        {
186
-            $exception = DB::transaction(function()
187
-            {
188
-                DB::transaction(function()
189
-                {
179
+        try {
180
+            $exception = DB::transaction(function () {
181
+                DB::transaction(function () {
190 182
                     // Student assessment data
191 183
                     $student_data = json_decode(Input::get('student_scores'));
192 184
 
@@ -198,51 +190,42 @@ class ActivitiesController extends \BaseController {
198 190
                     $activity = Activity::find(Input::get('activity_id'));
199 191
 
200 192
                     // Create or update student scores
201
-                    if($activity->outcomes_attempted==NULL)
202
-                    {
193
+                    if ($activity->outcomes_attempted == NULL) {
203 194
                         // For each student, save her/his assessment in the db
204
-                        foreach ($student_data as $single_student_data)
205
-                        {
195
+                        foreach ($student_data as $single_student_data) {
206 196
                             // Find student by id
207 197
                             $student = Student::find($single_student_data->student_id);
208 198
 
209 199
                             $comments = trim($single_student_data->comments);
210
-                            if($comments=='')
211
-                            {
200
+                            if ($comments == '') {
212 201
                                 $comments = NULL;
213 202
                             }
214 203
 
215 204
                             // Add the assessment to the pivot table
216 205
                             $student->assessed_activities()->attach($activity->id, array(
217 206
                                 'scores' => json_encode($single_student_data->scores),
218
-                                'percentage'=>$single_student_data->percentage,
207
+                                'percentage' => $single_student_data->percentage,
219 208
                                 'comments' => $single_student_data->comments
220 209
                             ));
221 210
                         }
222
-                    }
223
-                    else
224
-                    {
211
+                    } else {
225 212
                         // For each student, save her/his assessment in the db
226
-                        foreach ($student_data as $single_student_data)
227
-                        {
213
+                        foreach ($student_data as $single_student_data) {
228 214
                             // Find student by id
229 215
                             $student = Student::find($single_student_data->student_id);
230 216
 
231 217
                             $comments = trim($single_student_data->comments);
232
-                            if($comments=='')
233
-                            {
218
+                            if ($comments == '') {
234 219
                                 $comments = NULL;
235 220
                             }
236 221
 
237 222
                             // Update the assessment in the pivot table
238 223
                             $student->assessed_activities()->updateExistingPivot($activity->id, array(
239 224
                                 'scores' => json_encode($single_student_data->scores),
240
-                                'percentage'=>$single_student_data->percentage,
225
+                                'percentage' => $single_student_data->percentage,
241 226
                                 'comments' => $single_student_data->comments
242 227
                             ));
243
-
244 228
                         }
245
-
246 229
                     }
247 230
 
248 231
 
@@ -256,43 +239,37 @@ class ActivitiesController extends \BaseController {
256 239
                     $course_outcomes_attempted = NULL;
257 240
                     $course_outcomes_achieved = NULL;
258 241
 
259
-                    if($course->outcomes_attempted==NULL)
260
-                    {
242
+                    if ($course->outcomes_attempted == NULL) {
261 243
                         $course_outcomes_attempted = array_fill(1, $outcomeCount, 0);
262 244
                         $course_outcomes_achieved = array_fill(1, $outcomeCount, 0);
263
-                    }
264
-                    else
265
-                    {
245
+                    } else {
266 246
                         // the second argument is necessary to convert it into an array
267 247
                         $course_outcomes_attempted = json_decode($course->outcomes_attempted, true);
268 248
                         $course_outcomes_achieved = json_decode($course->outcomes_achieved, true);
269 249
                     }
270 250
 
271 251
 
272
-                    foreach($criteria_achievement as $criterion_id=>$criterion_achieved)
273
-                    {
252
+                    foreach ($criteria_achievement as $criterion_id => $criterion_achieved) {
274 253
                         // Find corresponding learning outcome
275 254
                         $criterion = Criterion::withTrashed()->find($criterion_id);
276 255
                         $outcome = Outcome::find($criterion->outcome_id);
277 256
 
278 257
                         // If criterion is achieved (1), add 1 to all arrays
279
-                        if($criterion_achieved===1)
280
-                        {
281
-                            $outcomes_attempted[$outcome->id]+=1;
282
-                            $outcomes_achieved[$outcome->id]+=1;
283
-                            $course_outcomes_attempted[$outcome->id]+=1;
284
-                            $course_outcomes_achieved[$outcome->id]+=1;
258
+                        if ($criterion_achieved === 1) {
259
+                            $outcomes_attempted[$outcome->id] += 1;
260
+                            $outcomes_achieved[$outcome->id] += 1;
261
+                            $course_outcomes_attempted[$outcome->id] += 1;
262
+                            $course_outcomes_achieved[$outcome->id] += 1;
285 263
                         }
286 264
                         // Else if it's 0, only add to the attempted outcomes arrays
287
-                        elseif($criterion_achieved===0)
288
-                        {
289
-                            $outcomes_attempted[$outcome->id]+=1;
290
-                            $course_outcomes_attempted[$outcome->id]+=1;
265
+                        elseif ($criterion_achieved === 0) {
266
+                            $outcomes_attempted[$outcome->id] += 1;
267
+                            $course_outcomes_attempted[$outcome->id] += 1;
291 268
                         }
292 269
                     }
293 270
 
294 271
                     // If all values are 0, throw exception
295
-                    if(count(array_unique($outcomes_attempted))==1 && $outcomes_attempted[1]==0)
272
+                    if (count(array_unique($outcomes_attempted)) == 1 && $outcomes_attempted[1] == 0)
296 273
                         throw new Exception("Error Processing Request", 1);
297 274
 
298 275
 
@@ -305,18 +282,14 @@ class ActivitiesController extends \BaseController {
305 282
 
306 283
 
307 284
                     // Publish results if not a draft. That is, update the activity's course.
308
-                    if(Input::get('draft')==false)
309
-                    {
285
+                    if (Input::get('draft') == false) {
310 286
                         // Update course
311 287
                         $course->outcomes_achieved = json_encode($course_outcomes_achieved);
312 288
                         $course->outcomes_attempted = json_encode($course_outcomes_attempted);
313 289
                         $course->save();
314 290
 
315 291
                         $activity->draft = false;
316
-
317
-                    }
318
-                    else
319
-                    {
292
+                    } else {
320 293
                         // Set draft to true
321 294
                         $activity->draft = true;
322 295
                     }
@@ -334,18 +307,15 @@ class ActivitiesController extends \BaseController {
334 307
 
335 308
                     // Check if any assessed activities remain
336 309
                     $remainingAssessed = false;
337
-                    foreach ($activities as $activity1)
338
-                    {
339
-                        if($activity1->outcomes_attempted!=NULL)
340
-                        {
341
-                            $remainingAssessed =true;
310
+                    foreach ($activities as $activity1) {
311
+                        if ($activity1->outcomes_attempted != NULL) {
312
+                            $remainingAssessed = true;
342 313
                             break;
343 314
                         }
344 315
                     }
345 316
 
346 317
                     //If there are still evaluated activities in the course, recalculate course outcomes
347
-                    if(count($activities) && $remainingAssessed)
348
-                    {
318
+                    if (count($activities) && $remainingAssessed) {
349 319
                         $outcomeCount = Outcome::all()->count();
350 320
 
351 321
                         // Variables to hold recalculated outcomes for the course
@@ -353,29 +323,24 @@ class ActivitiesController extends \BaseController {
353 323
                         $course_outcomes_achieved = array_fill(1, $outcomeCount, 0);
354 324
 
355 325
                         // For each activity
356
-                        foreach ($activities as $activity2)
357
-                        {
326
+                        foreach ($activities as $activity2) {
358 327
                             // If activity has been assessed
359
-                            if($activity2->outcomes_attempted!=NULL)
360
-                            {
328
+                            if ($activity2->outcomes_attempted != NULL) {
361 329
                                 // Get the achieved criteria
362 330
                                 $criteria_achievement = json_decode($activity2->criteria_achieved, true);
363
-                                foreach($criteria_achievement as $criterion_id=>$criterion_achieved)
364
-                                {
331
+                                foreach ($criteria_achievement as $criterion_id => $criterion_achieved) {
365 332
                                     // Find corresponding learning outcome;
366 333
                                     $criterion = Criterion::withTrashed()->find($criterion_id);
367 334
                                     $outcome = Outcome::find($criterion->outcome_id);
368 335
 
369 336
                                     // If criterion is achieved (1), add 1 to both arrays
370
-                                    if($criterion_achieved === 1)
371
-                                    {
372
-                                        $course_outcomes_attempted[$outcome->id]+=1;
373
-                                        $course_outcomes_achieved[$outcome->id]+=1;
337
+                                    if ($criterion_achieved === 1) {
338
+                                        $course_outcomes_attempted[$outcome->id] += 1;
339
+                                        $course_outcomes_achieved[$outcome->id] += 1;
374 340
                                     }
375 341
                                     // Else, only add to the attempted outcomes arrays
376
-                                    elseif($criterion_achieved === 0)
377
-                                    {
378
-                                        $course_outcomes_attempted[$outcome->id]+=1;
342
+                                    elseif ($criterion_achieved === 0) {
343
+                                        $course_outcomes_attempted[$outcome->id] += 1;
379 344
                                     }
380 345
                                 }
381 346
                             }
@@ -383,54 +348,46 @@ class ActivitiesController extends \BaseController {
383 348
 
384 349
                         // Update course
385 350
                         DB::table('courses')
386
-                        ->where('id', $course->id)
387
-                        ->update(array(
388
-                            'outcomes_attempted'=> json_encode($course_outcomes_attempted),
389
-                            'outcomes_achieved'=> json_encode($course_outcomes_achieved),
390
-                            'updated_at' => date('Y-m-d H:i:s'))
391
-                        );
351
+                            ->where('id', $course->id)
352
+                            ->update(array(
353
+                                'outcomes_attempted' => json_encode($course_outcomes_attempted),
354
+                                'outcomes_achieved' => json_encode($course_outcomes_achieved),
355
+                                'updated_at' => date('Y-m-d H:i:s')
356
+                            ));
392 357
                     }
393 358
                     // Otherwise, set them all to NULL
394
-                    else
395
-                    {
359
+                    else {
396 360
                         DB::table('courses')
397
-                        ->where('id', $course->id)
398
-                        ->update(array(
399
-                            'outcomes_attempted'=> NULL,
400
-                            'outcomes_achieved'=> NULL,
401
-                            'updated_at' => date('Y-m-d H:i:s'))
402
-                        );
361
+                            ->where('id', $course->id)
362
+                            ->update(array(
363
+                                'outcomes_attempted' => NULL,
364
+                                'outcomes_achieved' => NULL,
365
+                                'updated_at' => date('Y-m-d H:i:s')
366
+                            ));
403 367
                     }
404
-
405 368
                 });
406 369
             });
407 370
 
408
-            if(is_null($exception))
409
-            {
371
+            if (is_null($exception)) {
410 372
                 Session::flash('status', 'success');
411 373
                 Session::flash('message', 'Assessment Saved. To add transforming actions click "Transforming Actions".');
412 374
                 return action('ActivitiesController@show', array(Input::get('activity_id')));
413 375
             }
414
-
415
-        }
416
-        catch(Exception $e)
417
-        {
418
-            Log::info('e:'.$e);
376
+        } catch (Exception $e) {
377
+            Log::info('e:' . $e);
378
+            echo $e->getMessage();
419 379
             Session::flash('status', 'danger');
420 380
             Session::flash('message', 'Error saving assessment. Try again later.');
421 381
 
422 382
             return action('ActivitiesController@show', array(Input::get('activity_id')));
423
-
424 383
         }
425 384
     }
426 385
 
427 386
     public function deleteAssessment()
428 387
     {
429 388
 
430
-        try
431
-        {
432
-            $exception = DB::transaction(function()
433
-            {
389
+        try {
390
+            $exception = DB::transaction(function () {
434 391
                 $activity = DB::table('activities')->where('id', Input::get('id'))->first();
435 392
 
436 393
                 $course = DB::table('courses')->where('id', $activity->course_id)->first();
@@ -441,14 +398,14 @@ class ActivitiesController extends \BaseController {
441 398
                     ->where('id', Input::get('id'))
442 399
                     ->update(array(
443 400
                         'draft' => 0,
444
-                        'outcomes_attempted'=> NULL,
445
-                        'outcomes_achieved'=> NULL,
446
-                        'criteria_achieved'=> NULL,
447
-                        'transforming_actions'=> NULL,
448
-                        'assessment_comments'=> NULL,
449
-                        'criteria_achieved_percentage'=> NULL,
450
-                        'updated_at' => date('Y-m-d H:i:s'))
451
-                    );
401
+                        'outcomes_attempted' => NULL,
402
+                        'outcomes_achieved' => NULL,
403
+                        'criteria_achieved' => NULL,
404
+                        'transforming_actions' => NULL,
405
+                        'assessment_comments' => NULL,
406
+                        'criteria_achieved_percentage' => NULL,
407
+                        'updated_at' => date('Y-m-d H:i:s')
408
+                    ));
452 409
 
453 410
                 // Delete students score
454 411
                 DB::table('assessments')->where('activity_id', $activity->id)->delete();
@@ -462,18 +419,15 @@ class ActivitiesController extends \BaseController {
462 419
 
463 420
                 // Check if any assessed activties remain
464 421
                 $remainingAssessed = false;
465
-                foreach ($activities as $activity)
466
-                {
467
-                    if($activity->outcomes_attempted!=NULL)
468
-                    {
469
-                        $remainingAssessed =true;
422
+                foreach ($activities as $activity) {
423
+                    if ($activity->outcomes_attempted != NULL) {
424
+                        $remainingAssessed = true;
470 425
                         break;
471 426
                     }
472 427
                 }
473 428
 
474 429
                 //If there are still evaluated activities in the course, recalculate course outcomes
475
-                if(count($activities) && $remainingAssessed)
476
-                {
430
+                if (count($activities) && $remainingAssessed) {
477 431
                     $outcomeCount = Outcome::all()->count();
478 432
 
479 433
                     // Variables to hold recalculated outcomes for the course
@@ -481,29 +435,24 @@ class ActivitiesController extends \BaseController {
481 435
                     $course_outcomes_achieved = array_fill(1, $outcomeCount, 0);
482 436
 
483 437
                     // For each activity
484
-                    foreach ($activities as $activity)
485
-                    {
438
+                    foreach ($activities as $activity) {
486 439
                         // If activity has been assessed
487
-                        if($activity->outcomes_attempted!=NULL)
488
-                        {
440
+                        if ($activity->outcomes_attempted != NULL) {
489 441
                             // Get the achieved criteria
490 442
                             $criteria_achievement = json_decode($activity->criteria_achieved, true);
491
-                            foreach($criteria_achievement as $criterion_id=>$criterion_achieved)
492
-                            {
443
+                            foreach ($criteria_achievement as $criterion_id => $criterion_achieved) {
493 444
                                 // Find corresponding learning outcome;
494 445
                                 $criterion = Criterion::withTrashed()->find($criterion_id);
495 446
                                 $outcome = Outcome::find($criterion->outcome_id);
496 447
 
497 448
                                 // If criterion is achieved (1), add 1 to both arrays
498
-                                if($criterion_achieved === 1)
499
-                                {
500
-                                    $course_outcomes_attempted[$outcome->id]+=1;
501
-                                    $course_outcomes_achieved[$outcome->id]+=1;
449
+                                if ($criterion_achieved === 1) {
450
+                                    $course_outcomes_attempted[$outcome->id] += 1;
451
+                                    $course_outcomes_achieved[$outcome->id] += 1;
502 452
                                 }
503 453
                                 // Else, only add to the attempted outcomes arrays
504
-                                elseif($criterion_achieved === 0)
505
-                                {
506
-                                    $course_outcomes_attempted[$outcome->id]+=1;
454
+                                elseif ($criterion_achieved === 0) {
455
+                                    $course_outcomes_attempted[$outcome->id] += 1;
507 456
                                 }
508 457
                             }
509 458
                         }
@@ -511,36 +460,31 @@ class ActivitiesController extends \BaseController {
511 460
 
512 461
                     // Update course
513 462
                     DB::table('courses')
514
-                    ->where('id', $course->id)
515
-                    ->update(array(
516
-                        'outcomes_attempted'=> json_encode($course_outcomes_attempted),
517
-                        'outcomes_achieved'=> json_encode($course_outcomes_achieved),
518
-                        'updated_at' => date('Y-m-d H:i:s'))
519
-                    );
463
+                        ->where('id', $course->id)
464
+                        ->update(array(
465
+                            'outcomes_attempted' => json_encode($course_outcomes_attempted),
466
+                            'outcomes_achieved' => json_encode($course_outcomes_achieved),
467
+                            'updated_at' => date('Y-m-d H:i:s')
468
+                        ));
520 469
                 }
521 470
                 // Otherwise, set them all to NULL
522
-                else
523
-                {
471
+                else {
524 472
                     DB::table('courses')
525
-                    ->where('id', $course->id)
526
-                    ->update(array(
527
-                        'outcomes_attempted'=> NULL,
528
-                        'outcomes_achieved'=> NULL,
529
-                        'updated_at' => date('Y-m-d H:i:s'))
530
-                    );
473
+                        ->where('id', $course->id)
474
+                        ->update(array(
475
+                            'outcomes_attempted' => NULL,
476
+                            'outcomes_achieved' => NULL,
477
+                            'updated_at' => date('Y-m-d H:i:s')
478
+                        ));
531 479
                 }
532 480
             });
533 481
 
534
-            if(is_null($exception))
535
-            {
482
+            if (is_null($exception)) {
536 483
                 Session::flash('status', 'success');
537 484
                 Session::flash('message', 'Assessment deleted.');
538 485
                 return Redirect::back();
539 486
             }
540
-
541
-        }
542
-        catch (Exception $e)
543
-        {
487
+        } catch (Exception $e) {
544 488
             Session::flash('status', 'danger');
545 489
             Session::flash('message', 'Error saving  assessment. Try again later.');
546 490
 
@@ -552,25 +496,21 @@ class ActivitiesController extends \BaseController {
552 496
     {
553 497
         $course = Activity::find($id)->course;
554 498
 
555
-        if(Activity::destroy($id))
556
-        {
499
+        if (Activity::destroy($id)) {
557 500
             // Recalculate course outcomes
558 501
             $activities = $course->activities;
559 502
 
560 503
             // Check if any assessed activties remain
561 504
             $remainingAssessed = false;
562
-            foreach ($course->activities as $activity)
563
-            {
564
-                if($activity->outcomes_attempted!=NULL)
565
-                {
566
-                    $remainingAssessed =true;
505
+            foreach ($course->activities as $activity) {
506
+                if ($activity->outcomes_attempted != NULL) {
507
+                    $remainingAssessed = true;
567 508
                     break;
568 509
                 }
569 510
             }
570 511
 
571 512
             //If there are still evaluated activities in the course, recalculate course outcomes
572
-            if(!$course->activities->isEmpty() && $remainingAssessed )
573
-            {
513
+            if (!$course->activities->isEmpty() && $remainingAssessed) {
574 514
                 $outcomeCount = Outcome::all()->count();
575 515
 
576 516
                 // Variables to hold recalculated outcomes for the course
@@ -578,60 +518,48 @@ class ActivitiesController extends \BaseController {
578 518
                 $course_outcomes_achieved = array_fill(1, $outcomeCount, 0);
579 519
 
580 520
                 // For each activity
581
-                foreach ($activities as $activity)
582
-                {
583
-                  // If activity has been assessed
584
-                  if($activity->outcomes_attempted!=NULL)
585
-                  {
586
-                    // Get the achieved criteria
587
-                    $criteria_achievement = json_decode($activity->criteria_achieved, true);
588
-                    foreach($criteria_achievement as $criterion_id=>$criterion_achieved)
589
-                    {
590
-                      // Find corresponding learning outcome;
591
-                      $criterion = Criterion::withTrashed()->find($criterion_id);
592
-                      $outcome = Outcome::find($criterion->outcome_id);
593
-
594
-                      // If criterion is achieved (1), add 1 to both arrays
595
-                      if($criterion_achieved === 1)
596
-                      {
597
-                        $course_outcomes_attempted[$outcome->id]+=1;
598
-                        $course_outcomes_achieved[$outcome->id]+=1;
599
-                      }
600
-                      // Else, only add to the attempted outcomes arrays
601
-                      elseif($criterion_achieved === 0)
602
-                      {
603
-                        $course_outcomes_attempted[$outcome->id]+=1;
604
-                      }
521
+                foreach ($activities as $activity) {
522
+                    // If activity has been assessed
523
+                    if ($activity->outcomes_attempted != NULL) {
524
+                        // Get the achieved criteria
525
+                        $criteria_achievement = json_decode($activity->criteria_achieved, true);
526
+                        foreach ($criteria_achievement as $criterion_id => $criterion_achieved) {
527
+                            // Find corresponding learning outcome;
528
+                            $criterion = Criterion::withTrashed()->find($criterion_id);
529
+                            $outcome = Outcome::find($criterion->outcome_id);
530
+
531
+                            // If criterion is achieved (1), add 1 to both arrays
532
+                            if ($criterion_achieved === 1) {
533
+                                $course_outcomes_attempted[$outcome->id] += 1;
534
+                                $course_outcomes_achieved[$outcome->id] += 1;
535
+                            }
536
+                            // Else, only add to the attempted outcomes arrays
537
+                            elseif ($criterion_achieved === 0) {
538
+                                $course_outcomes_attempted[$outcome->id] += 1;
539
+                            }
540
+                        }
605 541
                     }
606
-                  }
607 542
                 }
608 543
 
609 544
                 // Update course
610 545
                 $course->outcomes_achieved = json_encode($course_outcomes_achieved);
611 546
                 $course->outcomes_attempted = json_encode($course_outcomes_attempted);
612
-            }
613
-            else
614
-            {
547
+            } else {
615 548
                 $course->outcomes_achieved = NULL;
616 549
                 $course->outcomes_attempted = NULL;
617 550
             }
618 551
 
619
-            if($course->save())
620
-            {
552
+            if ($course->save()) {
621 553
                 Session::flash('status', 'success');
622 554
                 Session::flash('message', 'Activity deleted.');
623
-            }
624
-            else
625
-            {
555
+            } else {
626 556
                 Session::flash('status', 'danger');
627 557
                 Session::flash('message', 'Error deleting activity. Try again later.');
628 558
                 return Redirect::back();
629 559
             }
630 560
 
631 561
             return Redirect::action('CoursesController@show', array($course->id));
632
-        }
633
-        else
634
-        {
562
+        } else {
635 563
             Session::flash('status', 'danger');
636 564
             Session::flash('message', 'Error deleting activity. Try again later.');
637 565
             return Redirect::back();
@@ -640,12 +568,10 @@ class ActivitiesController extends \BaseController {
640 568
 
641 569
     public function update($id)
642 570
     {
643
-        try
644
-        {
571
+        try {
645 572
             $activity = Activity::find($id);
646 573
 
647
-            if(Input::has('update_activity_information'))
648
-            {
574
+            if (Input::has('update_activity_information')) {
649 575
                 /** Validation rules */
650 576
                 $validator = Validator::make(
651 577
                     array(
@@ -654,27 +580,25 @@ class ActivitiesController extends \BaseController {
654 580
                         'date' => Input::get('date'),
655 581
                     ),
656 582
                     array(
657
-                        'name' => 'required|unique:activities,course_id,'.$id,
583
+                        'name' => 'required|unique:activities,course_id,' . $id,
658 584
                         'description' => 'required|min:10',
659 585
                         'date' => 'required|dateFormat:Y-m-d'
660 586
                     ),
661 587
                     array(
662
-                        'date.dateFormat'=>'The date does not match the correct format: yyyy-mm-dd.'
588
+                        'date.dateFormat' => 'The date does not match the correct format: yyyy-mm-dd.'
663 589
                     )
664 590
                 );
665 591
 
666 592
                 /** If validation fails */
667
-                if ($validator->fails())
668
-                {
593
+                if ($validator->fails()) {
669 594
                     /** Prepare error message */
670 595
                     $message = 'Error(s) updating the Activity<ul>';
671 596
 
672
-                    foreach ($validator->messages()->all('<li>:message</li>') as $validationError)
673
-                    {
674
-                        $message.=$validationError;
597
+                    foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
598
+                        $message .= $validationError;
675 599
                     }
676 600
 
677
-                    $message.='</ul>';
601
+                    $message .= '</ul>';
678 602
 
679 603
                     /** Send error message and old data */
680 604
                     Session::flash('status', 'warning');
@@ -686,23 +610,17 @@ class ActivitiesController extends \BaseController {
686 610
                 $activity->name = Input::get('name');
687 611
                 $activity->description = Input::get('description');
688 612
                 $activity->date = Input::get('date');
689
-            }
690
-            elseif(Input::has('update_transforming_actions'))
691
-            {
692
-                if(trim(Input::get('transforming_actions')) !="")
613
+            } elseif (Input::has('update_transforming_actions')) {
614
+                if (trim(Input::get('transforming_actions')) != "")
693 615
                     $activity->transforming_actions = Input::get('transforming_actions');
694 616
                 else
695 617
                     $activity->transforming_actions = NULL;
696
-            }
697
-            elseif(Input::has('update_assessment_comments'))
698
-            {
699
-                if(trim(Input::get('assessment_comments')) !="")
618
+            } elseif (Input::has('update_assessment_comments')) {
619
+                if (trim(Input::get('assessment_comments')) != "")
700 620
                     $activity->assessment_comments = Input::get('assessment_comments');
701 621
                 else
702 622
                     $activity->assessment_comments = NULL;
703
-            }
704
-            else
705
-            {
623
+            } else {
706 624
                 Session::flash('status', 'danger');
707 625
                 Session::flash('message', 'Error updating Activity. Please try again later.');
708 626
                 return Redirect::action('ActivitiesController@show', array($activity->id));
@@ -714,15 +632,11 @@ class ActivitiesController extends \BaseController {
714 632
             Session::flash('status', 'success');
715 633
             Session::flash('message', 'Activity succesfully updated.');
716 634
             return Redirect::action('ActivitiesController@show', array($activity->id));
717
-
718
-        }
719
-        catch(Exception $e)
720
-        {
635
+        } catch (Exception $e) {
721 636
             Session::flash('status', 'warning');
722 637
             Session::flash('message', 'Error updating Activity. Please try again later.');
723 638
             return Redirect::action('ActivitiesController@show', array($activity->id));
724 639
         }
725
-
726 640
     }
727 641
 
728 642
     //TODO the code in the next 2 functions is the same as the assess function except for the view returned. try to refactor this to avoid copying code.
@@ -732,7 +646,7 @@ class ActivitiesController extends \BaseController {
732 646
         $activity = Activity::find($id);
733 647
 
734 648
         // If activity does not exist, display 404
735
-        if(!$activity)
649
+        if (!$activity)
736 650
             App::abort('404');
737 651
 
738 652
         // Get activity's course
@@ -756,8 +670,7 @@ class ActivitiesController extends \BaseController {
756 670
 
757 671
         // Decode the scores (blade workaround)
758 672
         $scores_array = array();
759
-        foreach ($assessments as $index=>$assessment)
760
-        {
673
+        foreach ($assessments as $index => $assessment) {
761 674
             $scores_array[$assessment->id] = json_decode($assessment->scores, true);
762 675
         }
763 676
 
@@ -769,7 +682,7 @@ class ActivitiesController extends \BaseController {
769 682
         $activity = Activity::find($id);
770 683
 
771 684
         // If activity does not exist, display 404
772
-        if(!$activity)
685
+        if (!$activity)
773 686
             App::abort('404');
774 687
 
775 688
         // Get activity's course
@@ -793,13 +706,10 @@ class ActivitiesController extends \BaseController {
793 706
 
794 707
         // Decode the scores (blade workaround)
795 708
         $scores_array = array();
796
-        foreach ($assessments as $index=>$assessment)
797
-        {
709
+        foreach ($assessments as $index => $assessment) {
798 710
             $scores_array[$assessment->id] = json_decode($assessment->scores, true);
799 711
         }
800 712
 
801 713
         return View::make('local.professors.print_assessment', compact('activity', 'title', 'students', 'course', 'rubric_contents', 'assessments', 'scores_array', 'rubric'));
802 714
     }
803
-
804
-
805 715
 }

+ 273
- 174
app/controllers/AdministratorsController.php Ver arquivo

@@ -1,207 +1,306 @@
1 1
 <?php
2 2
 
3 3
 class AdministratorsController extends \BaseController
4
-{
4
+{	
5
+	private function outcomes_semesters($selected_semesters, $level)
6
+	{
7
+		$min_start="9000-01-01 00:00:00";
8
+		$max_end="1000-01-01 00:00:00";
9
+		foreach($selected_semesters as $semester)
10
+		{
11
+			if($min_start>$semester->start)
12
+			{
13
+				$min_start=$semester->start;
14
+			}
15
+			if($max_end<$semester->end)
16
+			{
17
+				$max_end=$semester->end;
18
+			}
19
+		}
20
+		$outcomes = Outcome::where(function($query) use ($min_start)
21
+								   {
22
+										$query->where('deactivation_date', '>=', $min_start)
23
+											  ->orWhere('deactivation_date', null);
24
+								   })
25
+							->where('activation_date', '<=', $max_end)
26
+							->where(function($query2) use ($level)
27
+									{
28
+										$query2->where("level", $level+1)
29
+											   ->orWhere("level",3);
30
+									})
31
+							->orderBy('name', 'ASC')
32
+							->get();
33
+        $outcomeCount = Outcome::where(function($query) use ($min_start)
34
+									   {
35
+											$query->where('deactivation_date', '>=', $min_start)
36
+												  ->orWhere('deactivation_date', null);
37
+										})
38
+							->where('activation_date', '<=', $max_end)
39
+							->where(function($query2) use ($level)
40
+										{
41
+											$query2->where("level",$level+1)
42
+												   ->orWhere("level",3);
43
+										})
44
+								->count();
45
+	
46
+		foreach($outcomes as $outcome)
47
+		{
48
+			
49
+// 		var_dump($outcome->id);
50
+// 		print "<br>";
51
+			$outcomes_attempted[$outcome->id]=$outcome->attempted($selected_semesters, $level);
52
+			$outcomes_achieved[$outcome->id]=$outcome->achieved($selected_semesters, $level);	
53
+		}
54
+
55
+        $uhs_school_id = School::where('name', 'LIKE', '%UHS%')->first()->id;
56
+        $uhs_program_id = Program::where('name', 'LIKE', '%UHS%')->first()->id;
57
+
58
+        foreach ($outcomes as $outcome)
59
+        {
60
+			$achievedProgramsPerOutcome[$outcome->id]=0;         // For each program with courses that do assessment
61
+			$attemptedProgramsPerOutcome[$outcome->id]=0;         // For each program with courses that do assessment
62
+            foreach (Program::with(array('courses' => function($query){
63
+//                 $query->whereNotNull('outcomes_attempted');
64
+                $query->where('code', '!=', 'TEST');
65
+                $query->whereIn('semester_id', Session::get('semesters_ids'));
66
+            }))->where('is_graduate', $level)->where('school_id', '!=', $uhs_school_id)->orderBy('name', 'asc')->get() as $program)
67
+            {
68
+				$achieved_outcomes_per_program[$program->id]=0;
69
+				$attempted_outcomes_per_program[$program->id]=0;
70
+            	$participating_programs[$program->id]=(object)array('id'=>$program->id, 'name'=>$program->name, 'is_graduate'=> $program->is_graduate, 'school_id'=>$program->school_id);
71
+
72
+// 				SELECT ac.id activity_criterion_id, ac.activity_id, ac.expected_student_score, ac.expected_percentage_students_achieving, co.program_id FROM activity_criterion ac, new_criteria c, activities a, objectives o, courses co where co.id=a.course_id and co.semester_id=13 and a.id=ac.activity_id and c.id = ac.criterion_id and o.id=c.objective_id and o.outcome_id = 2 order by program_id
73
+				$program_attempted_outcome=$program->attempted_outcome($outcome->id, $selected_semesters);
74
+				$attempted_outcomes_per_program[$program->id]+=$program_attempted_outcome;
75
+// 				var_dump($program_attempted_outcome);
76
+// 				exit();
77
+				if($program_attempted_outcome)
78
+				{
79
+					$program_achieved_outcome=$program->achieved_outcome($outcome->id, $selected_semesters);
80
+					$achieved_outcomes_per_program[$program->id]+=$program_achieved_outcome;
81
+
82
+                    $attemptedProgramsPerOutcome[$outcome->id]+=$program_attempted_outcome;
83
+//                     $attemptedProgramsPerOutcome[$outcome->id]+=1;
84
+					$achievedProgramsPerOutcome[$outcome->id]+=$program_achieved_outcome;
85
+// 					$achieved_outcomes_per_program[$outcome->id]=$program->achieved_outcome($outcome->id, $selected_semesters);
86
+// 					if($attempted_outcomes_per_program[$outcome->id]!=0 && 100.0*$achieved_outcomes_per_program[$outcome->id]/$attempted_outcomes_per_program[$outcome->id] >= $outcome->expected_outcome)
87
+// 					{
88
+// 						$achievedProgramsPerOutcome[$outcome->id]+=1;
89
+// 						// $output[]= 'END OF PROGRAM: '.$program->name.'-'.json_encode($achievedProgramsPerOutcome);
90
+// 					}
91
+				}
92
+			}
93
+		}
94
+	
95
+		return array('outcomes'=>$outcomes,'outcomes_attempted'=>$outcomes_attempted, 'outcomes_achieved'=>$outcomes_achieved, 'attemptedProgramsPerOutcome'=>$attemptedProgramsPerOutcome, 'achievedProgramsPerOutcome'=>$achievedProgramsPerOutcome,'participating_programs'=>$participating_programs);
96
+	
97
+	
98
+	
99
+	}
5 100
     public function overview()
6 101
     {
102
+    
103
+        $selected_semesters = Semester::find(Session::get('semesters_ids'));
104
+        
105
+		$subgraduado=$this->outcomes_semesters($selected_semesters,0);
106
+        $outcomes_subgrad=$subgraduado['outcomes'];
107
+        $undergrad_outcomes_achieved=$subgraduado['outcomes_achieved']; 
108
+        $undergrad_outcomes_attempted=$subgraduado['outcomes_attempted']; 
109
+        $attemptedUndergradProgramsPerOutcome=$subgraduado['attemptedProgramsPerOutcome']; 
110
+        $achievedUndergradProgramsPerOutcome=$subgraduado['achievedProgramsPerOutcome']; 
111
+        $participating_undergrad_programs=$subgraduado['participating_programs']; 
112
+		
113
+		
114
+		$graduado=$this->outcomes_semesters($selected_semesters,1);
115
+        $outcomes_grad=$graduado['outcomes'];
116
+        $grad_outcomes_achieved=$graduado['outcomes_achieved']; 
117
+        $grad_outcomes_attempted=$graduado['outcomes_attempted']; 
118
+        $attemptedGradProgramsPerOutcome=$graduado['attemptedProgramsPerOutcome']; 
119
+        $achievedGradProgramsPerOutcome=$graduado['achievedProgramsPerOutcome']; 
120
+        $participating_grad_programs=$graduado['participating_programs']; 
121
+		
7 122
         //Total amount of learning outcomes
8
-        $outcomeCount = Outcome::withTrashed()->count();
9
-
123
+//         $outcomeCount = Outcome::withTrashed()->count();
124
+//         $selected_semester = Semester::find(Session::get('semesters_ids')[0]);
125
+//         $outcomes_subgrad = Outcome::where(function($query) use ($selected_semester)
126
+//         								   {
127
+// 												$query->where('deactivation_date', '>=', $selected_semester->start)
128
+// 													  ->orWhere('deactivation_date', null);
129
+//         								   })
130
+//         							->where('activation_date', '<=', $selected_semester->end)
131
+//         							->where(function($query2)
132
+//         								    {
133
+// 												$query2->where("level",1)
134
+// 													   ->orWhere("level",3);
135
+//         									})
136
+//         							->orderBy('name', 'ASC')
137
+//         							->get();
138
+//         $outcomeCount_subgrad = Outcome::where(function($query) use ($selected_semester)
139
+//         									   {
140
+//         									   		$query->where('deactivation_date', '>=', $selected_semester->start)
141
+//         									   			  ->orWhere('deactivation_date', null);
142
+//         									   	})
143
+//            							->where('activation_date', '<=', $selected_semester->end)
144
+//      								->where(function($query2)
145
+//         									    {
146
+//         									    	$query2->where("level",1)
147
+//         									    		   ->orWhere("level",3);
148
+//         									    })
149
+//         								->count();
150
+// 
151
+//         $outcomes_grad = Outcome::where(function($query) use ($selected_semester){$query->where('deactivation_date', '>=', $selected_semester->start)->orWhere('deactivation_date', null);})->where(function($query2){$query2->where("level",2)->orWhere("level",3);})->orderBy('name', 'ASC')->get();
152
+//         $outcomeCount_grad = Outcome::where(function($query) use ($selected_semester){$query->where('deactivation_date', '>=', $selected_semester->start)->orWhere('deactivation_date', null);})->where(function($query2){$query2->where("level",2)->orWhere("level",3);})->count();
153
+
154
+// 		print($outcomeCount_subgrad);
155
+// 		print($outcomeCount_grad);
10 156
         // Id for excluding UHS from records
11 157
         $uhs_school_id = School::where('name', 'LIKE', '%UHS%')->first()->id;
12
-        $uhs_program_id = Program::where('name', 'LIKE', '%UHS%')->first()->id;
158
+//         $uhs_program_id = Program::where('name', 'LIKE', '%UHS%')->first()->id;
13 159
 
14 160
         $schools = School::where('id', '!=', $uhs_school_id)->orderBy('name', 'asc')->get();
15 161
         $title = 'Campus Overview';
16
-        $outcomes = Outcome::withTrashed()->select('id', 'name', 'expected_outcome')->orderBy('name', 'asc')->get();
17
-
18
-        $undergrad_outcomes_achieved = array_fill(1, $outcomeCount, 0);
19
-        $undergrad_outcomes_attempted = array_fill(1, $outcomeCount, 0);
20
-        $grad_outcomes_achieved = array_fill(1, $outcomeCount, 0);
21
-        $grad_outcomes_attempted = array_fill(1, $outcomeCount, 0);
22
-
162
+        
163
+        
23 164
         /**
24
-         * Calculate campus wide outcome performance
165
+         * Calculate campus wide outcome performance by counting the number of students
166
+         $undergrad_outcomes_attempted will have the number of criteria that was assessed in undergradute courses during the selected semester 
167
+         $undergrad_outcomes_achieved will have the number of criteria that was assessed in undergradute courses  during the selected semester 
168
+            where the percentage of students that obtained a better or equal score than the expected_student_score established in the
169
+            activity_criterion table is greater or equal than the expected_percentage_students_achieving also established in the
170
+            activity_criterion table         
25 171
          */
26 172
 
27
-        // Calculate campus wide outcome performance for undergrad and grad
28
-        foreach (Course::with('program')
29
-            ->where('program_id', '!=', $uhs_program_id)
30
-            ->where('code', '!=', 'TEST')
31
-            ->whereNotNull('outcomes_achieved')
32
-            ->whereIn('semester_id', Session::get('semesters_ids'))->get() as $course)
33
-        {
34
-            if(!$course->program->is_graduate)
35
-            {
36
-                $course_outcomes_achieved =json_decode($course->outcomes_achieved, true);
37
-                $course_outcomes_attempted =json_decode($course->outcomes_attempted, true);
38
-                for($i=1; $i<=count($undergrad_outcomes_attempted); $i++)
39
-                {
40
-
41
-                    $undergrad_outcomes_achieved[$i]+=$course_outcomes_achieved[$i];
42
-                    $undergrad_outcomes_attempted[$i]+=$course_outcomes_attempted[$i];
43
-                }
44
-            }
45
-            else
46
-            {
47
-                $course_outcomes_achieved =json_decode($course->outcomes_achieved, true);
48
-                $course_outcomes_attempted =json_decode($course->outcomes_attempted, true);
49
-                for($i=1; $i<=count($grad_outcomes_attempted); $i++)
50
-                {
51
-
52
-                    $grad_outcomes_achieved[$i]+=$course_outcomes_achieved[$i];
53
-                    $grad_outcomes_attempted[$i]+=$course_outcomes_attempted[$i];
54
-                }
55
-            }
56
-
57
-        }
173
+// 		foreach($outcomes_subgrad as $outcome)
174
+// 		{
175
+// 			$undergrad_outcomes_attempted[$outcome->id]=$outcome->attempted($selected_semester->id,0);
176
+// 			$undergrad_outcomes_achieved[$outcome->id]=$outcome->achieved($selected_semester->id,0);	
177
+// 		}
178
+// 		var_dump($undergrad_outcomes_attempted);
179
+// 		print"<br>";
180
+// 		var_dump($undergrad_outcomes_achieved);
181
+// 		print"<br>";
182
+// 		foreach($outcomes_grad as $outcome)
183
+// 		{
184
+// 			$grad_outcomes_attempted[$outcome->id]=$outcome->attempted($selected_semester->id,1);
185
+// 			$grad_outcomes_achieved[$outcome->id]=$outcome->achieved($selected_semester->id,1);			
186
+// 		}
58 187
 
59 188
         /**
60 189
          * Calculate how many programs achieved and attempted each outcome
61 190
          */
62 191
 
63 192
         // Number of programs that achieved a particular learning outcome
64
-        $achievedUndergradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
193
+//         $achievedUndergradProgramsPerOutcome = array_fill(1, $outcomeCount_subgrad, 0);
65 194
 
66 195
         // Number of programs that attempted a particular learning outcome
67
-        $attemptedUndergradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
196
+//         $attemptedUndergradProgramsPerOutcome = array_fill(1, $outcomeCount_subgrad, 0);
68 197
 
69 198
         // Names of programs doing assessment
70 199
         // Fetch programs with participation
71
-        $participating_undergrad_programs = DB::table('VIEW_participating_programs')
72
-            ->whereIn('semester_id', Session::get('semesters_ids'))
73
-            ->where('is_graduate', 0)
74
-            ->groupBy('id')
75
-            ->orderBy('name', 'asc')
76
-            ->get();
77
-
78
-        $output = array();
79
-
80
-
81
-        // For each outcome
82
-        foreach ($outcomes as $outcome)
83
-        {
84
-            // For each program with courses that do assessment
85
-            foreach (Program::with(array('courses' => function($query){
86
-                $query->whereNotNull('outcomes_attempted');
87
-                $query->where('code', '!=', 'TEST');
88
-                $query->whereIn('semester_id', Session::get('semesters_ids'));
89
-            }))->where('is_graduate', 0)->orderBy('name', 'asc')->get() as $program)
90
-            {
91
-                // To acummulate all criteria for one program
92
-                $achieved_outcomes_per_undergrad_program = array_fill(1, $outcomeCount, 0);
93
-                $attempted_outcomes_per_undergrad_program = array_fill(1, $outcomeCount, 0);
94
-
95
-                //Flag for counting programs
96
-                $flag =false;
97
-
98
-                // For each course in the program
99
-                foreach ($program->courses as $course)
100
-                {
101
-                    // If the outcome in question is being evaluated
102
-                    $course_outcomes_attempted2 = json_decode($course->outcomes_attempted, true);
103
-                    $course_outcomes_achieved2 = json_decode($course->outcomes_achieved, true);
104
-                    if(array_key_exists($outcome->id, $course_outcomes_attempted2 )
105
-                        && $course_outcomes_attempted2[$outcome->id]>0)
106
-                    {
107
-                        $achieved_outcomes_per_undergrad_program[$outcome->id]+=$course_outcomes_achieved2[$outcome->id];
108
-                        $attempted_outcomes_per_undergrad_program[$outcome->id]+=$course_outcomes_attempted2[$outcome->id];
109
-
110
-
111
-                        // Add one to the programs assessing, if it wasn't added before
112
-                        if(!$flag)
113
-                        {
114
-                            $attemptedUndergradProgramsPerOutcome[$outcome->id]+=1;
115
-                            $flag= true;
116
-                        }
117
-                    }
118
-
119
-                    // $output[] = 'ACHIEVED: '.$program->name.'-'.json_encode($achieved_outcomes_per_undergrad_program);
120
-                    // $output[] = 'ATTEMPTED: '.$program->name.'-'.json_encode($attempted_outcomes_per_undergrad_program);
121
-
122
-                }
123
-                //If the accumulated achieved criteria for a specific outcome in a program divided by the accumulated attempted criteria for a specific outcome in a program is greated than the expected outcome
124
-                if($attempted_outcomes_per_undergrad_program[$outcome->id]!=0 && (float)$achieved_outcomes_per_undergrad_program[$outcome->id]/$attempted_outcomes_per_undergrad_program[$outcome->id]*100 >= $outcome->expected_outcome)
125
-                {
126
-                    $achievedUndergradProgramsPerOutcome[$outcome->id]+=1;
127
-                    // $output[]= 'END OF PROGRAM: '.$program->name.'-'.json_encode($achievedUndergradProgramsPerOutcome);
128
-                }
129
-            }
130
-        }
131
-
200
+//         $participating_undergrad_programs = DB::table('VIEW_participating_programs')
201
+//             ->whereIn('semester_id', Session::get('semesters_ids'))
202
+//             ->where('is_graduate', 0)
203
+//             ->groupBy('id')
204
+//             ->orderBy('name', 'asc')
205
+//             ->get();
206
+//         $output = array();
132 207
 
133 208
         /**
134
-         * Calculate how many programs achieved and attempted each outcome
209
+         * Calculate how many undergrad programs achieved and attempted each outcome
210
+         */
211
+//         foreach ($outcomes_subgrad as $outcome)
212
+//         {
213
+//  			$achieved_outcomes_per_undergrad_program[$outcome->id]=0;
214
+// 			$attempted_outcomes_per_undergrad_program[$outcome->id]=0;
215
+// 			$achievedUndergradProgramsPerOutcome[$outcome->id]=0;         // For each program with courses that do assessment
216
+// 			$attemptedUndergradProgramsPerOutcome[$outcome->id]=0;         // For each program with courses that do assessment
217
+//             foreach (Program::with(array('courses' => function($query){
218
+// //                 $query->whereNotNull('outcomes_attempted');
219
+//                 $query->where('code', '!=', 'TEST');
220
+//                 $query->whereIn('semester_id', Session::get('semesters_ids'));
221
+//             }))->where('is_graduate', 0)->where('school_id', '!=', $uhs_school_id)->orderBy('name', 'asc')->get() as $program)
222
+//             {
223
+//             	$participating_undergrad_programs[$program->id]=(object)array('id'=>$program->id, 'name'=>$program->name, 'is_graduate'=> $program->is_graduate, 'school_id'=>$program->school_id,'semestre_id',$selected_semester);
224
+// 
225
+// // 				SELECT ac.id activity_criterion_id, ac.activity_id, ac.expected_student_score, ac.expected_percentage_students_achieving, co.program_id FROM activity_criterion ac, new_criteria c, activities a, objectives o, courses co where co.id=a.course_id and co.semester_id=13 and a.id=ac.activity_id and c.id = ac.criterion_id and o.id=c.objective_id and o.outcome_id = 2 order by program_id
226
+// 				$program_attempted_outcome=$program->attempted_outcome($outcome->id, $selected_semester->id);
227
+// 				$attempted_outcomes_per_undergrad_program[$outcome->id]+=$program_attempted_outcome;
228
+// // 				var_dump($program_attempted_outcome);
229
+// // 				exit();
230
+// 				if($program_attempted_outcome)
231
+// 				{
232
+//                     $attemptedUndergradProgramsPerOutcome[$outcome->id]+=1;
233
+// 					$achieved_outcomes_per_undergrad_program[$outcome->id]=$program->achieved_outcome($outcome->id, $selected_semester->id);
234
+// 					if($attempted_outcomes_per_undergrad_program[$outcome->id]!=0 && 100.0*$achieved_outcomes_per_undergrad_program[$outcome->id]/$attempted_outcomes_per_undergrad_program[$outcome->id] >= $outcome->expected_outcome)
235
+// 					{
236
+// 						$achievedUndergradProgramsPerOutcome[$outcome->id]+=1;
237
+// 						// $output[]= 'END OF PROGRAM: '.$program->name.'-'.json_encode($achievedUndergradProgramsPerOutcome);
238
+// 					}
239
+// 				}
240
+// 			}
241
+// 		}
242
+// 		var_dump($attempted_outcomes_per_undergrad_program);
243
+// 		print"<br>";
244
+// 		var_dump($achieved_outcomes_per_undergrad_program);
245
+// 		print"<br>";
246
+// 		var_dump($attemptedUndergradProgramsPerOutcome);
247
+// 		print"<br>";
248
+// 		var_dump($achievedUndergradProgramsPerOutcome);
249
+// 		print"<br>";
250
+// 		exit();
251
+        /**
252
+         * Calculate how many grad programs achieved and attempted each outcome
253
+         $grad_outcomes_attempted will have the number of criteria that was assessed in gradute courses during the selected semester 
254
+         $grad_outcomes_achieved will have the number of criteria that was assessed in gradute courses  during the selected semester 
255
+            where the percentage of students that obtained a better or equal score than the expected_student_score established in the
256
+            activity_criterion table is greater or equal than the expected_percentage_students_achieving also established in the
257
+            activity_criterion table         
135 258
          */
136 259
 
137
-        // Number of programs that achieved a particular learning outcome
138
-        $achievedGradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
139
-
140
-        // Number of programs that attempted a particular learning outcome
141
-        $attemptedGradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
142 260
 
143 261
         // Names of programs doing assessment
144
-        $participating_grad_programs = DB::table('VIEW_participating_programs')
145
-            ->whereIn('semester_id', Session::get('semesters_ids'))
146
-            ->where('is_graduate', 1)
147
-            ->groupBy('id')
148
-            ->orderBy('name', 'asc')
149
-            ->get();
150
-
151
-        $output = array();
152
-
153
-
154
-        // For each outcome
155
-        foreach ($outcomes as $outcome)
156
-        {
157
-            // For each program with courses that do assessment
158
-            foreach (Program::with(array('courses' => function($query){
159
-                $query->whereNotNull('outcomes_attempted');
160
-                $query->where('code', '!=', 'TEST');
161
-                $query->whereIn('semester_id', Session::get('semesters_ids'));
162
-            }))->where('is_graduate', 1)->orderBy('name', 'asc')->get() as $program)
163
-            {
164
-                // To acummulate all criteria for one program
165
-                $achieved_outcomes_per_grad_program = array_fill(1, $outcomeCount, 0);
166
-                $attempted_outcomes_per_grad_program = array_fill(1, $outcomeCount, 0);
167
-
168
-                //Flag for counting programs
169
-                $flag =false;
170
-
171
-                // For each course in the program
172
-                foreach ($program->courses as $course)
173
-                {
174
-                    // If the outcome in question is being evaluated
175
-                    $course_outcomes_attempted2 = json_decode($course->outcomes_attempted, true);
176
-                    $course_outcomes_achieved2 = json_decode($course->outcomes_achieved, true);
177
-                    if(array_key_exists($outcome->id, $course_outcomes_attempted2 )
178
-                        && $course_outcomes_attempted2[$outcome->id]>0)
179
-                    {
180
-                        $achieved_outcomes_per_grad_program[$outcome->id]+=$course_outcomes_achieved2[$outcome->id];
181
-                        $attempted_outcomes_per_grad_program[$outcome->id]+=$course_outcomes_attempted2[$outcome->id];
182
-
183
-
184
-                        // Add one to the programs assessing, if it wasn't added before
185
-                        if(!$flag)
186
-                        {
187
-                            $attemptedGradProgramsPerOutcome[$outcome->id]+=1;
188
-                            $flag= true;
189
-                        }
190
-                    }
191
-
192
-                    // $output[] = 'ACHIEVED: '.$program->name.'-'.json_encode($achieved_outcomes_per_grad_program);
193
-                    // $output[] = 'ATTEMPTED: '.$program->name.'-'.json_encode($attempted_outcomes_per_grad_program);
194
-
195
-                }
196
-                //If the accumulated achieved criteria for a specific outcome in a program divided by the accumulated attempted criteria for a specific outcome in a program is greated than the expected outcome
197
-                if($attempted_outcomes_per_grad_program[$outcome->id]!=0 && (float)$achieved_outcomes_per_grad_program[$outcome->id]/$attempted_outcomes_per_grad_program[$outcome->id]*100 >= $outcome->expected_outcome)
198
-                {
199
-                    $achievedGradProgramsPerOutcome[$outcome->id]+=1;
200
-                    // $output[]= 'END OF PROGRAM: '.$program->name.'-'.json_encode($achievedGradProgramsPerOutcome);
201
-                }
202
-            }
203
-        }
204
-
205
-        return View::make('local.managers.admins.overview', compact('title', 'schools', 'outcomes', 'undergrad_outcomes_achieved', 'undergrad_outcomes_attempted', 'grad_outcomes_achieved', 'grad_outcomes_attempted', 'attemptedUndergradProgramsPerOutcome', 'participating_undergrad_programs', 'achievedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'participating_grad_programs', 'achievedGradProgramsPerOutcome'));
262
+//         $participating_grad_programs = DB::table('VIEW_participating_programs')
263
+//             ->whereIn('semester_id', Session::get('semesters_ids'))
264
+//             ->where('is_graduate', 1)
265
+//             ->groupBy('id')
266
+//             ->orderBy('name', 'asc')
267
+//             ->get();
268
+
269
+
270
+//         foreach ($outcomes_grad as $outcome)
271
+//         {
272
+//  			$achieved_outcomes_per_grad_program[$outcome->id]=0;
273
+// 			$attempted_outcomes_per_grad_program[$outcome->id]=0;
274
+// 			$achievedGradProgramsPerOutcome[$outcome->id]=0;         // For each program with courses that do assessment
275
+// 			$attemptedGradProgramsPerOutcome[$outcome->id]=0;         // For each program with courses that do assessment
276
+//             foreach (Program::with(array('courses' => function($query){
277
+//                 $query->whereNotNull('outcomes_attempted');
278
+//                 $query->where('code', '!=', 'TEST');
279
+//                 $query->whereIn('semester_id', Session::get('semesters_ids'));
280
+//             }))->where('is_graduate', 1)->where('school_id', '!=', $uhs_school_id)->orderBy('name', 'asc')->get() as $program)
281
+//             {
282
+//             	$participating_grad_programs[$program->id]=(object)array('id'=>$program->id, 'name'=>$program->name, 'is_graduate'=> $program->is_graduate, 'school_id'=>$program->school_id,'semestre_id',$selected_semester);
283
+// // 				SELECT ac.id activity_criterion_id, ac.activity_id, ac.expected_student_score, ac.expected_percentage_students_achieving, co.program_id FROM activity_criterion ac, new_criteria c, activities a, objectives o, courses co where co.id=a.course_id and co.semester_id=13 and a.id=ac.activity_id and c.id = ac.criterion_id and o.id=c.objective_id and o.outcome_id = 2 order by program_id
284
+// 				$program_attempted_outcome=$program->attempted_outcome($outcome->id, $selected_semester->id);
285
+// 				$attempted_outcomes_per_grad_program[$outcome->id]+=$program_attempted_outcome;
286
+// // 				var_dump($attempted_outcomes_per_undergrad_program);
287
+// // 				exit();
288
+// 				if($program_attempted_outcome)
289
+// 				{
290
+//                     $attemptedGradProgramsPerOutcome[$outcome->id]+=1;
291
+// 					$achieved_outcomes_per_grad_program[$outcome->id]=$program->achieved_outcome($outcome->id, $selected_semester->id);
292
+// 					if($attempted_outcomes_per_grad_program[$outcome->id]!=0 && (float)$achieved_outcomes_per_grad_program[$outcome->id]/$attempted_outcomes_per_grad_program[$outcome->id]*100 >= $outcome->expected_outcome)
293
+// 					{
294
+// 						$achievedGradProgramsPerOutcome[$outcome->id]+=1;
295
+// 						// $output[]= 'END OF PROGRAM: '.$program->name.'-'.json_encode($achievedUndergradProgramsPerOutcome);
296
+// 					}
297
+// 				}
298
+// 			}
299
+// 		}
300
+// 		var_dump($grad_outcomes_attempted);
301
+// 		print("<br>");
302
+// 		var_dump($grad_outcomes_achieved);
303
+// 		exit();
304
+        return View::make('local.managers.admins.overview', compact('title', 'schools', 'outcomes_subgrad', 'outcomes_grad', 'undergrad_outcomes_achieved', 'undergrad_outcomes_attempted', 'grad_outcomes_achieved', 'grad_outcomes_attempted', 'attemptedUndergradProgramsPerOutcome', 'participating_undergrad_programs', 'achievedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'participating_grad_programs', 'achievedGradProgramsPerOutcome'));
206 305
     }
207 306
 }

+ 76
- 27
app/controllers/CoursesController.php Ver arquivo

@@ -77,9 +77,25 @@ CoursesController extends \BaseController {
77 77
 		$activities = $course->activities;
78 78
 		$students = $course->students;
79 79
 
80
-		$outcomes = Outcome::orderBy('name', 'asc')->get();
81
-		$outcomes_achieved = json_decode($course->outcomes_achieved, true);
82
-        $outcomes_attempted = json_decode($course->outcomes_attempted, true);
80
+		$level=DB::table('courses')
81
+			->join('programs','programs.id','=','courses.program_id')
82
+			->where('courses.id', $id)
83
+        	->select('programs.is_graduate')
84
+        	->first();
85
+
86
+		$outcomes = Outcome::active_by_semesters(array($course->semester),$level->is_graduate);
87
+// 		$outcomeCount = count((array)$outcomes);
88
+		
89
+		$course = Course::where('id', $id)->first();
90
+		foreach($outcomes as $outcome)
91
+		{
92
+			$outcomes_attempted[$outcome->id]=$outcome->courses_attempted(array($course));
93
+			$outcomes_achieved[$outcome->id]=$outcome->courses_achieved(array($course));
94
+		}
95
+
96
+// 		$outcomes = Outcome::orderBy('name', 'asc')->get();
97
+// 		$outcomes_achieved = json_decode($course->outcomes_achieved, true);
98
+//         $outcomes_attempted = json_decode($course->outcomes_attempted, true);
83 99
 
84 100
         $schools = School::all();
85 101
 
@@ -104,44 +120,77 @@ CoursesController extends \BaseController {
104 120
 	{
105 121
         $title=$code.$number.' ('.$semester_code.')';
106 122
         $semester = Semester::where('code', $semester_code)->first();
123
+//         $selected_semesters = Semester::find(Session::get('semesters_ids'));
107 124
         $role = Auth::user()->role;
108
-
125
+		$level=DB::table('courses')
126
+			->join('programs','programs.id','=','courses.program_id')
127
+			->where('courses.code', $code)
128
+        	->where('courses.number', $number)
129
+        	->where('courses.semester_id', $semester->id)
130
+        	->select('programs.is_graduate')
131
+        	->first();
132
+//         var_dump($level);
133
+//         exit();
109 134
         $grouped_courses = Course::
110 135
         	where('code', $code)
111 136
         	->where('number', $number)
112 137
         	->where('semester_id', $semester->id)
113 138
         	->groupBy(array('code', 'number'))->get();
114 139
 
115
-        $outcomes = Outcome::orderBy('name', 'asc')->get();
116
-        $outcomeCount = Outcome::all()->count();
117
-
140
+//         $outcomes = Outcome::orderBy('name', 'asc')->get();
141
+//         $outcomeCount = Outcome::all()->count();
142
+		$outcomes = Outcome::active_by_semesters(array($semester),$level->is_graduate);
143
+		$outcomeCount = count((array)$outcomes);
144
+		
145
+		foreach($outcomes as $outcome)
146
+		{
147
+			$outcomes_attempted[$outcome->id]=$outcome->courses_attempted($grouped_courses);
148
+			$outcomes_achieved[$outcome->id]=$outcome->courses_achieved($grouped_courses);
149
+		}
150
+		
151
+		var_dump($outcomes_attempted);
152
+		print "<br>";
153
+		var_dump($outcomes_achieved);
154
+		print "<br>";
118 155
         foreach ($grouped_courses as $index => $grouped_course)
119 156
         {
120
-            // Blank outcomes for one course
121
-            $outcomes_achieved = array_fill(1, $outcomeCount, 0);
122
-            $outcomes_attempted = array_fill(1, $outcomeCount, 0);
123
-
124
-            // Find sections for this course
157
+//             // Blank outcomes for one course
158
+//             $outcomes_achieved = array_fill(1, $outcomeCount, 0);
159
+//             $outcomes_attempted = array_fill(1, $outcomeCount, 0);
160
+// 
161
+//             // Find sections for this course
125 162
             $sections = Course::
126 163
             	where('code', $grouped_course->code)
127 164
             	->where('number', $grouped_course->number)
128 165
             	->where('semester_id', $grouped_course->semester_id)
129 166
             	->get();
130
-
131
-            // For each of the sections, add the attempted and achieved criteria per outcome
132
-            foreach ($sections as $section)
133
-            {
134
-                if($section->outcomes_achieved!=NULL)
135
-                {
136
-                    $section_outcomes_achieved =json_decode($section->outcomes_achieved, true);
137
-                    $section_outcomes_attempted =json_decode($section->outcomes_attempted, true);
138
-                    for($i=1; $i<=count($outcomes_attempted); $i++)
139
-                    {
140
-                        $outcomes_achieved[$i]+=$section_outcomes_achieved[$i];
141
-                        $outcomes_attempted[$i]+=$section_outcomes_attempted[$i];
142
-                    }
143
-                }
144
-            }
167
+// 
168
+//             // For each of the sections, add the attempted and achieved criteria per outcome
169
+//             foreach ($sections as $section)
170
+//             {
171
+//                 if($section->outcomes_achieved!=NULL)
172
+//                 {
173
+//                     $section_outcomes_achieved =count($section->outcomes_attempted());
174
+// //                     var_dump($section_outcomes_achieved);
175
+// //                     exit();
176
+//                     $section_outcomes_attempted =count($section->outcomes_achieved());
177
+// //                     $section_outcomes_achieved =json_decode($section->outcomes_achieved, true);
178
+// //                     $section_outcomes_attempted =json_decode($section->outcomes_attempted, true);
179
+// 					foreach($outcomes as $outcome)
180
+// 					{
181
+// 						if(!isset($outcomes_achieved[$outcome->id]))$outcomes_achieved[$outcome->id]=0;
182
+// 						if(!isset($outcomes_attempted[$outcome->id]))$outcomes_attempted[$outcome->id]=0;
183
+//                         $outcomes_achieved[$outcome->id]+=$section_outcomes_achieved[$i];
184
+//                         $outcomes_attempted[$outcome->id]+=$section_outcomes_attempted[$i];					
185
+// 					
186
+// 					}
187
+// //                     for($i=1; $i<=count($outcomes_attempted); $i++)
188
+// //                     {
189
+// //                         $outcomes_achieved[$i]+=$section_outcomes_achieved[$i];
190
+// //                         $outcomes_attempted[$i]+=$section_outcomes_attempted[$i];
191
+// //                     }
192
+//                 }
193
+//             }
145 194
         }
146 195
 
147 196
         $section_ids = Course::

+ 442
- 168
app/controllers/CriteriaController.php Ver arquivo

@@ -1,47 +1,136 @@
1 1
 <?php
2 2
 
3
-class CriteriaController extends \BaseController {
3
+use Illuminate\Support\Facades\Input;
4
+
5
+class CriteriaController extends \BaseController
6
+{
4 7
 
5 8
     /**
6 9
      * Display a listing of the resource.
7 10
      *
11
+     *
8 12
      * @return Response
9 13
      */
14
+    public function editProgram()
15
+    {
16
+        $userProgram = Auth::user()['id'];
17
+
18
+        $userProgram = DB::select("select program_user.program_id from program_user where user_id = {$userProgram}");
19
+        Log::info($userProgram);
20
+        $title = "Criteria";
21
+        $outcomes = Outcome::orderBy('name', 'ASC')->lists('name', 'id');
22
+
23
+        $criteria = Criterion::withTrashed()->orderBy('name', 'ASC')->get();
24
+        $programs = Program::where("id", "=", $userProgram[0]->program_id)->get();
25
+        return View::make('local.managers.pCoords.criteria', compact('title', 'outcomes', 'schools', 'criteria', 'programs', 'objectives'));
26
+    }
27
+
28
+    public function editSchool()
29
+    {
30
+        $userSchool = Auth::user()['school_id'];
31
+        Log::info($userSchool);
32
+        $title = "Criteria";
33
+        $outcomes = Outcome::orderBy('name', 'ASC')->lists('name', 'id');
34
+
35
+        $schools = School::find($userSchool)->get();
36
+        $criteria = Criterion::withTrashed()->orderBy('name', 'ASC')->get();
37
+        $programs = Program::where("school_id", "=", $userSchool)->orderBy('name', 'ASC')->get();
38
+        $listOfId = array();
39
+        foreach ($programs as $program) {
40
+
41
+            $listOfId[] = $program->id;
42
+        }
43
+
44
+        $objectives = DB::table('objectives')->whereIn('program_id', $listOfId)->orderBy('text', 'ASC')->lists('text', 'id');
45
+
46
+
47
+
48
+
49
+
50
+        return View::make('local.managers.sCoords.criteria', compact('title', 'outcomes', 'schools', 'criteria', 'programs', 'objectives'));
51
+    }
52
+
53
+
10 54
     public function fetchCriterion()
11 55
     {
12 56
         return Criterion::find(Input::get('id'));
13 57
     }
58
+    public function fetchAllCriterion()
59
+    {
60
+        $program_id = Input::get('program_fetch');
61
+        $outcome_id = Input::get('outcome_fetch');
62
+        $json = array();
63
+        $json['criterion'] = DB::select("SELECT * FROM `new_criteria` where id in (select criterion_id from criterion_objective_outcome where outcome_id ={$outcome_id}) and id in(select criterion_id from program_criterion where program_id = {$program_id})");
64
+        return json_encode($json);
65
+    }
66
+    public function fetchObjectivesForSelect()
67
+    {
14 68
 
69
+        $json = array();
70
+        Log::info("GET COCKEd");
71
+        Log::info(Input::get('allOutcomes'));
72
+        foreach (Input::get('allOutcomes') as $id) {
73
+            $json['outcomes'][$id] = DB::select("select name from outcomes where id = {$id}");
74
+            $json['objectives'][$id] = DB::select("select objectives.id, objectives.text, outcomes.name from objectives, objective_outcome, outcomes where  objective_outcome.outcome_id ={$id} and objective_outcome.objective_id = objectives.id and objectives.active=1 and outcomes.id = objective_outcome.outcome_id");
75
+        }
76
+        Log::info(print_r($json, true));
77
+        return json_encode($json);
78
+    }
15 79
     public function fetchCriterionWithTrashed()
16 80
     {
17
-        return Criterion::withTrashed()->find(Input::get('id'));
81
+
82
+        $json = array();
83
+        $json['criteria'] = DB::select(" select * from new_criteria where id = ?", array(Input::get('id')));
84
+        $json['outcomes'] = DB::select("select  DISTINCT outcomes.id, outcomes.name from outcomes , criterion_objective_outcome where criterion_objective_outcome.criterion_id = ? and outcomes.id = criterion_objective_outcome.outcome_id order by outcomes.id", array(Input::get('id')));
85
+        $json['objectives'] = DB::select("SELECT DISTINCT objectives.id, objectives.text FROM objectives, criterion_objective_outcome where criterion_objective_outcome.criterion_id = ? and criterion_objective_outcome.objective_id= objectives.id ", array(Input::get('id')));
86
+        $json['objectives_outcome'] = DB::select("select objectives.id, objectives.text, objective_outcome.outcome_id from objective_outcome, objectives where objective_outcome.outcome_id in(select  DISTINCT outcomes.id from outcomes , criterion_objective_outcome where criterion_objective_outcome.criterion_id = ? and outcomes.id = criterion_objective_outcome.outcome_id) and objectives.id = objective_outcome.objective_id ORDER BY outcome_id", array(Input::get('id')));
87
+        $json['scales'] = DB::select("select title, description, min_score, max_score from scales, criterion_scale where criterion_scale.scale_id = scales.id and criterion_id = ?", array(Input::get('id')));
88
+        $json['program'] = DB::select("select criterion_id, program_id from program_criterion where criterion_id =?", array(Input::get('id')));
89
+        $json['activity_criterion'] = DB::select("select * from new_assessments where activity_criterion_id  in (select id from activity_criterion where criterion_id = ?)", array(Input::get('id')));
90
+
91
+        foreach ($json['outcomes'] as $id) {
92
+            $outId = $id->id;
93
+            $json['outcomes_assoc'][$outId] = DB::select("select name from outcomes where id = {$outId}");
94
+            $json['objectives_assoc'][$outId] = DB::select("select objectives.id, objectives.text, outcomes.name from objectives, objective_outcome, outcomes where  objective_outcome.outcome_id ={$outId} and objective_outcome.objective_id = objectives.id and objectives.active=1 and outcomes.id = objective_outcome.outcome_id");
95
+        }
96
+
97
+        return json_encode($json);
18 98
     }
19 99
 
100
+    public function delete()
101
+    {
102
+        DB::delete("delete from new_criteria where id = ?", array(Input::get('criterion_delete')));
103
+        $role = Auth::user()['role'];
104
+        switch ($role) {
105
+            case 1:
106
+                return Redirect::to('criteria')->withInput();
107
+
108
+            case 2:
109
+                return Redirect::to('school-criteria')->withInput();
20 110
 
111
+            case 3:
112
+                return Redirect::to('program-criteria')->withInput();
113
+        }
114
+    }
21 115
     public function isCriterionUnique($input, $existing_criterion = NULL)
22 116
     {
23 117
         // dd($input);
24 118
         Log::info('isCriterionUnique');
25 119
 
26
-        if(Input::get('program_id')!=0)
120
+        if (Input::get('program_id') != 0)
27 121
             $program_id = $input['program_id'];
28 122
         else
29 123
             $program_id = NULL;
30 124
 
31
-        $saved_criterion = Criterion::
32
-            withTrashed()
125
+        $saved_criterion = Criterion::withTrashed()
33 126
             ->where('name', '=', $input['name'])
34 127
             ->where('outcome_id', '=', $input['outcome_id'])
35 128
             ->where('program_id', '=', $program_id)
36
-            // ->where('description12', '=', $input['description12'])
37
-            // ->where('description34', '=', $input['description34'])
38
-            // ->where('description56', '=', $input['description56'])
39
-            // ->where('description78', '=', $input['description78'])
40 129
             ->first();
41 130
 
42
-    
43 131
 
44
-        if($saved_criterion)
132
+
133
+        if ($saved_criterion)
45 134
             return false;
46 135
         else
47 136
             return true;
@@ -56,28 +145,40 @@ class CriteriaController extends \BaseController {
56 145
 
57 146
         $trimmed = trim(preg_replace('/\t+/', '', Input::get('subcriteria')));
58 147
 
59
-        Log::info('trimmed 1 -->'.$trimmed.'<--');
148
+        Log::info('trimmed 1 -->' . $trimmed . '<--');
60 149
 
61 150
 
62
-        if($trimmed ==''){
151
+        if ($trimmed == '') {
63 152
             $trimmed = NULL;
64
-        }
65
-        else{
153
+        } else {
66 154
             $trimmed = json_encode(preg_split('/\r\n/', $trimmed));
67 155
         }
68 156
 
69
-        Log::info('trimmed 2 -->'.$trimmed.'<--');
157
+        Log::info('trimmed 2 -->' . $trimmed . '<--');
70 158
 
71 159
 
72 160
         $clean_input['subcriteria'] = $trimmed;
73
-        $clean_input['outcome_id'] = trim(preg_replace('/\t+/', '', Input::get('outcome_id')));
74
-        $clean_input['program_id'] = trim(preg_replace('/\t+/', '', Input::get('program_id')));
75
-        $clean_input['description12'] = trim(preg_replace('/\t+/', '', Input::get('description12')));
76
-        $clean_input['description34'] = trim(preg_replace('/\t+/', '', Input::get('description34')));
77
-        $clean_input['description56'] = trim(preg_replace('/\t+/', '', Input::get('description56')));
78
-        $clean_input['description78'] = trim(preg_replace('/\t+/', '', Input::get('description78')));
161
+        $clean_input['outcome_id'] = Input::get('outcome');
162
+
163
+
164
+
165
+        $clean_input['objective_id'] = Input::get('objective');
166
+
167
+
168
+
169
+
170
+        $clean_input['program_id'] = Input::get('program_id');
171
+
79 172
         $clean_input['copyright'] = trim(preg_replace('/\t+/', '', Input::get('copyright')));
80 173
         $clean_input['notes'] = trim(preg_replace('/\t+/', '', Input::get('notes')));
174
+        $clean_input['maximum_score'] =  (int) Input::get('maximum_score');
175
+        $clean_input['scale_title'] = Input::get('title');
176
+        $clean_input['scale_description'] = Input::get('Scales');
177
+        $clean_input['min_score'] = Input::get('min');
178
+        $clean_input['max_score'] = Input::get('max');
179
+
180
+        $clean_input['number_of_scales'] = sizeof($clean_input['scale_title']);
181
+
81 182
 
82 183
         return $clean_input;
83 184
     }
@@ -90,30 +191,20 @@ class CriteriaController extends \BaseController {
90 191
                 'name' => $clean_input['name'],
91 192
                 'subcriteria' => $clean_input['subcriteria'],
92 193
                 'outcome_id' => $clean_input['outcome_id'],
93
-                'description12' => $clean_input['description12'],
94
-                'description34' => $clean_input['description34'],
95
-                'description56' => $clean_input['description56'],
96
-                'description78' => $clean_input['description78'],
97 194
                 'notes' => $clean_input['notes'],
98 195
                 'copyright' => $clean_input['copyright'],
196
+                'maximum_score' => $clean_input['maximum_score']
99 197
             ),
100 198
             array(
101 199
                 'name' => 'required|string',
102 200
                 'subcriteria' => 'string',
103
-                'outcome_id' => 'required|numeric|integer',
104
-                'description12' => 'required|string',
105
-                'description34' => 'required|string',
106
-                'description56' => 'required|string',
107
-                'description78' => 'required|string',
201
+                'outcome_id' => 'required|array',
202
+
108 203
                 'notes' => 'string',
109 204
                 'copyright' => 'string',
110
-            ),
111
-            array(
112
-                'description12.required' => 'The Beginning (1-2) field is required.',
113
-                'description34.required' => 'The In Progress (3-4) field is required.',
114
-                'description56.required' => 'The Satisfactory (5-6) field is required.',
115
-                'description78.required' => 'The Excellent (7-8) field is required.',
205
+                'maximum_score' => 'required|integer'
116 206
             )
207
+
117 208
         );
118 209
     }
119 210
 
@@ -130,115 +221,232 @@ class CriteriaController extends \BaseController {
130 221
         $validator = $this->makeValidator($clean_input);
131 222
 
132 223
         /** If validation fails */
133
-        if ($validator->fails())
134
-        {
224
+        if ($validator->fails()) {
135 225
             /** Prepare error message */
136 226
             $message = '<p>Error(s) creating a new Criterion:</p><ul>';
137 227
 
138
-            foreach ($validator->messages()->all('<li>:message</li>') as $validationError)
139
-            {
140
-                $message.=$validationError;
228
+            foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
229
+                $message .= $validationError;
141 230
             }
142 231
 
143
-            $message.='</ul>';
232
+            $message .= '</ul>';
144 233
 
145 234
             /** Send error message and old data */
146 235
             Session::flash('status', 'danger');
147 236
             Session::flash('message', $message);
148
-            return Redirect::to('criteria')->withInput();
149
-        }
150
-        else
151
-        {
237
+            $role = Auth::user()['role'];
238
+            switch ($role) {
239
+                case 1:
240
+                    return Redirect::to('criteria')->withInput();
241
+
242
+                case 2:
243
+                    return Redirect::to('school-criteria')->withInput();
244
+
245
+                case 3:
246
+                    return Redirect::to('program-criteria')->withInput();
247
+            }
248
+        } else {
152 249
             // Check criterion uniqueness
153
-            if(!$this->isCriterionUnique($clean_input))
154
-            {
155
-                /** Send error message and old data */
250
+            /*if (!$this->isCriterionUnique($clean_input)) {
251
+                /** Send error message and old data
156 252
                 Session::flash('status', 'danger');
157 253
                 Session::flash('message', 'This criterion is a duplicate of an already saved criterion because its name and associated program are the same.');
158 254
                 return Redirect::to('criteria')->withInput();
159
-            }
255
+            }*/
160 256
 
161 257
             /** Instantiate new criterion */
162 258
             $criterion = new Criterion;
163
-            $criterion->name= $clean_input['name'];
259
+            $criterion->name = $clean_input['name'];
164 260
             $criterion->subcriteria = $clean_input['subcriteria'];
165
-            $criterion->outcome_id= $clean_input['outcome_id'];
166
-            $criterion->description12 = $clean_input['description12'];
167
-            $criterion->description34 = $clean_input['description34'];
168
-            $criterion->description56 = $clean_input['description56'];
169
-            $criterion->description78 = $clean_input['description78'];
170 261
 
171
-            if(Input::get('copyright'))
262
+
263
+            //gabriel añadió aqui
264
+
265
+            $criterion->number_of_scales = $clean_input['number_of_scales'];
266
+            $criterion->maximum_score = $clean_input['maximum_score'];
267
+
268
+            if (Input::get('copyright'))
172 269
                 $criterion->copyright = $clean_input['copyright'];
173 270
 
174
-            if(Input::get('notes'))
271
+            if (Input::get('notes'))
175 272
                 $criterion->notes = $clean_input['notes'];
176 273
 
177
-            // Set program
178
-            if(Input::get('program_id')!=0)
179
-                $criterion->program_id = $clean_input['program_id'];
180
-            else
181
-                $criterion->program_id = NULL;
182 274
 
183 275
 
184 276
             /** If criterion is saved, send success message */
185
-            if($criterion->save())
186
-            {
277
+            if ($criterion->save()) {
278
+
279
+                $criterionId = $criterion->id;
280
+                foreach ($clean_input['outcome_id'] as $outcome_id) {
281
+                    foreach ($clean_input['objective_id'] as $objective_id) {
282
+
283
+                        DB::insert("insert into `criterion_objective_outcome` (`objective_id`, `outcome_id`, `criterion_id`, `objective_outcome_id`) values ({$objective_id},{$outcome_id}, {$criterionId}, 0)");
284
+                    }
285
+                }
286
+
287
+                for ($i = 0; $i < sizeof($clean_input['scale_title']); $i++) {
288
+                    $scale = new Scale;
289
+                    $scale->title = $clean_input['scale_title'][$i];
290
+                    $scale->position = $i + 1;
291
+                    $scale->description = $clean_input['scale_description'][$i];
292
+                    $scale->min_score = $clean_input['min_score'][$i];
293
+                    $scale->max_score = $clean_input['max_score'][$i];
294
+
295
+                    if ($scale->save()) {
296
+                        DB::insert("insert into `criterion_scale` (`criterion_id`, `scale_id`) values({$criterionId},{$scale->id})");
297
+                    } else {
298
+                        Session::flash('status', 'danger');
299
+                        Session::flash('message', '<p>Error creating the Scales</p>');
300
+                        $role = Auth::user()['role'];
301
+                        switch ($role) {
302
+                            case 1:
303
+                                return Redirect::to('criteria')->withInput();
304
+
305
+                            case 2:
306
+                                return Redirect::to('school-criteria')->withInput();
307
+
308
+                            case 3:
309
+                                return Redirect::to('program-criteria')->withInput();
310
+                        }
311
+                    }
312
+                }
313
+
314
+                foreach ($clean_input['program_id'] as $program_id) {
315
+                    DB::insert("insert into `program_criterion` (`criterion_id`, `program_id`) values({$criterionId},{$program_id})");
316
+                }
317
+
187 318
                 Session::flash('status', 'success');
188
-                Session::flash('message', 'Criterion created: "'.$criterion->name.'".');
189
-                return Redirect::to('criteria')->withInput(Input::only('outcome_id'));
319
+                Session::flash('message', 'Criterion created: "' . $criterion->name . '".');
320
+                $role = Auth::user()['role'];
321
+                switch ($role) {
322
+                    case 1:
323
+                        return Redirect::to('criteria')->withInput();
324
+
325
+                    case 2:
326
+                        return Redirect::to('school-criteria')->withInput();
327
+
328
+                    case 3:
329
+                        return Redirect::to('program-criteria')->withInput();
330
+                }
190 331
             }
191 332
 
192 333
             /** If saving fails, send error message and old data */
193
-            else
194
-            {
334
+            else {
195 335
                 Session::flash('status', 'danger');
196 336
                 Session::flash('message', '<p>Error creating Criterion. Please try again later.</p>');
197
-                return Redirect::to('learning-outcomes-criteria')->withInput();
337
+                $role = Auth::user()['role'];
338
+                switch ($role) {
339
+                    case 1:
340
+                        return Redirect::to('criteria')->withInput();
341
+
342
+                    case 2:
343
+                        return Redirect::to('school-criteria')->withInput();
344
+
345
+                    case 3:
346
+                        return Redirect::to('program-criteria')->withInput();
347
+                }
198 348
             }
199 349
         }
200 350
     }
201 351
 
352
+
353
+
202 354
     public function edit()
203 355
     {
204 356
         $title = "Criteria";
205
-        $outcomes = Outcome::orderBy('name', 'ASC')->get();
357
+        $outcomes = Outcome::orderBy('name', 'ASC')->lists('name', 'id');
358
+
206 359
         $schools = School::orderBy('name', 'ASC')->get();
207 360
         $criteria = Criterion::withTrashed()->orderBy('name', 'ASC')->get();
208 361
         $programs = Program::orderBy('name', 'ASC')->get();
362
+        $objectives = DB::table('objectives')->orderBy('text', 'ASC')->lists('text', 'id');
363
+
364
+
365
+
366
+
367
+
368
+        return View::make('local.managers.admins.criteria', compact('title', 'outcomes', 'schools', 'criteria', 'programs', 'objectives'));
369
+    }
370
+
371
+    private function cleanInputEdit()
372
+    {
373
+        $clean_input = array();
374
+
375
+        $clean_input['name'] = trim(preg_replace('/\t+/', '', Input::get('name')));
376
+
377
+
378
+        $trimmed = trim(preg_replace('/\t+/', '', Input::get('subcriteria')));
379
+
380
+        Log::info('trimmed 1 -->' . $trimmed . '<--');
381
+
382
+
383
+        if ($trimmed == '') {
384
+            $trimmed = NULL;
385
+        } else {
386
+            $trimmed = json_encode(preg_split('/\r\n/', $trimmed));
387
+        }
388
+
389
+        Log::info('trimmed 2 -->' . $trimmed . '<--');
390
+
391
+
392
+        $clean_input['subcriteria'] = $trimmed;
393
+        $clean_input['outcome_id'] = Input::get('assoc_outcome');
394
+
395
+
396
+
397
+        $clean_input['objective_id'] = Input::get('assoc_objective');
398
+
399
+
400
+
401
+
402
+        $clean_input['program_id'] = Input::get('program_id');
403
+
404
+        $clean_input['copyright'] = trim(preg_replace('/\t+/', '', Input::get('copyright')));
405
+        $clean_input['notes'] = trim(preg_replace('/\t+/', '', Input::get('notes')));
406
+        $clean_input['maximum_score'] = (int) Input::get('assoc_maximum_score');
407
+        $clean_input['scale_title'] = Input::get('assoc_title');
408
+        $clean_input['scale_description'] = Input::get('assoc_scales');
409
+        $clean_input['number_of_scales'] = sizeof($clean_input['scale_title']);
209 410
 
210
-        return View::make('local.managers.admins.criteria', compact('title', 'outcomes', 'schools', 'criteria', 'programs'));
411
+
412
+        return $clean_input;
211 413
     }
212 414
 
213 415
     public function update()
214 416
     {
215 417
         $criterion = Criterion::withTrashed()->find(Input::get('id'));
216 418
 
217
-        $clean_input = $this->cleanInput();
419
+        $clean_input = $this->cleanInputEdit();
218 420
 
219 421
         /** Validation rules */
220 422
         $validator = $this->makeValidator($clean_input);
221 423
 
222 424
         /** If validation fails */
223
-        if ($validator->fails())
224
-        {
425
+        if ($validator->fails()) {
225 426
             /** Prepare error message */
226 427
             $message = 'Error(s) updating the Criterion: <ul>';
227 428
 
228
-            foreach ($validator->messages()->all('<li>:message</li>') as $validationError)
229
-            {
230
-                $message.=$validationError;
429
+            foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
430
+                $message .= $validationError;
231 431
             }
232 432
 
233
-            $message.='</ul>';
433
+            $message .= '</ul>';
234 434
 
235 435
             /** Send error message and old data */
236 436
             Session::flash('status', 'danger');
237 437
             Session::flash('message', $message);
238
-            return Redirect::back()->withInput();
239
-        }
240
-        else
241
-        {
438
+            $role = Auth::user()['role'];
439
+            switch ($role) {
440
+                case 1:
441
+                    return Redirect::to('objective')->withInput();
442
+
443
+                case 2:
444
+                    return Redirect::to('school-objective')->withInput();
445
+
446
+                case 3:
447
+                    return Redirect::to('program-objective')->withInput();
448
+            }
449
+        } else {
242 450
 
243 451
             // // Check criterion uniqueness
244 452
             // if(!$this->isCriterionUnique($clean_input, $criterion))
@@ -250,50 +458,107 @@ class CriteriaController extends \BaseController {
250 458
             // }
251 459
 
252 460
             /** Set info */
253
-            $criterion->name= $clean_input['name'];
461
+            $criterion->name = $clean_input['name'];
254 462
             $criterion->subcriteria = $clean_input['subcriteria'];
255
-            $criterion->outcome_id= $clean_input['outcome_id'];
256
-            $criterion->description12 = $clean_input['description12'];
257
-            $criterion->description34 = $clean_input['description34'];
258
-            $criterion->description56 = $clean_input['description56'];
259
-            $criterion->description78 = $clean_input['description78'];
463
+
464
+
465
+
466
+            $criterion->number_of_scales = $clean_input['number_of_scales'];
467
+            $criterion->maximum_score = $clean_input['maximum_score'];
468
+
469
+
260 470
 
261 471
             // Set program
262
-            if(Input::get('program_id')!=0)
472
+            if (Input::get('program_id') != 0)
263 473
                 $criterion->program_id = Input::get('program_id');
264 474
             else
265 475
                 $criterion->program_id = NULL;
266 476
 
267 477
             // Set status
268
-            if(Input::get('status')==0)
478
+            if (Input::get('status') == 0)
269 479
                 $criterion->deleted_at = date('Y-m-d H:i:s');
270 480
             else
271 481
                 $criterion->deleted_at = NULL;
272 482
 
273
-            if(Input::get('copyright'))
483
+            if (Input::get('copyright'))
274 484
                 $criterion->copyright = $clean_input['copyright'];
275 485
             else
276
-                $criterion->copyright=NULL;
486
+                $criterion->copyright = NULL;
277 487
 
278
-            if(Input::get('notes'))
488
+            if (Input::get('notes'))
279 489
                 $criterion->notes = $clean_input['notes'];
280 490
             else
281
-                $criterion->notes=NULL;
491
+                $criterion->notes = NULL;
282 492
 
283 493
             /** If criterion is updated, send success message */
284
-            if($criterion->save())
285
-            {
494
+            if ($criterion->save()) {
495
+                $criterionId = $criterion->id;
496
+                DB::delete("delete from `criterion_objective_outcome` where `criterion_id` ={$criterionId}");
497
+
498
+                foreach ($clean_input['outcome_id'] as $outcome_id) {
499
+                    foreach ($clean_input['objective_id'] as $objective_id) {
500
+
501
+                        DB::insert("insert into `criterion_objective_outcome` (`objective_id`, `outcome_id`, `criterion_id`,`objective_outcome_id`) values ({$objective_id},{$outcome_id}, {$criterionId}, 0)");
502
+                    }
503
+                }
504
+                DB::delete("delete from `scales` where id in (select scale_id id from criterion_scale where criterion_id = {$criterionId})");
505
+
506
+                for ($i = 0; $i < sizeof($clean_input['scale_title']); $i++) {
507
+                    $scale = new Scale;
508
+                    $scale->title = $clean_input['scale_title'][$i];
509
+                    $scale->position = $i + 1;
510
+                    $scale->description = $clean_input['scale_description'][$i];
511
+                    if ($scale->save()) {
512
+                        DB::insert("insert into `criterion_scale` (`criterion_id`, `scale_id`) values({$criterionId},{$scale->id})");
513
+                    } else {
514
+                        Session::flash('status', 'danger');
515
+                        Session::flash('message', '<p>Error creating the Scales</p>');
516
+                        $role = Auth::user()['role'];
517
+                        switch ($role) {
518
+                            case 1:
519
+                                return Redirect::to('objective')->withInput();
520
+
521
+                            case 2:
522
+                                return Redirect::to('school-objective')->withInput();
523
+
524
+                            case 3:
525
+                                return Redirect::to('program-objective')->withInput();
526
+                        }
527
+                    }
528
+                }
529
+
530
+
531
+
286 532
                 Session::flash('status', 'success');
287
-                Session::flash('message', 'Updated criterion: "'.$criterion->name.'"');
288
-                return Redirect::back();
533
+                Session::flash('message', 'Updated criterion: "' . $criterion->name . '"');
534
+                $role = Auth::user()['role'];
535
+                switch ($role) {
536
+                    case 1:
537
+                        return Redirect::to('objective')->withInput();
538
+
539
+                    case 2:
540
+                        return Redirect::to('school-objective')->withInput();
541
+
542
+                    case 3:
543
+                        return Redirect::to('program-objective')->withInput();
544
+                }
289 545
             }
290 546
 
291 547
             /** If saving fails, send error message and old data */
292
-            else
293
-            {
548
+            else {
294 549
                 Session::flash('status', 'danger');
295 550
                 Session::flash('message', 'Error updating the Criterion. Please try again later.');
296
-                return Redirect::back()->withInput();
551
+                $role = Auth::user()['role'];
552
+                switch ($role) {
553
+                    case 1:
554
+                        return Redirect::to('objective')->withInput();
555
+
556
+                    case 2:
557
+                        return Redirect::to('school-objective')->withInput();
558
+
559
+                    case 3:
560
+                        return Redirect::to('program-objective')->withInput();
561
+                }
297 562
             }
298 563
         }
299 564
     }
@@ -303,52 +568,57 @@ class CriteriaController extends \BaseController {
303 568
         // el ID de los semestres que el usuario tiene seleccionado.
304 569
         $semesters_ids = Session::get('semesters_ids');
305 570
         // buscar informacion de los semestres seleccionados
306
-        $semesters = Semester::whereIn('id',$semesters_ids)->get();
571
+        $semesters = Semester::whereIn('id', $semesters_ids)->get();
307 572
 
308 573
         $title = "Learning Outcomes and Criteria";
309 574
         $outcomes = Outcome::orderBy('name', 'ASC')->get();
575
+        // $outcomes = DB::table('outcomes')
576
+        //     ->orderBy('name', 'asc')
577
+        //     ->get();
310 578
         $schools = School::orderBy('name', 'ASC')->get();
579
+        // $schools = DB::table('schools')
580
+        //     ->orderBy('name', 'asc')
581
+        //     ->get();
311 582
         $criteria = Criterion::withTrashed()->orderBy('name', 'ASC')->get();
583
+        // $criteria = DB::table('criteria')
584
+        //     ->orderBy('name', 'asc')
585
+        //     ->get();
312 586
 
313 587
         // se annadio la nueva variable
314 588
         return View::make('global.view-learning-outcomes-criteria', compact('title', 'outcomes', 'schools', 'criteria', 'semesters'));
315 589
 
316 590
     }
317 591
 
592
+
318 593
     // copie index() y lo edite
319 594
     public function objectivesIndex()
320 595
     {
321
-        if(Auth::user()->role==1)
322
-        {
323
-          //uscar todos los objetivos
324
-          $objectives = DB::table('program_user')
325
-                                ->join('objectives','objectives.program_id','=','program_user.program_id')
326
-                                ->join('programs','programs.id','=','program_user.program_id')
327
-                                ->select('objectives.id','objectives.text','programs.name')
328
-                                ->orderBy('objectives.text', 'asc')
329
-                                ->get();
330
-        }
331
-        elseif(Auth::user()->role==2)
332
-        {
333
-          //buscar los objetivos de la departamento (school)
334
-          $objectives = DB::table('program_user')
335
-                                ->join('objectives','objectives.program_id','=','program_user.program_id')
336
-                                ->join('programs','programs.id','=','program_user.program_id')
337
-                                ->where('programs.school_id',Auth::user()->school_id)
338
-                                ->select('objectives.id','objectives.text','programs.name')
339
-                                ->orderBy('objectives.text', 'asc')
340
-                                ->get();
341
-        }
342
-        elseif((Auth::user()->role==3) || (Auth::user()->role==4))
343
-        {
344
-          //buscar los objetivos de los programas cuales el profesor esta
345
-          $objectives = DB::table('program_user')
346
-                                ->join('objectives','objectives.program_id','=','program_user.program_id')
347
-                                ->join('programs','programs.id','=','program_user.program_id')
348
-                                ->where('program_user.user_id',Auth::user()->id)
349
-                                ->select('objectives.id','objectives.text','programs.name')
350
-                                ->orderBy('objectives.text', 'asc')
351
-                                ->get();
596
+        if (Auth::user()->role == 1) {
597
+            //uscar todos los objetivos
598
+            $objectives = DB::table('program_user')
599
+                ->join('objectives', 'objectives.program_id', '=', 'program_user.program_id')
600
+                ->join('programs', 'programs.id', '=', 'program_user.program_id')
601
+                ->select('objectives.id', 'objectives.text', 'programs.name')
602
+                ->orderBy('objectives.text', 'asc')
603
+                ->get();
604
+        } elseif (Auth::user()->role == 2) {
605
+            //buscar los objetivos de la departamento (school)
606
+            $objectives = DB::table('program_user')
607
+                ->join('objectives', 'objectives.program_id', '=', 'program_user.program_id')
608
+                ->join('programs', 'programs.id', '=', 'program_user.program_id')
609
+                ->where('programs.school_id', Auth::user()->school_id)
610
+                ->select('objectives.id', 'objectives.text', 'programs.name')
611
+                ->orderBy('objectives.text', 'asc')
612
+                ->get();
613
+        } elseif ((Auth::user()->role == 3) || (Auth::user()->role == 4)) {
614
+            //buscar los objetivos de los programas cuales el profesor esta
615
+            $objectives = DB::table('program_user')
616
+                ->join('objectives', 'objectives.program_id', '=', 'program_user.program_id')
617
+                ->join('programs', 'programs.id', '=', 'program_user.program_id')
618
+                ->where('program_user.user_id', Auth::user()->id)
619
+                ->select('objectives.id', 'objectives.text', 'programs.name')
620
+                ->orderBy('objectives.text', 'asc')
621
+                ->get();
352 622
         }
353 623
 
354 624
         $title = "Learning Objectives and Criteria";
@@ -359,70 +629,75 @@ class CriteriaController extends \BaseController {
359 629
     public function destroy()
360 630
     {
361 631
         $criterion = Criterion::withTrashed()->find(Input::get('id'));
362
-        if(!$criterion->trashed())
363
-        {
364
-            try
365
-            {
632
+        if (!$criterion->trashed()) {
633
+            try {
366 634
                 $criterion->delete();
367 635
                 Session::flash('status', 'success');
368
-                Session::flash('message', 'Deactivated criterion: "'.$criterion->name.'"');
369
-            }
370
-            catch (Exception $e)
371
-            {
636
+                Session::flash('message', 'Deactivated criterion: "' . $criterion->name . '"');
637
+            } catch (Exception $e) {
372 638
                 Session::flash('status', 'danger');
373
-                Session::flash('message', 'Error deactivating criterion."'.$criterion->name.'"');
639
+                Session::flash('message', 'Error deactivating criterion."' . $criterion->name . '"');
374 640
             }
375
-            return Redirect::back();
376
-        }
377
-        else
378
-        {
379
-            try
380
-            {
641
+            $role = Auth::user()['role'];
642
+            switch ($role) {
643
+                case 1:
644
+                    return Redirect::to('objective')->withInput();
645
+
646
+                case 2:
647
+                    return Redirect::to('school-objective')->withInput();
648
+
649
+                case 3:
650
+                    return Redirect::to('program-objective')->withInput();
651
+            }
652
+        } else {
653
+            try {
381 654
                 $criterion->restore();
382 655
                 Session::flash('status', 'success');
383
-                Session::flash('message', 'Reactivated criterion: "'.$criterion->name.'"');
384
-            }
385
-            catch (Exception $e)
386
-            {
656
+                Session::flash('message', 'Reactivated criterion: "' . $criterion->name . '"');
657
+            } catch (Exception $e) {
387 658
                 Session::flash('status', 'danger');
388
-                Session::flash('message', 'Error reactivating criterion: "'.$criterion->name.'".');
659
+                Session::flash('message', 'Error reactivating criterion: "' . $criterion->name . '".');
389 660
             }
390
-            return Redirect::back();
661
+            $role = Auth::user()['role'];
662
+            switch ($role) {
663
+                case 1:
664
+                    return Redirect::to('objective')->withInput();
391 665
 
666
+                case 2:
667
+                    return Redirect::to('school-objective')->withInput();
668
+
669
+                case 3:
670
+                    return Redirect::to('program-objective')->withInput();
671
+            }
392 672
         }
393 673
     }
394 674
 
395 675
     public function filterCriteria()
396 676
     {
397
-        switch (Input::get('filter'))
398
-        {
677
+        switch (Input::get('filter')) {
399 678
             case 'all':
400 679
                 return Criteria::all();
401 680
                 break;
402 681
 
403 682
             case 'school':
404 683
                 // If scoord
405
-                if(Auth::user()->role == '2')
406
-                {
684
+                if (Auth::user()->role == '2') {
407 685
 
408 686
                     // Fetch all the programs whose school is the user's
409 687
                     $program_ids = DB::table('programs')->where('school_id', Auth::user()->school_id)->lists('id');
410 688
 
411 689
                     // Return all criteria belonging to any of those programs
412
-                    return Criterion::
413
-                        whereIn('program_id', $program_ids)
690
+                    return Criterion::whereIn('program_id', $program_ids)
414 691
                         ->orderBy('name', 'ASC')
415 692
                         ->get();
416 693
                 }
417 694
 
418 695
                 // If pcoord
419
-                else
420
-                {
696
+                else {
421 697
                     // Fetch all the programs from the user's school;
422 698
                     $program_ids = DB::table('programs')->where('school_id', Auth::user()->programs[0]->school->id)->lists('id');
423 699
 
424
-                    return Criterion::
425
-                        whereIn('program_id', $program_ids)
700
+                    return Criterion::whereIn('program_id', $program_ids)
426 701
                         ->orderBy('name', 'ASC')
427 702
                         ->get();
428 703
                 }
@@ -430,8 +705,7 @@ class CriteriaController extends \BaseController {
430 705
                 break;
431 706
 
432 707
             case 'program':
433
-                return Criterion::
434
-                    whereIn('program_id', Auth::user()->programs->lists('id'))
708
+                return Criterion::whereIn('program_id', Auth::user()->programs->lists('id'))
435 709
                     ->orderBy('name', 'ASC')
436 710
                     ->get();
437 711
                 break;

+ 465
- 0
app/controllers/Objective2Controller.php Ver arquivo

@@ -0,0 +1,465 @@
1
+<?php
2
+
3
+use Illuminate\Support\Facades\Auth;
4
+
5
+class Objective2Controller extends \BaseController
6
+{
7
+
8
+	/**
9
+	 * Display a listing of the resource.
10
+	 *
11
+	 * @return Response
12
+	 */
13
+
14
+	public function index()
15
+	{
16
+
17
+		$title = "Learning Outcomes and Criteria";
18
+		$outcomes = Outcome::orderBy('name', 'ASC')->get();
19
+		$schools = School::orderBy('name', 'ASC')->get();
20
+		$objectives = Objective::withTrashed()->orderBy('text', 'ASC')->get();
21
+
22
+		return View::make('global.view-learning-outcomes-criteria', compact('title', 'outcomes', 'schools', 'objectives'));
23
+	}
24
+
25
+
26
+
27
+	/**
28
+	 * Show the form for creating a new resource.
29
+	 *
30
+	 * @return Response
31
+	 */
32
+	public function isObjectiveUnique($input, $existing_Objective = NULL)
33
+	{
34
+
35
+		Log::info('isObjectiveUnique');
36
+
37
+		if (Input::get('program_id') != 0)
38
+			$program_id = $input['program_id'];
39
+		else
40
+			$program_id = NULL;
41
+
42
+		$saved_Objective = Objective::withTrashed()
43
+			->where('text', '=', $input['text'])
44
+			->where('outcome_id', '=', $input['outcome_id'])
45
+			->where('program_id', '=', $program_id)
46
+
47
+			->first();
48
+
49
+
50
+
51
+		if ($saved_Objective)
52
+			return false;
53
+		else
54
+			return true;
55
+	}
56
+
57
+
58
+	private function makeValidator($clean_input)
59
+	{
60
+		/** Validation rules */
61
+		return Validator::make(
62
+			array(
63
+				'text' => $clean_input['text'],
64
+
65
+				'outcome_id' => $clean_input['outcome_id'],
66
+				'program_id' => $clean_input['program_id']
67
+
68
+			),
69
+			array(
70
+				'text' => 'required|string',
71
+
72
+				'outcome_id' => 'required|array',
73
+				'program_id' => 'required|array'
74
+
75
+			)
76
+
77
+		);
78
+	}
79
+
80
+
81
+	private function cleanInput()
82
+	{
83
+		$clean_input = array();
84
+
85
+		$clean_input['text'] = trim(preg_replace('/\t+/', '', Input::get('text')));
86
+
87
+
88
+		$clean_input['outcome_id'] = Input::get('outcome');
89
+		$counter = Input::get('counter') + 0;
90
+
91
+		for ($i = 0; $i < $counter; $i++) {
92
+			$clean_input['outcome_id'][$i] = trim(preg_replace('/\t+/', '', $clean_input['outcome_id'][$i]));
93
+		}
94
+
95
+		$clean_input['program_id'] = Input::get('program_id');
96
+
97
+
98
+		return $clean_input;
99
+	}
100
+
101
+	private function cleanAssocInput()
102
+	{
103
+		$clean_input = array();
104
+
105
+		$clean_input['text'] = trim(preg_replace('/\t+/', '', Input::get('text')));
106
+
107
+
108
+		$clean_input['outcome_id'] = Input::get('assoc_outcome');
109
+
110
+
111
+
112
+		$clean_input['program_id'] = Input::get('program_id');
113
+
114
+
115
+		return $clean_input;
116
+	}
117
+	public function fetchObjective()
118
+	{
119
+		return Objective::find(Input::get('id'));
120
+	}
121
+
122
+	public function fetchObjectiveWithTrashed()
123
+	{
124
+		$json = array();
125
+
126
+		$json['program'] = DB::select("select program_id from objective_program where objective_id = ?", array(Input::get('id')));
127
+		$json['outcome'] = DB::select("select outcome_id from objective_outcome outc where outc.objective_id = ?", array(Input::get('id')));
128
+		$json['objective'] = DB::select("select text, id from objectives where id =?", array(Input::get('id')));
129
+		$json['assessment'] = DB::select("select * from assessments where activity_id  in (select activity_id from activity_criterion where criterion_id in (select criterion_id from criterion_objective_outcome where objective_id = ?))", array(Input::get('id')));
130
+		$json['assoc_criteria'] = DB::select("select name from criteria where id in(select criterion_id from criterion_objective_outcome where objective_id =?)", array(Input::get('id')));
131
+		return json_encode($json);
132
+	}
133
+	public function fetchAllobjectives()
134
+	{
135
+		$program_id = Input::get('program_fetch');
136
+		$outcome_id = Input::get('outcome_fetch');
137
+		$json = array();
138
+		$json['objective'] = DB::select("SELECT * FROM `objectives` where id in (select objective_id from criterion_objective_outcome where outcome_id ={$outcome_id}) and id in(select objective_id from objective_program where program_id = {$program_id})");
139
+		return json_encode($json);
140
+	}
141
+	public function delete()
142
+	{
143
+		DB::delete("delete from objectives where id = ?", array(Input::get('deleteObj')));
144
+		$role = Auth::user()['role'];
145
+		switch ($role) {
146
+			case 1:
147
+				return Redirect::to('objectives')->withInput();
148
+
149
+			case 2:
150
+				return Redirect::to('school-objectives')->withInput();
151
+
152
+			case 3:
153
+				return Redirect::to('program-objectives')->withInput();
154
+		}
155
+	}
156
+	/**
157
+	 * Create a new Objective.
158
+	 *
159
+	 * @return Redirect Redirect back to form page
160
+	 */
161
+	public function create()
162
+	{
163
+
164
+		$clean_input = $this->cleanInput();
165
+
166
+		/** Validation rules */
167
+		$validator = $this->makeValidator($clean_input);
168
+
169
+		/** If validation fails */
170
+		if ($validator->fails()) {
171
+			/** Prepare error message */
172
+			$message = '<p>Error(s) creating a new Objective:</p><ul>';
173
+
174
+			foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
175
+				$message .= $validationError;
176
+			}
177
+
178
+			$message .= '</ul>';
179
+
180
+			/** Send error message and old data */
181
+			Session::flash('status', 'danger');
182
+			Session::flash('message', $message);
183
+			$role = Auth::user()['role'];
184
+			switch ($role) {
185
+				case 1:
186
+					return Redirect::to('objective')->withInput();
187
+
188
+				case 2:
189
+					return Redirect::to('school-objective')->withInput();
190
+
191
+				case 3:
192
+					return Redirect::to('program-objective')->withInput();
193
+			}
194
+		} else {
195
+			// Check Objective uniqueness
196
+			if (!$this->isObjectiveUnique($clean_input)) {
197
+				/** Send error message and old data */
198
+				Session::flash('status', 'danger');
199
+				Session::flash('message', "This objective is a duplicate of an already saved Objective because it's and associated program are the same.");
200
+				$role = Auth::user()['role'];
201
+				switch ($role) {
202
+					case 1:
203
+						return Redirect::to('objective')->withInput();
204
+
205
+					case 2:
206
+						return Redirect::to('school-objective')->withInput();
207
+
208
+					case 3:
209
+						return Redirect::to('program-objective')->withInput();
210
+				}
211
+			}
212
+
213
+			/** Instantiate new Objective */
214
+			$objective = new Objective;
215
+			$objective->text = $clean_input['text'];
216
+
217
+
218
+
219
+
220
+
221
+
222
+
223
+			/** If Objective is saved, send success message */
224
+			if ($objective->save()) {
225
+				$objectiveId = $objective->id;
226
+				foreach ($clean_input['program_id'] as $program_id) {
227
+					DB::insert("insert into objective_program (objective_id, program_id) values({$objectiveId},{$program_id})");
228
+				}
229
+				foreach ($clean_input['outcome_id'] as $outcome_id) {
230
+					DB::insert("insert into `objective_outcome` (objective_id, outcome_id) values ({$objectiveId}, {$outcome_id})");
231
+
232
+					/*if (!($objectiveOutcome->save())) {
233
+						Session::flash('status', 'danger');
234
+						Session::flash('message', '<p>Error creating objective. Please try again later.</p>');
235
+						return Redirect::to('objective')->withInput();
236
+					}*/
237
+				}
238
+
239
+				Session::flash('status', 'success');
240
+				Session::flash('message', 'Objective created: "' . $objective->text . '".');
241
+				$role = Auth::user()['role'];
242
+				switch ($role) {
243
+					case 1:
244
+						return Redirect::to('objective')->withInput(Input::only('outcome_id'));
245
+
246
+					case 2:
247
+						return Redirect::to('school-objective')->withInput(Input::only('outcome_id'));
248
+
249
+					case 3:
250
+						return Redirect::to('program-objective')->withInput(Input::only('outcome_id'));
251
+				}
252
+			}
253
+
254
+			/** If saving fails, send error message and old data */
255
+			else {
256
+				Session::flash('status', 'danger');
257
+				Session::flash('message', '<p>Error creating objective. Please try again later.</p>');
258
+				$role = Auth::user()['role'];
259
+				switch ($role) {
260
+					case 1:
261
+						return Redirect::to('objective')->withInput();
262
+
263
+					case 2:
264
+						return Redirect::to('school-objective')->withInput();
265
+
266
+					case 3:
267
+						return Redirect::to('program-objective')->withInput();
268
+				}
269
+			}
270
+		}
271
+	}
272
+	/**
273
+	 * Store a newly created resource in storage.
274
+	 *
275
+	 * @return Response
276
+	 */
277
+	public function store()
278
+	{
279
+		//
280
+	}
281
+
282
+
283
+	/**
284
+	 * Display the specified resource.
285
+	 *
286
+	 * @param  int  $id
287
+	 * @return Response
288
+	 */
289
+	public function show($id)
290
+	{
291
+		//
292
+	}
293
+
294
+
295
+	/**
296
+	 * Show the form for editing the specified resource.
297
+	 *
298
+	 * @param  int  $id
299
+	 * @return Response
300
+	 */
301
+	public function edit()
302
+	{
303
+		$title = "Objective";
304
+		$outcomes = Outcome::orderBy('name', 'ASC')->lists('name', 'id');
305
+
306
+		$objectives = Objective::withTrashed()->orderBy('text', 'ASC')->get();
307
+		$programs = Program::orderBy('name', 'ASC')->get();
308
+
309
+		return View::make('local.managers.admins.objectives', compact('title', 'outcomes', 'objectives', 'programs'));
310
+	}
311
+
312
+	public function editProgram()
313
+	{
314
+		$userProgram = Auth::user()['id'];
315
+		Log::info(Auth::user());
316
+
317
+		$userProgram = DB::select("select program_user.program_id from program_user where user_id = {$userProgram}");
318
+
319
+		$title = "Objective";
320
+		$outcomes = Outcome::orderBy('name', 'ASC')->lists('name', 'id');
321
+
322
+		$objectives = Objective::withTrashed()->orderBy('text', 'ASC')->get();
323
+
324
+		$programs = Program::where("id", '=', $userProgram[0]->program_id)->get();
325
+
326
+
327
+
328
+
329
+		return View::make('local.managers.pCoords.objectives', compact('title', 'outcomes', 'objectives', 'programs'));
330
+	}
331
+
332
+	public function editSchool()
333
+	{
334
+		$userSchool = Auth::user()['school_id'];
335
+		Log::info($userSchool);
336
+		$title = "Objective";
337
+		$outcomes = Outcome::orderBy('name', 'ASC')->lists('name', 'id');
338
+
339
+		$objectives = Objective::withTrashed()->orderBy('text', 'ASC')->get();
340
+		$programs = Program::where("school_id", "=", $userSchool)->orderBy('name', 'ASC')->get();
341
+
342
+
343
+
344
+		return View::make('local.managers.sCoords.objectives', compact('title', 'outcomes', 'objectives', 'programs'));
345
+	}
346
+
347
+	/**
348
+	 * Update the specified resource in storage.
349
+	 *
350
+	 * @param  int  $id
351
+	 * @return Response
352
+	 */
353
+
354
+	public function update()
355
+
356
+	{
357
+
358
+		$Objective = Objective::withTrashed()->find(Input::get('id'));
359
+
360
+		$clean_input = $this->cleanAssocInput();
361
+
362
+		Log::info(print_r($clean_input, true));
363
+
364
+		/** Validation rules */
365
+		$validator = $this->makeValidator($clean_input);
366
+
367
+		/** If validation fails */
368
+		if ($validator->fails()) {
369
+			/** Prepare error message */
370
+			$message = 'Error(s) updating the Objective: <ul>';
371
+
372
+			foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
373
+				$message .= $validationError;
374
+			}
375
+
376
+			$message .= '</ul>';
377
+
378
+			/** Send error message and old data */
379
+			Session::flash('status', 'danger');
380
+			Session::flash('message', $message);
381
+			$role = Auth::user()['role'];
382
+			switch ($role) {
383
+				case 1:
384
+					return Redirect::to('objective')->withInput();
385
+
386
+				case 2:
387
+					return Redirect::to('school-objective')->withInput();
388
+
389
+				case 3:
390
+					return Redirect::to('program-objective')->withInput();
391
+			}
392
+		} else {
393
+
394
+
395
+
396
+			/** Set info */
397
+			$Objective->text = $clean_input['text'];
398
+
399
+
400
+
401
+
402
+			// Set status
403
+
404
+
405
+			/** If Objective is updated, send success message */
406
+			if ($Objective->save()) {
407
+
408
+				$objectiveId = $Objective->id;
409
+				DB::delete("delete from `objective_outcome` where objective_id ={$objectiveId}");
410
+				DB::delete("delete from objective_program where objective_id = {$objectiveId}");
411
+
412
+				foreach ($clean_input['program_id'] as $program_id) {
413
+					DB::insert("insert into `objective_program`(objective_id, program_id) values ({$objectiveId},{$program_id})");
414
+				}
415
+				foreach ($clean_input['outcome_id'] as $outcome_id) {
416
+					DB::insert("insert into `objective_outcome` (objective_id, outcome_id) values ({$objectiveId}, {$outcome_id})");
417
+				}
418
+
419
+				Session::flash('status', 'success');
420
+				Session::flash('message', 'Updated Objective: "' . $Objective->text . '"');
421
+				$role = Auth::user()['role'];
422
+				switch ($role) {
423
+					case 1:
424
+						return Redirect::to('objective')->withInput();
425
+
426
+					case 2:
427
+						return Redirect::to('school-objective')->withInput();
428
+
429
+					case 3:
430
+						return Redirect::to('program-objective')->withInput();
431
+				}
432
+			}
433
+
434
+			/** If saving fails, send error message and old data */
435
+			else {
436
+				Session::flash('status', 'danger');
437
+				Session::flash('message', 'Error updating the Objective. Please try again later.');
438
+				$role = Auth::user()['role'];
439
+				switch ($role) {
440
+					case 1:
441
+						return Redirect::to('objective')->withInput();
442
+
443
+					case 2:
444
+						return Redirect::to('school-objective')->withInput();
445
+
446
+					case 3:
447
+						return Redirect::to('program-objective')->withInput();
448
+				}
449
+			}
450
+		}
451
+	}
452
+
453
+
454
+
455
+	/**
456
+	 * Remove the specified resource from storage.
457
+	 *
458
+	 * @param  int  $id
459
+	 * @return Response
460
+	 */
461
+	public function destroy($id)
462
+	{
463
+		//
464
+	}
465
+}

+ 86
- 0
app/controllers/Objective_OutcomeController.php Ver arquivo

@@ -0,0 +1,86 @@
1
+<?php
2
+
3
+class Objective_OutcomeController extends \BaseController {
4
+
5
+	/**
6
+	 * Display a listing of the resource.
7
+	 *
8
+	 * @return Response
9
+	 */
10
+	public function index()
11
+	{
12
+		//
13
+	}
14
+
15
+
16
+	/**
17
+	 * Show the form for creating a new resource.
18
+	 *
19
+	 * @return Response
20
+	 */
21
+	public function create()
22
+	{
23
+		//
24
+	}
25
+
26
+
27
+	/**
28
+	 * Store a newly created resource in storage.
29
+	 *
30
+	 * @return Response
31
+	 */
32
+	public function store()
33
+	{
34
+		//
35
+	}
36
+
37
+
38
+	/**
39
+	 * Display the specified resource.
40
+	 *
41
+	 * @param  int  $id
42
+	 * @return Response
43
+	 */
44
+	public function show($id)
45
+	{
46
+		//
47
+	}
48
+
49
+
50
+	/**
51
+	 * Show the form for editing the specified resource.
52
+	 *
53
+	 * @param  int  $id
54
+	 * @return Response
55
+	 */
56
+	public function edit($id)
57
+	{
58
+		//
59
+	}
60
+
61
+
62
+	/**
63
+	 * Update the specified resource in storage.
64
+	 *
65
+	 * @param  int  $id
66
+	 * @return Response
67
+	 */
68
+	public function update($id)
69
+	{
70
+		//
71
+	}
72
+
73
+
74
+	/**
75
+	 * Remove the specified resource from storage.
76
+	 *
77
+	 * @param  int  $id
78
+	 * @return Response
79
+	 */
80
+	public function destroy($id)
81
+	{
82
+		//
83
+	}
84
+
85
+
86
+}

+ 336
- 264
app/controllers/OutcomesController.php Ver arquivo

@@ -2,7 +2,8 @@
2 2
 
3 3
 use Illuminate\Database\Eloquent\Collection;
4 4
 
5
-class OutcomesController extends \BaseController {
5
+class OutcomesController extends \BaseController
6
+{
6 7
 
7 8
 
8 9
     /**
@@ -25,7 +26,7 @@ class OutcomesController extends \BaseController {
25 26
     public function newIndex()
26 27
     {
27 28
         $title = "Learning Outcomes";
28
-//        TODO: Check when semester doesnt exist or session is empty
29
+        //        TODO: Check when semester doesnt exist or session is empty
29 30
         $selected_semester = Semester::find(Session::get('semesters_ids')[0]);
30 31
         $outcomes = Outcome::withTrashed()->where('deactivation_date', '>=', $selected_semester->start)->orWhere('deactivation_date', null)->orderBy('name', 'ASC')->get();
31 32
         $schools = School::orderBy('name', 'ASC')->get();
@@ -35,141 +36,186 @@ class OutcomesController extends \BaseController {
35 36
 
36 37
     public function show($id)
37 38
     {
38
-        DB::disableQueryLog();
39 39
         $outcome = Outcome::find($id);
40
+        $selected_semesters = Semester::find(Session::get('semesters_ids'));
41
+        $programs = $outcome->programs_attempted($selected_semesters);
42
+
43
+        $undergradResults = array("names" => array(), "schools" => array(), "achieved" => array(), "attempted" => array(), "successRate" => array());
44
+        $gradResults = array("names" => array(), "schools" => array(), "achieved" => array(), "attempted" => array(), "successRate" => array());
45
+        foreach ($programs as $program_id) {
46
+ //        	var_dump($program_id);
47
+//         	exit();
48
+        	$program = Program::where('id', '=', $program_id->id)->first();
49
+        	$school = School::where('id', '=', $program->school_id)->first();
50
+        	if($program->is_graduate)
51
+        	{
52
+        		$gradResults['names'][] = $program->name;
53
+        		$gradResults['schools'][] = $school->name;
54
+        		$attempted = $program->attempted_criteria_by_outcome($id, $selected_semesters);
55
+        		$gradResults['attempted'][] = $attempted;
56
+        		$achieved = $program->achieved_criteria_by_outcome($id, $selected_semesters);
57
+        		$gradResults['achieved'][] = $achieved;
58
+        		$gradResults['successRate'][] = sprintf("%.2f",100*$achieved/$attempted);
59
+
60
+        	}
61
+        	else
62
+        	{
63
+        		$undergradResults['names'][] = $program->name;
64
+        		$undergradResults['schools'][] = $school->name;
65
+        		$attempted = $program->attempted_criteria_by_outcome($id,$selected_semesters);
66
+        		$undergradResults['attempted'][] = $attempted;
67
+        		$achieved = $program->achieved_criteria_by_outcome($id,$selected_semesters);
68
+        		$undergradResults['achieved'][] = $achieved;
69
+        		$undergradResults['successRate'][] = sprintf("%.2f",100*$achieved/$attempted);
70
+        	}
40 71
 
41
-        $undergradResults=array("names"=>array(), "schools"=>array(), "achieved"=>array(), "attempted"=>array(), "successRate"=>array());
42
-        $gradResults = array("names"=>array(), "schools"=>array(), "achieved"=>array(), "attempted"=>array(), "successRate"=>array());
43
-
44
-        //Calculate performance for this outcome for each undergrad program
45
-        $undergradPrograms = Program::where('is_graduate','=', 0)
46
-            ->where(function($query)
47
-            {
48
-                if(Auth::user()->school_id)
49
-                {
50
-                    $query->where('school_id', Auth::user()->school_id);
51
-                }
52
-            })
53
-            ->with('courses')
54
-            ->orderBy('name', 'asc')->get();
55
-
56
-        foreach($undergradPrograms as $program)
57
-        {
58
-            $undergradResults["names"][$program->id]=$program->name;
59
-            $undergradResults["schools"][$program->id]=$program->school->name;
60
-            $programAssessed=false;
61
-
62
-            $undergradResults["attempted"][$program->id]=0;
63
-            $undergradResults["achieved"][$program->id]=0;
64
-
65
-            foreach($program->courses as $course)
66
-            {
67
-                $course_outcomes_achieved = json_decode($course->outcomes_achieved, true);
68
-                $course_outcomes_attempted = json_decode($course->outcomes_attempted, true);
69
-
70
-                $attemptedCriteriaCount=0;
71
-                $achievedCriteriaCount=0;
72
-
73
-                // If this outcome was evaluated
74
-                if(
75
-                    $course_outcomes_attempted
76
-                    && array_key_exists($outcome->id, $course_outcomes_attempted)
77
-                    && $course_outcomes_attempted[$outcome->id]!=0)
78
-                {
79
-                    // Count +1 for attempted and achieved in the program
80
-                    $attemptedCriteriaCount+=$course_outcomes_attempted[$outcome->id];
81
-                    $achievedCriteriaCount+=$course_outcomes_achieved[$outcome->id];
82
-                    $programAssessed=true;
83
-
84
-                    if($attemptedCriteriaCount>0  &&(float)$achievedCriteriaCount/$attemptedCriteriaCount*100 > $outcome->expected_outcome)
85
-                    {
86
-                        $undergradResults["achieved"][$program->id]+=1;
87
-                    }
88
-                    $undergradResults["attempted"][$program->id]+=1;
89
-                }
90
-            }
91
-
92
-            // Calculate success rate for this program
93
-            if($programAssessed && $undergradResults["attempted"][$program->id]>0)
94
-                $undergradResults["successRate"][$program->id]= round((float)$undergradResults["achieved"][$program->id]/$undergradResults["attempted"][$program->id]*100, 2).'%';
95
-            else
96
-                $undergradResults["successRate"][$program->id]= 'N/M';
97 72
         }
98 73
 
74
+	   	$title = "Outcome Results: ".$outcome->name;
99 75
 
100
-        //Calculate performance for this outcome for each grad program
101
-        $gradPrograms = Program::where('is_graduate','=', 1)
102
-            ->where(function($query)
103
-            {
104
-                if(Auth::user()->school_id)
105
-                {
106
-                    $query->where('school_id', Auth::user()->school_id);
107
-                }
108
-            })
109
-            ->with(array('courses'=>function($query)
110
-            {
111
-                $query->whereNotNull('outcomes_attempted');
112
-            }))
113
-            ->orderBy('name', 'asc')->get();
114
-
115
-        foreach($gradPrograms as $program)
116
-        {
117
-            $gradResults["names"][$program->id]=$program->name;
118
-            $gradResults["schools"][$program->id]=$program->school->name;
119
-
120
-            $programAssessed=false;
121
-
122
-            $gradResults["attempted"][$program->id]=0;
123
-            $gradResults["achieved"][$program->id]=0;
124
-
125
-            foreach($program->courses as $course)
126
-            {
127
-                $course_outcomes_achieved = json_decode($course->outcomes_achieved, true);
128
-                $course_outcomes_attempted = json_decode($course->outcomes_attempted, true);
129
-
130
-                $attemptedCriteriaCount=0;
131
-                $achievedCriteriaCount=0;
132
-
133
-                // If this outcome was evaluated
134
-                if(
135
-                    $course_outcomes_attempted
136
-                    && array_key_exists($outcome->id, $course_outcomes_attempted)
137
-                    && $course_outcomes_attempted[$outcome->id]!=0)
138
-                {
139
-                    // Count +1 for attempted and achieved in the program
140
-                    $attemptedCriteriaCount+=$course_outcomes_attempted[$outcome->id];
141
-                    $achievedCriteriaCount+=$course_outcomes_achieved[$outcome->id];
142
-                    $programAssessed=true;
143
-
144
-                    if($attemptedCriteriaCount>0  &&(float)$achievedCriteriaCount/$attemptedCriteriaCount*100 > $outcome->expected_outcome)
145
-                    {
146
-                        $gradResults["achieved"][$program->id]+=1;
147
-                    }
148
-                    $gradResults["attempted"][$program->id]+=1;
149
-                }
150
-            }
151
-
152
-            // Calculate success rate for this program
153
-            if($programAssessed && $gradResults["attempted"][$program->id]>0)
154
-                $gradResults["successRate"][$program->id]= round((float)$gradResults["achieved"][$program->id]/$gradResults["attempted"][$program->id]*100, 2).'%';
155
-            else
156
-                $gradResults["successRate"][$program->id]= 'N/M';
157
-        }
158 76
 
159
-        $title = "Outcome Results: ".$outcome->name;
77
+//  		$undergradResults["successRate"]
160 78
 
161
-        return View::make('local.managers.admins.learning-outcome', compact('title', 'outcome', 'undergradResults', 'gradResults'));
79
+        return View::make('local.managers.admins.learning-outcome_new', compact('title', 'outcome', 'undergradResults', 'gradResults'));
162 80
     }
163 81
 
82
+//     public function show($id)
83
+//     {
84
+//         DB::disableQueryLog();
85
+//         $outcome = Outcome::find($id);
86
+//
87
+//         $undergradResults=array("names"=>array(), "schools"=>array(), "achieved"=>array(), "attempted"=>array(), "successRate"=>array());
88
+//         $gradResults = array("names"=>array(), "schools"=>array(), "achieved"=>array(), "attempted"=>array(), "successRate"=>array());
89
+//
90
+//         //Calculate performance for this outcome for each undergrad program
91
+//         $undergradPrograms = Program::where('is_graduate','=', 0)
92
+//             ->where(function($query)
93
+//             {
94
+//                 if(Auth::user()->school_id)
95
+//                 {
96
+//                     $query->where('school_id', Auth::user()->school_id);
97
+//                 }
98
+//             })
99
+//             ->with('courses')
100
+//             ->orderBy('name', 'asc')->get();
101
+//
102
+//         foreach($undergradPrograms as $program)
103
+//         {
104
+//             $undergradResults["names"][$program->id]=$program->name;
105
+//             $undergradResults["schools"][$program->id]=$program->school->name;
106
+//             $programAssessed=false;
107
+//
108
+//             $undergradResults["attempted"][$program->id]=0;
109
+//             $undergradResults["achieved"][$program->id]=0;
110
+//
111
+//             foreach($program->courses as $course)
112
+//             {
113
+//                 $course_outcomes_achieved = json_decode($course->outcomes_achieved, true);
114
+//                 $course_outcomes_attempted = json_decode($course->outcomes_attempted, true);
115
+//
116
+//                 $attemptedCriteriaCount=0;
117
+//                 $achievedCriteriaCount=0;
118
+//
119
+//                 // If this outcome was evaluated
120
+//                 if(
121
+//                     $course_outcomes_attempted
122
+//                     && array_key_exists($outcome->id, $course_outcomes_attempted)
123
+//                     && $course_outcomes_attempted[$outcome->id]!=0)
124
+//                 {
125
+//                     // Count +1 for attempted and achieved in the program
126
+//                     $attemptedCriteriaCount+=$course_outcomes_attempted[$outcome->id];
127
+//                     $achievedCriteriaCount+=$course_outcomes_achieved[$outcome->id];
128
+//                     $programAssessed=true;
129
+//
130
+//                     if($attemptedCriteriaCount>0  &&(float)$achievedCriteriaCount/$attemptedCriteriaCount*100 > $outcome->expected_outcome)
131
+//                     {
132
+//                         $undergradResults["achieved"][$program->id]+=1;
133
+//                     }
134
+//                     $undergradResults["attempted"][$program->id]+=1;
135
+//                 }
136
+//             }
137
+//
138
+//             // Calculate success rate for this program
139
+//             if($programAssessed && $undergradResults["attempted"][$program->id]>0)
140
+//                 $undergradResults["successRate"][$program->id]= round((float)$undergradResults["achieved"][$program->id]/$undergradResults["attempted"][$program->id]*100, 2).'%';
141
+//             else
142
+//                 $undergradResults["successRate"][$program->id]= 'N/M';
143
+//         }
144
+//
145
+//
146
+//         //Calculate performance for this outcome for each grad program
147
+//         $gradPrograms = Program::where('is_graduate','=', 1)
148
+//             ->where(function($query)
149
+//             {
150
+//                 if(Auth::user()->school_id)
151
+//                 {
152
+//                     $query->where('school_id', Auth::user()->school_id);
153
+//                 }
154
+//             })
155
+//             ->with(array('courses'=>function($query)
156
+//             {
157
+//                 $query->whereNotNull('outcomes_attempted');
158
+//             }))
159
+//             ->orderBy('name', 'asc')->get();
160
+//
161
+//         foreach($gradPrograms as $program)
162
+//         {
163
+//             $gradResults["names"][$program->id]=$program->name;
164
+//             $gradResults["schools"][$program->id]=$program->school->name;
165
+//
166
+//             $programAssessed=false;
167
+//
168
+//             $gradResults["attempted"][$program->id]=0;
169
+//             $gradResults["achieved"][$program->id]=0;
170
+//
171
+//             foreach($program->courses as $course)
172
+//             {
173
+//                 $course_outcomes_achieved = json_decode($course->outcomes_achieved, true);
174
+//                 $course_outcomes_attempted = json_decode($course->outcomes_attempted, true);
175
+//
176
+//                 $attemptedCriteriaCount=0;
177
+//                 $achievedCriteriaCount=0;
178
+//
179
+//                 // If this outcome was evaluated
180
+//                 if(
181
+//                     $course_outcomes_attempted
182
+//                     && array_key_exists($outcome->id, $course_outcomes_attempted)
183
+//                     && $course_outcomes_attempted[$outcome->id]!=0)
184
+//                 {
185
+//                     // Count +1 for attempted and achieved in the program
186
+//                     $attemptedCriteriaCount+=$course_outcomes_attempted[$outcome->id];
187
+//                     $achievedCriteriaCount+=$course_outcomes_achieved[$outcome->id];
188
+//                     $programAssessed=true;
189
+//
190
+//                     if($attemptedCriteriaCount>0  &&(float)$achievedCriteriaCount/$attemptedCriteriaCount*100 > $outcome->expected_outcome)
191
+//                     {
192
+//                         $gradResults["achieved"][$program->id]+=1;
193
+//                     }
194
+//                     $gradResults["attempted"][$program->id]+=1;
195
+//                 }
196
+//             }
197
+//
198
+//             // Calculate success rate for this program
199
+//             if($programAssessed && $gradResults["attempted"][$program->id]>0)
200
+//                 $gradResults["successRate"][$program->id]= round((float)$gradResults["achieved"][$program->id]/$gradResults["attempted"][$program->id]*100, 2).'%';
201
+//             else
202
+//                 $gradResults["successRate"][$program->id]= 'N/M';
203
+//         }
204
+//
205
+//         $title = "Outcome Results: ".$outcome->name;
206
+//
207
+//         return View::make('local.managers.admins.learning-outcome', compact('title', 'outcome', 'undergradResults', 'gradResults'));
208
+//     }
209
+
164 210
     // TODO: Clean up and verify relationships are correct
165 211
     public function newShow($id)
166 212
     {
167
-//        DB::disableQueryLog();
168
-//        $outcome = null;
213
+        //        DB::disableQueryLog();
214
+        //        $outcome = null;
169 215
         if ($id === 'all') {
170 216
             $outcome = Outcome::with('objectives.criteria')->get();
171 217
             $title = 'All Outcomes';
172
-            $criteria = $outcome->reduce(function($carry, $outcome) {
218
+            $criteria = $outcome->reduce(function ($carry, $outcome) {
173 219
                 return $carry->merge($outcome->criteria);
174 220
             }, Collection::make([]));
175 221
             $report_link = URL::action('OutcomesController@newReportAll');
@@ -180,26 +226,26 @@ class OutcomesController extends \BaseController {
180 226
             $report_link = URL::action('OutcomesController@newReport', ['id' => $outcome->id]);
181 227
         }
182 228
 
183
-//        $objectives = $outcome->objectives;
184
-//        var_dump(get_class_methods($criteria));
185
-//        var_dump($criteria);
186
-        $rubrics = $criteria->reduce(function($carry, $crit) {
229
+        //        $objectives = $outcome->objectives;
230
+        //        var_dump(get_class_methods($criteria));
231
+        //        var_dump($criteria);
232
+        $rubrics = $criteria->reduce(function ($carry, $crit) {
187 233
             return $carry->merge($crit->rubrics);
188 234
         }, Collection::make([]))->load('activities');
189
-        $activities = $rubrics->reduce(function($carry, $rubric) {
235
+        $activities = $rubrics->reduce(function ($carry, $rubric) {
190 236
             return $carry->merge($rubric->activities);
191 237
         }, Collection::make([]));
192
-        $courses = $activities->reduce(function($carry, $activity) {
238
+        $courses = $activities->reduce(function ($carry, $activity) {
193 239
             if ($activity->course !== null) {
194 240
                 $carry->push($activity->course);
195 241
             }
196 242
             return $carry;
197 243
         }, Collection::make([]));
198
-        $activities = $activities->filter(function($activity) {
244
+        $activities = $activities->filter(function ($activity) {
199 245
             return ($activity->course === null);
200 246
         });
201 247
 
202
-//        var_dump(DB::getQueryLog());
248
+        //        var_dump(DB::getQueryLog());
203 249
         return View::make('local.managers.admins.new-learning-outcome', compact('title', 'outcome', 'courses', 'activities', 'report_link'));
204 250
     }
205 251
 
@@ -208,14 +254,19 @@ class OutcomesController extends \BaseController {
208 254
         $outcome = Outcome::find($id);
209 255
         $objectives = $outcome->objectives;
210 256
         $criteria = $outcome->criteria;
211
-        $programs = $objectives->map(function ($objective) { return $objective->program; })
212
-            ->merge($criteria->map(function ($criteria) { return $criteria->program; }))
213
-            ->filter(function ($program) { return $program->users->contains(Auth::user()); });
257
+        $programs = $objectives->map(function ($objective) {
258
+            return $objective->program;
259
+        })
260
+            ->merge($criteria->map(function ($criteria) {
261
+                return $criteria->program;
262
+            }))
263
+            ->filter(function ($program) {
264
+                return $program->users->contains(Auth::user());
265
+            });
214 266
         $title = $outcome->name . ' Report';
215 267
 
216 268
 
217 269
         return View::make('local.managers.admins.new-report', compact('title', 'outcome', 'objectives'));
218
-
219 270
     }
220 271
 
221 272
     public function newReportAll()
@@ -224,7 +275,6 @@ class OutcomesController extends \BaseController {
224 275
         $title = 'All Outcomes Report';
225 276
 
226 277
         return View::make('local.managers.admins.new-report-all', compact('title', 'outcomes'));
227
-
228 278
     }
229 279
 
230 280
     public function update()
@@ -233,8 +283,7 @@ class OutcomesController extends \BaseController {
233 283
         Session::flash('status', 'success');
234 284
         Session::flash('message', 'Learning Outcomes updated.');
235 285
 
236
-        foreach ($outcomeArray as $outcomeObject)
237
-        {
286
+        foreach ($outcomeArray as $outcomeObject) {
238 287
 
239 288
 
240 289
             $validator = Validator::make(
@@ -250,12 +299,10 @@ class OutcomesController extends \BaseController {
250 299
                 )
251 300
             );
252 301
 
253
-            if(!$validator->fails())
254
-            {
255
-                try
256
-                {
302
+            if (!$validator->fails()) {
303
+                try {
257 304
                     $outcome = Outcome::withTrashed()
258
-                        ->where('id','=', $outcomeObject['id'])
305
+                        ->where('id', '=', $outcomeObject['id'])
259 306
                         ->firstOrFail();
260 307
                     $outcome->name = $outcomeObject['name'];
261 308
                     $outcome->definition = $outcomeObject['definition'];
@@ -263,30 +310,24 @@ class OutcomesController extends \BaseController {
263 310
                     $outcome->save();
264 311
 
265 312
                     // If delete is 1, and outcome isn't already trashed, delete
266
-                    if($outcomeObject['delete']==1 && !$outcome->trashed())
313
+                    if ($outcomeObject['delete'] == 1 && !$outcome->trashed())
267 314
                         $outcome->delete();
268 315
                     // If delete is 0, and outcome is already trashed, restore
269
-                    elseif($outcomeObject['delete']==0 && $outcome->trashed())
316
+                    elseif ($outcomeObject['delete'] == 0 && $outcome->trashed())
270 317
                         $outcome->restore();
271
-                }
272
-
273
-                catch(Exception $e)
274
-                {
318
+                } catch (Exception $e) {
275 319
 
276 320
                     Session::flash('message', $e->getMessage());
277 321
                 }
278
-            }
279
-            else
280
-            {
322
+            } else {
281 323
                 /** Prepare error message */
282 324
                 $message = 'Error(s) updating the Learning Outcomes: <ul>';
283 325
 
284
-                foreach ($validator->messages()->all('<li>:message</li>') as $validationError)
285
-                {
286
-                    $message.=$validationError;
326
+                foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
327
+                    $message .= $validationError;
287 328
                 }
288 329
 
289
-                $message.='</ul>';
330
+                $message .= '</ul>';
290 331
 
291 332
                 /** Send error message and old data */
292 333
                 Session::flash('status', 'danger');
@@ -299,16 +340,15 @@ class OutcomesController extends \BaseController {
299 340
     }
300 341
 
301 342
     /**
302
-    *Copy of update(), but also updates activation_date, deactivation_date and level
303
-    */
343
+     *Copy of update(), but also updates activation_date, deactivation_date and level
344
+     */
304 345
     public function updateMore()
305 346
     {
306 347
         $outcomeArray = json_decode(Input::get('outcomeArray'), true);
307 348
         Session::flash('status', 'success');
308 349
         Session::flash('message', 'Learning Outcomes updated.');
309 350
 
310
-        foreach ($outcomeArray as $outcomeObject)
311
-        {
351
+        foreach ($outcomeArray as $outcomeObject) {
312 352
 
313 353
 
314 354
             $validator = Validator::make(
@@ -326,12 +366,10 @@ class OutcomesController extends \BaseController {
326 366
                 )
327 367
             );
328 368
 
329
-            if(!$validator->fails())
330
-            {
331
-                try
332
-                {
369
+            if (!$validator->fails()) {
370
+                try {
333 371
                     $outcome = Outcome::withTrashed()
334
-                        ->where('id','=', $outcomeObject['id'])
372
+                        ->where('id', '=', $outcomeObject['id'])
335 373
                         ->firstOrFail();
336 374
                     $outcome->name = $outcomeObject['name'];
337 375
                     $outcome->definition = $outcomeObject['definition'];
@@ -342,30 +380,24 @@ class OutcomesController extends \BaseController {
342 380
                     $outcome->save();
343 381
 
344 382
                     // If delete is 1, and outcome isn't already trashed, delete
345
-                    if($outcomeObject['delete']==1 && !$outcome->trashed())
383
+                    if ($outcomeObject['delete'] == 1 && !$outcome->trashed())
346 384
                         $outcome->delete();
347 385
                     // If delete is 0, and outcome is already trashed, restore
348
-                    elseif($outcomeObject['delete']==0 && $outcome->trashed())
386
+                    elseif ($outcomeObject['delete'] == 0 && $outcome->trashed())
349 387
                         $outcome->restore();
350
-                }
351
-
352
-                catch(Exception $e)
353
-                {
388
+                } catch (Exception $e) {
354 389
 
355 390
                     Session::flash('message', $e->getMessage());
356 391
                 }
357
-            }
358
-            else
359
-            {
392
+            } else {
360 393
                 /** Prepare error message */
361 394
                 $message = 'Error(s) updating the Learning Outcomes: <ul>';
362 395
 
363
-                foreach ($validator->messages()->all('<li>:message</li>') as $validationError)
364
-                {
365
-                    $message.=$validationError;
396
+                foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
397
+                    $message .= $validationError;
366 398
                 }
367 399
 
368
-                $message.='</ul>';
400
+                $message .= '</ul>';
369 401
 
370 402
                 /** Send error message and old data */
371 403
                 Session::flash('status', 'danger');
@@ -380,40 +412,33 @@ class OutcomesController extends \BaseController {
380 412
     public function fetchCriteria()
381 413
     {
382 414
 
383
-        if(Input::get('filter'))
384
-        {
385
-            switch (Input::get('filter'))
386
-            {
415
+        if (Input::get('filter')) {
416
+            switch (Input::get('filter')) {
387 417
                 case 'all':
388 418
                     return Outcome::find(Input::get('id'))->criteria;
389 419
                     break;
390 420
 
391 421
                 case 'school':
392 422
                     // If scoord
393
-                    if(Auth::user()->role == '2')
394
-                    {
423
+                    if (Auth::user()->role == '2') {
395 424
 
396 425
                         // Fetch all the programs whose school is the user's
397 426
                         $program_ids = DB::table('programs')->where('school_id', Auth::user()->school_id)->lists('id');
398 427
 
399 428
                         // Return all criteria belonging to any of those programs
400
-                        return Criterion::
401
-                            where('outcome_id', Input::get('id'))
429
+                        return Criterion::where('outcome_id', Input::get('id'))
402 430
                             ->whereIn('program_id', $program_ids)
403 431
                             ->orderBy('name', 'ASC')
404 432
                             ->get();
405
-
406 433
                     }
407 434
 
408 435
                     // If pcoord
409
-                    else
410
-                    {
436
+                    else {
411 437
 
412 438
                         // Fetch all the programs from the user's school;
413 439
                         $program_ids = DB::table('programs')->where('school_id', Auth::user()->programs[0]->school->id)->lists('id');
414 440
 
415
-                        return Criterion::
416
-                            where('outcome_id', Input::get('id'))
441
+                        return Criterion::where('outcome_id', Input::get('id'))
417 442
                             ->whereIn('program_id', $program_ids)
418 443
                             ->orderBy('name', 'ASC')
419 444
                             ->get();
@@ -422,8 +447,7 @@ class OutcomesController extends \BaseController {
422 447
                     break;
423 448
 
424 449
                 case 'program':
425
-                    return Criterion::
426
-                        where('outcome_id', Input::get('id'))
450
+                    return Criterion::where('outcome_id', Input::get('id'))
427 451
                         ->whereIn('program_id', Auth::user()->programs->lists('id'))
428 452
                         ->orderBy('name', 'ASC')
429 453
                         ->get();
@@ -433,9 +457,7 @@ class OutcomesController extends \BaseController {
433 457
                     return Outcome::find(Input::get('id'))->criteria;
434 458
                     break;
435 459
             }
436
-        }
437
-        else
438
-        {
460
+        } else {
439 461
             return Outcome::find(Input::get('id'))->criteria;
440 462
         }
441 463
     }
@@ -458,41 +480,35 @@ class OutcomesController extends \BaseController {
458 480
         );
459 481
 
460 482
         /** If validation fails */
461
-        if ($validator->fails())
462
-        {
483
+        if ($validator->fails()) {
463 484
             /** Prepare error message */
464 485
             $message = '<p>Error(s) creating a new Learning Outcome</p><ul>';
465 486
 
466
-            foreach ($validator->messages()->all('<li>:message</li>') as $validationError)
467
-            {
468
-                $message.=$validationError;
487
+            foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
488
+                $message .= $validationError;
469 489
             }
470 490
 
471
-            $message.='</ul>';
491
+            $message .= '</ul>';
472 492
 
473 493
             /** Send error message and old data */
474 494
             Session::flash('status', 'warning');
475 495
             Session::flash('message', $message);
476 496
             return Redirect::to('learning-outcomes')->withInput();
477
-        }
478
-        else
479
-        {
497
+        } else {
480 498
             /** Instantiate new outcome */
481 499
             $outcome = new Outcome;
482
-            $outcome->name= Input::get('name');
500
+            $outcome->name = Input::get('name');
483 501
             $outcome->definition = Input::get('definition');
484 502
 
485 503
             /** If outcome is saved, send success message */
486
-            if($outcome->save())
487
-            {
504
+            if ($outcome->save()) {
488 505
                 Session::flash('status', 'success');
489 506
                 Session::flash('message', '<p>Learning Outcome added.</p>');
490 507
                 return Redirect::to('learning-outcomes');
491 508
             }
492 509
 
493 510
             /** If saving fails, send error message and old data */
494
-            else
495
-            {
511
+            else {
496 512
                 Session::flash('status', 'warning');
497 513
                 Session::flash('message', '<p>Error adding Learning Outcome. Please try again later.</p>');
498 514
                 return Redirect::to('learning-outcomes')->withInput();
@@ -502,15 +518,78 @@ class OutcomesController extends \BaseController {
502 518
 
503 519
     public function fetchOutcome()
504 520
     {
521
+        // original code using models
522
+        // TODO: models have to be updated because of the database update
523
+
505 524
         $id = Input::get('id');
506 525
 
507
-        $outcome = Outcome::find($id);
526
+        $outcome_info = DB::table('outcomes')
527
+            ->where('outcomes.id', $id)
528
+            ->get();
529
+        $outcome = $outcome_info[0];
530
+
531
+        $diferent_levels = DB::table('criterion_objective_outcome')
532
+            ->join('new_criteria', 'new_criteria.id', '=', 'criterion_objective_outcome.criterion_id')
533
+            ->join('objectives', 'objectives.id', '=', 'criterion_objective_outcome.objective_id')
534
+            ->where('criterion_objective_outcome.outcome_id', $id)
535
+            ->distinct('new_criteria.number_of_scales')
536
+            ->select('new_criteria.number_of_scales as levels')
537
+            ->orderBy('new_criteria.number_of_scales', 'asc')
538
+            ->get();
508 539
 
509
-        $outcome->criteria;
540
+        $criteria_array = array();
541
+
542
+        $outcome->criteria = array();
543
+        foreach ($diferent_levels as $level) {
544
+          $level = $level->levels;
545
+
546
+          // buscar todos los criterios con el level y ponerlos en un array
547
+          $outcome_criterias = DB::table('criterion_objective_outcome')
548
+              ->join('new_criteria', 'new_criteria.id', '=', 'criterion_objective_outcome.criterion_id')
549
+              ->join('objectives', 'objectives.id', '=', 'criterion_objective_outcome.objective_id')
550
+              ->where('criterion_objective_outcome.outcome_id', $id)
551
+              ->where('new_criteria.number_of_scales', $level)
552
+              ->whereNull('new_criteria.deleted_at')
553
+              ->select('new_criteria.id','new_criteria.name')
554
+              ->orderBy('new_criteria.name', 'asc')
555
+              ->get();
556
+          $outcome_criterias = $outcome_criterias;
557
+
558
+          foreach ($outcome_criterias as $criteria_id) {
559
+
560
+            $scales =
561
+              DB::select(
562
+                  DB::raw("
563
+                  SELECT *
564
+                  FROM (
565
+                    SELECT new_criteria.id as criterion_id,
566
+                      ROW_NUMBER() OVER(PARTITION BY scales.id) rn,
567
+                      scales.position,
568
+                      scales.title, scales.description,
569
+                      criterion_objective_outcome.outcome_id,criterion_objective_outcome.objective_id,
570
+                      criterion_scale.scale_id
571
+                    FROM new_criteria,criterion_scale,scales, criterion_objective_outcome, objectives
572
+                    where new_criteria.id=criterion_scale.criterion_id
573
+                      and scales.id = criterion_scale.scale_id
574
+                      and new_criteria.id = criterion_objective_outcome.criterion_id
575
+                      and objectives.id = criterion_objective_outcome.objective_id
576
+                      and criterion_objective_outcome.outcome_id = $id
577
+                      and new_criteria.id = $criteria_id->id
578
+                    ORDER BY new_criteria.name ASC) a
579
+                  WHERE rn = 1
580
+                  ORDER BY `a`.`position` ASC
581
+                      ")
582
+              );
583
+              // insertar la informacion de los criterios con N niveles en el arreglo de arreglos
584
+              $criteria_id->scales = $scales;
585
+              // $i++;
586
+            }//ends foreach criteria_id
587
+            array_push($outcome->criteria, array($outcome_criterias,'amount_of_levels'=>$level));
588
+        }//ends foreach level
510 589
 
511 590
         return array
512 591
         (
513
-            'outcome' => $outcome
592
+            'outcome' => $outcome,
514 593
         );
515 594
     }
516 595
 
@@ -536,7 +615,6 @@ class OutcomesController extends \BaseController {
536 615
                 App::abort('404');
537 616
                 break;
538 617
         }
539
-
540 618
     }
541 619
 
542 620
     /**
@@ -546,26 +624,25 @@ class OutcomesController extends \BaseController {
546 624
     {
547 625
         $outcome = Outcome::find($outcome_id);
548 626
 
549
-        if(!$outcome)
627
+        if (!$outcome)
550 628
             App::abort('404');
551
-        $title = "Assessment Report: ".$outcome->name;
629
+        $title = "Assessment Report: " . $outcome->name;
552 630
 
553 631
 
554
-        $schools = School::
555
-            has('courses')
556
-            ->with(array('programs'=>function($query) use($outcome_id){
632
+        $schools = School::has('courses')
633
+            ->with(array('programs' => function ($query) use ($outcome_id) {
557 634
                 $query
558
-                ->has('courses')
559
-                ->with(array('courses'=>function($query2) use($outcome_id){
560
-                    $query2
561
-                    ->has('activities')
562
-                    ->whereNotNull('outcomes_attempted')
563
-                    // ->where('outcomes_attempted', 'NOT LIKE', '%"'.$outcome_id.'":0%')
564
-                    ->whereIn('semester_id', Session::get('semesters_ids'))
565
-                    ->groupBy(array('code', 'number'));
566
-                }));
635
+                    ->has('courses')
636
+                    ->with(array('courses' => function ($query2) use ($outcome_id) {
637
+                        $query2
638
+                            ->has('activities')
639
+                            ->whereNotNull('outcomes_attempted')
640
+                            // ->where('outcomes_attempted', 'NOT LIKE', '%"'.$outcome_id.'":0%')
641
+                            ->whereIn('semester_id', Session::get('semesters_ids'))
642
+                            ->groupBy(array('code', 'number'));
643
+                    }));
567 644
             }))
568
-         ->get();
645
+            ->get();
569 646
 
570 647
         return View::make('local.managers.admins.assessment_report', compact('title', 'outcome', 'schools'));
571 648
     }
@@ -575,16 +652,15 @@ class OutcomesController extends \BaseController {
575 652
     {
576 653
         $outcome = Outcome::find($outcome_id);
577 654
 
578
-        if(!$outcome)
655
+        if (!$outcome)
579 656
             App::abort('404');
580
-        $title = "Assessment Report: ".$outcome->name;
657
+        $title = "Assessment Report: " . $outcome->name;
581 658
 
582
-        $schools = School::
583
-        has('courses')
584
-            ->with(array('programs'=>function($query) use($outcome_id){
659
+        $schools = School::has('courses')
660
+            ->with(array('programs' => function ($query) use ($outcome_id) {
585 661
                 $query
586 662
                     ->has('courses')
587
-                    ->with(array('courses'=>function($query2) use($outcome_id){
663
+                    ->with(array('courses' => function ($query2) use ($outcome_id) {
588 664
                         $query2
589 665
                             ->has('activities')
590 666
                             ->whereNotNull('outcomes_attempted')
@@ -605,26 +681,25 @@ class OutcomesController extends \BaseController {
605 681
     {
606 682
         $outcome = Outcome::find($outcome_id);
607 683
 
608
-        if(!$outcome)
684
+        if (!$outcome)
609 685
             App::abort('404');
610
-        $title = "Assessment Report: ".$outcome->name;
686
+        $title = "Assessment Report: " . $outcome->name;
611 687
 
612 688
 
613
-        $school = School::
614
-            where('id', Auth::user()->school_id)
615
-            ->has('courses')
616
-            ->with(array('programs'=>function($query){
617
-            $query
689
+        $school = School::where('id', Auth::user()->school_id)
618 690
             ->has('courses')
619
-            ->with(array('courses'=>function($query2){
620
-                $query2
621
-                ->has('activities')
622
-                ->whereNotNull('outcomes_attempted')
623
-                ->whereIn('semester_id', Session::get('semesters_ids'))
624
-                ->groupBy(array('code', 'number'));
625
-            }));
626
-         }))
627
-         ->first();
691
+            ->with(array('programs' => function ($query) {
692
+                $query
693
+                    ->has('courses')
694
+                    ->with(array('courses' => function ($query2) {
695
+                        $query2
696
+                            ->has('activities')
697
+                            ->whereNotNull('outcomes_attempted')
698
+                            ->whereIn('semester_id', Session::get('semesters_ids'))
699
+                            ->groupBy(array('code', 'number'));
700
+                    }));
701
+            }))
702
+            ->first();
628 703
 
629 704
         return View::make('local.managers.sCoords.assessment_report', compact('title', 'outcome', 'school'));
630 705
     }
@@ -636,20 +711,19 @@ class OutcomesController extends \BaseController {
636 711
     {
637 712
         $outcome = Outcome::find($outcome_id);
638 713
 
639
-        if(!$outcome)
714
+        if (!$outcome)
640 715
             App::abort('404');
641
-        $title = "Assessment Report: ".$outcome->name;
716
+        $title = "Assessment Report: " . $outcome->name;
642 717
 
643 718
 
644
-        $program = Program::
645
-            where('id', $program_id)
719
+        $program = Program::where('id', $program_id)
646 720
             ->has('courses')
647
-            ->with(array('courses'=>function($query){
721
+            ->with(array('courses' => function ($query) {
648 722
                 $query
649
-                ->has('activities')
650
-                ->whereNotNull('outcomes_attempted')
651
-                ->whereIn('semester_id', Session::get('semesters_ids'))
652
-                ->groupBy(array('code', 'number'));
723
+                    ->has('activities')
724
+                    ->whereNotNull('outcomes_attempted')
725
+                    ->whereIn('semester_id', Session::get('semesters_ids'))
726
+                    ->groupBy(array('code', 'number'));
653 727
             }))
654 728
             ->first();
655 729
 
@@ -663,7 +737,6 @@ class OutcomesController extends \BaseController {
663 737
         $title = "My Courses' Assessment Reports";
664 738
 
665 739
         return View::make('local.professors.assessment_reports', compact('title', 'outcomes'));
666
-
667 740
     }
668 741
 
669 742
 
@@ -672,13 +745,12 @@ class OutcomesController extends \BaseController {
672 745
     {
673 746
         $outcome = Outcome::find($outcome_id);
674 747
 
675
-        if(!$outcome)
748
+        if (!$outcome)
676 749
             App::abort('404');
677
-        $title = "My Courses' Assessment Report: ".$outcome->name;
750
+        $title = "My Courses' Assessment Report: " . $outcome->name;
678 751
 
679 752
 
680
-        $courses = Course::
681
-            where('user_id', Auth::user()->id)
753
+        $courses = Course::where('user_id', Auth::user()->id)
682 754
             ->has('activities')
683 755
             ->whereNotNull('outcomes_attempted')
684 756
             ->whereIn('semester_id', Session::get('semesters_ids'))

+ 146
- 23
app/controllers/ProgramsController.php Ver arquivo

@@ -6,36 +6,79 @@ class ProgramsController extends \BaseController
6 6
   /**
7 7
    * Shows a particular program
8 8
    */
9
+
9 10
   public function show($id)
10 11
   {
11 12
 
12 13
     $program = Program::find($id);
13 14
     $title= $program->school->name.': '.$program->name;
14 15
     $program_courses = $program->courses;
15
-    $outcomes = Outcome::orderBy('name', 'asc')->get();
16
+//     $outcomes = Outcome::orderBy('name', 'asc')->get();
16 17
     $schools = School::all();
17
-    $outcomeCount = Outcome::all()->count();
18
-
19
-
20
-    $outcomes_achieved = array_fill(1, $outcomeCount, 0);
21
-    $outcomes_attempted = array_fill(1, $outcomeCount, 0);
22
-
23
-    $assessed_courses_count=0;
24
-    foreach ($program_courses as $course)
25
-    {
26
-        if($course->outcomes_achieved!=NULL)
27
-        {
28
-            $course_outcomes_achieved =json_decode($course->outcomes_achieved, true);
29
-            $course_outcomes_attempted =json_decode($course->outcomes_attempted, true);
30
-            for($i=1; $i<=count($outcomes_attempted); $i++)
31
-            {
32
-                $outcomes_achieved[$i]+=$course_outcomes_achieved[$i];
33
-                $outcomes_attempted[$i]+=$course_outcomes_attempted[$i];
34
-            }
35
-            $assessed_courses_count+=1;
36
-        }
37
-    }
38
-
18
+//     $outcomeCount = Outcome::all()->count();
19
+
20
+    $selected_semesters = Semester::find(Session::get('semesters_ids'));
21
+
22
+	$level=$program->is_graduate;
23
+	$min_start="9000-01-01 00:00:00";
24
+	$max_end="1000-01-01 00:00:00";
25
+	foreach($selected_semesters as $semester)
26
+	{
27
+		if($min_start>$semester->start)
28
+		{
29
+			$min_start=$semester->start;
30
+		}
31
+		if($max_end<$semester->end)
32
+		{
33
+			$max_end=$semester->end;
34
+		}
35
+	}
36
+	$outcomes = Outcome::where(function($query) use ($min_start)
37
+							   {
38
+									$query->where('deactivation_date', '>=', $min_start)
39
+										  ->orWhere('deactivation_date', null);
40
+							   })
41
+						->where('activation_date', '<=', $max_end)
42
+						->where(function($query2) use ($level)
43
+								{
44
+									$query2->where("level", $level+1)
45
+										   ->orWhere("level",3);
46
+								})
47
+						->orderBy('name', 'ASC')
48
+						->get();
49
+	$outcomeCount = Outcome::where(function($query) use ($min_start)
50
+								   {
51
+										$query->where('deactivation_date', '>=', $min_start)
52
+											  ->orWhere('deactivation_date', null);
53
+									})
54
+						->where('activation_date', '<=', $max_end)
55
+						->where(function($query2) use ($level)
56
+									{
57
+										$query2->where("level",$level+1)
58
+											   ->orWhere("level",3);
59
+									})
60
+							->count();
61
+
62
+	foreach($outcomes as $outcome)
63
+	{
64
+		$outcomes_attempted[$outcome->id]=$program->attempted_outcome($outcome->id, $selected_semesters);
65
+		if($outcomes_attempted[$outcome->id])$outcomes_achieved[$outcome->id]=$program->achieved_outcome($outcome->id, $selected_semesters);
66
+	}
67
+
68
+	foreach($outcomes as $outcome)
69
+	{
70
+		$assessed_courses[$outcome->id]=DB::table('activity_criterion')
71
+	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
72
+	    	->join('courses', 'activities.course_id', '=', 'courses.id')
73
+	    	->join('programs', 'programs.id', '=', 'courses.program_id')
74
+	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'activity_criterion.criterion_id')
75
+	    	->where('criterion_objective_outcome.outcome_id','=',$outcome->id)
76
+	    	->where('programs.id','=',$program->id)
77
+	    	->where('courses.semester_id','=',$semester)
78
+	    	->count(DB::raw('DISTINCT courses.id'))
79
+			;
80
+	}
81
+	$assessed_courses_count=array_sum($assessed_courses);
39 82
     /**
40 83
      * List of grouped courses (grouped sections)
41 84
      */
@@ -76,10 +119,15 @@ class ProgramsController extends \BaseController
76 119
         })
77 120
         ->get();
78 121
 
122
+// 	var_dump($outcomes_attempted);
123
+// 	print "<br>";
124
+// 	var_dump($outcomes_achieved);
125
+// 	print "<br>";
79 126
     return View::make('local.managers.shared.program', compact('title', 'outcomes', 'outcomes_attempted', 'outcomes_achieved', 'schools', 'program_courses', 'assessed_courses_count', 'grouped_courses', 'program', 'users'));
80 127
 
81 128
 }
82 129
 
130
+
83 131
 public function showReport()
84 132
 {
85 133
 
@@ -171,6 +219,81 @@ public function showReport()
171 219
    return View::make('local.managers.shared.program_report', compact('title','programs_info','selected_divulgaciones','selected_semesters','tables_names'));
172 220
 }
173 221
 
222
+//   public function show($id)
223
+//   {
224
+//
225
+//     $program = Program::find($id);
226
+//     $title= $program->school->name.': '.$program->name;
227
+//     $program_courses = $program->courses;
228
+//     $outcomes = Outcome::orderBy('name', 'asc')->get();
229
+//     $schools = School::all();
230
+//     $outcomeCount = Outcome::all()->count();
231
+//
232
+//
233
+//     $outcomes_achieved = array_fill(1, $outcomeCount, 0);
234
+//     $outcomes_attempted = array_fill(1, $outcomeCount, 0);
235
+//
236
+//     $assessed_courses_count=0;
237
+//     foreach ($program_courses as $course)
238
+//     {
239
+//         if($course->outcomes_achieved!=NULL)
240
+//         {
241
+//             $course_outcomes_achieved =json_decode($course->outcomes_achieved, true);
242
+//             $course_outcomes_attempted =json_decode($course->outcomes_attempted, true);
243
+//             for($i=1; $i<=count($outcomes_attempted); $i++)
244
+//             {
245
+//                 $outcomes_achieved[$i]+=$course_outcomes_achieved[$i];
246
+//                 $outcomes_attempted[$i]+=$course_outcomes_attempted[$i];
247
+//             }
248
+//             $assessed_courses_count+=1;
249
+//         }
250
+//     }
251
+//
252
+//     /**
253
+//      * List of grouped courses (grouped sections)
254
+//      */
255
+//
256
+//     $grouped_courses = Course::
257
+//       select(DB::raw('name, code, number, max(outcomes_attempted) as outcomes_attempted, semester_id, program_id'))
258
+//       ->with('semester')
259
+//       ->with('program')
260
+//       ->where('program_id', $program->id)
261
+//       ->whereIn('semester_id', Session::get('semesters_ids'))
262
+//       ->groupBy(array('code', 'number', 'semester_id'))
263
+//       ->orderBy('code')
264
+//       ->orderBy('number')
265
+//       ->orderBy('semester_id')
266
+//       ->get();
267
+//
268
+//     // Program contact information
269
+//     $users = User::
270
+//         select('users.*')
271
+//         ->leftJoin('program_user', 'users.id', '=', 'program_user.user_id')
272
+//         ->where(function($query) use($program)
273
+//         {
274
+//             $query
275
+//                 ->where('school_id', $program->school_id)
276
+//                 ->where('role', 2);
277
+//         })
278
+//         ->orWhere(function($query) use($program)
279
+//         {
280
+//             $query
281
+//                 ->where('role', 3)
282
+//                 ->where('program_id', $program->id);
283
+//         })
284
+//         ->orWhere(function($query) use($program)
285
+//         {
286
+//             $query
287
+//                 ->where('role', 4)
288
+//                 ->where('program_id', $program->id);
289
+//         })
290
+//         ->get();
291
+//
292
+//     return View::make('local.managers.shared.program', compact('title', 'outcomes', 'outcomes_attempted', 'outcomes_achieved', 'schools', 'program_courses', 'assessed_courses_count', 'grouped_courses', 'program', 'users'));
293
+//
294
+// }
295
+
296
+
174 297
   /**
175 298
    * Info to print a program
176 299
    */

+ 70
- 66
app/controllers/RubricsController.php Ver arquivo

@@ -1,6 +1,7 @@
1 1
 <?php
2 2
 
3
-class RubricsController extends \BaseController {
3
+class RubricsController extends \BaseController
4
+{
4 5
 
5 6
     /**
6 7
      * Show the form for creating a new rubric
@@ -15,6 +16,35 @@ class RubricsController extends \BaseController {
15 16
         if (!$activity)
16 17
             App::abort('404');
17 18
 
19
+        $title = 'Rubric for <em>' . $activity->name . '</em>';
20
+
21
+        // Select templates that belong to everyone or belong to the activity's course's school
22
+        $templates = Template::where('is_visible', '=', 1)
23
+            ->where(function ($query) use ($activity) {
24
+                if (Auth::user()->role != 1) {
25
+                    $query
26
+                        ->where('school_id', $activity->course->program->school->id)
27
+                        ->orWhere('school_id', '=', NULL);
28
+                }
29
+            })
30
+            ->orderBy('name', 'ASC')->get();
31
+
32
+        $rubrics = Auth::user()->rubrics;
33
+        $outcomes = Outcome::orderBy('name', 'ASC')->get();
34
+        $criteria = Criterion::orderBy('name', 'ASC')->get();
35
+        $rubric = $activity->rubric;
36
+
37
+        return View::make('local.professors.rubrics', compact('title', 'templates', 'outcomes', 'criteria', 'rubrics', 'activity', 'rubric'));
38
+    }
39
+
40
+    public function newOtherMethod($activity_id)
41
+    {
42
+        $activity = Activity::find($activity_id);
43
+
44
+        // If activity does not exist, display 404
45
+        if (!$activity)
46
+            App::abort('404');
47
+
18 48
         $title = 'Rubric for <em>'.$activity->name.'</em>';
19 49
 
20 50
         // Select templates that belong to everyone or belong to the activity's course's school
@@ -48,10 +78,9 @@ class RubricsController extends \BaseController {
48 78
 
49 79
         DB::beginTransaction();
50 80
 
51
-        try
52
-        {
81
+        try {
53 82
             // Get rubric contents
54
-            $rubric_contents= json_decode(Input::get('contents'));
83
+            $rubric_contents = json_decode(Input::get('contents'));
55 84
 
56 85
             // Process rubric
57 86
             $rubric = new Rubric;
@@ -63,24 +92,21 @@ class RubricsController extends \BaseController {
63 92
             $rubric->save();
64 93
 
65 94
             // Process activity
66
-            $activity = Activity::find(Input::get('activity_id'));
67
-            $activity->rubric_id = $rubric->id;
68
-            $activity->save();
95
+//             $activity = Activity::find(Input::get('activity_id'));
96
+//             $activity->rubric_id = $rubric->id;
97
+//             $activity->save();
69 98
 
99
+			DB::table('new_rubric_activity')->insert(array('activity_id'=>Input::get('activity_id'),'rubric_id'=> $rubric->id));
70 100
             DB::commit();
71 101
 
72 102
             Session::flash('status', 'success');
73 103
             Session::flash('message', 'Rubric assigned.');
74 104
 
75
-            return action('ActivitiesController@show', array($activity->id));
76
-
105
+            return action('ActivitiesController@show', array(Input::get('activity_id')));
77 106
 
78
-        }
79
-        catch(Exception $e)
80
-        {
81 107
             DB::rollBack();
82 108
             Session::flash('status', 'danger');
83
-            Session::flash('message', 'Error creating Rubric. Try again later.');
109
+            Session::flash('message', 'Error creating Rubric. Try again later.'.$e);
84 110
         }
85 111
     }
86 112
 
@@ -111,17 +137,15 @@ class RubricsController extends \BaseController {
111 137
 
112 138
         try {
113 139
             // Get associated activity
114
-            $activity= Activity::where('rubric_id', '=', $rubric->id)->first();
140
+            $activity = Activity::where('rubric_id', '=', $rubric->id)->first();
115 141
 
116 142
             // If the associated activity has been assessed, delete the records
117
-            if($activity->outcomes_attempted!=NULL)
118
-            {
143
+            if ($activity->outcomes_attempted != NULL) {
119 144
                 DB::table('assessments')->where('activity_id', '=', $activity->id)->delete();
120
-                $activity->criteria_achieved_percentage= NULL;
121
-                $activity->criteria_achieved= NULL;
122
-                $activity->outcomes_achieved=NULL;
123
-                $activity->outcomes_attempted=NULL;
124
-
145
+                $activity->criteria_achieved_percentage = NULL;
146
+                $activity->criteria_achieved = NULL;
147
+                $activity->outcomes_achieved = NULL;
148
+                $activity->outcomes_attempted = NULL;
125 149
             }
126 150
 
127 151
             $rubric->save();
@@ -133,46 +157,38 @@ class RubricsController extends \BaseController {
133 157
 
134 158
             // Check if any assessed activities remain
135 159
             $remainingAssessed = false;
136
-            foreach ($course->activities as $activity)
137
-            {
138
-                if($activity->outcomes_attempted!=NULL)
139
-                {
140
-                    $remainingAssessed =true;
160
+            foreach ($course->activities as $activity) {
161
+                if ($activity->outcomes_attempted != NULL) {
162
+                    $remainingAssessed = true;
141 163
                     break;
142 164
                 }
143 165
             }
144 166
 
145 167
             //If there are still evaluated activities in the course, recalculate course outcomes
146
-            if(!$activities->isEmpty() && $remainingAssessed)
147
-            {
168
+            if (!$activities->isEmpty() && $remainingAssessed) {
148 169
                 // Variables to hold recalculated outcomes for the course
149 170
                 $course_outcomes_attempted = array_fill(1, Outcome::all()->count(), 0);
150 171
                 $course_outcomes_achieved = array_fill(1, Outcome::all()->count(), 0);
151 172
 
152 173
                 // For each activity
153
-                foreach ($activities as $activity)
154
-                {
174
+                foreach ($activities as $activity) {
155 175
                     // If activity has been assessed
156
-                    if($activity->outcomes_attempted!=NULL)
157
-                    {
176
+                    if ($activity->outcomes_attempted != NULL) {
158 177
                         // Get the achieved criteria
159 178
                         $criteria_achievement = json_decode($activity->criteria_achieved, true);
160
-                        foreach($criteria_achievement as $criterion_id=>$criterion_achieved)
161
-                        {
179
+                        foreach ($criteria_achievement as $criterion_id => $criterion_achieved) {
162 180
                             // Find corresponding learning outcome;
163 181
                             $criterion = Criterion::find($criterion_id);
164 182
                             $outcome = Outcome::find($criterion->outcome_id);
165 183
 
166 184
                             // If criterion is achieved (1), add 1 to both arrays
167
-                            if($criterion_achieved === 1)
168
-                            {
169
-                                $course_outcomes_attempted[$outcome->id]+=1;
170
-                                $course_outcomes_achieved[$outcome->id]+=1;
185
+                            if ($criterion_achieved === 1) {
186
+                                $course_outcomes_attempted[$outcome->id] += 1;
187
+                                $course_outcomes_achieved[$outcome->id] += 1;
171 188
                             }
172 189
                             // Else, only add to the attempted outcomes arrays
173
-                            elseif($criterion_achieved === 0)
174
-                            {
175
-                                $course_outcomes_attempted[$outcome->id]+=1;
190
+                            elseif ($criterion_achieved === 0) {
191
+                                $course_outcomes_attempted[$outcome->id] += 1;
176 192
                             }
177 193
                         }
178 194
                     }
@@ -181,14 +197,10 @@ class RubricsController extends \BaseController {
181 197
                 // Update course
182 198
                 $course->outcomes_achieved = json_encode($course_outcomes_achieved);
183 199
                 $course->outcomes_attempted = json_encode($course_outcomes_attempted);
184
-
185
-            }
186
-            else
187
-            {
200
+            } else {
188 201
                 // Update course
189 202
                 $course->outcomes_achieved = NULL;
190 203
                 $course->outcomes_attempted = NULL;
191
-
192 204
             }
193 205
 
194 206
             $course->save();
@@ -198,9 +210,7 @@ class RubricsController extends \BaseController {
198 210
             Session::flash('message', 'Rubric updated.');
199 211
 
200 212
             return action('ActivitiesController@show', array($activity->id));
201
-        }
202
-        catch (Exception $e)
203
-        {
213
+        } catch (Exception $e) {
204 214
             DB::rollBack();
205 215
             Session::flash('status', 'danger');
206 216
             Session::flash('message', 'Error: The rubric could not be updated. Try again later.');
@@ -216,13 +226,10 @@ class RubricsController extends \BaseController {
216 226
     {
217 227
         $rubric = Rubric::find(Input::get('id'));
218 228
 
219
-        if($rubric->delete())
220
-        {
229
+        if ($rubric->delete()) {
221 230
             Session::flash('status', 'success');
222 231
             Session::flash('message', 'Rubric deleted.');
223
-        }
224
-        else
225
-        {
232
+        } else {
226 233
             Session::flash('status', 'danger');
227 234
             Session::flash('message', 'Error: The rubric could not be deleted. Try again later.');
228 235
         }
@@ -243,10 +250,10 @@ class RubricsController extends \BaseController {
243 250
 
244 251
         // If activity does not belong to the requesting user, display 403
245 252
         if ($course->user_id != Auth::id())
246
-                App::abort('403', 'Access Forbidden');
253
+            App::abort('403', 'Access Forbidden');
247 254
 
248 255
         $rubric = Rubric::where('id', '=', $activity->rubric_id)->firstOrFail();
249
-        $title = $activity->name.': '.$rubric->name;
256
+        $title = $activity->name . ': ' . $rubric->name;
250 257
         return View::make('local.professors.viewrubric', compact('rubric', 'activity', 'title', 'course'));
251 258
     }
252 259
 
@@ -259,7 +266,7 @@ class RubricsController extends \BaseController {
259 266
     {
260 267
         // If user is a professor, display 403.
261 268
         if (Auth::user()->role == 4)
262
-                App::abort('403', 'Access Forbidden');
269
+            App::abort('403', 'Access Forbidden');
263 270
 
264 271
         $rubric = Rubric::where('id', '=', $rubric_id)->firstOrFail();
265 272
         $title = $rubric->name;
@@ -275,10 +282,10 @@ class RubricsController extends \BaseController {
275 282
 
276 283
         // If activity does not belong to the requesting user, display 403
277 284
         if ($course->user_id != Auth::id())
278
-                App::abort('403', 'Access Forbidden');
285
+            App::abort('403', 'Access Forbidden');
279 286
 
280 287
         $rubric = Rubric::where('id', '=', $activity->rubric_id)->firstOrFail();
281
-        $title = $activity->name.': '.$rubric->name;
288
+        $title = $activity->name . ': ' . $rubric->name;
282 289
         return View::make('local.professors.downloadrubric', compact('rubric', 'activity', 'title', 'course'));
283 290
     }
284 291
 
@@ -290,10 +297,10 @@ class RubricsController extends \BaseController {
290 297
 
291 298
         // If activity does not belong to the requesting user, display 403
292 299
         if ($course->user_id != Auth::id())
293
-                App::abort('403', 'Access Forbidden');
300
+            App::abort('403', 'Access Forbidden');
294 301
 
295 302
         $rubric = Rubric::where('id', '=', $activity->rubric_id)->firstOrFail();
296
-        $title = $activity->name.': '.$rubric->name;
303
+        $title = $activity->name . ': ' . $rubric->name;
297 304
         return View::make('local.professors.printrubric', compact('rubric', 'activity', 'title', 'course'));
298 305
     }
299 306
 
@@ -304,13 +311,10 @@ class RubricsController extends \BaseController {
304 311
 
305 312
         $rubric_contents = json_decode($rubric->contents);
306 313
 
307
-        foreach ($rubric_contents as $key => $criterion)
308
-        {
309
-            if($criterion->id == $criterion_id)
310
-            {
314
+        foreach ($rubric_contents as $key => $criterion) {
315
+            if ($criterion->id == $criterion_id) {
311 316
                 return json_encode($criterion);
312 317
             }
313 318
         }
314 319
     }
315
-
316 320
 }

+ 555
- 0
app/controllers/ThreeYearPlanController.php Ver arquivo

@@ -0,0 +1,555 @@
1
+<?php
2
+
3
+use Illuminate\Database\Eloquent\Collection;
4
+
5
+class ThreeYearPlanController extends \BaseController
6
+{
7
+
8
+  public function threeYearsReport()
9
+  {
10
+      $user_id = auth::user()->id;
11
+
12
+      // el ID de los semestres que el usuario tiene seleccionado.
13
+      $semesters_ids = Session::get('semesters_ids');
14
+      // buscar informacion de los semestres seleccionados
15
+      $semesters = Semester::whereIn('id',$semesters_ids)->get();
16
+
17
+      $title = "Three Year Plans Planning";
18
+      $outcomes = Outcome::orderBy('name', 'ASC')
19
+          ->where('deactivation_date','=','0000-00-00')
20
+          ->orWhereNull('deactivation_date')
21
+          ->get();
22
+      // $outcomes = DB::table('outcomes')
23
+      //     ->orderBy('name', 'asc')
24
+      //     ->get();
25
+      $typs = DB::table('three_year_plan')
26
+          ->orderBy('year_start', 'asc')
27
+          ->get();
28
+      $criteria = Criterion::withTrashed()->orderBy('name', 'ASC')->get();
29
+      // $criteria = DB::table('criteria')
30
+      //     ->orderBy('name', 'asc')
31
+      //     ->get();
32
+      $program_id = DB::table('program_user')
33
+      ->where('user_id',$user_id)
34
+      // ->where('user_id',8) //voy a usar 8 porque user 60 no tiene
35
+      ->select('program_id')
36
+      ->get();
37
+      $program_id = $program_id[0]->program_id; //program id 15 debido al user 8
38
+
39
+      // se annadio la nueva variable
40
+      return View::make('global.view-three-year-plan', compact('title', 'outcomes', 'typs', 'criteria', 'semesters', 'program_id'));
41
+
42
+  }
43
+
44
+
45
+  public function fetchThreeYears()
46
+  {
47
+      $id = Input::get('id');
48
+
49
+      $semesters = DB::table('typ_semesters')
50
+          ->join('semesters','semesters.id','=','typ_semesters.semester_id')
51
+          ->where('typ_semesters.typ_id',$id)
52
+          // ->select('semesters.*')
53
+          ->orderBy('typ_semesters.semester_id', 'asc')
54
+          ->get();
55
+      $typs = DB::table('three_year_plan')
56
+          ->where('id',$id)
57
+          ->orderBy('year_start', 'asc')
58
+          ->get();
59
+
60
+      $typs  = $typs[0];
61
+      $typs->semesters = $semesters;
62
+
63
+      return array
64
+      (
65
+          'typ' => $typs,
66
+      );
67
+  }
68
+
69
+  public function update_typ_outcomes_semesters()
70
+  {
71
+    $outcomeSemesterArray = json_decode(Input::get('outcomeSemesterArray'), true);
72
+    $typ_id = Input::get('typ_id');
73
+
74
+    $user_id = auth::user()->id; //ya, tester es 60
75
+    $program_id = DB::table('program_user')
76
+    ->where('user_id',$user_id)
77
+    // ->where('user_id',8) //voy a usar 8 porque user 60 no tiene
78
+    ->select('program_id')
79
+    ->get();
80
+    $program_id = $program_id[0]->program_id; //program id 15 debido al user 8
81
+
82
+
83
+    $result = DB::table('typ_program')
84
+        ->where('three_year_plan_id',$typ_id)
85
+        ->where('program_id',$program_id)
86
+        ->get();
87
+
88
+    // create the relation if it doesnt exist
89
+    if(count($result) == 0){
90
+      $typ_program_id = DB::table('typ_program')->insertGetId(
91
+          array('three_year_plan_id' => $typ_id,
92
+                'program_id' => $program_id)
93
+      );
94
+    } else {
95
+      $typ_program_id = $result[0]->id;
96
+    }
97
+
98
+
99
+
100
+    //go through array
101
+    foreach ($outcomeSemesterArray as $outcome_semester) {
102
+
103
+      // foreach of the 6 semesters
104
+      foreach ($outcome_semester["semesters"] as $semester) {
105
+        $insert = $semester[1];
106
+
107
+        $outcome_id = explode("-sem",$semester[0])[0];
108
+
109
+        $semester_code = explode("-sem",$semester[0])[1];
110
+        $result = DB::table('semesters')
111
+            ->where('code',$semester_code)
112
+            ->select('id')
113
+            ->get();
114
+        if(count($result) == 0){
115
+          continue;
116
+        }
117
+        $semester_id = $result[0]->id;
118
+
119
+        // verify if it exists
120
+        $result = DB::table('typ_semester_outcome')
121
+            ->where('typ_program_id',$typ_program_id)
122
+            ->where('semester_id',$semester_id)
123
+            ->where('outcome_id',$outcome_id)
124
+            ->get();
125
+
126
+        // if true, it should get inserted
127
+        if ($insert == true) {
128
+          // if == 0, then insert
129
+          if(count($result) == 0){
130
+            $_ = DB::table('typ_semester_outcome')->insertGetId(
131
+                array('typ_program_id' => $typ_program_id,
132
+                      'semester_id' => $semester_id,
133
+                      'outcome_id' => $outcome_id)
134
+            );
135
+
136
+          }
137
+          //if exists, then do nothing
138
+
139
+        }
140
+        // if false, it should get deleted
141
+        else { //value == false
142
+
143
+          // if == 0, it doesnt exist. we do nothing
144
+          if(count($result) == 0){
145
+            //pass
146
+          }
147
+          //if exists, then do nothing
148
+          else {
149
+            DB::table('typ_semester_outcome')
150
+                ->where('typ_program_id', $typ_program_id)
151
+                ->where('semester_id', $semester_id)
152
+                ->where('outcome_id', $outcome_id)
153
+                ->delete();
154
+          }
155
+        }
156
+      }
157
+    }
158
+    return;
159
+  }
160
+
161
+  public function lookup_typ_semester_outcome()
162
+  {
163
+    $box_value = array();
164
+
165
+    $info = Input::get('info');
166
+
167
+    foreach ($info as $values) {
168
+      $outcome_id = $values[0];
169
+      $semester_code = $values[1];
170
+      $program_id = $values[2];
171
+      $box_id = $values[3];
172
+      $typ_id = $values[4];
173
+
174
+      //buscar id del typ
175
+      $result = DB::table('typ_program')
176
+          ->where('three_year_plan_id',$typ_id)
177
+          ->where('program_id',$program_id)
178
+          ->get();
179
+      $typ_program_id = $result[0]->id;
180
+
181
+      // buscar si existe el outcome_semester
182
+      $result = DB::table('typ_semester_outcome')
183
+          ->join('semesters','semesters.id','=','typ_semester_outcome.semester_id')
184
+          ->where('typ_program_id',$typ_program_id)
185
+          ->where('semesters.code',$semester_code)
186
+          ->where('outcome_id',$outcome_id)
187
+          ->get();
188
+
189
+      // if it doesnt exist
190
+      if (count($result)==0){
191
+        array_push($box_value,array($box_id,0));
192
+      } else {
193
+        array_push($box_value,array($box_id,1));
194
+      }
195
+
196
+    }
197
+    return array
198
+    (
199
+      'box_value' => ($box_value)
200
+    );
201
+  }
202
+
203
+  public function section2_on_change()
204
+  {
205
+    $typ_id = Input::get('typ_id');
206
+    // typ_id: (typ_id),
207
+    $outcome_id = Input::get('outcome_id');
208
+    // outcome_id: (outcome_id),
209
+    $semester_id = Input::get('semester_id');
210
+    // semester_id: (semester_id),
211
+    $previous_objective_id = Input::get('previous_objective_id');
212
+    // previous_objective_id: (previous_objective_id),
213
+    $new_objective_id = Input::get('new_objective_id');
214
+    // new_objective_id: (new_objective_id)
215
+
216
+    // get program_id
217
+    $user_id = auth::user()->id; //ya, tester es 60
218
+    $program_id = DB::table('program_user')
219
+        ->where('user_id',$user_id)
220
+        // ->where('user_id',8) //voy a usar 8 porque user 60 no tiene
221
+        ->select('program_id')
222
+        ->get();
223
+    $program_id = $program_id[0]->program_id; //program id 15 debido al user 8
224
+
225
+    // get typ_program_id
226
+    $result = DB::table('typ_program')
227
+        ->where('three_year_plan_id',$typ_id)
228
+        ->where('program_id',$program_id)
229
+        ->get();
230
+    $typ_program_id = $result[0]->id;
231
+
232
+    // get typ_semester_outcome_id
233
+    $result = DB::table('typ_semester_outcome')
234
+        ->where('typ_program_id',$typ_program_id)
235
+        ->where('semester_id',$semester_id)
236
+        ->where('outcome_id',$outcome_id)
237
+        ->get();
238
+    $typ_semester_outcome_id = $result[0]->id;
239
+
240
+    //delete old objective relation if it exists
241
+    if ($previous_objective_id != 'nothing_selected') {
242
+      $result = DB::table('typ_semester_objectives')
243
+          ->where('typ_semester_outcome_id',$typ_semester_outcome_id)
244
+          ->where('objective_id',$previous_objective_id)
245
+          ->get();
246
+      if (count($result) != 0) {
247
+        DB::table('typ_semester_objectives')
248
+            ->where('typ_semester_outcome_id', $typ_semester_outcome_id)
249
+            ->where('objective_id', $previous_objective_id)
250
+            ->delete();
251
+      }
252
+    }
253
+
254
+    //create new objective relation
255
+    if ($new_objective_id != 'nothing_selected') {
256
+      $result = DB::table('typ_semester_objectives')
257
+          ->where('typ_semester_outcome_id',$typ_semester_outcome_id)
258
+          ->where('objective_id',$new_objective_id)
259
+          ->get();
260
+      if (count($result) == 0) {
261
+        $_ = DB::table('typ_semester_objectives')->insertGetId(
262
+            array(
263
+              'typ_semester_outcome_id' => $typ_semester_outcome_id,
264
+              'objective_id' => $new_objective_id)
265
+        );
266
+      }
267
+    }
268
+    return 'update was succes';
269
+  }
270
+
271
+  public function section2_arrive()
272
+  {
273
+    // get program_id
274
+    $user_id = auth::user()->id; //ya, tester es 60
275
+    $program_id = DB::table('program_user')
276
+        ->where('user_id',$user_id)
277
+        // ->where('user_id',8) //voy a usar 8 porque user 60 no tiene
278
+        ->select('program_id')
279
+        ->get();
280
+    $program_id = $program_id[0]->program_id; //program id 15 debido al user 8
281
+
282
+    // get typ_program_id
283
+    $typ_id = Input::get('typ_id');
284
+    $result = DB::table('typ_program')
285
+        ->where('three_year_plan_id',$typ_id)
286
+        ->where('program_id',$program_id)
287
+        ->get();
288
+    $typ_program_id = $result[0]->id;
289
+
290
+
291
+    //search selected outcomes,semesters and get their objectives
292
+    $selected_outcomes = DB::table('typ_semester_outcome')
293
+        ->join('outcomes','outcomes.id','=','typ_semester_outcome.outcome_id')
294
+        ->where('typ_semester_outcome.typ_program_id',$typ_program_id)
295
+        ->distinct('typ_semester_outcome.outcome_id')
296
+        ->select('typ_semester_outcome.outcome_id')
297
+        ->orderBy('outcomes.name', 'asc')
298
+        ->get();
299
+
300
+    $selected_objectives_array = array();
301
+    $outcomes_info_array = array();
302
+    // $objectives_info_array = array();
303
+    $semesters_array = array();
304
+
305
+    $info = array();
306
+    foreach ($selected_outcomes as $outcome) {
307
+
308
+
309
+      $outcome_id = $outcome->outcome_id;
310
+      $result_outcomes = DB::table('outcomes')
311
+          ->where('outcomes.id',$outcome_id)
312
+          ->orderBy('outcomes.name', 'asc')
313
+          ->get();
314
+
315
+      foreach ($result_outcomes as $outcome_) {
316
+
317
+        $result_semesters = DB::table('typ_semester_outcome')
318
+            ->join('semesters','semesters.id','=','typ_semester_outcome.semester_id')
319
+            ->where('typ_semester_outcome.typ_program_id',$typ_program_id)
320
+            ->where('typ_semester_outcome.outcome_id',$outcome_->id)
321
+            ->select('typ_semester_outcome.id','typ_semester_outcome.semester_id','semesters.code','semesters.name')
322
+            ->get();
323
+        // buscar info sobre selected_semsters
324
+        $outcome_->selected_semesters = array();
325
+        foreach ($result_semesters as $semesters_) {
326
+          $typ_semester_outcome_id = $semesters_->id;
327
+
328
+          // lookup previusly selected objectives
329
+          $result_objectives = DB::table('typ_semester_objectives')
330
+              ->join('objectives','objectives.id','=','typ_semester_objectives.objective_id')
331
+              ->where('typ_semester_objectives.typ_semester_outcome_id', $typ_semester_outcome_id)
332
+              ->orderBy('typ_semester_objectives.id', 'asc')
333
+              ->get();
334
+
335
+          $semesters_->selected_objectives = array();
336
+          foreach ($result_objectives as $objectives_) {
337
+
338
+            array_push($semesters_->selected_objectives, $objectives_);
339
+          }
340
+
341
+          // lookup available objectives
342
+          $result_objectives = DB::table('criterion_objective_outcome')
343
+              ->join('outcomes','outcomes.id','=','criterion_objective_outcome.outcome_id')
344
+              ->join('objectives','objectives.id','=','criterion_objective_outcome.objective_id')
345
+              ->join('objective_program','objective_program.objective_id','=','objectives.id')
346
+              ->where('objective_program.program_id',$program_id)
347
+              ->where('criterion_objective_outcome.outcome_id',$outcome_id)
348
+              ->select('objectives.id','objectives.text','outcomes.name as outcome_name')
349
+              ->orderBy('objectives.text', 'asc')
350
+              ->get();
351
+
352
+          $semesters_->available_objectives = array();
353
+          foreach ($result_objectives as $objectives_) {
354
+
355
+            array_push($semesters_->available_objectives, $objectives_);
356
+          }
357
+
358
+          array_push($outcome_->selected_semesters, $semesters_);
359
+        }
360
+        array_push($info, $outcome_);
361
+      }
362
+    }
363
+    return $info;
364
+  }
365
+
366
+  public function section3_arrive()
367
+  {
368
+    // get program_id
369
+    $user_id = auth::user()->id; //ya, tester es 60
370
+    $program_id = DB::table('program_user')
371
+        ->where('user_id',$user_id)
372
+        // ->where('user_id',8) //voy a usar 8 porque user 60 no tiene
373
+        ->select('program_id')
374
+        ->get();
375
+    $program_id = $program_id[0]->program_id; //program id 15 debido al user 8
376
+
377
+    // get typ_program_id
378
+    $typ_id = Input::get('typ_id');
379
+    $result = DB::table('typ_program')
380
+        ->where('three_year_plan_id',$typ_id)
381
+        ->where('program_id',$program_id)
382
+        ->get();
383
+    $typ_program_id = $result[0]->id;
384
+
385
+
386
+    //search selected outcomes,semesters and get their objectives
387
+    $selected_outcomes = DB::table('typ_semester_outcome')
388
+        ->join('outcomes','outcomes.id','=','typ_semester_outcome.outcome_id')
389
+        ->where('typ_semester_outcome.typ_program_id',$typ_program_id)
390
+        ->distinct('typ_semester_outcome.outcome_id')
391
+        ->select('typ_semester_outcome.outcome_id')
392
+        ->orderBy('outcomes.name', 'asc')
393
+        ->get();
394
+
395
+    $selected_objectives_array = array();
396
+    $outcomes_info_array = array();
397
+    // $objectives_info_array = array();
398
+    $semesters_array = array();
399
+
400
+    $info = array();
401
+    foreach ($selected_outcomes as $outcome) {
402
+
403
+
404
+      $outcome_id = $outcome->outcome_id;
405
+      $result_outcomes = DB::table('outcomes')
406
+          ->where('outcomes.id',$outcome_id)
407
+          ->get();
408
+
409
+      foreach ($result_outcomes as $outcome_) {
410
+
411
+        $result_semesters = DB::table('typ_semester_outcome')
412
+            ->join('semesters','semesters.id','=','typ_semester_outcome.semester_id')
413
+            ->where('typ_semester_outcome.typ_program_id',$typ_program_id)
414
+            ->where('typ_semester_outcome.outcome_id',$outcome_->id)
415
+            ->select('typ_semester_outcome.id','typ_semester_outcome.semester_id','semesters.code','semesters.name')
416
+            ->get();
417
+        // buscar info sobre selected_semsters
418
+        $outcome_->selected_semesters = array();
419
+        foreach ($result_semesters as $semesters_) {
420
+          $semester_id = $semesters_->semester_id;
421
+
422
+          $typ_semester_outcome_id = $semesters_->id;
423
+          $result_objectives = DB::table('typ_semester_objectives')
424
+              ->join('objectives','objectives.id','=','typ_semester_objectives.objective_id')
425
+              ->where('typ_semester_objectives.typ_semester_outcome_id', $typ_semester_outcome_id)
426
+              ->select('typ_semester_objectives.id as typ_semester_objectives_id','objectives.*','typ_semester_objectives.*')
427
+              ->orderBy('typ_semester_objectives.id', 'asc')
428
+              ->get();
429
+
430
+          $semesters_->selected_objectives = array();
431
+          foreach ($result_objectives as $objectives_) {
432
+            $objective_id = $objectives_->objective_id;
433
+            $program_id = $objectives_->program_id;
434
+            $result_courses = DB::table('objective_program')
435
+                ->join('objectives','objectives.id','=','objective_program.objective_id')
436
+                ->join('courses','courses.program_id','=','objective_program.program_id')
437
+                ->where('objective_program.objective_id', $objective_id)
438
+                ->where('objective_program.program_id', $program_id)
439
+                ->where('courses.semester_id', $semester_id)
440
+                ->distinct('courses.name','courses.code')
441
+                ->select('courses.id as course_id','courses.name','courses.code','objective_program.objective_id','objective_program.program_id')
442
+                ->orderBy('courses.name', 'asc')
443
+                ->groupBy('courses.name','courses.code')
444
+                ->get();
445
+
446
+            $objectives_->available_courses = array();
447
+            foreach ($result_courses as $courses_) {
448
+              array_push($objectives_->available_courses, $courses_);
449
+            }
450
+
451
+            // search for previusly selected courses
452
+            $typ_semester_objective_id = $objectives_->typ_semester_objectives_id;
453
+            $result_courses = DB::table('typ_semester_courses')
454
+                ->join('courses','courses.id','=','typ_semester_courses.course_id')
455
+                ->where('typ_semester_courses.typ_semester_objective_id', $typ_semester_objective_id)
456
+                ->select('courses.id as course_id','courses.*','typ_semester_courses.*')
457
+                ->orderBy('courses.name', 'asc')
458
+                ->get();
459
+
460
+            $objectives_->selected_courses = array();
461
+            foreach ($result_courses as $courses_) {
462
+              array_push($objectives_->selected_courses, $courses_);
463
+            }
464
+
465
+            array_push($semesters_->selected_objectives, $objectives_);
466
+          }
467
+
468
+          array_push($outcome_->selected_semesters, $semesters_);
469
+        }
470
+        array_push($info, $outcome_);
471
+      }
472
+    }
473
+    return $info;
474
+  }
475
+
476
+
477
+  public function section3_on_change()
478
+  {
479
+    $typ_id = Input::get('typ_id');
480
+    // typ_id: (typ_id),
481
+    $outcome_id = Input::get('outcome_id');
482
+    // outcome_id: (outcome_id),
483
+    $semester_id = Input::get('semester_id');
484
+    // semester_id: (semester_id),
485
+    $objective_id = Input::get('objective_id');
486
+    // objective_id: (objective_id),
487
+    $previous_course_id = Input::get('previous_course_id');
488
+    // previous_course_id: (previous_course_id),
489
+    $new_course_id = Input::get('new_course_id');
490
+    // new_course_id: (new_course_id)
491
+
492
+    // get program_id
493
+    $user_id = auth::user()->id; //ya, tester es 60
494
+    $program_id = DB::table('program_user')
495
+        ->where('user_id',$user_id)
496
+        // ->where('user_id',8) //voy a usar 8 porque user 60 no tiene
497
+        ->select('program_id')
498
+        ->get();
499
+    $program_id = $program_id[0]->program_id; //program id 15 debido al user 8
500
+
501
+    // get typ_program_id
502
+    $result = DB::table('typ_program')
503
+        ->where('three_year_plan_id',$typ_id)
504
+        ->where('program_id',$program_id)
505
+        ->get();
506
+    $typ_program_id = $result[0]->id;
507
+
508
+    // get typ_semester_outcome_id
509
+    $result = DB::table('typ_semester_outcome')
510
+        ->where('typ_program_id',$typ_program_id)
511
+        ->where('semester_id',$semester_id)
512
+        ->where('outcome_id',$outcome_id)
513
+        ->get();
514
+    $typ_semester_outcome_id = $result[0]->id;
515
+
516
+    // get typ_semester_objective_id
517
+    $result = DB::table('typ_semester_objectives')
518
+        ->where('typ_semester_outcome_id',$typ_semester_outcome_id)
519
+        ->where('objective_id',$objective_id)
520
+        ->get();
521
+    $typ_semester_objective_id = $result[0]->id;
522
+
523
+    //delete old objective relation if it exists
524
+    if ($previous_course_id != 'nothing_selected') {
525
+      $result = DB::table('typ_semester_courses')
526
+          ->where('typ_semester_objective_id',$typ_semester_objective_id)
527
+          ->where('course_id',$previous_course_id)
528
+          ->get();
529
+      if (count($result) != 0) {
530
+        DB::table('typ_semester_courses')
531
+            ->where('typ_semester_objective_id', $typ_semester_objective_id)
532
+            ->where('course_id', $previous_course_id)
533
+            ->delete();
534
+      }
535
+    }
536
+
537
+    //create new objective relation
538
+    if ($new_course_id != 'nothing_selected') {
539
+      $result = DB::table('typ_semester_courses')
540
+          ->where('typ_semester_objective_id',$typ_semester_objective_id)
541
+          ->where('course_id',$new_course_id)
542
+          ->get();
543
+      if (count($result) == 0) {
544
+        $_ = DB::table('typ_semester_courses')->insertGetId(
545
+            array(
546
+              'typ_semester_objective_id' => $typ_semester_objective_id,
547
+              'course_id' => $new_course_id)
548
+        );
549
+      }
550
+    }
551
+    return 'update succes?';
552
+  }
553
+
554
+
555
+}

+ 928
- 0
app/controllers/TransformativeActionsController.php Ver arquivo

@@ -0,0 +1,928 @@
1
+<?php
2
+
3
+use Illuminate\Support\Facades\Input;
4
+
5
+class TransformativeActionsController extends \BaseController
6
+{
7
+
8
+    public function editTA()
9
+    {
10
+        $title = "Transformative Action";
11
+        $role = Auth::user()['role'];
12
+        $outcomes = Outcome::orderBy('name', 'ASC')->lists('name', 'id');
13
+
14
+        $schools = School::orderBy('name', 'ASC')->get();
15
+        $criteria = Criterion::withTrashed()->orderBy('name', 'ASC')->get();
16
+        $programs = Program::orderBy('name', 'ASC')->get();
17
+        $user_id = auth::user()->id;
18
+
19
+        $program_id = DB::table('program_user')
20
+            ->where('user_id',$user_id)
21
+            ->select('program_id')
22
+            ->get();
23
+        $program_id = $program_id[0]->program_id; //program id 15 debido al user 8
24
+        $outcomes = Outcome::orderBy('name', 'ASC')
25
+                    ->where('deactivation_date','=','0000-00-00')
26
+                    ->orWhereNull('deactivation_date')
27
+                    ->get();
28
+        $objectives = array();
29
+
30
+        // if user is program coordinator
31
+        if ($role == 3){
32
+          //1 edit panel: load the TA that
33
+          //    are custom ('transformative_actions.by_professor' == 0)
34
+          //    were approved in past ('transformative_actions.is_custom' == 1)
35
+          $ta_edit_panel = DB::table('transformative_actions')
36
+                          ->where('transformative_actions.is_custom', 1)
37
+                          ->where('transformative_actions.program_id', $program_id)
38
+                          ->where('transformative_actions.by_professor', 0)
39
+                          ->orderBy('at_text', 'ASC')
40
+                          ->get();
41
+          //2 approve panel: load TAs that
42
+          //    can be approved ('transformative_actions.by_professor' == 1)
43
+          $ta_approval_panel = DB::table('transformative_actions')
44
+                            ->where('transformative_actions.is_custom', 1)
45
+                            ->where('transformative_actions.program_id', $program_id)
46
+                            ->where('transformative_actions.by_professor',1)
47
+                            ->orderBy('at_text', 'ASC')
48
+                            ->get();
49
+          //2.1 approve panel: load the filter options.
50
+          // the "->where()" should be the same from $ta_approval_panel,
51
+          //  but with aditional joins and different select
52
+          //
53
+          // get the names of the professors
54
+          $professor_filter_approvePanel = DB::table('transformative_actions')
55
+                            ->join('users','users.id','=','transformative_actions.user_id')
56
+                            ->where('transformative_actions.is_custom', 1)
57
+                            ->where('transformative_actions.program_id', $program_id)
58
+                            ->where('transformative_actions.by_professor', 1)
59
+                            ->select('users.*')
60
+                            ->groupby('transformative_actions.user_id')
61
+                            ->orderBy('users.first_name', 'ASC')
62
+                            ->get();
63
+          // get the courses from asociated with a TA
64
+          $course_filter_approvePanel = DB::table('ta_course')
65
+                            ->join('transformative_actions','transformative_actions.id','=','ta_course.ta_id')
66
+                            ->join('courses','courses.id','=','ta_course.course_id')
67
+                            ->where('transformative_actions.is_custom', 1)
68
+                            ->where('transformative_actions.program_id', $program_id)
69
+                            ->where('transformative_actions.by_professor', 1)
70
+                            ->select('courses.*')
71
+                            ->groupBy('courses.name','courses.code')
72
+                            ->orderBy('courses.name', 'ASC')
73
+                            ->orderBy('courses.code', 'ASC')
74
+                            ->get();
75
+          // get the outcome asociated with a TA
76
+          $outcome_filter_approvePanel = DB::table('transformative_actions')
77
+                            ->join('transformative_objective_program','transformative_objective_program.ta_id','=','transformative_actions.id')
78
+                            ->join('criterion_objective_outcome','criterion_objective_outcome.objective_id','=','transformative_objective_program.objective_id')
79
+                            ->join('outcomes','outcomes.id','=','criterion_objective_outcome.outcome_id')
80
+                            ->where('transformative_actions.is_custom', 1)
81
+                            ->where('transformative_actions.program_id', $program_id)
82
+                            ->where('transformative_actions.by_professor', 1)
83
+                            ->select('outcomes.*')
84
+                            ->groupBy('outcomes.id')
85
+                            ->orderBy('outcomes.name', 'ASC')
86
+                            ->get();
87
+          //3 edit panel: load the filter options.
88
+          // the "->where()" should be the same from $ta_edit_panel,
89
+          //  but with aditional joins and different select
90
+          //
91
+          $professor_filter_editPanel = DB::table('transformative_actions')
92
+                            ->join('users','users.id','=','transformative_actions.user_id')
93
+                            ->where('transformative_actions.is_custom', 1)
94
+                            ->where('transformative_actions.program_id', $program_id)
95
+                            ->where('transformative_actions.by_professor', 0)
96
+                            ->select('users.*')
97
+                            ->groupby('transformative_actions.user_id')
98
+                            ->orderBy('users.first_name', 'ASC')
99
+                            ->get();
100
+          $course_filter_editPanel =  DB::table('ta_course')
101
+                            ->join('transformative_actions','transformative_actions.id','=','ta_course.ta_id')
102
+                            ->join('courses','courses.id','=','ta_course.course_id')
103
+                            ->where('transformative_actions.is_custom', 1)
104
+                            ->where('transformative_actions.program_id', $program_id)
105
+                            ->where('transformative_actions.by_professor', 0)
106
+                            ->select('courses.*')
107
+                            ->groupBy('courses.name','courses.code')
108
+                            ->orderBy('courses.name', 'ASC')
109
+                            ->orderBy('courses.code', 'ASC')
110
+                            ->get();
111
+          $outcome_filter_editPanel = DB::table('transformative_actions')
112
+                            ->join('transformative_objective_program','transformative_objective_program.ta_id','=','transformative_actions.id')
113
+                            ->join('criterion_objective_outcome','criterion_objective_outcome.objective_id','=','transformative_objective_program.objective_id')
114
+                            ->join('outcomes','outcomes.id','=','criterion_objective_outcome.outcome_id')
115
+                            ->where('transformative_actions.is_custom', 1)
116
+                            ->where('transformative_actions.program_id', $program_id)
117
+                            ->where('transformative_actions.by_professor', 0)
118
+                            ->select('outcomes.*')
119
+                            ->groupBy('outcomes.id')
120
+                            ->orderBy('outcomes.name', 'ASC')
121
+                            ->get();
122
+          // 4 create panel: search all courses
123
+          $courses_create = DB::table('courses')
124
+                            ->where('courses.program_id',$program_id)
125
+                            ->select('courses.*')
126
+                            ->groupBy('courses.name','courses.code')
127
+                            ->orderBy('courses.name', 'ASC')
128
+                            ->orderBy('courses.code', 'ASC')
129
+                            ->get();
130
+        }
131
+        // if user is profesor
132
+        elseif ($role == 4){
133
+          // 1 the user can only edit TA that need approval and has been submited by the same user
134
+          $ta_edit_panel = DB::table('transformative_actions')
135
+                          ->where('transformative_actions.is_custom', 1)
136
+                          ->where('transformative_actions.program_id',$program_id)
137
+                          ->where('transformative_actions.user_id', Auth::user()->id)
138
+                          ->where('transformative_actions.by_professor',1)
139
+                          ->select('transformative_actions.*')
140
+                          ->orderBy('at_text', 'ASC')
141
+                          ->get();
142
+          // 2 approve panel: dont load TA since professors cant approve them
143
+          $ta_approval_panel = array();
144
+          // 3 edit panel: load professor filter for his courses
145
+          $professor_filter_editPanel = array();
146
+          $course_filter_editPanel =  DB::table('ta_course')
147
+                            ->join('transformative_actions','transformative_actions.id','=','ta_course.ta_id')
148
+                            ->join('courses','courses.id','=','ta_course.course_id')
149
+                            ->where('transformative_actions.is_custom', 1)
150
+                            ->where('transformative_actions.user_id', Auth::user()->id)
151
+                            ->where('transformative_actions.program_id', $program_id)
152
+                            ->where('transformative_actions.by_professor', 1)
153
+                            ->select('courses.*')
154
+                            ->groupBy('courses.name','courses.code')
155
+                            ->orderBy('courses.name', 'ASC')
156
+                            ->orderBy('courses.code', 'ASC')
157
+                            ->get();
158
+          $outcome_filter_editPanel = DB::table('transformative_actions')
159
+                            ->join('transformative_objective_program','transformative_objective_program.ta_id','=','transformative_actions.id')
160
+                            ->join('criterion_objective_outcome','criterion_objective_outcome.objective_id','=','transformative_objective_program.objective_id')
161
+                            ->join('outcomes','outcomes.id','=','criterion_objective_outcome.outcome_id')
162
+                            ->where('transformative_actions.is_custom', 1)
163
+                            ->where('transformative_actions.user_id', Auth::user()->id)
164
+                            ->where('transformative_actions.program_id',$program_id)
165
+                            ->where('transformative_actions.by_professor', 1)
166
+                            ->select('outcomes.*')
167
+                            ->groupBy('outcomes.id')
168
+                            ->orderBy('outcomes.name', 'ASC')
169
+                            ->get();
170
+          // these arent used by professors
171
+          $professor_filter_approvePanel = array();
172
+          $course_filter_approvePanel = array();
173
+          $outcome_filter_approvePanel = array();
174
+
175
+          // 4 create panel: search courses given by the professor
176
+          $courses_create = DB::table('courses')
177
+                            ->where('courses.program_id',$program_id)
178
+                            ->where('courses.user_id', Auth::user()->id)
179
+                            ->select('courses.*')
180
+                            ->groupBy('courses.name','courses.code')
181
+                            ->orderBy('courses.name', 'ASC')
182
+                            ->orderBy('courses.code', 'ASC')
183
+                            ->get();
184
+        }
185
+
186
+        return View::make('local.managers.admins.transformativeAction', compact('title','role', 'outcomes', 'schools', 'criteria', 'programs', 'outcomes', 'objectives',
187
+        'ta_edit_panel','ta_approval_panel','courses_create',
188
+        'professor_filter_approvePanel', 'course_filter_approvePanel', 'outcome_filter_approvePanel',
189
+        'professor_filter_editPanel', 'outcome_filter_editPanel', 'course_filter_editPanel'
190
+      ));
191
+    }
192
+
193
+
194
+    private function cleanInput()
195
+    {
196
+        $clean_input = array();
197
+
198
+
199
+        $trimmed = trim(preg_replace('/\t+/', '', Input::get('text')));
200
+
201
+        Log::info('trimmed 1 -->' . $trimmed . '<--');
202
+
203
+        // if ($trimmed == '') {
204
+        //     $trimmed = NULL;
205
+        // } else {
206
+        //     $trimmed = json_encode(preg_split('/\r\n/', $trimmed));
207
+        // }
208
+
209
+        Log::info('trimmed 2 -->' . $trimmed . '<--');
210
+
211
+
212
+        $clean_input['text'] = $trimmed;
213
+
214
+        //////
215
+        $trimmed = trim(preg_replace('/\t+/', '', Input::get('description')));
216
+
217
+        Log::info('trimmed 3 -->' . $trimmed . '<--');
218
+
219
+        // if ($trimmed == '') {
220
+        //     $trimmed = NULL;
221
+        // } else {
222
+        //     $trimmed = json_encode(preg_split('/\r\n/', $trimmed));
223
+        // }
224
+
225
+        Log::info('trimmed 4 -->' . $trimmed . '<--');
226
+
227
+
228
+        $clean_input['description'] = $trimmed;
229
+
230
+
231
+
232
+        $clean_input['objectiveid'] = Input::get('objectiveid');
233
+        $clean_input['courseid'] = Input::get('courseid');
234
+        $clean_input['approval'] = Input::get('approval');
235
+        $clean_input['ta_id'] = Input::get('ta_id');
236
+
237
+        return $clean_input;
238
+    }
239
+
240
+    private function makeValidator($clean_input)
241
+    {
242
+
243
+      /** Validation rules */
244
+      return Validator::make(
245
+            array(
246
+                'text' => $clean_input['text'],
247
+                'description' => $clean_input['description'],
248
+                'objectiveid' => $clean_input['objectiveid'],
249
+                'courseid' => $clean_input['courseid'],
250
+                'approval' => $clean_input['approval'],
251
+                'ta_id' => $clean_input['ta_id'],
252
+            ),
253
+            array(
254
+                'text' => 'required|string',
255
+                'description' => 'required|string',
256
+                'objectiveid' => 'required|array',
257
+                'courseid' => 'required|array',
258
+                'approval' => 'integer',
259
+                'ta_id' => 'integer',
260
+            )
261
+        );
262
+    }
263
+
264
+
265
+    /**
266
+     * Create a new transformative action.
267
+     *
268
+     * @return Redirect Redirect back to form page
269
+     */
270
+    public function createTA()
271
+    {
272
+        $clean_input = $this->cleanInput();
273
+
274
+        /** Validation rules */
275
+        $validator = $this->makeValidator($clean_input);
276
+
277
+        /** If validation fails */
278
+        if ($validator->fails()) {
279
+            /** Prepare error message */
280
+            $message = '<p>Error(s) creating a new Transformative Action:</p><ul>';
281
+
282
+            foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
283
+                $message .= $validationError;
284
+            }
285
+
286
+            $message .= '</ul>';
287
+
288
+            /** Send error message and old data */
289
+            Session::flash('status', 'danger');
290
+            Session::flash('message', $message);
291
+            $role = Auth::user()['role'];
292
+            return Redirect::to('transformativeAction')->withInput();
293
+        } else {
294
+
295
+          $user_id = auth::user()->id;
296
+          $program_id = DB::table('program_user')
297
+              ->where('user_id',$user_id)
298
+              ->select('program_id')
299
+              ->get();
300
+          $program_id = $program_id[0]->program_id;
301
+          $role = Auth::user()['role'];
302
+          $by_professor = 1;
303
+          if($role == 3){
304
+            $by_professor = 0;
305
+          }
306
+
307
+          // $by_professor = $clean_input['approval'];
308
+
309
+          $current_timestamp = date('Y/m/d H:i:s', time());
310
+          // insert the TA
311
+          $ta_id = DB::table('transformative_actions')->insertGetId(
312
+              array('at_text' => $clean_input['text'],
313
+                    'description' => $clean_input['description'],
314
+                    'is_custom' => 1,
315
+                    'user_id' => $user_id,
316
+                    'program_id' => $program_id,
317
+                    'created_at' => $current_timestamp,
318
+                    'by_professor' => $by_professor,
319
+                  )
320
+          );
321
+
322
+          //
323
+          // // insert the multiple TA_objective_program
324
+          foreach ($clean_input['objectiveid'] as $objective_id) {
325
+            DB::table('transformative_objective_program')->insert(
326
+                array(
327
+                  'ta_id' => $ta_id,
328
+                  'objective_id' => $objective_id,
329
+                  'program_id' => $program_id,
330
+                  'created_at' => $current_timestamp,
331
+                  )
332
+            );
333
+          }
334
+
335
+          //
336
+          // // insert the multiple TA_course
337
+          foreach ($clean_input['courseid'] as $course_id) {
338
+            DB::table('TA_course')->insert(
339
+                array(
340
+                  'ta_id' => $ta_id,
341
+                  'course_id' => $course_id,
342
+                  )
343
+            );
344
+          }
345
+
346
+          Session::flash('status', 'success');
347
+          Session::flash('message', 'Transformative Action created: "' . $clean_input['text'] . '".');
348
+          $role = Auth::user()['role'];
349
+          return Redirect::to('transformativeAction')->withInput();
350
+        }
351
+    }
352
+
353
+
354
+    public function approveTA()
355
+    {
356
+      $role = Auth::user()['role'];
357
+      if($role != 3){
358
+        $message = 'Only Program Coordinators can approve a TA';
359
+        Session::flash('status', 'danger');
360
+        Session::flash('message', $message);
361
+        return Redirect::to('transformativeAction')->withInput();
362
+      }
363
+
364
+      $ta_id = Input::get('ta_id');
365
+      $text = Input::get('at_text');
366
+
367
+      if($ta_id == 0){
368
+        $message = 'Please select a Transformative Action</p>';
369
+
370
+        Session::flash('status', 'danger');
371
+        Session::flash('message', $message);
372
+
373
+        $role = Auth::user()['role'];
374
+        return Redirect::to('transformativeAction')->withInput();
375
+      }
376
+
377
+      $current_timestamp = date('Y/m/d H:i:s', time());
378
+
379
+      // edit the TA
380
+      DB::table('transformative_actions')
381
+                  ->where('id', $ta_id)
382
+                  ->update([
383
+                        'by_professor' => 0,
384
+                        'updated_at' => $current_timestamp,
385
+                    ]);
386
+
387
+      Session::flash('status', 'success');
388
+      Session::flash('message', 'Approved the Transformative Action: "' . $text . '".');
389
+      $role = Auth::user()['role'];
390
+      return Redirect::to('transformativeAction')->withInput();
391
+    }
392
+
393
+
394
+
395
+
396
+
397
+
398
+    public function updateTA()
399
+    {
400
+      $clean_input = $this->cleanInput();
401
+
402
+      /** Validation rules */
403
+      $validator = $this->makeValidator($clean_input);
404
+
405
+      /** If validation fails */
406
+      if ($validator->fails()) {
407
+          /** Prepare error message */
408
+          $message = 'Error(s) updating the Transformative Action: <ul>';
409
+
410
+          foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
411
+              $message .= $validationError;
412
+          }
413
+
414
+          $message .= '</ul>';
415
+
416
+          /** Send error message and old data */
417
+          Session::flash('status', 'danger');
418
+          Session::flash('message', $message);
419
+          $role = Auth::user()['role'];
420
+          return Redirect::to('transformativeAction')->withInput();
421
+      } else {
422
+
423
+          $user_id = auth::user()->id;
424
+          $program_id = DB::table('program_user')
425
+              ->where('user_id',$user_id)
426
+              ->select('program_id')
427
+              ->get();
428
+          $program_id = $program_id[0]->program_id;
429
+          $role = Auth::user()['role'];
430
+          $by_professor = $clean_input['approval'];
431
+          if($role == 4){
432
+            $by_professor = 1;
433
+          }
434
+
435
+          // $by_professor = $clean_input['approval'];
436
+
437
+          $current_timestamp = date('Y/m/d H:i:s', time());
438
+          // edit the TA
439
+          DB::table('transformative_actions')
440
+                      ->where('id', $clean_input['ta_id'])
441
+                      ->update([
442
+                            'by_professor' => $by_professor,
443
+                            'at_text' => $clean_input['text'],
444
+                            'description' => $clean_input['description'],
445
+                            'updated_at' => $current_timestamp,
446
+                        ]);
447
+
448
+
449
+          $ta_id = $clean_input['ta_id'];
450
+          $new_objective_id = $clean_input['objectiveid'];
451
+          $old_objective_id = DB::table('transformative_objective_program')
452
+                      ->where('ta_id',$ta_id)
453
+                      ->select('objective_id')
454
+                      ->lists('objective_id');
455
+
456
+          //delete existing objective_id if it isnt in new_ids array
457
+          foreach ($old_objective_id as $old_id) {
458
+            if(in_array($old_id,$new_objective_id)){
459
+              //do nothing if a new id is already in atble
460
+            }
461
+            else {
462
+              //if old id not in new id, delete
463
+              DB::table('transformative_objective_program')
464
+                ->where('ta_id',$ta_id)
465
+                ->where('objective_id', $old_id)
466
+                ->delete();
467
+            }
468
+          }
469
+
470
+          //
471
+          foreach ($new_objective_id as $new_id) {
472
+            $result = DB::table('transformative_objective_program')
473
+                        ->where('objective_id',$new_id)
474
+                        ->select('objective_id')
475
+                        ->lists('objective_id');
476
+
477
+            if(count($result) == 0){
478
+              //if the new_id does not exists, do nothing
479
+              DB::table('transformative_objective_program')->insert(
480
+                array(
481
+                  'ta_id' => $ta_id,
482
+                  'objective_id' => $new_id,
483
+                  'program_id' => $program_id,
484
+                  'created_at' => $current_timestamp,
485
+                )
486
+              );
487
+            }
488
+            else {
489
+              //if the new_id already exists, do nothing
490
+            }
491
+          }
492
+
493
+
494
+          $new_course_id = $clean_input['courseid'];
495
+          $old_course_id = DB::table('ta_course')
496
+                      ->where('ta_id',$ta_id)
497
+                      ->select('course_id')
498
+                      ->lists('course_id');
499
+
500
+          //delete existing course_id if it isnt in new_ids array
501
+          foreach ($old_course_id as $old_id) {
502
+            if(in_array($old_id,$new_course_id)){
503
+              //do nothing if a new id is already in atble
504
+            }
505
+            else {
506
+              //if old id not in new id, delete
507
+              DB::table('ta_course')
508
+                ->where('ta_id',$ta_id)
509
+                ->where('course_id', $old_id)
510
+                ->delete();
511
+            }
512
+          }
513
+          //add course_id if it isnt already inserted
514
+          foreach ($new_course_id as $new_id) {
515
+            $result = DB::table('ta_course')
516
+                        ->where('ta_id',$ta_id)
517
+                        ->where('course_id',$new_id)
518
+                        ->select('course_id')
519
+                        ->lists('course_id');
520
+
521
+            if(count($result) == 0){
522
+              //if the new_id does not exists, do nothing
523
+              DB::table('ta_course')->insert(
524
+                array(
525
+                  'ta_id' => $ta_id,
526
+                  'course_id' => $new_id,
527
+                )
528
+              );
529
+            }
530
+            else {
531
+              //if the new_id already exists, do nothing
532
+            }
533
+          }
534
+
535
+          Session::flash('status', 'success');
536
+          Session::flash('message', 'Updated Transformative Action: "' . $clean_input['text'] . '".');
537
+          $role = Auth::user()['role'];
538
+          return Redirect::to('transformativeAction')->withInput();
539
+      }
540
+    }
541
+
542
+
543
+    public function deleteTA()
544
+    {
545
+      $ta_id = array(Input::get('ta_id'));
546
+
547
+      // si envia id 0, el backend se queja en la linea: $ta = $ta[0];
548
+      // nunca deberia ocurrir, pero es un safity measure.
549
+      if($ta_id == 0){
550
+        $message = 'Please select a Transformative Action</p>';
551
+
552
+        Session::flash('status', 'danger');
553
+        Session::flash('message', $message);
554
+
555
+        $role = Auth::user()['role'];
556
+        return Redirect::to('transformativeAction')->withInput();
557
+      }
558
+
559
+      $ta = DB::table('transformative_actions')
560
+          ->where('transformative_actions.is_custom', 1)
561
+          ->where('id',$ta_id)
562
+          ->get();
563
+      $ta = $ta[0];
564
+
565
+      $used = DB::table('annual_plan_transformative')
566
+              ->where('id',$ta_id)
567
+              ->get();
568
+
569
+      $recommended = $ta->by_professor;
570
+      // the TA can only be deleted if error if the TA is not currently as "Recommended"
571
+      // and isnt used in an anual plan
572
+      if ($recommended == 1 && count($used) == 0) {
573
+        // delete the TA if it qualifies
574
+        DB::delete("delete from transformative_actions where id = ?", $ta_id);
575
+
576
+        $name = $ta->at_text;
577
+
578
+        $message = 'The Transformative Action has been deleted:</p><ul>';
579
+        $message .= '<li> '.$name.' </li>';
580
+        $message .= '</ul>';
581
+
582
+        Session::flash('status', 'success');
583
+        Session::flash('message', $message);
584
+        $role = Auth::user()['role'];
585
+        return Redirect::to('transformativeAction')->withInput();
586
+      }
587
+
588
+
589
+      $message = 'Transformative Actions can only be deleted if:</p><ul>';
590
+      $message .= '<li> It has a status of "Recommended"</li>';
591
+      $message .= '<li> It is not currently used in a plan</li>';
592
+      $message .= '</ul>';
593
+
594
+      Session::flash('status', 'danger');
595
+      Session::flash('message', $message);
596
+
597
+      $role = Auth::user()['role'];
598
+      return Redirect::to('transformativeAction')->withInput();
599
+    }
600
+
601
+
602
+
603
+
604
+
605
+    public function selectTA()
606
+    {
607
+      $ta_id = Input::get("ta_id");
608
+      $user_id = Auth::user()->id;
609
+      $program_id = DB::table('program_user')
610
+          ->where('user_id',$user_id)
611
+          ->select('program_id')
612
+          ->get();
613
+      $program_id = $program_id[0]->program_id;
614
+
615
+      $objectives = DB::table('transformative_actions')
616
+                        ->join('transformative_objective_program','transformative_objective_program.ta_id','=','transformative_actions.id')
617
+                        ->join('objectives','objectives.id','=','transformative_objective_program.objective_id')
618
+                        ->where('transformative_actions.id',$ta_id)
619
+                        ->select('objectives.text as text', 'objectives.id as id')
620
+                        ->orderBy('objectives.text', 'ASC')
621
+                        ->get();
622
+
623
+      $an_objective = $objectives[0]->id;
624
+      $outcome_id = DB::table('criterion_objective_outcome')
625
+                    ->where('criterion_objective_outcome.objective_id',$an_objective)
626
+                    ->select('criterion_objective_outcome.outcome_id')
627
+                    ->get();
628
+      $outcome_id = $outcome_id[0]->outcome_id;
629
+
630
+
631
+      $objectives_from_outcome = DB::table('objectives')
632
+                    ->join('objective_program','objective_program.objective_id','=','objectives.id')
633
+                    ->join('criterion_objective_outcome','criterion_objective_outcome.objective_id','=','objectives.id')
634
+                    ->where('criterion_objective_outcome.outcome_id',$outcome_id)
635
+                    ->where('objective_program.program_id',$program_id)
636
+                    ->orderBy('objectives.text', 'ASC')
637
+                    ->select('objectives.text as text', 'objectives.id as id')
638
+                    ->get();
639
+      $selected_courses = DB::table('ta_course')
640
+                    ->join('courses','courses.id','=','ta_course.course_id')
641
+                    ->where('ta_id',$ta_id)
642
+                    ->orderBy('courses.name', 'ASC')
643
+                    ->orderBy('courses.code', 'ASC')
644
+                    ->select('courses.*')
645
+                    ->get();
646
+      $name = DB::table('transformative_actions')
647
+                  ->where('id',$ta_id)
648
+                  ->select('at_text as name')
649
+                  ->lists('name');
650
+      $description = DB::table('transformative_actions')
651
+                  ->where('id',$ta_id)
652
+                  ->select('description')
653
+                  ->lists('description');
654
+      $status = DB::table('transformative_actions')
655
+                  ->where('id',$ta_id)
656
+                  ->select('by_professor as status')
657
+                  ->lists('status');
658
+      $status = $status[0];
659
+      $plans_count = DB::table('annual_plan_transformative')
660
+                  ->where('id',$ta_id)
661
+                  ->get();
662
+      $plans_count = count($plans_count);
663
+      $can_be_deleted = false;
664
+      if($plans_count == 0 && $status == 1){
665
+        $can_be_deleted = true;
666
+      }
667
+      return array(
668
+        'objectives' => $objectives,
669
+        'objectives_from_outcome' => $objectives_from_outcome,
670
+        'selected_courses' => $selected_courses,
671
+        'name' => $name,
672
+        'description' => $description,
673
+        'status' => $status,
674
+        'can_be_deleted' => $can_be_deleted,
675
+        'plans_count' => $plans_count,
676
+      );
677
+    }
678
+
679
+    public function objectivesFromOutcome()
680
+    {
681
+      $user_id = Auth::user()->id;
682
+      $program_id = DB::table('program_user')
683
+          ->where('user_id',$user_id)
684
+          ->select('program_id')
685
+          ->get();
686
+      $program_id = $program_id[0]->program_id;
687
+      $ta_id = Input::get("ta_id");
688
+      $outcome_id = Input::get("outcome_id");
689
+
690
+      $objectives = DB::table('objectives')
691
+                    ->join('objective_program','objective_program.objective_id','=','objectives.id')
692
+                    ->join('criterion_objective_outcome','criterion_objective_outcome.objective_id','=','objectives.id')
693
+                    ->where('criterion_objective_outcome.outcome_id',$outcome_id)
694
+                    ->where('objective_program.program_id',$program_id)
695
+                    ->orderBy('objectives.text', 'ASC')
696
+                    ->select('objectives.text as text', 'objectives.id as id')
697
+                    ->get();
698
+
699
+      return array(
700
+        'objectives' => $objectives,
701
+      );
702
+    }
703
+
704
+    // return TA filtered by the user on the approve or edit panel
705
+    public function filterTA()
706
+    {
707
+      $user_id = Auth::user()->id;
708
+      $role = Auth::user()['role'];
709
+      $professor_id = Input::get('professor_id');
710
+      $course_id = Input::get('course_id');
711
+      $outcome_id = Input::get('outcome_id');
712
+      $panel_id = Input::get('panel_id');
713
+      $program_id = DB::table('program_user')
714
+          ->where('user_id',$user_id)
715
+          ->select('program_id')
716
+          ->get();
717
+      $program_id = $program_id[0]->program_id;
718
+
719
+      // if the user is a coordinator filtering the approvePanel
720
+      if ($role == '3' && $panel_id == 'approvePanel'){
721
+
722
+        // if professor isnt a desired filter, search all professors
723
+        if ($professor_id == 0){
724
+          $all_ta_users = DB::table('transformative_actions')
725
+                        ->where('transformative_actions.is_custom', 1)
726
+                        ->where('transformative_actions.program_id', $program_id)
727
+                        ->where('transformative_actions.by_professor',1)
728
+                        ->select('transformative_actions.user_id')
729
+                        ->get();
730
+          $professor_id = array();
731
+          foreach ($all_ta_users as $key => $user) {
732
+            array_push($professor_id, $user->user_id);
733
+          }
734
+        }else{
735
+          $professor_id = array($professor_id);
736
+        }
737
+        // if course isnt a desired filter, search all courses
738
+        if ($course_id == 0){
739
+          $courses =  DB::table('ta_course')
740
+                    ->join('transformative_actions','transformative_actions.id','=','ta_course.ta_id')
741
+                    ->join('courses','courses.id','=','ta_course.course_id')
742
+                    ->where('transformative_actions.is_custom', 1)
743
+                    ->where('transformative_actions.program_id', $program_id)
744
+                    ->where('transformative_actions.by_professor', 1)
745
+                    ->select('courses.id')
746
+                    ->get();
747
+
748
+          $course_id = array();
749
+          foreach ($courses as $key => $course) {
750
+            array_push($course_id, $course->id);
751
+          }
752
+        }else{
753
+          $course_id = array($course_id);
754
+        }
755
+        // if outcome isnt a desired filter, search all outcomes
756
+        if ($outcome_id == 0){
757
+          $outcomes = DB::table('transformative_actions')
758
+                      ->join('transformative_objective_program','transformative_objective_program.ta_id','=','transformative_actions.id')
759
+                      ->join('criterion_objective_outcome','criterion_objective_outcome.objective_id','=','transformative_objective_program.objective_id')
760
+                      ->join('outcomes','outcomes.id','=','criterion_objective_outcome.outcome_id')
761
+                      ->where('transformative_actions.is_custom', 1)
762
+                      ->where('transformative_actions.program_id', $program_id)
763
+                      ->where('transformative_actions.by_professor', 1)
764
+                      ->select('outcomes.id')
765
+                      ->groupBy('outcomes.id')
766
+                      ->get();
767
+          $outcome_id = array();
768
+          foreach ($outcomes as $key => $outcome) {
769
+            array_push($outcome_id, $outcome->id);
770
+          }
771
+        }else{
772
+          $outcome_id = array($outcome_id);
773
+        }
774
+
775
+        // search TA with filters
776
+        $filtered_at = DB::table('transformative_actions')
777
+                      ->join('ta_course','ta_course.ta_id','=','transformative_actions.id')
778
+                      ->join('transformative_objective_program','transformative_objective_program.ta_id','=','transformative_actions.id')
779
+                      ->join('criterion_objective_outcome','criterion_objective_outcome.objective_id','=','transformative_objective_program.objective_id')
780
+                      ->where('transformative_actions.is_custom', 1)
781
+                      ->where('transformative_actions.program_id',$program_id)
782
+                      ->where('transformative_actions.by_professor',1)
783
+                      ->whereIn('transformative_actions.user_id',$professor_id)
784
+                      ->whereIn('criterion_objective_outcome.outcome_id',$outcome_id)
785
+                      ->whereIn('ta_course.course_id',$course_id)
786
+                      ->select('transformative_actions.*')
787
+                      ->groupBy('transformative_actions.id')
788
+                      ->orderBy('transformative_actions.at_text', 'ASC')
789
+                      ->get();
790
+        return $filtered_at;
791
+      }
792
+      // if the user is a coordinator filtering the editPanel
793
+      elseif($role == '3' && $panel_id == 'editPanel'){
794
+
795
+        // if professor isnt a desired filter, search all professors
796
+        if ($professor_id == 0){
797
+          $all_ta_users = DB::table('transformative_actions')
798
+                        ->where('transformative_actions.is_custom', 1)
799
+                        ->where('transformative_actions.program_id', $program_id)
800
+                        ->where('transformative_actions.by_professor',0)
801
+                        ->select('transformative_actions.user_id')
802
+                        ->get();
803
+          $professor_id = array();
804
+          foreach ($all_ta_users as $key => $user) {
805
+            array_push($professor_id, $user->user_id);
806
+          }
807
+        }else{
808
+          $professor_id = array($professor_id);
809
+        }
810
+        // if course isnt a desired filter, search all courses
811
+        if ($course_id == 0){
812
+          $courses =  DB::table('ta_course')
813
+                    ->join('transformative_actions','transformative_actions.id','=','ta_course.ta_id')
814
+                    ->join('courses','courses.id','=','ta_course.course_id')
815
+                    ->where('transformative_actions.is_custom', 1)
816
+                    ->where('transformative_actions.program_id', $program_id)
817
+                    ->where('transformative_actions.by_professor', 0)
818
+                    ->select('courses.id')
819
+                    ->get();
820
+
821
+          $course_id = array();
822
+          foreach ($courses as $key => $course) {
823
+            array_push($course_id, $course->id);
824
+          }
825
+        }else{
826
+          $course_id = array($course_id);
827
+        }
828
+        // if outcome isnt a desired filter, search all outcomes
829
+        if ($outcome_id == 0){
830
+          $outcomes = DB::table('transformative_actions')
831
+                      ->join('transformative_objective_program','transformative_objective_program.ta_id','=','transformative_actions.id')
832
+                      ->join('criterion_objective_outcome','criterion_objective_outcome.objective_id','=','transformative_objective_program.objective_id')
833
+                      ->join('outcomes','outcomes.id','=','criterion_objective_outcome.outcome_id')
834
+                      ->where('transformative_actions.is_custom', 1)
835
+                      ->where('transformative_actions.program_id', $program_id)
836
+                      ->where('transformative_actions.by_professor', 0)
837
+                      ->select('outcomes.id')
838
+                      ->groupBy('outcomes.id')
839
+                      ->get();
840
+          $outcome_id = array();
841
+          foreach ($outcomes as $key => $outcome) {
842
+            array_push($outcome_id, $outcome->id);
843
+          }
844
+        }else{
845
+          $outcome_id = array($outcome_id);
846
+        }
847
+
848
+        // search TA with filters
849
+        $filtered_at = DB::table('transformative_actions')
850
+                      ->join('ta_course','ta_course.ta_id','=','transformative_actions.id')
851
+                      ->join('transformative_objective_program','transformative_objective_program.ta_id','=','transformative_actions.id')
852
+                      ->join('criterion_objective_outcome','criterion_objective_outcome.objective_id','=','transformative_objective_program.objective_id')
853
+                      ->where('transformative_actions.is_custom', 1)
854
+                      ->where('transformative_actions.program_id',$program_id)
855
+                      ->where('transformative_actions.by_professor',0)
856
+                      ->whereIn('transformative_actions.user_id',$professor_id)
857
+                      ->whereIn('criterion_objective_outcome.outcome_id',$outcome_id)
858
+                      ->whereIn('ta_course.course_id',$course_id)
859
+                      ->select('transformative_actions.*')
860
+                      ->groupBy('transformative_actions.id')
861
+                      ->orderBy('transformative_actions.at_text', 'ASC')
862
+                      ->get();
863
+        return $filtered_at;
864
+      }
865
+      // if the user is a professor filtering the editPanel
866
+      elseif($role == '4' && $panel_id == 'editPanel'){
867
+
868
+        // if course isnt a desired filter, search all courses
869
+        if ($course_id == 0){
870
+          $courses = DB::table('ta_course')
871
+                    ->join('transformative_actions','transformative_actions.id','=','ta_course.ta_id')
872
+                    ->join('courses','courses.id','=','ta_course.course_id')
873
+                    ->where('transformative_actions.user_id', Auth::user()->id)
874
+                    ->where('transformative_actions.is_custom', 1)
875
+                    ->where('transformative_actions.program_id', $program_id)
876
+                    ->where('transformative_actions.by_professor', 1)
877
+                    ->select('courses.id')
878
+                    ->get();
879
+
880
+          $course_id = array();
881
+          foreach ($courses as $key => $course) {
882
+            array_push($course_id, $course->id);
883
+          }
884
+        }else{
885
+          $course_id = array($course_id);
886
+        }
887
+        // if outcome isnt a desired filter, search all outcomes
888
+        if ($outcome_id == 0){
889
+          $outcomes = DB::table('transformative_actions')
890
+                      ->join('transformative_objective_program','transformative_objective_program.ta_id','=','transformative_actions.id')
891
+                      ->join('criterion_objective_outcome','criterion_objective_outcome.objective_id','=','transformative_objective_program.objective_id')
892
+                      ->join('outcomes','outcomes.id','=','criterion_objective_outcome.outcome_id')
893
+                      ->where('transformative_actions.user_id', Auth::user()->id)
894
+                      ->where('transformative_actions.is_custom', 1)
895
+                      ->where('transformative_actions.program_id', $program_id)
896
+                      ->where('transformative_actions.by_professor', 1)
897
+                      ->select('outcomes.id')
898
+                      ->groupBy('outcomes.id')
899
+                      ->get();
900
+          $outcome_id = array();
901
+          foreach ($outcomes as $key => $outcome) {
902
+            array_push($outcome_id, $outcome->id);
903
+          }
904
+        }else{
905
+          $outcome_id = array($outcome_id);
906
+        }
907
+
908
+        // search TA with filters
909
+        $filtered_at = DB::table('transformative_actions')
910
+                      ->join('ta_course','ta_course.ta_id','=','transformative_actions.id')
911
+                      ->join('transformative_objective_program','transformative_objective_program.ta_id','=','transformative_actions.id')
912
+                      ->join('criterion_objective_outcome','criterion_objective_outcome.objective_id','=','transformative_objective_program.objective_id')
913
+                      ->where('transformative_actions.user_id', Auth::user()->id)
914
+                      ->where('transformative_actions.is_custom', 1)
915
+                      ->where('transformative_actions.program_id',$program_id)
916
+                      ->where('transformative_actions.by_professor',1)
917
+                      ->whereIn('criterion_objective_outcome.outcome_id',$outcome_id)
918
+                      ->whereIn('ta_course.course_id',$course_id)
919
+                      ->select('transformative_actions.*')
920
+                      ->groupBy('transformative_actions.id')
921
+                      ->orderBy('transformative_actions.at_text', 'ASC')
922
+                      ->get();
923
+        return $filtered_at;
924
+      }
925
+      return 'ilegal';
926
+    }
927
+
928
+}

+ 360
- 358
app/controllers/UsersController.php Ver arquivo

@@ -1,6 +1,7 @@
1 1
 <?php
2 2
 
3
-class UsersController extends \BaseController {
3
+class UsersController extends \BaseController
4
+{
4 5
 
5 6
 	/**
6 7
 	 * Display a listing of the users.
@@ -9,16 +10,60 @@ class UsersController extends \BaseController {
9 10
 	 */
10 11
 	public function index()
11 12
 	{
12
-		$title="Users";
13
+		$title = "Users";
13 14
 
14
-		$users = User::
15
-			with('programs', 'school')
15
+		$users = User::with('programs', 'school')
16 16
 			->orderBy('surnames')
17 17
 			->orderBy('first_name')
18 18
 			->get();
19
+		Log::info('LmaOOOOO get cocked');
20
+
19 21
 
20 22
 		$schools = School::orderBy('name', 'asc')->get();
21 23
 		$access_level  = count(User::select('role')->where('has_access', 1)->groupBy('role')->get());
24
+		try {
25
+			Log::info("Schools");
26
+			foreach ($schools as $school) {
27
+				Log::info(print_r($school, true));
28
+			}
29
+			foreach ($users as $user) {
30
+				Log::info("ID");
31
+				Log::info($user->id);
32
+				Log::info("Name");
33
+				Log::info($user->surname . $user->first_name);
34
+				Log::info("if funciona??");
35
+				Log::info($user->school_id);
36
+				Log::info("elseif??");
37
+				Log::info(count($user->programs));
38
+				if ($user->school_id) {
39
+					Log::info("Schoool");
40
+					Log::info($user->school->name);
41
+					Log::info($user->school_id);
42
+				} elseif (count($user->programs) > 0) {
43
+					Log::info("Entre aqui");
44
+					Log::info($user->programs[0]->school_id);
45
+					Log::info($user->programs[0]->school->name);
46
+				} else Log::info("Not so cocked");
47
+
48
+				Log::info("bueno vamos a ver que hay???");
49
+				Log::info(count($user->programs));
50
+				if (count($user->programs)) {
51
+					foreach ($user->programs as $program) {
52
+						Log::info($program->id);
53
+						Log::info($program->name);
54
+					}
55
+				} else Log::info("Tal vez cocked");
56
+				Log::info("email");
57
+				Log::info($user->email);
58
+				Log::info("Role" . $user->role);
59
+				Log::info($user->office_phone);
60
+				Log::info($user->cell_phone);
61
+			}
62
+		} catch (Exception $e) {
63
+			Log::info("get Cocked" . $e);
64
+		}
65
+		Log::info("el error era en la base de datos XDDDDDDD");
66
+
22 67
 
23 68
 		return View::make('local.managers.admins.users', compact('title', 'users', 'schools', 'access_level'));
24 69
 	}
@@ -32,6 +77,7 @@ class UsersController extends \BaseController {
32 77
 	public function edit()
33 78
 	{
34 79
 		$user = Auth::user();
80
+		Log::info($user);
35 81
 		$title = "Profile";
36 82
 		$schools = School::orderBy('name', 'asc')->get();
37 83
 		$programs = $user->programs;
@@ -45,140 +91,129 @@ class UsersController extends \BaseController {
45 91
 	 * @return Response
46 92
 	 */
47 93
 	public function store()
48
-    {
49
-    	$user = Auth::user();
50
-	    if(Input::get('submit_new_user') && Auth::user()->role==1)
51
-	    {
52
-
53
-	    	$first_name = strtoupper(Input::get('new_first_name'));
54
-	    	$surnames = strtoupper(Input::get('new_surnames'));
55
-	    	$email = strtolower(Input::get('new_email'));
56
-	    	$school_id = Input::get('new_school');
57
-
58
-	    	// Validation rules
59
-	        $validator = Validator::make(
60
-	            array(
61
-	                'first_name' => $first_name,
62
-	                'surnames' => $surnames,
63
-	                'email' => $email,
64
-	                'school_id' => $school_id,
65
-	            ),
66
-	            array(
67
-	                'first_name' => 'required',
68
-	                'surnames' => 'required',
69
-	                'email' => 'required|email',
70
-	                'school_id' => 'integer',
71
-	            )
72
-	        );
73
-
74
-	        /** If validation fails */
75
-	        if ($validator->fails())
76
-	        {
77
-	            /** Prepare error message */
78
-	            $message = 'Error(s) creating a user:<ul>';
79
-
80
-	            foreach ($validator->messages()->all('<li>:message</li>') as $validationError)
81
-	            {
82
-	                $message.=$validationError;
83
-	            }
84
-
85
-	            $message.='</ul>';
86
-
87
-	            /** Send error message and old data */
88
-	            Session::flash('status', 'danger');
89
-	            Session::flash('message', $message);
90
-	            return Redirect::back()->withInput();
91
-	        }
92
-
93
-
94
-	        DB::beginTransaction();
95
-	        try
96
-	        {
97
-                switch (Input::get('new_role'))
98
-                {
99
-                	case '1':
100
-
101
-                		User::create(array(
102
-                			'first_name' => $first_name,
103
-                			'surnames' => $surnames,
104
-                			'email'=> $email,
105
-                			'role'=> 1,
106
-                			'school_id'=> NULL,
107
-                			'has_access' => 1
108
-                		));
109
-                		break;
110
-
111
-                	case '2':
112
-                		User::create(array(
113
-                			'first_name' => $first_name,
114
-                			'surnames' => $surnames,
115
-                			'email'=> $email,
116
-                			'role'=> 2,
117
-                			'school_id'=> (int)Input::get('new_school'), // como que aqui
118
-                			'has_access' => 1
119
-                		));
120
-
121
-                		break;
122
-
123
-                	case '3':
124
-                		$user = User::create(array(
125
-                			'first_name' => $first_name,
126
-                			'surnames' => $surnames,
127
-                			'email'=> $email,
128
-                			'role'=> 3,
129
-                			'school_id'=> NULL,
130
-                			'has_access' => 1
131
-                		));
132
-
133
-                		// Attach new programs
134
-                		foreach (Input::get('programs') as $key => $program_id)
135
-                		{
136
-                			$user->programs()->attach($program_id);
137
-                		}
138
-
139
-                		$user->save();
140
-                		break;
141
-
142
-                	case '4':
143
-
144
-                		$user = User::create(array(
145
-                			'first_name' => $first_name,
146
-                			'surnames' => $surnames,
147
-                			'email'=> $email,
148
-                			'role'=> 4,
149
-                			'school_id'=> NULL,
150
-                			'has_access' => 1
151
-                		));
152
-
153
-                		// Attach new programs
154
-                		foreach (Input::get('new_programs') as $key => $program_id)
155
-                		{
156
-                			$user->programs()->attach($program_id);
157
-                		}
158
-                		$user->save();
159
-                		break;
160
-                }
161
-
162
-	            DB::commit();
163
-
164
-                Session::flash('status', 'success');
165
-                Session::flash('message', 'User created ('.date('m/d/y h:i:s A').')');
166
-                return Redirect::back();
167
-
168
-	        }
169
-	        catch(Exception $e)
170
-	        {
171
-	        	DB::rollBack();
172
-
173
-	            Session::flash('status', 'danger');
174
-	            Session::flash('message', 'Error creating. Try again later or contact the system administrator.');
175
-
176
-	            return Redirect::back();
177
-	        }
178
-	    }
179
-	    else
180
-	    	App::abort('404');
181
-    }
94
+	{
95
+		$user = Auth::user();
96
+		if (Input::get('submit_new_user') && Auth::user()->role == 1) {
97
+
98
+			$first_name = strtoupper(Input::get('new_first_name'));
99
+			$surnames = strtoupper(Input::get('new_surnames'));
100
+			$email = strtolower(Input::get('new_email'));
101
+			$school_id = Input::get('new_school');
102
+
103
+			// Validation rules
104
+			$validator = Validator::make(
105
+				array(
106
+					'first_name' => $first_name,
107
+					'surnames' => $surnames,
108
+					'email' => $email,
109
+					'school_id' => $school_id,
110
+				),
111
+				array(
112
+					'first_name' => 'required',
113
+					'surnames' => 'required',
114
+					'email' => 'required|email',
115
+					'school_id' => 'integer',
116
+				)
117
+			);
118
+
119
+			/** If validation fails */
120
+			if ($validator->fails()) {
121
+				/** Prepare error message */
122
+				$message = 'Error(s) creating a user:<ul>';
123
+
124
+				foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
125
+					$message .= $validationError;
126
+				}
127
+
128
+				$message .= '</ul>';
129
+
130
+				/** Send error message and old data */
131
+				Session::flash('status', 'danger');
132
+				Session::flash('message', $message);
133
+				return Redirect::back()->withInput();
134
+			}
135
+
136
+
137
+			DB::beginTransaction();
138
+			try {
139
+				switch (Input::get('new_role')) {
140
+					case '1':
141
+
142
+						User::create(array(
143
+							'first_name' => $first_name,
144
+							'surnames' => $surnames,
145
+							'email' => $email,
146
+							'role' => 1,
147
+							'school_id' => NULL,
148
+							'has_access' => 1
149
+						));
150
+						break;
151
+
152
+					case '2':
153
+						User::create(array(
154
+							'first_name' => $first_name,
155
+							'surnames' => $surnames,
156
+							'email' => $email,
157
+							'role' => 2,
158
+							'school_id' => (int)Input::get('new_school'), // como que aqui
159
+							'has_access' => 1
160
+						));
161
+
162
+						break;
163
+
164
+					case '3':
165
+						$user = User::create(array(
166
+							'first_name' => $first_name,
167
+							'surnames' => $surnames,
168
+							'email' => $email,
169
+							'role' => 3,
170
+							'school_id' => NULL,
171
+							'has_access' => 1
172
+						));
173
+
174
+						// Attach new programs
175
+						foreach (Input::get('programs') as $key => $program_id) {
176
+							$user->programs()->attach($program_id);
177
+						}
178
+
179
+						$user->save();
180
+						break;
181
+
182
+					case '4':
183
+
184
+						$user = User::create(array(
185
+							'first_name' => $first_name,
186
+							'surnames' => $surnames,
187
+							'email' => $email,
188
+							'role' => 4,
189
+							'school_id' => NULL,
190
+							'has_access' => 1
191
+						));
192
+
193
+						// Attach new programs
194
+						foreach (Input::get('new_programs') as $key => $program_id) {
195
+							$user->programs()->attach($program_id);
196
+						}
197
+						$user->save();
198
+						break;
199
+				}
200
+
201
+				DB::commit();
202
+
203
+				Session::flash('status', 'success');
204
+				Session::flash('message', 'User created (' . date('m/d/y h:i:s A') . ')');
205
+				return Redirect::back();
206
+			} catch (Exception $e) {
207
+				DB::rollBack();
208
+
209
+				Session::flash('status', 'danger');
210
+				Session::flash('message', 'Error creating. Try again later or contact the system administrator.');
211
+
212
+				return Redirect::back();
213
+			}
214
+		} else
215
+			App::abort('404');
216
+	}
182 217
 
183 218
 	/**
184 219
 	 * Update the user in storage.
@@ -187,230 +222,197 @@ class UsersController extends \BaseController {
187 222
 	 * @return Response
188 223
 	 */
189 224
 	public function update()
190
-    {
191
-    	$user = Auth::user();
192
-        if(Input::get('submit_contact_info'))
193
-    	{
194
-	        // Validation rules
195
-	        $validator = Validator::make(
196
-	            array(
197
-                    'office_phone' => Input::get('office_phone'),
198
-                    'office_extension' => Input::get('office_extension'),
199
-	                'cell_phone' => Input::get('cell_phone'),
200
-	            ),
201
-	            array(
202
-                    'office_phone' => 'string|max:20|required_with:office_extension',
203
-	                'office_extension' => 'digits_between:1,5|required_with:office_phone|unique:users,office_extension,'.$user->id,
204
-                    'cell_phone' => 'string|max:20'
205
-	            )
206
-	        );
207
-
208
-	        /** If validation fails */
209
-	        if ($validator->fails())
210
-	        {
211
-	            /** Prepare error message */
212
-	            $message = 'Error(s) updating your Contact nformation<ul>';
213
-
214
-	            foreach ($validator->messages()->all('<li>:message</li>') as $validationError)
215
-	            {
216
-	                $message.=$validationError;
217
-	            }
218
-
219
-	            $message.='</ul>';
220
-
221
-	            /** Send error message and old data */
222
-	            Session::flash('status', 'danger');
223
-	            Session::flash('message', $message);
224
-	            return Redirect::back()->withInput();
225
-	        }
226
-	        else
227
-	        {
228
-	            /** Set new contact info */
229
-	            if(Input::get('office_phone'))
230
-                {
231
-                    $user->office_phone = Input::get('office_phone');
232
-                    $user->office_extension = Input::get('office_extension');
233
-                }
234
-				else
235
-				{
225
+	{
226
+		$user = Auth::user();
227
+		if (Input::get('submit_contact_info')) {
228
+			// Validation rules
229
+			$validator = Validator::make(
230
+				array(
231
+					'office_phone' => Input::get('office_phone'),
232
+					'office_extension' => Input::get('office_extension'),
233
+					'cell_phone' => Input::get('cell_phone'),
234
+				),
235
+				array(
236
+					'office_phone' => 'string|max:20|required_with:office_extension',
237
+					'office_extension' => 'digits_between:1,5|required_with:office_phone|unique:users,office_extension,' . $user->id,
238
+					'cell_phone' => 'string|max:20'
239
+				)
240
+			);
241
+
242
+			/** If validation fails */
243
+			if ($validator->fails()) {
244
+				/** Prepare error message */
245
+				$message = 'Error(s) updating your Contact nformation<ul>';
246
+
247
+				foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
248
+					$message .= $validationError;
249
+				}
250
+
251
+				$message .= '</ul>';
252
+
253
+				/** Send error message and old data */
254
+				Session::flash('status', 'danger');
255
+				Session::flash('message', $message);
256
+				return Redirect::back()->withInput();
257
+			} else {
258
+				/** Set new contact info */
259
+				if (Input::get('office_phone')) {
260
+					$user->office_phone = Input::get('office_phone');
261
+					$user->office_extension = Input::get('office_extension');
262
+				} else {
236 263
 					$user->office_phone = NULL;
237
-                    $user->office_extension = NULL;
264
+					$user->office_extension = NULL;
238 265
 				}
239 266
 
240
-                if(Input::get('cell_phone'))
241
-                {
242
-                    $user->cell_phone = Input::get('cell_phone');
243
-                }
244
-				else
245
-				{
246
-                    $user->cell_phone = NULL;
267
+				if (Input::get('cell_phone')) {
268
+					$user->cell_phone = Input::get('cell_phone');
269
+				} else {
270
+					$user->cell_phone = NULL;
247 271
 				}
248 272
 
249
-	            /** If alt email is updated, send success message */
250
-	            if($user->save())
251
-	            {
252
-	                Session::flash('status', 'success');
253
-	                Session::flash('message', 'Contact Information updated.');
254
-	                return Redirect::back();
255
-	            }
256
-
257
-	            /** If saving fails, send error message and old data */
258
-	            else
259
-	            {
260
-	                Session::flash('status', 'warning');
261
-	                Session::flash('message', 'Error updating your Contact Information. Please try again later.');
262
-	                return Redirect::back()->withInput();
263
-	            }
264
-	        }
265
-	    }
266
-
267
-	    else if(Input::get('submit_roles') && Auth::user()->role==1)
268
-	    {
269
-	        try
270
-	        {
271
-	            $exception = DB::transaction(function()
272
-	            {
273
-                    $user = User::find(Input::get('id'));
274
-
275
-                    switch (Input::get('role')) {
276
-                    	case '1':
277
-                    		$user->role = 1;
278
-                    		$user->school_id = NULL;
279
-
280
-                    		// Delete all programs associated to the user
281
-                    		$user->programs()->detach();
282
-
283
-                    		$user->has_access = 1;
284
-
285
-                    		break;
286
-
287
-                    	case '2':
288
-                    		$user->role = 2;
289
-                    		$user->school_id = Input::get('school');
290
-
291
-                    		// Delete all programs associated to the user
292
-                    		$user->programs()->detach();
293
-
294
-
295
-                    		break;
296
-
297
-                    	case '3':
298
-                    		$user->role = 3;
299
-                    		$user->school_id = NULL;
300
-
301
-                    		// Delete all programs associated to the user
302
-                    		$user->programs()->detach();
303
-
304
-                    		// Attach new programs
305
-                    		foreach (Input::get('programs') as $key => $program_id)
306
-                    		{
307
-                    			$user->programs()->attach($program_id);
308
-                    		}
309
-                    		// $user->program_id = Input::get('program');
310
-
311
-                    		break;
312
-
313
-                    	case '4':
314
-                    		$user->role = 4;
315
-                    		$user->school_id = NULL;
316
-
317
-                    		// Delete all programs associated to the user
318
-                    		$user->programs()->detach();
319
-
320
-                    		// Attach new programs
321
-                    		foreach (Input::get('programs') as $key => $program_id)
322
-                    		{
323
-                    			$user->programs()->attach($program_id);
324
-                    		}
325
-                    		// $user->program_id = Input::get('program');
326
-
327
-                    		break;
328
-                    }
329
-
330
-                    $user->has_access = Input::get('has_access');
331
-                    $user->save();
332
-
333
-	            });
334
-
335
-	            if(is_null($exception))
336
-	            {
337
-	                Session::flash('status', 'success');
338
-	                Session::flash('message', 'User <b>'.User::find(Input::get('id'))->email.'</b> updated ('.date('m/d/y h:i:s A').'). To ensure proper access, click \'Update\' in the \'Access Level\' section at the bottom of the page.');
339
-	                return Redirect::back();
340
-	            }
341
-
342
-	        }
343
-	        catch(Exception $e)
344
-	        {
345
-	            Session::flash('status', 'danger');
346
-	            Session::flash('message', 'Error updating users. Try again later.');
347
-
348
-	            return Redirect::back();
349
-	        }
350
-	    }
351
-	    else
352
-	    	App::abort('403');
353
-    }
354
-
355
-    public function updateAccess()
356
-    {
357
-    	try
358
-        {
359
-            $exception = DB::transaction(function()
360
-            {
361
-                switch (Input::get('access_level')) {
362
-		    		case '1':
363
-		    			DB::table('users')
364
-			            ->whereIn('role', array(1))
365
-			            ->update(array('has_access' => 1));
366
-
367
-			            DB::table('users')
368
-			            ->whereIn('role', array(2, 3, 4))
369
-			            ->update(array('has_access' => 0));
370
-		    			break;
371
-
372
-		    		case '2':
373
-		    			DB::table('users')
374
-			            ->whereIn('role', array(1, 2))
375
-			            ->update(array('has_access' => 1));
376
-
377
-			            DB::table('users')
378
-			            ->whereIn('role', array(3, 4))
379
-			            ->update(array('has_access' => 0));
380
-		    			break;
381
-
382
-		    		case '3':
383
-		    			DB::table('users')
384
-			            ->whereIn('role', array(1, 2, 3))
385
-			            ->update(array('has_access' => 1));
386
-
387
-			            DB::table('users')
388
-			            ->whereIn('role', array(4))
389
-			            ->update(array('has_access' => 0));
390
-		    			break;
391
-
392
-		    		case '4':
393
-		    			DB::table('users')
394
-			            ->whereIn('role', array(1, 2, 3, 4))
395
-			            ->update(array('has_access' => 1));
396
-		    			break;
397
-		    	}
398
-            });
399
-
400
-            if(is_null($exception))
401
-            {
402
-                Session::flash('status', 'success');
403
-                Session::flash('message', 'Access level updated ('.date('m/d/y, h:i:s a').').');
404
-            }
405
-
406
-        }
407
-        catch(Exception $e)
408
-        {
409
-            Session::flash('status', 'danger');
410
-            Session::flash('message', 'Error updating access level. Try again later ('.date('m/d/y, h:i:s a').').');
411
-        }
412
-
413
-        return Redirect::back();
414
-    }
273
+				/** If alt email is updated, send success message */
274
+				if ($user->save()) {
275
+					Session::flash('status', 'success');
276
+					Session::flash('message', 'Contact Information updated.');
277
+					return Redirect::back();
278
+				}
279
+
280
+				/** If saving fails, send error message and old data */
281
+				else {
282
+					Session::flash('status', 'warning');
283
+					Session::flash('message', 'Error updating your Contact Information. Please try again later.');
284
+					return Redirect::back()->withInput();
285
+				}
286
+			}
287
+		} else if (Input::get('submit_roles') && Auth::user()->role == 1) {
288
+			try {
289
+				$exception = DB::transaction(function () {
290
+					$user = User::find(Input::get('id'));
291
+
292
+					switch (Input::get('role')) {
293
+						case '1':
294
+							$user->role = 1;
295
+							$user->school_id = NULL;
296
+
297
+							// Delete all programs associated to the user
298
+							$user->programs()->detach();
415 299
 
300
+							$user->has_access = 1;
301
+
302
+							break;
303
+
304
+						case '2':
305
+							$user->role = 2;
306
+							$user->school_id = Input::get('school');
307
+
308
+							// Delete all programs associated to the user
309
+							$user->programs()->detach();
310
+
311
+
312
+							break;
313
+
314
+						case '3':
315
+							$user->role = 3;
316
+							$user->school_id = NULL;
317
+
318
+							// Delete all programs associated to the user
319
+							$user->programs()->detach();
320
+
321
+							// Attach new programs
322
+							foreach (Input::get('programs') as $key => $program_id) {
323
+								$user->programs()->attach($program_id);
324
+							}
325
+							// $user->program_id = Input::get('program');
326
+
327
+							break;
328
+
329
+						case '4':
330
+							$user->role = 4;
331
+							$user->school_id = NULL;
332
+
333
+							// Delete all programs associated to the user
334
+							$user->programs()->detach();
335
+
336
+							// Attach new programs
337
+							foreach (Input::get('programs') as $key => $program_id) {
338
+								$user->programs()->attach($program_id);
339
+							}
340
+							// $user->program_id = Input::get('program');
341
+
342
+							break;
343
+					}
344
+
345
+					$user->has_access = Input::get('has_access');
346
+					$user->save();
347
+				});
348
+
349
+				if (is_null($exception)) {
350
+					Session::flash('status', 'success');
351
+					Session::flash('message', 'User <b>' . User::find(Input::get('id'))->email . '</b> updated (' . date('m/d/y h:i:s A') . '). To ensure proper access, click \'Update\' in the \'Access Level\' section at the bottom of the page.');
352
+					return Redirect::back();
353
+				}
354
+			} catch (Exception $e) {
355
+				Session::flash('status', 'danger');
356
+				Session::flash('message', 'Error updating users. Try again later.');
357
+
358
+				return Redirect::back();
359
+			}
360
+		} else
361
+			App::abort('403');
362
+	}
363
+
364
+	public function updateAccess()
365
+	{
366
+		try {
367
+			$exception = DB::transaction(function () {
368
+				switch (Input::get('access_level')) {
369
+					case '1':
370
+						DB::table('users')
371
+							->whereIn('role', array(1))
372
+							->update(array('has_access' => 1));
373
+
374
+						DB::table('users')
375
+							->whereIn('role', array(2, 3, 4))
376
+							->update(array('has_access' => 0));
377
+						break;
378
+
379
+					case '2':
380
+						DB::table('users')
381
+							->whereIn('role', array(1, 2))
382
+							->update(array('has_access' => 1));
383
+
384
+						DB::table('users')
385
+							->whereIn('role', array(3, 4))
386
+							->update(array('has_access' => 0));
387
+						break;
388
+
389
+					case '3':
390
+						DB::table('users')
391
+							->whereIn('role', array(1, 2, 3))
392
+							->update(array('has_access' => 1));
393
+
394
+						DB::table('users')
395
+							->whereIn('role', array(4))
396
+							->update(array('has_access' => 0));
397
+						break;
398
+
399
+					case '4':
400
+						DB::table('users')
401
+							->whereIn('role', array(1, 2, 3, 4))
402
+							->update(array('has_access' => 1));
403
+						break;
404
+				}
405
+			});
406
+
407
+			if (is_null($exception)) {
408
+				Session::flash('status', 'success');
409
+				Session::flash('message', 'Access level updated (' . date('m/d/y, h:i:s a') . ').');
410
+			}
411
+		} catch (Exception $e) {
412
+			Session::flash('status', 'danger');
413
+			Session::flash('message', 'Error updating access level. Try again later (' . date('m/d/y, h:i:s a') . ').');
414
+		}
415
+
416
+		return Redirect::back();
417
+	}
416 418
 }

+ 12
- 13
app/database/migrations/2018_08_28_140328_remove_outcome_id_from_objectives_table.php Ver arquivo

@@ -3,7 +3,8 @@
3 3
 use Illuminate\Database\Migrations\Migration;
4 4
 use Illuminate\Database\Schema\Blueprint;
5 5
 
6
-class RemoveOutcomeIdFromObjectivesTable extends Migration {
6
+class RemoveOutcomeIdFromObjectivesTable extends Migration
7
+{
7 8
 
8 9
 	/**
9 10
 	 * Run the migrations.
@@ -12,11 +13,11 @@ class RemoveOutcomeIdFromObjectivesTable extends Migration {
12 13
 	 */
13 14
 	public function up()
14 15
 	{
15
-		Schema::table('objectives', function(Blueprint $table)
16
-		{
17
-            $table->dropForeign('objectives_outcome_id_foreign');
18
-			$table->dropColumn('outcome_id');
19
-		});
16
+		//Schema::table('objectives', function(Blueprint $table)
17
+		//{
18
+		//    $table->dropForeign('objectives_outcome_id_foreign');
19
+		//	$table->dropColumn('outcome_id');
20
+		//});
20 21
 	}
21 22
 
22 23
 
@@ -27,12 +28,11 @@ class RemoveOutcomeIdFromObjectivesTable extends Migration {
27 28
 	 */
28 29
 	public function down()
29 30
 	{
30
-		Schema::table('objectives', function(Blueprint $table)
31
-		{
32
-            $table
33
-                ->integer('outcome_id')
34
-                ->after('id')
35
-                ->unsigned();
31
+		Schema::table('objectives', function (Blueprint $table) {
32
+			$table
33
+				->integer('outcome_id')
34
+				->after('id')
35
+				->unsigned();
36 36
 			$table
37 37
 				->foreign('outcome_id')
38 38
 				->references('id')
@@ -41,5 +41,4 @@ class RemoveOutcomeIdFromObjectivesTable extends Migration {
41 41
 				->onUpdate('cascade');
42 42
 		});
43 43
 	}
44
-
45 44
 }

+ 9
- 10
app/database/migrations/2020_04_04_005817_add_outcome_id_to_objectives_table.php Ver arquivo

@@ -3,7 +3,8 @@
3 3
 use Illuminate\Database\Migrations\Migration;
4 4
 use Illuminate\Database\Schema\Blueprint;
5 5
 
6
-class AddOutcomeIdToObjectivesTable extends Migration {
6
+class AddOutcomeIdToObjectivesTable extends Migration
7
+{
7 8
 
8 9
 	/**
9 10
 	 * Run the migrations.
@@ -12,12 +13,12 @@ class AddOutcomeIdToObjectivesTable extends Migration {
12 13
 	 */
13 14
 	public function up()
14 15
 	{
15
-		Schema::table('objectives', function(Blueprint $table)
16
-		{
17
-			$table->integer('outcome_id')->unsigned();
16
+		//Schema::table('objectives', function(Blueprint $table)
17
+		//{
18
+		//	$table->integer('outcome_id')->unsigned();
18 19
 
19
-			$table->foreign('outcome_id')->references('id')->on('outcomes')->onDelete('cascade')->onUpdate('cascade');
20
-		});
20
+		//	$table->foreign('outcome_id')->references('id')->on('outcomes')->onDelete('cascade')->onUpdate('cascade');
21
+		//});
21 22
 	}
22 23
 
23 24
 
@@ -28,12 +29,10 @@ class AddOutcomeIdToObjectivesTable extends Migration {
28 29
 	 */
29 30
 	public function down()
30 31
 	{
31
-		Schema::table('objectives', function(Blueprint $table)
32
-		{
33
-		    $table->dropForeign('objectives_outcome_id_foreign');
32
+		Schema::table('objectives', function (Blueprint $table) {
33
+			$table->dropForeign('objectives_outcome_id_foreign');
34 34
 
35 35
 			$table->dropColumn('outcome_id');
36 36
 		});
37 37
 	}
38
-
39 38
 }

+ 0
- 43
app/database/migrations/2020_04_22_122910_add_criteria_id_to_assessments_table.php Ver arquivo

@@ -1,43 +0,0 @@
1
-<?php
2
-
3
-use Illuminate\Database\Migrations\Migration;
4
-use Illuminate\Database\Schema\Blueprint;
5
-
6
-class AddCriteriaIdToAssessmentsTable extends Migration {
7
-
8
-	/**
9
-	 * Run the migrations.
10
-	 *
11
-	 * @return void
12
-	 */
13
-	public function up()
14
-	{
15
-		Schema::table('assessments', function(Blueprint $table)
16
-		{
17
-			$table->integer('criterion_id')->unsigned();
18
-
19
-			$table
20
-                ->foreign('criterion_id')
21
-                ->references('id')
22
-                ->on('criteria')
23
-                ->onDelete('cascade')
24
-                ->onUpdate('cascade');
25
-		});
26
-	}
27
-
28
-
29
-	/**
30
-	 * Reverse the migrations.
31
-	 *
32
-	 * @return void
33
-	 */
34
-	public function down()
35
-	{
36
-		Schema::table('assessments', function(Blueprint $table)
37
-		{
38
-		    $table->dropForeign('assessments_criterion_id_foreign');
39
-		    $table->dropColumn('criterion_id');
40
-		});
41
-	}
42
-
43
-}

+ 47
- 0
app/database/migrations/2020_10_04_142756_create_new_assessments_table.php Ver arquivo

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

+ 52
- 0
app/database/migrations/2020_10_05_124915_create_activity_criterion_table.php Ver arquivo

@@ -0,0 +1,52 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class CreateActivityCriterionTable extends Migration {
7
+
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function up()
14
+	{
15
+		Schema::create('activity_criterion', function(Blueprint $table)
16
+		{
17
+			$table->increments('id');
18
+			$table->integer('activity_id')->unsigned();
19
+			$table->integer('criterion_id')->unsigned();
20
+			$table
21
+				->foreign('activity_id')
22
+				->references('id')
23
+				->on('activities')
24
+				->onDelete('cascade')
25
+				->onUpdate('cascade');
26
+			$table
27
+				->foreign('criterion_id')
28
+				->references('id')
29
+				->on('criteria')
30
+				->onDelete('cascade')
31
+				->onUpdate('cascade');
32
+			$table->text('transformative_actions')->nullable();
33
+			$table->integer('expected_student_score')->nullable();
34
+			$table->decimal('expected_percentage_students_achieving', 5, 2)->nullable();
35
+			$table->decimal('percentage_students_who_achieved', 5, 2)->nullable();
36
+			$table->decimal('weight', 3, 2)->default(1.0);
37
+			$table->timestamps();
38
+		});
39
+	
40
+	}
41
+
42
+	/**
43
+	 * Reverse the migrations.
44
+	 *
45
+	 * @return void
46
+	 */
47
+	public function down()
48
+	{
49
+		Schema::drop('activity_criterion');
50
+	}
51
+
52
+}

+ 35
- 0
app/database/migrations/2020_10_05_130252_add_max_score_num_scales_new_criteria_table.php Ver arquivo

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

+ 35
- 0
app/database/migrations/2020_10_05_142424_create_scales_table.php Ver arquivo

@@ -0,0 +1,35 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class CreateScalesTable extends Migration {
7
+
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function up()
14
+	{
15
+		Schema::create('scales', function(Blueprint $table)
16
+		{
17
+			$table->increments('id');
18
+			$table->integer('position');
19
+			$table->string('title');
20
+			$table->string('description');
21
+			$table->timestamps();
22
+		});
23
+	}
24
+
25
+	/**
26
+	 * Reverse the migrations.
27
+	 *
28
+	 * @return void
29
+	 */
30
+	public function down()
31
+	{
32
+		Schema::drop('scales');
33
+	}
34
+
35
+}

+ 47
- 0
app/database/migrations/2020_10_05_142912_create_criterion_scale_table.php Ver arquivo

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

+ 34
- 0
app/database/migrations/2020_10_05_232429_add_assessment_comments_to_activity_criterion.php Ver arquivo

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

+ 36
- 0
app/database/migrations/2020_10_09_131800_add_level_activation_date_to_outcomes.php Ver arquivo

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

+ 53
- 0
app/database/migrations/2020_10_16_190923_create_criterion_objective_outcome_table.php Ver arquivo

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

+ 57
- 0
app/database/migrations/2020_10_18_145108_create_outcome_performance_table.php Ver arquivo

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

+ 30
- 0
app/database/migrations/2020_10_29_122332_MakeOutcomeNullable.php Ver arquivo

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

+ 30
- 0
app/database/migrations/2020_10_29_195413_MakeObjectiveNullable.php Ver arquivo

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

+ 30
- 0
app/database/migrations/2020_10_29_224846_Make_criterion_objective_outcome_changeForeignKey.php Ver arquivo

@@ -0,0 +1,30 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class MakeCriterionObjectiveOutcomeChangeForeignKey extends Migration
7
+{
8
+
9
+	/**
10
+	 * Run the migrations.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function up()
15
+	{
16
+		Schema::table('criterion_objective_outcome', function (Blueprint $table) {
17
+			$table->dropForeign('criterion_objective_outcome_criterion_id_foreign');
18
+			$table->foreign('criterion_id')->references('id')->on('new_criteria')->onDelete('cascade')->onUpdate('cascade');
19
+		});
20
+	}
21
+
22
+	/**
23
+	 * Reverse the migrations.
24
+	 *
25
+	 * @return void
26
+	 */
27
+	public function down()
28
+	{
29
+	}
30
+}

+ 35
- 0
app/database/migrations/2020_11_06_011242_changeCriteriaObjOutcome.php Ver arquivo

@@ -0,0 +1,35 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+use Illuminate\Support\Facades\Schema;
6
+
7
+class ChangeCriteriaObjOutcome extends Migration
8
+{
9
+
10
+	/**
11
+	 * Run the migrations.
12
+	 *
13
+	 * @return void
14
+	 */
15
+	public function up()
16
+	{
17
+		Schema::table('criterion_objective_outcome', function (Blueprint $table) {
18
+			//$table->dropForeign('criterion_objective_outcome_objective_id_foreign');
19
+			//$table->dropForeign('criterion_objective_outcome_outcome_id_foreign');
20
+			//$table->integer('objective_outcome_id');
21
+			DB::statement("ALTER TABLE `criterion_objective_outcome` CHANGE COLUMN `objective_outcome_id` `objective_outcome_id` INT(10) UNSIGNED NOT NULL");
22
+			$table->foreign('objective_outcome_id')->references('id')->on('objective_outcome')->onDelete('cascade')->onUpdate('cascade');
23
+		});
24
+	}
25
+
26
+	/**
27
+	 * Reverse the migrations.
28
+	 *
29
+	 * @return void
30
+	 */
31
+	public function down()
32
+	{
33
+		//
34
+	}
35
+}

+ 35
- 0
app/database/migrations/2020_12_04_111708_dropDescriptionInCriteria.php Ver arquivo

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

+ 44
- 0
app/database/migrations/2020_12_10_175517_createProgramCriterion2.php Ver arquivo

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

+ 34
- 0
app/database/migrations/2020_12_10_223135_addMinMaxInScales.php Ver arquivo

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

+ 47
- 0
app/database/migrations/2021_01_28_160558_ObjectiveProgramMigrate.php Ver arquivo

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

+ 33
- 0
app/database/migrations/2021_01_28_174905_fixObjectivesTable.php Ver arquivo

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

+ 33
- 0
app/database/migrations/2021_01_31_165057_fix_objectives_table_2.php Ver arquivo

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

+ 31
- 0
app/database/migrations/2021_01_31_171210_fix_criterion_scale.php Ver arquivo

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

+ 39
- 0
app/database/migrations/2021_02_16_142747_create_cycles_table.php Ver arquivo

@@ -0,0 +1,39 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class CreateCyclesTable extends Migration {
7
+
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	 public function up()
14
+ 	{
15
+ 		Schema::create('cycles', function(Blueprint $table)
16
+ 		{
17
+			// 		id unico
18
+ 			$table->increments('id');
19
+			// 		cuando a~nos tiene el ciclo('3')
20
+			$table->integer('years_in_cycle');
21
+			// 		cuando comienza el ciclo ('2019')
22
+			$table->integer('start');
23
+			// 		cuando termina  el ciclo ('2022')
24
+			$table->integer('end');
25
+ 			$table->timestamps();
26
+ 		});
27
+ 	}
28
+
29
+ 	/**
30
+ 	 * Reverse the migrations.
31
+ 	 *
32
+ 	 * @return void
33
+ 	 */
34
+ 	public function down()
35
+ 	{
36
+ 		Schema::drop('cycles');
37
+ 	}
38
+
39
+}

+ 50
- 0
app/database/migrations/2021_02_16_142832_create_cycles_semesters_table.php Ver arquivo

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

+ 39
- 0
app/database/migrations/2021_02_17_205601_create_cycles_table.php Ver arquivo

@@ -0,0 +1,39 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class CreateCyclesTable extends Migration {
7
+
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	 public function up()
14
+ 	{
15
+ 		Schema::create('cycles', function(Blueprint $table)
16
+ 		{
17
+			// 		id unico
18
+ 			$table->increments('id')->unsigned();
19
+			// 		cuando a~nos tiene el ciclo('3')
20
+			$table->integer('years_in_cycle');
21
+			// 		cuando comienza el ciclo ('2019')
22
+			$table->integer('start');
23
+			// 		cuando termina  el ciclo ('2022')
24
+			$table->integer('end');
25
+ 			$table->timestamps();
26
+ 		});
27
+ 	}
28
+
29
+ 	/**
30
+ 	 * Reverse the migrations.
31
+ 	 *
32
+ 	 * @return void
33
+ 	 */
34
+ 	public function down()
35
+ 	{
36
+ 		Schema::drop('cycles');
37
+ 	}
38
+
39
+}

+ 50
- 0
app/database/migrations/2021_02_17_205659_create_cycles_semesters_table.php Ver arquivo

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

+ 50
- 0
app/database/migrations/2021_02_17_205734_create_three_year_plans_table.php Ver arquivo

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

+ 48
- 0
app/database/migrations/2021_02_17_205809_create_typ_parts_table.php Ver arquivo

@@ -0,0 +1,48 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class CreateTypPartsTable extends Migration {
7
+
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function up()
14
+	{
15
+		Schema::create('typ_parts', function(Blueprint $table)
16
+		{
17
+			$table->increments('id')->unsigned();
18
+			$table->integer('three_year_plan_id')->unsigned();
19
+			$table
20
+				->foreign('three_year_plan_id')
21
+				->references('id')
22
+				->on('three_year_plans')
23
+				->onDelete('cascade')
24
+				->onUpdate('cascade');
25
+			$table->integer('semester_id')->unsigned();
26
+			$table
27
+					->foreign('semester_id')
28
+					->references('id')
29
+					->on('semesters')
30
+					->onDelete('cascade')
31
+					->onUpdate('cascade');
32
+			$table->timestamps();
33
+		});
34
+
35
+		// DB::statement("ALTER TABLE `typ_parts` comment 'Annual plans that are part of a three-year plan'");
36
+	}
37
+
38
+	/**
39
+	 * Reverse the migrations.
40
+	 *
41
+	 * @return void
42
+	 */
43
+	public function down()
44
+	{
45
+		Schema::drop('typ_parts');
46
+	}
47
+
48
+}

+ 63
- 0
app/database/migrations/2021_02_17_205850_create_typ_part_outcomes_table.php Ver arquivo

@@ -0,0 +1,63 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class CreateTypPartOutcomesTable extends Migration
7
+{
8
+
9
+	/**
10
+	 * Run the migrations.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function up()
15
+	{
16
+		Schema::create('typ_part_outcomes', function (Blueprint $table) {
17
+
18
+			$table->increments('id')->unsigned();
19
+			$table->integer('typ_part_id')->unsigned();
20
+			$table
21
+				->foreign('typ_part_id')
22
+				->references('id')
23
+				->on('typ_parts')
24
+				->onDelete('cascade')
25
+				->onUpdate('cascade');
26
+			$table->integer('outcome_id')->unsigned();
27
+			$table
28
+				->foreign('outcome_id')
29
+				->references('id')
30
+				->on('outcomes')
31
+				->onDelete('cascade')
32
+				->onUpdate('cascade');
33
+			$table->integer('objective_id')->unsigned()->nullable();
34
+			$table
35
+				->foreign('objective_id')
36
+				->references('id')
37
+				->on('objectives')
38
+				->onDelete('cascade')
39
+				->onUpdate('cascade');
40
+			$table->integer('course_id')->unsigned()->nullable();
41
+			$table
42
+				->foreign('course_id')
43
+				->references('id')
44
+				->on('courses')
45
+				->onDelete('cascade')
46
+				->onUpdate('cascade');
47
+			$table->tinyInteger('display_order');
48
+			$table->timestamps();
49
+		});
50
+
51
+		// DB::statement("ALTER TABLE typ_part_outcomes comment 'Outcomes for the annual plans of the three year plans'");
52
+	}
53
+
54
+	/**
55
+	 * Reverse the migrations.
56
+	 *
57
+	 * @return void
58
+	 */
59
+	public function down()
60
+	{
61
+		Schema::drop('typ_part_outcomes');
62
+	}
63
+}

+ 33
- 0
app/database/migrations/2021_02_25_180526_three_year_plan.php Ver arquivo

@@ -0,0 +1,33 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class ThreeYearPlan extends Migration
7
+{
8
+
9
+	/**
10
+	 * Run the migrations.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function up()
15
+	{
16
+		Schema::create('three_year_plan', function (Blueprint $table) {
17
+			$table->increments('id');
18
+			$table->timestamps();
19
+			$table->integer('year_start')->unsigned();
20
+			$table->integer('year_end')->unsigned();
21
+		});
22
+	}
23
+
24
+	/**
25
+	 * Reverse the migrations.
26
+	 *
27
+	 * @return void
28
+	 */
29
+	public function down()
30
+	{
31
+		Schema::drop('three_year_plan');
32
+	}
33
+}

+ 50
- 0
app/database/migrations/2021_02_25_181424_typ_semesters.php Ver arquivo

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

+ 43
- 0
app/database/migrations/2021_02_25_181544_typ_program.php Ver arquivo

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

+ 50
- 0
app/database/migrations/2021_02_25_181623_typ_semester_outcome.php Ver arquivo

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

+ 46
- 0
app/database/migrations/2021_02_25_181644_typ_semester_objectives.php Ver arquivo

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

+ 49
- 0
app/database/migrations/2021_02_25_181655_typ_semester_courses.php Ver arquivo

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

+ 51
- 0
app/database/migrations/2021_03_29_151147_create_Transformative_Actions.php Ver arquivo

@@ -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 CreateTransformativeActions extends Migration
8
+{
9
+
10
+	/**
11
+	 * Run the migrations.
12
+	 *
13
+	 * @return void
14
+	 */
15
+	public function up()
16
+	{
17
+		Schema::create('transformative_actions', function (Blueprint $table) {
18
+
19
+			$table->increments('id');
20
+			$table->timestamps();
21
+			$table->boolean('is_custom');
22
+			$table->integer('user_id')->unsigned()->nullable();
23
+			$table->integer('program_id')->unsigned()->nullable();
24
+			$table->text('at_text');
25
+			$table->text('description');
26
+			$table->boolean('by_professor');
27
+
28
+			$table->foreign('user_id')
29
+				->references('id')
30
+				->on('users')
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('transformative_actions');
50
+	}
51
+}

+ 52
- 0
app/database/migrations/2021_03_29_151507_create_transformative_objective_program.php Ver arquivo

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

+ 51
- 0
app/database/migrations/2021_03_29_151542_create_annual_report_transformative.php Ver arquivo

@@ -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 CreateAnnualReportTransformative extends Migration
8
+{
9
+
10
+	/**
11
+	 * Run the migrations.
12
+	 *
13
+	 * @return void
14
+	 */
15
+	public function up()
16
+	{
17
+		Schema::create('annual_report_transformative', function (Blueprint $table) {
18
+			$table->increments('id');
19
+			$table->boolean('accomplished');
20
+			$table->integer('cycle_of_life');
21
+			$table->integer("semester_used")->unsigned();
22
+			$table->integer('semester_continue')->unsigned()->nullable();
23
+			$table->integer('trans_op_id')->unsigned();
24
+			$table->foreign('trans_op_id')
25
+				->references('id')
26
+				->on('transformative_objective_program')
27
+				->onDelete('cascade')
28
+				->onUpdate('cascade');
29
+			$table->foreign('semester_used')
30
+				->references('id')
31
+				->on('semesters')
32
+				->onDelete('cascade')
33
+				->onUpdate('cascade');
34
+			$table->foreign('semester_continue')
35
+				->references('id')
36
+				->on('semesters')
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('annual_report_transformative');
50
+	}
51
+}

+ 42
- 0
app/database/migrations/2021_03_29_154844_create_annual_plan_transformative.php Ver arquivo

@@ -0,0 +1,42 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class CreateAnnualPlanTransformative extends Migration
7
+{
8
+
9
+	/**
10
+	 * Run the migrations.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function up()
15
+	{
16
+		Schema::create('annual_plan_transformative', function (Blueprint $table) {
17
+			$table->increments('id');
18
+			$table->integer('annual_plan')->unsigned();
19
+			$table->integer('trans_op_id')->unsigned();
20
+			$table->foreign('trans_op_id')
21
+				->references('id')
22
+				->on('transformative_objective_program')
23
+				->onDelete('cascade')
24
+				->onUpdate('cascade');
25
+			$table->foreign('annual_plan')
26
+				->references('id')
27
+				->on('annual_plans')
28
+				->onDelete('cascade')
29
+				->onUpdate('cascade');
30
+		});
31
+	}
32
+
33
+	/**
34
+	 * Reverse the migrations.
35
+	 *
36
+	 * @return void
37
+	 */
38
+	public function down()
39
+	{
40
+		Schema::drop('annual_plan_transformative');
41
+	}
42
+}

+ 44
- 0
app/database/migrations/2021_04_25_194120_create_ta_course_table.php Ver arquivo

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

+ 30
- 0
app/database/migrations/emails/feedback-email-copy.blade.php Ver arquivo

@@ -0,0 +1,30 @@
1
+<!DOCTYPE html>
2
+<html lang="en-US">
3
+	<head>
4
+		<meta charset="utf-8">
5
+	</head>
6
+	<body style="width: 960px;">
7
+		<div>{{HTML::image('/images/olas-email-header.png', 'OLAS Header Image', array('class'=>'logo img-responsive'))}}</div>		
8
+		<div>
9
+			<h2 style="color: #E70033;">Copy of your feedback for OLAS (no-reply)</h2>
10
+			
11
+			<hr style="border: 0; height: 0; border-top: 1px solid rgba(0, 0, 0, 0.1); border-bottom: 1px solid rgba(255, 255, 255, 0.3);">
12
+			<h3>Type: </h3>
13
+			<p>{{ $type }}</p>
14
+
15
+			<h3>Email: </h3>
16
+			<p>{{ $email }}</p>
17
+
18
+			<h3>Comment: </h3>
19
+			<p>{{ $comment }}</p>
20
+			<hr style="border: 0; height: 0; border-top: 1px solid rgba(0, 0, 0, 0.1); border-bottom: 1px solid rgba(255, 255, 255, 0.3);">
21
+
22
+			<p>This is an automatic email message. Please do not reply, as the inbox is not monitored.</p>
23
+
24
+			<p>Regards,</p>
25
+			<p style="color: #E70033;"><strong>OLAS UPRRP Administration<strong></p><br/>
26
+			
27
+
28
+		</div>
29
+	</body>
30
+</html>

+ 125
- 0
app/database/seeds/FillNewAssessmentActivityCriterion.php Ver arquivo

@@ -0,0 +1,125 @@
1
+<?php
2
+
3
+class FillNewAssessmentActivityCriterion extends Seeder {
4
+
5
+    public function run()
6
+    {
7
+    
8
+//   DB::enableQueryLog();
9
+    	$activities=DB::table('activities')
10
+    					->join('new_rubric_activity', 'activities.id', '=', 'new_rubric_activity.activity_id')
11
+    					->join('rubrics', 'rubrics.id', '=', 'new_rubric_activity.rubric_id')
12
+    					->join('new_criterion_rubric', 'rubrics.id', '=', 'new_criterion_rubric.rubric_id')
13
+						->select('activities.*','rubrics.expected_percentage','rubrics.expected_points','new_criterion_rubric.criterion_id')
14
+						->orderBy('activities.id')
15
+						->orderBy('new_criterion_rubric.criterion_id')
16
+    					->get();
17
+//   DB::enableQueryLog();
18
+// 		dd(DB::getQueryLog());
19
+// 		exit();
20
+		$activity_antes=-1;
21
+		foreach ($activities as $activity)
22
+		{
23
+			$activity_id=$activity->id;
24
+			$expected_percentage_students_achieving=$activity->expected_percentage;
25
+			$transformative_actions=$activity->transforming_actions;
26
+			$assessment_comments=$activity->assessment_comments;
27
+			$expected_student_score=$activity->expected_points;
28
+			$criterion_id=$activity->criterion_id;
29
+// 			$datos=json_decode($activity->criteria_achieved, true);
30
+// 			$i=0;
31
+// 			foreach($datos as $criterion_id=>$score)
32
+// 			{
33
+			$existe_ya=DB::table('activity_criterion')->where('activity_id', $activity_id)->where('criterion_id', $criterion_id)->first();
34
+			if(empty($existe_ya))
35
+			{			
36
+				if($activity_antes==$activity_id)
37
+				{
38
+					DB::table('activity_criterion')->insert(
39
+					array("activity_id"=>$activity_id,
40
+						  "criterion_id"=>$criterion_id,
41
+						  "expected_percentage_students_achieving"=>$expected_percentage_students_achieving,
42
+						  "expected_student_score"=>$expected_student_score
43
+						  )
44
+						);
45
+				}
46
+				else
47
+				{
48
+					$activity_antes=$activity_id;
49
+					DB::table('activity_criterion')->insert(
50
+					array("activity_id"=>$activity_id,
51
+						  "criterion_id"=>$criterion_id,
52
+						  "expected_percentage_students_achieving"=>$expected_percentage_students_achieving,
53
+						  "expected_student_score"=>$expected_student_score,
54
+						  "transformative_actions"=>$transformative_actions,
55
+						  "assessment_comments"=>$assessment_comments
56
+						  )
57
+						);				
58
+				}
59
+				print $activity_id.':'.$criterion_id;print"\n";
60
+			}
61
+// 				$i++;
62
+// 			}
63
+		}
64
+    	
65
+//     exit();
66
+    	$assessments=DB::table('assessments')->get();
67
+    $i=0;
68
+		foreach ($assessments as $assessment)
69
+		{
70
+// 			var_dump($assessment);exit();
71
+			$student_id=$assessment->student_id;
72
+			$activity_id=$assessment->activity_id;
73
+			$datos=json_decode($assessment->scores, true);
74
+// 			$criterion=(array)DB::table('activity_criterion')->where('activity_id', $activity_id)->first();
75
+// 			var_dump($rubric);exit();
76
+// 			$criterion_id=$criterion["criterion_id"];
77
+// 			print_r($datos);
78
+// 			print"\n";
79
+// 			print $rubric->id;print"\t";
80
+			foreach($datos as $criterion_id=>$score)
81
+			{
82
+// 				print $dato["id"];print"\n";
83
+// 				var_dump($new_criterion);
84
+				$activity_criterion=DB::table('activity_criterion')->where('criterion_id', $criterion_id)->where('activity_id', $activity_id)->first();
85
+				if(empty($activity_criterion))
86
+				{
87
+// 					var_dump($criterion_id);
88
+					var_dump($assessment);
89
+// 					$activities=DB::table('activities')->where('id', $activity_id)->first();
90
+// 					$criterion_rubric=DB::table('new_criterion_rubric')->where('criterion_id', $criterion_id)->first();
91
+// 					var_dump($activities);
92
+// 					var_dump($criterion_rubric);
93
+// 					exit();
94
+					$activity_criterion_id=DB::table('activity_criterion')->insertGetId(
95
+						array("activity_id"=>$activity_id,
96
+							  "criterion_id"=>$criterion_id,
97
+							  "transformative_actions"=>$transformative_actions,
98
+							  "assessment_comments"=>$assessment_comments
99
+							  )
100
+						);				
101
+					
102
+				}
103
+				else $activity_criterion_id=$activity_criterion->id;
104
+				$existe_ya=DB::table('new_assessments')->where('student_id', $student_id)->where('activity_criterion_id', $activity_criterion_id)->first();
105
+				if(empty($existe_ya))
106
+				{
107
+					DB::table('new_assessments')->insert(array("student_id"=>$student_id,"activity_criterion_id"=>$activity_criterion_id,'score'=>$score));
108
+					print".";
109
+				}
110
+			}
111
+// 			print $activity_id.':'.$criterion_id;print"\n";
112
+
113
+			$i++;
114
+		}
115
+
116
+
117
+// 		$course = Rubric::where('code', $code)->where('number', $number)->where('section', $section)->where('semester_id', $semester_id)->first();
118
+
119
+
120
+
121
+
122
+	}
123
+
124
+
125
+}

+ 94
- 0
app/database/seeds/FillNewCriterionRubric.php Ver arquivo

@@ -0,0 +1,94 @@
1
+<?php
2
+
3
+class FillNewCriterionRubric extends Seeder {
4
+
5
+    public function run()
6
+    {
7
+    	$rubrics=DB::table('rubrics')->get();
8
+    $i=0;
9
+		foreach ($rubrics as $rubric)
10
+		{
11
+			$datos=json_decode($rubric->contents, true);
12
+// 			print_r($datos);
13
+// 			print"\n";
14
+// 			print $rubric->id;print"\t";
15
+// 			if($rubric->id==29){var_dump($datos);}
16
+			foreach($datos as $dato)
17
+			{
18
+				if($rubric->id==29){print $dato["id"];print"Entrando\n";}
19
+				$new_criterion=(array)DB::table('criteria')->where('id', $dato["id"])->first();
20
+// 				var_dump($new_criterion);
21
+				$program_id=(array)DB::table('courses')
22
+				->join('activities', 'courses.id', '=', 'activities.course_id')
23
+				->join('new_rubric_activity', 'new_rubric_activity.activity_id', '=', 'activities.id')
24
+				->select('courses.program_id')
25
+				->where('new_rubric_activity.rubric_id',$rubric->id)
26
+				->first();
27
+				if(empty($program_id))$program_id['program_id']=1;
28
+	// 			else var_dump($program_id);
29
+
30
+// 				var_dump($program_id);
31
+// 				var_dump($new_criterion);
32
+				if(!empty($new_criterion))
33
+				{
34
+					$existe=(array)DB::table('objectives')->where('id', $new_criterion["id"])->first();
35
+					$objective_id=$new_criterion["id"];
36
+					if(empty($existe))
37
+					{
38
+						$existe4=(array)DB::table('objectives')->where('program_id', $program_id['program_id'])->where('text', $new_criterion["name"])->first();
39
+	// 					print_r($existe4);print"\n";
40
+						if(!empty($existe4))
41
+						{
42
+	// 						DB::table('objectives')->insert(array("id"=> $new_criterion["id"],"program_id"=>$program_id['program_id'],"text"=>$new_criterion["name"],'outcome_id'=>$new_criterion['outcome_id']));
43
+							$objective_id=$existe4["id"];
44
+						}
45
+						else 
46
+						{
47
+							print "A crear entrada en objectives:  $objective_id";
48
+// 							var_dump(array("id"=> $objective_id,"program_id"=>$program_id['program_id'],"text"=>$new_criterion["name"],'outcome_id'=>$new_criterion['outcome_id']));
49
+							DB::table('objectives')->insert(array("id"=> $objective_id,"program_id"=>$program_id['program_id'],"text"=>$new_criterion["name"],'outcome_id'=>$new_criterion['outcome_id']));
50
+						}
51
+					}
52
+					else
53
+					{
54
+						$existe4=(array)DB::table('objectives')->where('program_id', $program_id['program_id'])->where('text', $new_criterion["name"])->first();
55
+	// 					print_r($existe4);print"\n";
56
+						if(empty($existe4))
57
+						{
58
+							$objective_id=DB::table('objectives')->insertGetId(array("program_id"=>$program_id['program_id'],"text"=>$new_criterion["name"],'outcome_id'=>$new_criterion['outcome_id']));
59
+						}
60
+
61
+					}
62
+					$new_criterion["objective_id"]=$objective_id;
63
+					unset($new_criterion['outcome_id']);
64
+// 					var_dump($new_criterion);
65
+					$existe2=(array)DB::table('new_criteria')->where('id', $new_criterion["id"])->first();
66
+					if(empty($existe2))
67
+					{
68
+						DB::table('new_criteria')->insert($new_criterion);
69
+					}
70
+					$existe3=(array)DB::table('new_criterion_rubric')->where('criterion_id', $new_criterion["id"])->where('rubric_id', $rubric->id)->first();
71
+					if(empty($existe3))
72
+					{
73
+						DB::table('new_criterion_rubric')->insert(
74
+						array('criterion_id' => $dato["id"], 'rubric_id' => $rubric->id)
75
+						);
76
+					}
77
+				}
78
+	// 			if($i)exit();
79
+		
80
+			}
81
+// 			if($rubric->id==29){exit();}
82
+		$i++;
83
+		}
84
+
85
+
86
+// 		$course = Rubric::where('code', $code)->where('number', $number)->where('section', $section)->where('semester_id', $semester_id)->first();
87
+
88
+
89
+
90
+
91
+	}
92
+
93
+
94
+}

+ 59
- 0
app/database/seeds/FillScalesCriteria.php Ver arquivo

@@ -0,0 +1,59 @@
1
+<?php
2
+
3
+class FillScalesCriteria extends Seeder {
4
+
5
+    public function run()
6
+    {
7
+
8
+    	$criteria=DB::table('criteria')->get();
9
+		foreach($criteria as $criterion)
10
+		{
11
+			$existe=DB::table('scales')->where('title',"description12")->where('description',$criterion->description12)->where('position',1)->first();
12
+			if(empty($existe))
13
+			{
14
+				$scale_id=DB::table('scales')->insertGetId(array('title'=>"description12",'description'=>$criterion->description12,'position'=>1));		
15
+			}
16
+			else
17
+			{
18
+				$scale_id=$existe->id;
19
+			}
20
+			DB::table('criterion_scale')->insert(array("scale_id"=>$scale_id,"criterion_id"=>$criterion->id));
21
+			$existe=DB::table('scales')->where('title',"description34")->where('description',$criterion->description34)->where('position',2)->first();
22
+			if(empty($existe))
23
+			{
24
+				$scale_id=DB::table('scales')->insertGetId(array('title'=>"description34",'description'=>$criterion->description34,'position'=>2));
25
+			}
26
+			else
27
+			{
28
+				$scale_id=$existe->id;
29
+			}
30
+			DB::table('criterion_scale')->insert(array("scale_id"=>$scale_id,"criterion_id"=>$criterion->id));
31
+			$existe=DB::table('scales')->where('title',"description56")->where('description',$criterion->description56)->where('position',3)->first();
32
+			if(empty($existe))
33
+			{
34
+				$scale_id=DB::table('scales')->insertGetId(array('title'=>"description56",'description'=>$criterion->description56,'position'=>3));
35
+			}
36
+			else
37
+			{
38
+				$scale_id=$existe->id;
39
+			}
40
+			DB::table('criterion_scale')->insert(array("scale_id"=>$scale_id,"criterion_id"=>$criterion->id));
41
+			$existe=DB::table('scales')->where('title',"description78")->where('description',$criterion->description78)->where('position',4)->first();
42
+			if(empty($existe))
43
+			{
44
+				$scale_id=DB::table('scales')->insertGetId(array('title'=>"description78",'description'=>$criterion->description78,'position'=>4));
45
+			}
46
+			else
47
+			{
48
+				$scale_id=$existe->id;
49
+			}
50
+			$existe_ya=DB::table('criterion_scale')->where('scale_id', $scale_id)->where('criterion_id', $criterion->id)->first();
51
+			if(empty($existe_ya))DB::table('criterion_scale')->insert(array("scale_id"=>$scale_id,"criterion_id"=>$criterion->id));
52
+
53
+		
54
+		}
55
+
56
+	}
57
+
58
+
59
+}

+ 43
- 0
app/database/unusedMigrations/2018_08_28_140328_remove_outcome_id_from_objectives_table.php Ver arquivo

@@ -0,0 +1,43 @@
1
+<?php
2
+
3
+use Illuminate\Database\Migrations\Migration;
4
+use Illuminate\Database\Schema\Blueprint;
5
+
6
+class RemoveOutcomeIdFromObjectivesTable extends Migration
7
+{
8
+
9
+	/**
10
+	 * Run the migrations.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function up()
15
+	{
16
+		Schema::table('objectives', function (Blueprint $table) {
17
+			$table->dropForeign('objectives_outcome_id_foreign');
18
+			$table->dropColumn('outcome_id');
19
+		});
20
+	}
21
+
22
+
23
+	/**
24
+	 * Reverse the migrations.
25
+	 *
26
+	 * @return void
27
+	 */
28
+	public function down()
29
+	{
30
+		Schema::table('objectives', function (Blueprint $table) {
31
+			$table
32
+				->integer('outcome_id')
33
+				->after('id')
34
+				->unsigned();
35
+			$table
36
+				->foreign('outcome_id')
37
+				->references('id')
38
+				->on('outcomes')
39
+				->onDelete('cascade')
40
+				->onUpdate('cascade');
41
+		});
42
+	}
43
+}

+ 39
- 0
app/database/unusedMigrations/2020_04_04_005817_add_outcome_id_to_objectives_table.php Ver arquivo

@@ -0,0 +1,39 @@
1
+<?php
2
+
3
+use Illuminate\Database\Migrations\Migration;
4
+use Illuminate\Database\Schema\Blueprint;
5
+
6
+class AddOutcomeIdToObjectivesTable extends Migration {
7
+
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function up()
14
+	{
15
+		Schema::table('objectives', function(Blueprint $table)
16
+		{
17
+			$table->integer('outcome_id')->unsigned();
18
+
19
+			$table->foreign('outcome_id')->references('id')->on('outcomes')->onDelete('cascade')->onUpdate('cascade');
20
+		});
21
+	}
22
+
23
+
24
+	/**
25
+	 * Reverse the migrations.
26
+	 *
27
+	 * @return void
28
+	 */
29
+	public function down()
30
+	{
31
+		Schema::table('objectives', function(Blueprint $table)
32
+		{
33
+		    $table->dropForeign('objectives_outcome_id_foreign');
34
+
35
+			$table->dropColumn('outcome_id');
36
+		});
37
+	}
38
+
39
+}

+ 46
- 0
app/database/unusedMigrations/2020_10_04_141759_create_activity_criterion_table.php Ver arquivo

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

+ 52
- 0
app/database/unusedMigrations/2020_10_05_124915_create_activity_criterion_table.php Ver arquivo

@@ -0,0 +1,52 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class CreateActivityCriterionTable extends Migration {
7
+
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function up()
14
+	{
15
+		Schema::create('activity_criterion', function(Blueprint $table)
16
+		{
17
+			$table->increments('id');
18
+			$table->integer('activity_id')->unsigned();
19
+			$table->integer('criterion_id')->unsigned();
20
+			$table
21
+				->foreign('activity_id')
22
+				->references('id')
23
+				->on('activities')
24
+				->onDelete('cascade')
25
+				->onUpdate('cascade');
26
+			$table
27
+				->foreign('criterion_id')
28
+				->references('id')
29
+				->on('criteria')
30
+				->onDelete('cascade')
31
+				->onUpdate('cascade');
32
+			$table->text('transformative_actions')->nullable();
33
+			$table->integer('expected_student_score')->nullable();
34
+			$table->decimal('expected_percentage_students_achieving', 5, 2)->nullable();
35
+			$table->decimal('percentage_students_who_achieved', 5, 2)->nullable();
36
+			$table->decimal('weight', 3, 2)->default(1.0);
37
+			$table->timestamps();
38
+		});
39
+	
40
+	}
41
+
42
+	/**
43
+	 * Reverse the migrations.
44
+	 *
45
+	 * @return void
46
+	 */
47
+	public function down()
48
+	{
49
+		Schema::drop('activity_criterion');
50
+	}
51
+
52
+}

+ 35
- 0
app/database/unusedMigrations/2020_10_05_130252_add_max_score_num_scales_new_criteria_table.php Ver arquivo

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

+ 35
- 0
app/database/unusedMigrations/2020_10_05_142424_create_scales_table.php Ver arquivo

@@ -0,0 +1,35 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class CreateScalesTable extends Migration {
7
+
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function up()
14
+	{
15
+		Schema::create('scales', function(Blueprint $table)
16
+		{
17
+			$table->increments('id');
18
+			$table->integer('position');
19
+			$table->string('title');
20
+			$table->string('description');
21
+			$table->timestamps();
22
+		});
23
+	}
24
+
25
+	/**
26
+	 * Reverse the migrations.
27
+	 *
28
+	 * @return void
29
+	 */
30
+	public function down()
31
+	{
32
+		Schema::drop('scales');
33
+	}
34
+
35
+}

+ 47
- 0
app/database/unusedMigrations/2020_10_05_142912_create_criterion_scale_table.php Ver arquivo

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

+ 34
- 0
app/database/unusedMigrations/2020_10_05_232429_add_assessment_comments_to_activity_criterion.php Ver arquivo

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

+ 36
- 0
app/database/unusedMigrations/2020_10_08_203557_create_new_criteria_table2.php Ver arquivo

@@ -0,0 +1,36 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+use Illuminate\Support\Facades\Schema;
6
+
7
+class CreateNewCriteriaTable2 extends Migration
8
+{
9
+
10
+	/**
11
+	 * Run the migrations.
12
+	 *
13
+	 * @return void
14
+	 */
15
+	public function up()
16
+	{
17
+		Schema::table('new_criteria', function ($table) {
18
+			$table->integer('outcome_id')->unsigned();
19
+
20
+			$table->foreign('outcome_id')->references('id')->on('outcomes')->onDelete('cascade')->onUpdate('cascade');
21
+		});
22
+	}
23
+
24
+
25
+	/**
26
+	 * Reverse the migrations.
27
+	 *
28
+	 * @return void
29
+	 */
30
+	public function down()
31
+	{
32
+		Schema::table('new_criteria', function ($table) {
33
+			$table->dropColumn('outcome_id');
34
+		});
35
+	}
36
+}

+ 33
- 0
app/database/unusedMigrations/2020_10_08_215013_drop_objective_id_new_criteria.php Ver arquivo

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

+ 34
- 0
app/database/unusedMigrations/2020_10_09_085334_add_activities_rubric_id.php Ver arquivo

@@ -0,0 +1,34 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class AddActivitiesRubricId extends Migration
7
+{
8
+
9
+	/**
10
+	 * Run the migrations.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function up()
15
+	{
16
+		Schema::table('activities', function ($table) {
17
+			$table->integer('rubric_id')->unsigned();
18
+
19
+			//$table->foreign('rubric_id')->references('id')->on('rubrics')->onDelete('cascade')->onUpdate('cascade');
20
+		});
21
+	}
22
+
23
+	/**
24
+	 * Reverse the migrations.
25
+	 *
26
+	 * @return void
27
+	 */
28
+	public function down()
29
+	{
30
+		Schema::table('activities', function ($table) {
31
+			$table->dropColumn('rubric_id');
32
+		});
33
+	}
34
+}

+ 35
- 0
app/database/unusedMigrations/2020_10_09_092810_drop_assessment_criteria.php Ver arquivo

@@ -0,0 +1,35 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class DropAssessmentCriteria extends Migration
7
+{
8
+
9
+	/**
10
+	 * Run the migrations.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function up()
15
+	{
16
+		Schema::table('assessments', function ($table) {
17
+			$table->dropForeign('assessments_criterion_id_foreign');
18
+			$table->integer('criterion_id')->unsigned();
19
+
20
+			$table->foreign('criterion_id')->references('id')->on('new_criteria')->onDelete('cascade')->onUpdate('cascade');
21
+		});
22
+	}
23
+
24
+	/**
25
+	 * Reverse the migrations.
26
+	 *
27
+	 * @return void
28
+	 */
29
+	public function down()
30
+	{
31
+		Schema::table('assessments', function ($table) {
32
+			$table->dropForeign('criterion_id');
33
+		});
34
+	}
35
+}

+ 35
- 0
app/database/unusedMigrations/2020_10_09_094503_add_criterion_to_assessment.php Ver arquivo

@@ -0,0 +1,35 @@
1
+<?php
2
+
3
+use Illuminate\Database\Schema\Blueprint;
4
+use Illuminate\Database\Migrations\Migration;
5
+
6
+class AddCriterionToAssessment extends Migration
7
+{
8
+
9
+	/**
10
+	 * Run the migrations.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function up()
15
+	{ {
16
+			Schema::table('assessments', function ($table) {
17
+
18
+
19
+
20
+				$table->foreign('criterion_id')->references('id')->on('new_criteria')->onDelete('cascade')->onUpdate('cascade');
21
+			});
22
+		}
23
+	}
24
+	/**
25
+	 * Reverse the migrations.
26
+	 *
27
+	 * @return void
28
+	 */
29
+	public function down()
30
+	{
31
+		Schema::table('assessments', function ($table) {
32
+			$table->dropForeign('criterion_id');
33
+		});
34
+	}
35
+}

+ 29
- 0
app/database/unusedMigrations/2020_10_09_095246_drop_foreign_assesment_criterion.php Ver arquivo

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

+ 36
- 0
app/database/unusedMigrations/2020_10_09_131800_add_level_activation_date_to_outcomes.php Ver arquivo

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

+ 30
- 55
app/filters.php Ver arquivo

@@ -11,19 +11,16 @@
11 11
 |
12 12
 */
13 13
 
14
-App::before(function($request)
15
-{
16
-	Log::debug('START '.Request::getClientIp().': '.Request::method().' '.Request::path());
17
-
18
-	if( ! Request::secure())
19
-    {
20
-        return Redirect::secure(Request::path());
21
-    }
14
+App::before(function ($request) {
15
+	Log::debug('START ' . Request::getClientIp() . ': ' . Request::method() . ' ' . Request::path());
16
+
17
+	//if (!Request::secure()) {
18
+	//	return Redirect::secure(Request::path());
19
+	//}
22 20
 });
23 21
 
24 22
 
25
-App::after(function($request, $response)
26
-{
23
+App::after(function ($request, $response) {
27 24
 	//
28 25
 });
29 26
 
@@ -38,37 +35,28 @@ App::after(function($request, $response)
38 35
 |
39 36
 */
40 37
 
41
-Route::filter('auth', function()
42
-{
43
-	if (Auth::guest())
44
-	{
45
-		if (Request::ajax())
46
-		{
38
+Route::filter('auth', function () {
39
+	if (Auth::guest()) {
40
+		if (Request::ajax()) {
47 41
 			return Response::make('Unauthorized', 401);
48
-		}
49
-		else
50
-		{
42
+		} else {
51 43
 			return Redirect::guest('/');
52 44
 		}
53 45
 	}
54 46
 });
55 47
 
56 48
 
57
-Route::filter('auth.basic', function()
58
-{
49
+Route::filter('auth.basic', function () {
59 50
 	return Auth::basic();
60 51
 });
61 52
 
62
-Route::filter('has_access', function()
63
-{
64
-	if(!Auth::user()->has_access)
65
-	{
53
+Route::filter('has_access', function () {
54
+	if (!Auth::user()->has_access) {
66 55
 		Session::flash('status', 'info');
67 56
 		Session::flash('message', 'At this time, access to OLAS is limited to some users. Check back later or contact an administrator.');
68 57
 		Auth::logout();
69 58
 		return Redirect::action('AuthController@showLogin');
70 59
 	}
71
-
72 60
 });
73 61
 /*
74 62
 |--------------------------------------------------------------------------
@@ -81,10 +69,8 @@ Route::filter('has_access', function()
81 69
 |
82 70
 */
83 71
 
84
-Route::filter('guest', function()
85
-{
86
-	if (Auth::check())
87
-	{
72
+Route::filter('guest', function () {
73
+	if (Auth::check()) {
88 74
 		switch (Auth::user()->role) {
89 75
 			case 1:
90 76
 				return Redirect::to('administrator');
@@ -115,10 +101,8 @@ Route::filter('guest', function()
115 101
 |
116 102
 */
117 103
 
118
-Route::filter('admin', function()
119
-{
120
-	if (Auth::user()->role !=1)
121
-	{
104
+Route::filter('admin', function () {
105
+	if (Auth::user()->role != 1) {
122 106
 		switch (Auth::user()->role) {
123 107
 			case 2:
124 108
 				return Redirect::to('school-coordinator');
@@ -145,13 +129,10 @@ Route::filter('admin', function()
145 129
 |
146 130
 */
147 131
 
148
-Route::filter('scoord', function()
149
-{
132
+Route::filter('scoord', function () {
150 133
 
151
-	if (!(Auth::user()->role ==2 || Auth::user()->role ==1))
152
-	{
153
-		switch (Auth::user()->role)
154
-		{
134
+	if (!(Auth::user()->role == 2 || Auth::user()->role == 1)) {
135
+		switch (Auth::user()->role) {
155 136
 
156 137
 			case 3:
157 138
 				return Redirect::to('program-coordinator');
@@ -174,10 +155,8 @@ Route::filter('scoord', function()
174 155
 |
175 156
 */
176 157
 
177
-Route::filter('pcoord', function()
178
-{
179
-	if (!(Auth::user()->role ==3 || Auth::user()->role ==2 || Auth::user()->role ==1))
180
-	{
158
+Route::filter('pcoord', function () {
159
+	if (!(Auth::user()->role == 3 || Auth::user()->role == 2 || Auth::user()->role == 1)) {
181 160
 		return Redirect::to('professor');
182 161
 	}
183 162
 });
@@ -192,12 +171,10 @@ Route::filter('pcoord', function()
192 171
 |
193 172
 */
194 173
 
195
-Route::filter('prof', function()
196
-{
174
+Route::filter('prof', function () {
197 175
 	// If user has no courses then s/he is not a professor
198 176
 	// and must be redirected to her/his overview page
199
-	if (!count(Auth::user()->courses))
200
-	{
177
+	if (!count(Auth::user()->courses)) {
201 178
 		switch (Auth::user()->role) {
202 179
 			case 1:
203 180
 				return Redirect::to('administrator');
@@ -221,15 +198,13 @@ Route::filter('prof', function()
221 198
 |
222 199
 | The CSRF filter is responsible for protecting your application against
223 200
 | cross-site request forgery attacks. If this special token in a user
224
-| session does not match the one given in this request, we'll bail.
201
+| session does not match the one given in this request, we'll bail
225 202
 |
226
-*/
203
+ */
227 204
 
228
-Route::filter('csrf', function()
229
-{
205
+Route::filter('csrf', function () {
230 206
 	$token = Request::ajax() ? Request::header('X-CSRF-Token') : Input::get('_token');
231
-	if (Session::token() !== $token)
232
-	{
233
-	  throw new Illuminate\Session\TokenMismatchException;
207
+	if (Session::token() !== $token) {
208
+		throw new Illuminate\Session\TokenMismatchException;
234 209
 	}
235 210
 });

+ 2
- 1
app/models/Activity.php Ver arquivo

@@ -10,7 +10,8 @@ class Activity extends Eloquent
10 10
 
11 11
   public function rubric()
12 12
   {
13
-    return $this->belongsTo('Rubric');
13
+//     return $this->belongsTo('Rubric');
14
+    return $this->belongsToMany('Rubric','new_rubric_activity');
14 15
   }
15 16
 
16 17
   public function course()

+ 52
- 0
app/models/Course.php Ver arquivo

@@ -42,6 +42,58 @@ class Course extends Eloquent
42 42
 
43 43
   }
44 44
 
45
+  public function outcomes_attempted()
46
+  {
47
+	return DB::table('courses')
48
+	    	->join('activities', 'activities.course_id', '=', 'courses.id')
49
+	    	->join('activity_criterion', 'activity_criterion.activity_id', '=', 'activities.id')
50
+	    	->join('new_criteria', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
51
+	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
52
+	    	->where('courses.id','=',$this->id)
53
+	    	->select('criterion_objective_outcome.outcome_id')
54
+	    	->distinct()
55
+	    	->orderBy('criterion_objective_outcome.outcome_id')
56
+	    	->get();
57
+
58
+//   	SELECT distinct cr.outcome_id FROM  courses c, activities a, activity_criterion ac, criteria cr WHERE c.id=a.course_id and a.id=ac.activity_id and ac.criterion_id=cr.id and c.id=1
59
+// 	return $this->id;
60
+  }
61
+
62
+  public function outcomes_achieved()
63
+  {
64
+		 $criteria=DB::table('new_criteria')
65
+	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
66
+	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
67
+	    	->join('courses', 'activities.course_id', '=', 'courses.id')
68
+	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
69
+	    	->where('courses.id','=',$this->id)
70
+	    	->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
71
+	    	->distinct()
72
+	    	->get()
73
+			;
74
+
75
+		$conteo=0;
76
+		foreach($criteria as $criterion)
77
+		{	
78
+			$students_attempted=Criterion::students_attempted($criterion->id, $criterion->activity_id);
79
+			$students_achieved=Criterion::students_achieved($criterion->id, $criterion->activity_id);
80
+		
81
+			if($students_attempted)
82
+			{
83
+				$percentage_students_who_achieved=100.0*$students_achieved/$students_attempted;
84
+			}
85
+			else
86
+			{
87
+				$percentage_students_who_achieved=0;
88
+			}
89
+			if($percentage_students_who_achieved>=$criterion->expected_percentage_students_achieving)
90
+			{
91
+				$conteo++;
92
+			}
93
+		}		
94
+		return $conteo;
95
+  }
96
+
45 97
   public function semester()
46 98
   {
47 99
     return $this->belongsTo('Semester');

+ 56
- 0
app/models/Criterion.php Ver arquivo

@@ -37,9 +37,65 @@ class Criterion extends Eloquent
37 37
 		return $this->belongsTo('Program');
38 38
 	}
39 39
 
40
+// 	public function activities()
41
+// 	{
42
+// 		return $this->hasManyThrough('Activity','activity_criterion');
43
+// 	}
44
+// 
40 45
 	public function subcriteria()
41 46
 	{
42 47
 		return json_decode($this->subcriteria);
43 48
 	}
49
+	
50
+	public static function students_attempted($criterion_id,$activity_id)	
51
+	{
52
+		$students_attempted=0;
53
+// 		var_dump($criterion_id);
54
+// 		var_dump($semester);
55
+// 		exit();
56
+		$activities_criterions=DB::table('activity_criterion')
57
+			->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
58
+			->join('courses', 'activities.course_id', '=', 'courses.id')
59
+			->where('activities.id','=',$activity_id)
60
+			->where('activity_criterion.criterion_id','=',$criterion_id)
61
+			->select('activity_criterion.id')
62
+			->distinct()
63
+			->get();
64
+			
65
+		foreach($activities_criterions as $activity_criterion)
66
+		{
67
+		
68
+			 $students_attempted+=DB::table('new_assessments')
69
+				->join('activity_criterion', 'new_assessments.activity_criterion_id', '=', 'activity_criterion.id')
70
+				->where('activity_criterion.id',$activity_criterion->id)
71
+				->count();
72
+		}
73
+		return $students_attempted;
74
+	}
75
+
76
+	public static function students_achieved($criterion_id,$activity_id)	
77
+	{
78
+		$students_achieved=0;
79
+		$activities_criterions=DB::table('activity_criterion')
80
+			->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
81
+			->join('courses', 'activities.course_id', '=', 'courses.id')
82
+			->where('activities.id','=',$activity_id)
83
+			->where('activity_criterion.criterion_id','=',$criterion_id)
84
+			->select('activity_criterion.id','expected_student_score')
85
+			->distinct()
86
+			->get();
87
+			
88
+		foreach($activities_criterions as $activity_criterion)
89
+		{
90
+		
91
+// 			$expected_student_score=DB::table('new_criteria')->where('id',$criterion_id)->select('expected_student_score')->get();
92
+			 $students_achieved+=DB::table('new_assessments')
93
+				->join('activity_criterion', 'new_assessments.activity_criterion_id', '=', 'activity_criterion.id')
94
+				->where('activity_criterion.id',$activity_criterion->id)
95
+				->where('new_assessments.score','>=',$activity_criterion->expected_student_score)
96
+				->count();
97
+		}
98
+		return $students_achieved;
99
+	}
44 100
 
45 101
 }

+ 29
- 26
app/models/Objective.php Ver arquivo

@@ -1,43 +1,46 @@
1 1
 <?php
2 2
 
3
+use Illuminate\Database\Eloquent\SoftDeletingTrait;
4
+
3 5
 class Objective extends Eloquent
4 6
 {
7
+    use SoftDeletingTrait;
8
+    protected $fillable = array('text', 'outcome_id', 'program_id', 'active');
9
+    protected $table = 'objectives';
5 10
 
6
-  protected $fillable = array('text', 'outcome_id', 'program_id', 'active');
11
+    /**
12
+     * Return the program that the objective belongs to
13
+     *
14
+     * @return Illuminate\Database\Eloquent\Model
15
+     */
16
+    public function program()
17
+    {
18
+        return $this->belongsTo('Program');
19
+    }
7 20
 
8
-  /**
9
-   * Return the program that the objective belongs to
10
-   *
11
-   * @return Illuminate\Database\Eloquent\Model
12
-   */
13
-  public function program()
14
-  {
15
-  	return $this->belongsTo('Program');
16
-  }
21
+    /**
22
+     * Return the outcomes that the objective belongs to
23
+     *
24
+     * @return Illuminate\Database\Eloquent\Model
25
+     */
17 26
 
18
-  /**
19
-   * Return the outcomes that the objective belongs to
20
-   *
21
-   * @return Illuminate\Database\Eloquent\Model
22
-   */
23
-  public function outcomes()
24
-  {
25
-  	return $this->belongsToMany('Outcome', 'objective_outcome', 'objective_id', 'outcome_id');
26
-  }
27
+    public function outcomes()
28
+    {
29
+        return $this->belongsToMany('Outcome', 'objective_outcome', 'objective_id', 'outcome_id');
30
+    }
27 31
 
28
-  public function outcome()
29
-  {
30
-      return $this->belongsTo('Outcome');
31
-  }
32
+    public function outcome()
33
+    {
34
+        return $this->belongsTo('Outcome');
35
+    }
32 36
 
33 37
     /**
34 38
      * Return the program that the objective belongs to
35 39
      *
36 40
      * @return Illuminate\Database\Eloquent\Model
37 41
      */
38
-    public function criteria()
42
+    public function outcome_id()
39 43
     {
40
-        return $this->hasMany('Criterion');
44
+        return $this->hasMany('Objective_Outcome', 'objective_id');
41 45
     }
42
-
43 46
 }

+ 38
- 0
app/models/Objective_Outcome.php Ver arquivo

@@ -0,0 +1,38 @@
1
+<?php
2
+
3
+use Illuminate\Database\Eloquent\SoftDeletingTrait;
4
+
5
+class Objective_Outcome extends Eloquent
6
+{
7
+    use SoftDeletingTrait;
8
+    protected $fillable = array('outcome_id', 'objective_id');
9
+    protected $table = 'objective_outcome';
10
+
11
+    /**
12
+     * Return the program that the objective belongs to
13
+     *
14
+     * @return Illuminate\Database\Eloquent\Model
15
+     */
16
+    public function outcome()
17
+    {
18
+        return $this->belongsTo('Outcome');
19
+    }
20
+
21
+    /**
22
+     * Return the outcomes that the objective belongs to
23
+     *
24
+     * @return Illuminate\Database\Eloquent\Model
25
+     */
26
+
27
+
28
+
29
+    /**
30
+     * Return the program that the objective belongs to
31
+     *
32
+     * @return Illuminate\Database\Eloquent\Model
33
+     */
34
+    public function objective()
35
+    {
36
+        return $this->belongsTo('Objective');
37
+    }
38
+}

+ 315
- 0
app/models/Outcome.php Ver arquivo

@@ -24,6 +24,321 @@ class Outcome extends Eloquent
24 24
 	    return $this->hasMany('Objective');
25 25
 //		return $this->belongsToMany('Objective', 'objective_outcome');
26 26
 	}
27
+// 	public function attempted($semester, $is_grad)
28
+// 	{
29
+// 		return DB::table('new_criteria')
30
+// 	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
31
+// 	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
32
+// 	    	->join('courses', 'activities.course_id', '=', 'courses.id')
33
+// 	    	->join('programs', 'programs.id', '=', 'courses.program_id')
34
+// 	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
35
+// 	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
36
+// 	    	->where('programs.is_graduate','=',$is_grad)
37
+// 	    	->where('courses.semester_id','=',$semester)
38
+// 	    	->count(DB::raw('DISTINCT new_criteria.id,activity_criterion.activity_id'))
39
+// 			;
40
+//
41
+// 	}
42
+// 	public function attempted($semester, $is_grad)
43
+// 	{
44
+// 		 $criteria=DB::table('new_criteria')
45
+// 	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
46
+// 	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
47
+// 	    	->join('courses', 'activities.course_id', '=', 'courses.id')
48
+// 	    	->join('programs', 'programs.id', '=', 'courses.program_id')
49
+// 	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
50
+// 	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
51
+// 	    	->where('programs.is_graduate','=',$is_grad)
52
+// 	    	->where('courses.semester_id','=',$semester)
53
+// 	    	->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
54
+// 	    	->distinct()
55
+// 	    	->get()
56
+// 			;
57
+// 		$conteo=0;
58
+// 		foreach($criteria as $criterion)
59
+// 		{
60
+// 			$students_attempted=Criterion::students_attempted($criterion->id, $criterion->activity_id);
61
+// 			if($students_attempted)
62
+// 			{
63
+// 				$conteo++;
64
+// 			}
65
+// 		}
66
+// 		return $conteo;
67
+// 	}
68
+	public function active_by_semesters($selected_semesters, $level)
69
+	{
70
+		$min_start="9000-01-01 00:00:00";
71
+		$max_end="1000-01-01 00:00:00";
72
+		foreach($selected_semesters as $semester)
73
+		{
74
+			if($min_start>$semester->start)
75
+			{
76
+				$min_start=$semester->start;
77
+			}
78
+			if($max_end<$semester->end)
79
+			{
80
+				$max_end=$semester->end;
81
+			}
82
+		}
83
+		$outcomes = Outcome::where(function($query) use ($min_start)
84
+								   {
85
+										$query->where('deactivation_date', '>=', $min_start)
86
+											  ->orWhere('deactivation_date', null);
87
+								   })
88
+							->where('activation_date', '<=', $max_end)
89
+							->where(function($query2) use ($level)
90
+									{
91
+										$query2->where("level", $level+1)
92
+											   ->orWhere("level",3);
93
+									})
94
+							->orderBy('name', 'ASC')
95
+							->get();
96
+
97
+// 		return array('outcomes'=>$outcomes,'outcomes_attempted'=>$outcomes_attempted, 'outcomes_achieved'=>$outcomes_achieved, 'attemptedProgramsPerOutcome'=>$attemptedProgramsPerOutcome, 'achievedProgramsPerOutcome'=>$achievedProgramsPerOutcome,'participating_programs'=>$participating_programs);
98
+		return $outcomes;
99
+	}
100
+
101
+	public function programs_attempted($semesters)
102
+	{
103
+		$semesters_array=[];
104
+		foreach($semesters as $semester)
105
+		{
106
+			$semesters_array[]=$semester->id;
107
+		}
108
+		 $programs=DB::table('programs')
109
+	    	->join('courses', 'programs.id', '=', 'courses.program_id')
110
+	    	->join('activities', 'activities.course_id', '=', 'courses.id')
111
+	    	->join('activity_criterion', 'activity_criterion.activity_id', '=', 'activities.id')
112
+	    	->join('new_criteria', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
113
+	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
114
+	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
115
+	    	->whereIn('courses.semester_id',$semesters_array)
116
+	    	->distinct()
117
+	    	->select('programs.id')
118
+	    	->get()
119
+			;
120
+
121
+		return $programs;
122
+
123
+	}
124
+
125
+	public function attempted($semesters, $is_grad)
126
+	{
127
+		$semesters_array=[];
128
+		foreach($semesters as $semester)
129
+		{
130
+			$semesters_array[]=$semester->id;
131
+		}
132
+		 $criteria=DB::table('new_criteria')
133
+	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
134
+	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
135
+	    	->join('courses', 'activities.course_id', '=', 'courses.id')
136
+	    	->join('programs', 'programs.id', '=', 'courses.program_id')
137
+	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
138
+	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
139
+	    	->where('programs.is_graduate','=',$is_grad)
140
+	    	->whereIn('courses.semester_id',$semesters_array)
141
+	    	->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
142
+	    	->distinct()
143
+	    	->get()
144
+			;
145
+		$conteo=0;
146
+		foreach($criteria as $criterion)
147
+		{
148
+			$students_attempted=Criterion::students_attempted($criterion->id, $criterion->activity_id);
149
+			if($students_attempted)
150
+			{
151
+				$conteo++;
152
+			}
153
+		}
154
+// 		var_dump($conteo);
155
+// 		exit();
156
+		return $conteo;
157
+	}
158
+
159
+	public function courses_attempted($courses)
160
+	{
161
+		$courses_array=[];
162
+		foreach($courses as $course)
163
+		{
164
+// 		var_dump($course);
165
+// 		exit();
166
+			$courses_array[]=$course->id;
167
+		}
168
+		 $criteria=DB::table('new_criteria')
169
+	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
170
+	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
171
+	    	->join('courses', 'activities.course_id', '=', 'courses.id')
172
+	    	->join('programs', 'programs.id', '=', 'courses.program_id')
173
+	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
174
+	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
175
+	    	->whereIn('courses.id',$courses_array)
176
+	    	->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
177
+	    	->distinct()
178
+	    	->get()
179
+			;
180
+		$conteo=0;
181
+		foreach($criteria as $criterion)
182
+		{
183
+			$students_attempted=Criterion::students_attempted($criterion->id, $criterion->activity_id);
184
+			if($students_attempted)
185
+			{
186
+				$conteo++;
187
+			}
188
+		}
189
+// 		var_dump($conteo);
190
+// 		exit();
191
+		return $conteo;
192
+	}
193
+
194
+	public function courses_achieved($courses)
195
+	{
196
+		$courses_array=[];
197
+		foreach($courses as $course)
198
+		{
199
+			$courses_array[]=$course->id;
200
+		}
201
+
202
+		 $criteria=DB::table('new_criteria')
203
+	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
204
+	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
205
+	    	->join('courses', 'activities.course_id', '=', 'courses.id')
206
+	    	->join('programs', 'programs.id', '=', 'courses.program_id')
207
+	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
208
+	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
209
+	    	->whereIn('courses.id',$courses_array)
210
+	    	->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
211
+	    	->distinct()
212
+	    	->get()
213
+			;
214
+
215
+
216
+		$conteo=0;
217
+		foreach($criteria as $criterion)
218
+		{
219
+			$students_attempted=Criterion::students_attempted($criterion->id, $criterion->activity_id);
220
+			$students_achieved=Criterion::students_achieved($criterion->id, $criterion->activity_id);
221
+
222
+			if($students_attempted)
223
+			{
224
+				$percentage_students_who_achieved=100.0*$students_achieved/$students_attempted;
225
+			}
226
+			else
227
+			{
228
+				$percentage_students_who_achieved=0;
229
+			}
230
+			if($percentage_students_who_achieved>=$criterion->expected_percentage_students_achieving)
231
+			{
232
+				$conteo++;
233
+			}
234
+		}
235
+		return $conteo;
236
+	}
237
+
238
+	public function achieved($semesters, $is_grad)
239
+	{
240
+		$semesters_array=[];
241
+		foreach($semesters as $semester)
242
+		{
243
+			$semesters_array[]=$semester->id;
244
+		}
245
+
246
+//   DB::enableQueryLog();
247
+		 $criteria=DB::table('new_criteria')
248
+	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
249
+	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
250
+	    	->join('courses', 'activities.course_id', '=', 'courses.id')
251
+	    	->join('programs', 'programs.id', '=', 'courses.program_id')
252
+	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
253
+	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
254
+	    	->where('programs.is_graduate','=',$is_grad)
255
+	    	->whereIn('courses.semester_id',$semesters_array)
256
+	    	->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
257
+	    	->distinct()
258
+	    	->get()
259
+			;
260
+// 		dd(DB::getQueryLog());
261
+
262
+		$conteo=0;
263
+		foreach($criteria as $criterion)
264
+		{
265
+			$students_attempted=Criterion::students_attempted($criterion->id, $criterion->activity_id);
266
+			$students_achieved=Criterion::students_achieved($criterion->id, $criterion->activity_id);
267
+
268
+			if($students_attempted)
269
+			{
270
+				$percentage_students_who_achieved=100.0*$students_achieved/$students_attempted;
271
+			}
272
+			else
273
+			{
274
+				$percentage_students_who_achieved=0;
275
+			}
276
+			if($percentage_students_who_achieved>=$criterion->expected_percentage_students_achieving)
277
+			{
278
+				$conteo++;
279
+			}
280
+		}
281
+		return $conteo;
282
+	}
283
+
284
+
285
+// 	public function achieved($semester, $is_grad)
286
+// 	{
287
+//
288
+// //   DB::enableQueryLog();
289
+// 		 $criteria=DB::table('new_criteria')
290
+// 	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
291
+// 	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
292
+// 	    	->join('courses', 'activities.course_id', '=', 'courses.id')
293
+// 	    	->join('programs', 'programs.id', '=', 'courses.program_id')
294
+// 	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
295
+// 	    	->where('criterion_objective_outcome.outcome_id','=',$this->id)
296
+// 	    	->where('programs.is_graduate','=',$is_grad)
297
+// 	    	->where('courses.semester_id','=',$semester)
298
+// 	    	->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
299
+// 	    	->distinct()
300
+// 	    	->get()
301
+// 			;
302
+// // 		dd(DB::getQueryLog());
303
+//
304
+// 		$conteo=0;
305
+// 		foreach($criteria as $criterion)
306
+// 		{
307
+// 			$outcome_performance=DB::table('outcome_performance')
308
+// 				->where('outcome_performance.outcome_id','=',$this->id)
309
+// 				->where('outcome_performance.criterion_id','=',$criterion->id)
310
+// 				->where('outcome_performance.semester_id','=',$semester)
311
+// 				->where('outcome_performance.level','=',$is_grad)
312
+// 				->select('students_attempted','students_achieved')
313
+// 				->first();
314
+// 			if(!empty($outcome_performance) and $outcome_performance->students_attempted)
315
+// 			{
316
+// 				$percentage_students_who_achieved=100.0*$outcome_performance->students_achieved/$outcome_performance->students_attempted;
317
+// 			}
318
+// 			else
319
+// 			{
320
+// 				$students_attempted=Criterion::students_attempted($criterion->id, $criterion->activity_id);
321
+// 				$students_achieved=Criterion::students_achieved($criterion->id, $criterion->activity_id);
322
+//
323
+// 				if($students_attempted)
324
+// 				{
325
+// 					$percentage_students_who_achieved=100.0*$students_achieved/$students_attempted;
326
+// 					DB::table('outcome_performance')->insert(array('criterion_id'=>$criterion->id,'outcome_id'=>$this->id,'semester_id'=>$semester,
327
+// 					'students_attempted' => $students_attempted,'students_achieved' => $students_achieved,'level'=>$is_grad));
328
+// 				}
329
+// 				else
330
+// 				{
331
+// 					$percentage_students_who_achieved=0;
332
+// 				}
333
+// 			}
334
+// 			if($percentage_students_who_achieved>=$criterion->expected_percentage_students_achieving)
335
+// 			{
336
+// 				$conteo++;
337
+// 			}
338
+// 		}
339
+// 		return $conteo;
340
+// 	}
341
+//
27 342
 
28 343
 	public static function active()
29 344
     {

+ 210
- 0
app/models/Program.php Ver arquivo

@@ -102,6 +102,216 @@ class Program extends Eloquent
102 102
 		return $this->hasMany('Criterion');
103 103
 	}
104 104
 
105
+// 	public function attempted_outcome($outcome_id, $semester)
106
+// 	{
107
+// 		$conteo= DB::table('activity_criterion')
108
+// 	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
109
+// 	    	->join('courses', 'activities.course_id', '=', 'courses.id')
110
+// 	    	->join('programs', 'programs.id', '=', 'courses.program_id')
111
+// 	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'activity_criterion.criterion_id')
112
+// 	    	->where('criterion_objective_outcome.outcome_id','=',$outcome_id)
113
+// 	    	->where('programs.id','=',$this->id)
114
+// 	    	->where('courses.semester_id','=',$semester)
115
+// 	    	->count(DB::raw('DISTINCT criterion_objective_outcome.outcome_id'))
116
+// 			;	    	
117
+// 		return $conteo;		
118
+// 	}
119
+
120
+	public function attempted_criteria_by_outcome($outcome_id, $semesters)
121
+	{
122
+		$semesters_array=[];
123
+		foreach($semesters as $semester)
124
+		{
125
+			$semesters_array[]=$semester->id;
126
+		}
127
+		
128
+		$conteo= DB::table('activity_criterion')
129
+	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
130
+	    	->join('courses', 'activities.course_id', '=', 'courses.id')
131
+	    	->join('programs', 'programs.id', '=', 'courses.program_id')
132
+	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'activity_criterion.criterion_id')
133
+	    	->where('criterion_objective_outcome.outcome_id','=',$outcome_id)
134
+	    	->where('programs.id','=',$this->id)
135
+	    	->whereIn('courses.semester_id',$semesters_array)
136
+	    	->count(DB::raw('DISTINCT criterion_objective_outcome.criterion_id'))
137
+			;	    	
138
+		return $conteo;		
139
+	}
140
+
141
+	public function attempted_outcome($outcome_id, $semesters)
142
+	{
143
+		$semesters_array=[];
144
+		foreach($semesters as $semester)
145
+		{
146
+			$semesters_array[]=$semester->id;
147
+		}
148
+		
149
+		$conteo= DB::table('activity_criterion')
150
+	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
151
+	    	->join('courses', 'activities.course_id', '=', 'courses.id')
152
+	    	->join('programs', 'programs.id', '=', 'courses.program_id')
153
+	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'activity_criterion.criterion_id')
154
+	    	->where('criterion_objective_outcome.outcome_id','=',$outcome_id)
155
+	    	->where('programs.id','=',$this->id)
156
+	    	->whereIn('courses.semester_id',$semesters_array)
157
+	    	->count(DB::raw('DISTINCT criterion_objective_outcome.outcome_id'))
158
+			;	    	
159
+		return $conteo;		
160
+	}
161
+	
162
+	public function achieved_criteria_by_outcome($outcome_id, $semesters)
163
+	{
164
+		$semesters_array=[];
165
+		foreach($semesters as $semester)
166
+		{
167
+			$semesters_array[]=$semester->id;
168
+		}
169
+		
170
+//   DB::enableQueryLog();
171
+// 		dd(DB::getQueryLog());
172
+		 $criteria=DB::table('new_criteria')
173
+	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
174
+	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
175
+	    	->join('courses', 'activities.course_id', '=', 'courses.id')
176
+	    	->join('programs', 'programs.id', '=', 'courses.program_id')
177
+	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
178
+	    	->where('criterion_objective_outcome.outcome_id','=',$outcome_id)
179
+	    	->where('programs.id','=',$this->id)
180
+	    	->whereIn('courses.semester_id',$semesters_array)
181
+	    	->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
182
+	    	->distinct()
183
+	    	->get()
184
+			;
185
+// 		dd(DB::getQueryLog());
186
+		 
187
+		$conteo=0;
188
+		$attempted_criteria_per_program_array=[];
189
+// 		$students_attempted=0;
190
+// 		$students_achieved=0;
191
+		foreach($criteria as $criterion)
192
+		{	
193
+			if(!isset($students_attempted[$criterion->id]))$students_attempted[$criterion->id]=0;
194
+			if(!isset($students_achieved[$criterion->id]))$students_achieved[$criterion->id]=0;
195
+			$attempted_criteria_per_program_array[$criterion->id]=1;
196
+			$students_attempted[$criterion->id]+=Criterion::students_attempted($criterion->id, $criterion->activity_id);
197
+			$students_achieved[$criterion->id]+=Criterion::students_achieved($criterion->id, $criterion->activity_id);
198
+		}
199
+// 		var_dump($outcome_id);
200
+// 		var_dump($this->id);
201
+// 		if(isset($students_attempted))var_dump($students_attempted);
202
+// 		else{print "aqui hay algo";}
203
+// 		print "<br>";
204
+// 		if(isset($students_achieved))var_dump($students_achieved);
205
+// 		print "<br>";
206
+// 		print "<br>";
207
+// 			exit();
208
+		if(isset($students_attempted))
209
+		{
210
+			foreach($students_attempted as $criteria_id => $students_attempted_n)
211
+			{
212
+				if($students_attempted_n)
213
+				{
214
+					$percentage_students_who_achieved=100.0*$students_achieved[$criteria_id]/$students_attempted[$criteria_id];
215
+				}
216
+				else
217
+				{
218
+					$percentage_students_who_achieved=0;
219
+				}
220
+				if($percentage_students_who_achieved>=$criterion->expected_percentage_students_achieving)
221
+				{
222
+					$conteo++;
223
+				}
224
+			}		
225
+		}
226
+		$attempted_criteria_per_program=count($attempted_criteria_per_program_array);
227
+		$achievedProgramOutcome=0;
228
+		$outcome=Outcome::where('id',$outcome_id)->select('expected_outcome')->first();
229
+// 		var_dump($outcome->expected_outcome);
230
+// 		exit();
231
+		if($attempted_criteria_per_program!=0 && 100.0*$conteo/$attempted_criteria_per_program >= $outcome->expected_outcome)
232
+		{
233
+			$achievedProgramOutcome=1;
234
+			// $output[]= 'END OF PROGRAM: '.$program->name.'-'.json_encode($achievedProgramsPerOutcome);
235
+		}
236
+		return $conteo;
237
+	}
238
+
239
+	public function achieved_outcome($outcome_id, $semesters)
240
+	{
241
+		$semesters_array=[];
242
+		foreach($semesters as $semester)
243
+		{
244
+			$semesters_array[]=$semester->id;
245
+		}
246
+		
247
+//   DB::enableQueryLog();
248
+// 		dd(DB::getQueryLog());
249
+		 $criteria=DB::table('new_criteria')
250
+	    	->join('activity_criterion', 'activity_criterion.criterion_id', '=', 'new_criteria.id')
251
+	    	->join('activities', 'activity_criterion.activity_id', '=', 'activities.id')
252
+	    	->join('courses', 'activities.course_id', '=', 'courses.id')
253
+	    	->join('programs', 'programs.id', '=', 'courses.program_id')
254
+	    	->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'new_criteria.id')
255
+	    	->where('criterion_objective_outcome.outcome_id','=',$outcome_id)
256
+	    	->where('programs.id','=',$this->id)
257
+	    	->whereIn('courses.semester_id',$semesters_array)
258
+	    	->select('new_criteria.id','expected_percentage_students_achieving','activity_criterion.activity_id')
259
+	    	->distinct()
260
+	    	->get()
261
+			;
262
+// 		dd(DB::getQueryLog());
263
+		 
264
+		$conteo=0;
265
+		$attempted_criteria_per_program_array=[];
266
+// 		$students_attempted=0;
267
+// 		$students_achieved=0;
268
+		foreach($criteria as $criterion)
269
+		{	
270
+			if(!isset($students_attempted[$criterion->id]))$students_attempted[$criterion->id]=0;
271
+			if(!isset($students_achieved[$criterion->id]))$students_achieved[$criterion->id]=0;
272
+			$attempted_criteria_per_program_array[$criterion->id]=1;
273
+			$students_attempted[$criterion->id]+=Criterion::students_attempted($criterion->id, $criterion->activity_id);
274
+			$students_achieved[$criterion->id]+=Criterion::students_achieved($criterion->id, $criterion->activity_id);
275
+		}
276
+// 		var_dump($outcome_id);
277
+// 		var_dump($this->id);
278
+// 		if(isset($students_attempted))var_dump($students_attempted);
279
+// 		else{print "aqui hay algo";}
280
+// 		print "<br>";
281
+// 		if(isset($students_achieved))var_dump($students_achieved);
282
+// 		print "<br>";
283
+// 		print "<br>";
284
+// 			exit();
285
+		if(isset($students_attempted))
286
+		{
287
+			foreach($students_attempted as $criteria_id => $students_attempted_n)
288
+			{
289
+				if($students_attempted_n)
290
+				{
291
+					$percentage_students_who_achieved=100.0*$students_achieved[$criteria_id]/$students_attempted[$criteria_id];
292
+				}
293
+				else
294
+				{
295
+					$percentage_students_who_achieved=0;
296
+				}
297
+				if($percentage_students_who_achieved>=$criterion->expected_percentage_students_achieving)
298
+				{
299
+					$conteo++;
300
+				}
301
+			}		
302
+		}
303
+		$attempted_criteria_per_program=count($attempted_criteria_per_program_array);
304
+		$achievedProgramOutcome=0;
305
+		$outcome=Outcome::where('id',$outcome_id)->select('expected_outcome')->first();
306
+// 		var_dump($outcome->expected_outcome);
307
+// 		exit();
308
+		if($attempted_criteria_per_program!=0 && 100.0*$conteo/$attempted_criteria_per_program >= $outcome->expected_outcome)
309
+		{
310
+			$achievedProgramOutcome=1;
311
+			// $output[]= 'END OF PROGRAM: '.$program->name.'-'.json_encode($achievedProgramsPerOutcome);
312
+		}
313
+		return $achievedProgramOutcome;
314
+	}
105 315
 
106 316
 	public static function generalComponentPrograms(){
107 317
 		return self::whereIn('id', array(123,124,125,126,127,128,129))->get();

+ 17
- 0
app/models/Scale.php Ver arquivo

@@ -0,0 +1,17 @@
1
+<?php
2
+
3
+use Illuminate\Database\Eloquent\SoftDeletingTrait;
4
+
5
+class Scale extends Eloquent
6
+{
7
+    use SoftDeletingTrait;
8
+    protected $dates = ['deleted_at'];
9
+
10
+    protected $table = 'scales';
11
+
12
+    public function outcomes()
13
+    {
14
+        //
15
+
16
+    }
17
+}

+ 13
- 12
app/models/User.php Ver arquivo

@@ -7,7 +7,8 @@ use Illuminate\Auth\Reminders\RemindableInterface;
7 7
 
8 8
 use Zizaco\Entrust\HasRole;
9 9
 
10
-class User extends Eloquent implements UserInterface, RemindableInterface {
10
+class User extends Eloquent implements UserInterface, RemindableInterface
11
+{
11 12
 
12 13
 	use UserTrait, RemindableTrait, HasRole;
13 14
 
@@ -31,17 +32,17 @@ class User extends Eloquent implements UserInterface, RemindableInterface {
31 32
 	protected $fillable = array('ssn', 'first_name', 'surnames', 'email', 'role', 'school_id', 'has_access', 'cell_phone', 'office_phone', 'office_extension');
32 33
 
33 34
 	/**
34
-     * Searchable rules.
35
-     *
36
-     * @var array
37
-     */
38
-    protected $searchable = [
39
-        'columns' => [
40
-            'first_name' => 10,
41
-            'surnames' => 10,
42
-            'email' => 2,
43
-        ],
44
-    ];
35
+	 * Searchable rules.
36
+	 *
37
+	 * @var array
38
+	 */
39
+	protected $searchable = [
40
+		'columns' => [
41
+			'first_name' => 10,
42
+			'surnames' => 10,
43
+			'email' => 2,
44
+		],
45
+	];
45 46
 
46 47
 
47 48
 	public function program()

+ 178
- 123
app/routes.php Ver arquivo

@@ -33,8 +33,7 @@ View::composer(array(
33 33
     'local.managers.admins._navigation',
34 34
     'local.managers.sCoords._navigation',
35 35
     'local.managers.pCoords._navigation',
36
-    ), function($view)
37
-{
36
+), function ($view) {
38 37
     // Get user's courses' numbers
39 38
     $courses = Auth::user()->courses;
40 39
 
@@ -54,10 +53,11 @@ View::composer(array(
54 53
     'local.managers.shared.program',
55 54
     'local.managers.shared.rubrics',
56 55
     'global.view-learning-outcomes-criteria',
57
-    'global.view-learning-outcomes-criteria'), function($view)
58
-    {
59
-        $view->with('role', Auth::user()->role);
60
-    });
56
+    'global.view-learning-outcomes-criteria',
57
+    'global.view-three-year-plan'
58
+), function ($view) {
59
+    $view->with('role', Auth::user()->role);
60
+});
61 61
 
62 62
 
63 63
 /*
@@ -66,33 +66,29 @@ View::composer(array(
66 66
 
67 67
 /** Use modified guest filter to redirect logged in user */
68 68
 Route::get('/', array('before' => 'guest', 'uses' => 'AuthController@showLogin'));
69
-Route::post('/login', array('uses'=>'AuthController@login'));
69
+Route::post('/login', array('uses' => 'AuthController@login'));
70 70
 
71 71
 /**
72 72
  * Protected Routes
73 73
  */
74
-Route::group(array('before' => 'auth|has_access'), function()
75
-{
74
+Route::group(array('before' => 'auth|has_access'), function () {
76 75
 
77 76
     /**
78 77
      * Recalculate course outcomes
79 78
      *
80
-    */
79
+     */
81 80
 
82
-    Route::get('recalculateCourses', function()
83
-    {
81
+    Route::get('recalculateCourses', function () {
84 82
 
85 83
         DB::disableQueryLog();
86 84
 
87
-        if(Auth::user()->id!=58)
85
+        if (Auth::user()->id != 58)
88 86
             Redirect::action('AuthController@showLogin');
89 87
 
90
-        try
91
-        {
88
+        try {
92 89
             $courses = Course::all();
93 90
 
94
-            foreach ($courses as $course)
95
-            {
91
+            foreach ($courses as $course) {
96 92
                 echo $course->id;
97 93
                 // Recalculate course outcomes
98 94
                 $activities = Activity::where('course_id', $course->id)
@@ -102,8 +98,7 @@ Route::group(array('before' => 'auth|has_access'), function()
102 98
 
103 99
 
104 100
                 //If there are still evaluated activities in the course, recalculate course outcomes
105
-                if(!$activities->isEmpty())
106
-                {
101
+                if (!$activities->isEmpty()) {
107 102
                     $outcomeCount = Outcome::all()->count();
108 103
 
109 104
                     // Variables to hold recalculated outcomes for the course
@@ -111,104 +106,112 @@ Route::group(array('before' => 'auth|has_access'), function()
111 106
                     $course_outcomes_achieved = array_fill(1, $outcomeCount, 0);
112 107
 
113 108
                     // For each activity
114
-                    foreach ($activities as $activity2)
115
-                    {
109
+                    foreach ($activities as $activity2) {
116 110
                         // If activity has been assessed
117
-                        if($activity2->outcomes_attempted!=NULL)
118
-                        {
111
+                        if ($activity2->outcomes_attempted != NULL) {
119 112
                             echo '<ul>';
120 113
                             // Get the achieved criteria
121 114
                             $criteria_achievement = json_decode($activity2->criteria_achieved, true);
122
-                            foreach($criteria_achievement as $criterion_id=>$criterion_achieved)
123
-                            {
115
+                            foreach ($criteria_achievement as $criterion_id => $criterion_achieved) {
124 116
                                 // Find corresponding learning outcome;
125 117
                                 $criterion = Criterion::withTrashed()->where('id', $criterion_id)->first();
126 118
 
127
-                                print '<li>'.$criterion->id.'</li>';
119
+                                print '<li>' . $criterion->id . '</li>';
128 120
 
129 121
 
130 122
                                 $outcome = Outcome::find($criterion->outcome_id);
131 123
 
132 124
                                 // If criterion is achieved (1), add 1 to both arrays
133
-                                if($criterion_achieved === 1)
134
-                                {
135
-                                    $course_outcomes_attempted[$outcome->id]+=1;
136
-                                    $course_outcomes_achieved[$outcome->id]+=1;
125
+                                if ($criterion_achieved === 1) {
126
+                                    $course_outcomes_attempted[$outcome->id] += 1;
127
+                                    $course_outcomes_achieved[$outcome->id] += 1;
137 128
                                 }
138 129
                                 // Else, only add to the attempted outcomes arrays
139
-                                elseif($criterion_achieved === 0)
140
-                                {
141
-                                    $course_outcomes_attempted[$outcome->id]+=1;
130
+                                elseif ($criterion_achieved === 0) {
131
+                                    $course_outcomes_attempted[$outcome->id] += 1;
142 132
                                 }
143 133
                             }
144 134
 
145 135
                             echo '</ul>';
146
-
147 136
                         }
148 137
                     }
149 138
 
150 139
                     // Update course
151 140
                     DB::table('courses')
152
-                    ->where('id', $course->id)
153
-                    ->update(array(
154
-                        'outcomes_attempted'=> json_encode($course_outcomes_attempted),
155
-                        'outcomes_achieved'=> json_encode($course_outcomes_achieved),
156
-                        'updated_at' => date('Y-m-d H:i:s'))
157
-                    );
141
+                        ->where('id', $course->id)
142
+                        ->update(array(
143
+                            'outcomes_attempted' => json_encode($course_outcomes_attempted),
144
+                            'outcomes_achieved' => json_encode($course_outcomes_achieved),
145
+                            'updated_at' => date('Y-m-d H:i:s')
146
+                        ));
158 147
                 }
159 148
                 // Otherwise, set them all to NULL
160
-                else
161
-                {
149
+                else {
162 150
                     DB::table('courses')
163
-                    ->where('id', $course->id)
164
-                    ->update(array(
165
-                        'outcomes_attempted'=> NULL,
166
-                        'outcomes_achieved'=> NULL,
167
-                        'updated_at' => date('Y-m-d H:i:s'))
168
-                    );
151
+                        ->where('id', $course->id)
152
+                        ->update(array(
153
+                            'outcomes_attempted' => NULL,
154
+                            'outcomes_achieved' => NULL,
155
+                            'updated_at' => date('Y-m-d H:i:s')
156
+                        ));
169 157
                 }
170 158
             }
171 159
 
172 160
             return 'success';
173
-        }
174
-        catch(Exception $e)
175
-        {
176
-            return 'failure ('.$e->getLine().'): '.$e->getMessage();
161
+        } catch (Exception $e) {
162
+            return 'failure (' . $e->getLine() . '): ' . $e->getMessage();
177 163
         }
178 164
     });
179 165
 
180 166
     /**
181
-    * Shared Routes
182
-    */
167
+     * Shared Routes
168
+     */
183 169
 
184 170
     // Fetch all criteria associated to an outcome
185
-    Route::post( 'fetchCriteria', array(
171
+    Route::post('fetchCriteria', array(
186 172
         'as' => 'fetchCriteria',
187 173
         'uses' => 'OutcomesController@fetchCriteria'
188
-    ) );
174
+    ));
189 175
 
190 176
     // Fetch a criterion for a rubric
191
-    Route::post( 'fetchCriterion', array(
177
+    Route::post('fetchCriterion', array(
192 178
         'as' => 'fetchCriterion',
193 179
         'uses' => 'CriteriaController@fetchCriterion'
194
-    ) );
195
-
180
+    ));
181
+    // Fetch Criterions associated to programs
182
+    Route::post('fetchAllCriterion', array(
183
+        'as' => 'fetchAllCriterion',
184
+        'uses' => 'CriteriaController@fetchAllCriterion'
185
+    ));
186
+    Route::post('delete', array(
187
+        'as' => 'delete',
188
+        'uses' => 'CriteriaController@delete'
189
+    ));
190
+    Route::post('delete', array(
191
+        'as' => 'delete',
192
+        'uses' => 'TransformativeActionsController@deleteTA'
193
+    ));
196 194
     // Fetch a criterion for a rubric
197
-    Route::post( 'fetchCriterionWithTrashed', array(
195
+    Route::post('fetchCriterionWithTrashed', array(
198 196
         'as' => 'fetchCriterionWithTrashed',
199 197
         'uses' => 'CriteriaController@fetchCriterionWithTrashed'
200
-    ) );
198
+    ));
199
+    //Fetch objectives for criteria when outcome is chosen
200
+    Route::post('fetchObjectivesForSelect', array(
201
+        'as' => 'fetchObjectivesForSelect',
202
+        'uses' => 'CriteriaController@fetchObjectivesForSelect'
203
+    ));
201 204
 
202 205
     // Fetch a criterion for a rubric with custom content
203
-    Route::post( 'fetchRubricCriterion', array(
206
+    Route::post('fetchRubricCriterion', array(
204 207
         'as' => 'fetchRubricCriterion',
205 208
         'uses' => 'RubricsController@fetchRubricCriterion'
206
-    ) );
209
+    ));
207 210
 
208 211
     // Load a rubric template
209
-    Route::post('loadTemplate', array('uses'=>'TemplatesController@fetch'));
212
+    Route::post('loadTemplate', array('uses' => 'TemplatesController@fetch'));
210 213
 
211
-    Route::post('filterSemesters', array('uses'=>'SemestersController@filterSemesters'));
214
+    Route::post('filterSemesters', array('uses' => 'SemestersController@filterSemesters'));
212 215
 
213 216
 
214 217
     // Log out user
@@ -216,57 +219,71 @@ Route::group(array('before' => 'auth|has_access'), function()
216 219
 
217 220
     // Edit and update user profile
218 221
     Route::get('profile', 'UsersController@edit');
219
-    Route::post('profile/update', array('before' => 'csrf', 'uses'=>'UsersController@update'));
222
+    Route::post('profile/update', array('before' => 'csrf', 'uses' => 'UsersController@update'));
220 223
 
221 224
     // Allows users to give feeback
222
-    Route::post('feedback/send', array('before' => 'csrf', 'uses'=>'FeedbackController@send'));
223
-    Route::resource('feedback', 'FeedbackController',
224
-                array('only' => array('create')));
225
+    Route::post('feedback/send', array('before' => 'csrf', 'uses' => 'FeedbackController@send'));
226
+    Route::resource(
227
+        'feedback',
228
+        'FeedbackController',
229
+        array('only' => array('create'))
230
+    );
225 231
 
226 232
     // Show users all learning outcomes and criteria
227 233
     Route::get('learning-outcomes-criteria', 'CriteriaController@index');
228
-    Route::post('fetchOutcome', array('before' => 'csrf', 'uses'=>'OutcomesController@fetchOutcome'));
234
+    Route::post('fetchOutcome', array('before' => 'csrf', 'uses' => 'OutcomesController@fetchOutcome'));
229 235
     // Show users all objectives and criteria
230 236
     Route::get('learning-objectives-criteria', 'CriteriaController@objectivesIndex');
231
-    Route::post('fetchObjectiveForCriteria', array('before' => 'csrf', 'uses'=>'ObjectivesController@fetchObjectiveForCriteria'));
237
+    Route::post('fetchObjectiveForCriteria', array('before' => 'csrf', 'uses' => 'ObjectivesController@fetchObjectiveForCriteria'));
232 238
 
233 239
     // Show professor overview to users with courses
234 240
     Route::get('professor', 'ProfessorsController@overview');
235 241
 
236 242
     // Assessment reports for users' courses
237 243
     Route::get('my-assessment-reports', 'OutcomesController@professorAssessmentReports');
238
-    Route::post('objectives/fetch', array('before' => 'csrf', 'uses'=>'ObjectivesController@fetch'));
244
+    Route::post('objectives/fetch', array('before' => 'csrf', 'uses' => 'ObjectivesController@fetch'));
245
+
246
+    // Transformative Actions for p-coordinators and professors
247
+    Route::get('transformativeAction', array('uses' => 'TransformativeActionsController@editTA'));
248
+    Route::post('transformativeAction/createTA', array('before' => 'csrf', 'uses' => 'TransformativeActionsController@createTA'));
249
+    Route::post('transformativeAction/selectTA', array('before' => 'csrf', 'uses' => 'TransformativeActionsController@selectTA'));
250
+    Route::post('transformativeAction/updateTA', array('before' => 'csrf', 'uses'=>'TransformativeActionsController@updateTA'));
251
+    Route::post('transformativeAction/filterTA', array('before' => 'csrf', 'uses'=>'TransformativeActionsController@filterTA'));
252
+    Route::post('transformativeAction/objectivesFromOutcome', array('before' => 'csrf', 'uses'=>'TransformativeActionsController@objectivesFromOutcome'));
239 253
 
240 254
     /**
241 255
      * Administrator Routes
242 256
      */
243
-    Route::group( array('before' => 'admin'), function()
244
-    {
257
+    Route::group(array('before' => 'admin'), function () {
245 258
         Route::get('/administrator', 'AdministratorsController@overview');
246
-        Route::post( 'administrator/rubrics', array(
259
+        Route::post('administrator/rubrics', array(
247 260
             'as' => 'rubrics',
248 261
             'before' => 'csrf',
249 262
             'uses' => 'CriteriaController@fetch'
250
-        ) );
251
-        Route::post('createOutcome', array('before' => 'csrf', 'uses'=>'OutcomesController@create'));
252
-        Route::post('createCriterion', array('before' => 'csrf', 'uses'=>'CriteriaController@create'));
263
+        ));
264
+        Route::post('createOutcome', array('before' => 'csrf', 'uses' => 'OutcomesController@create'));
265
+        Route::post('createCriterion', array('before' => 'csrf', 'uses' => 'CriteriaController@create'));
253 266
 
254 267
         Route::get('learning-outcomes', 'OutcomesController@index');
268
+        Route::post('fetchObjectives', 'Objective2Controller@fetchAllObjectives');
255 269
         // TODO: Change later
256 270
         Route::get('new-learning-outcomes', 'OutcomesController@newIndex');
257
-        Route::post('learning-outcomes/update', array('before' => 'csrf', 'uses' => 'OutcomesController@update'));
271
+
258 272
         Route::post('learning-outcomes/update', array('before' => 'csrf', 'uses' => 'OutcomesController@updateMore'));
259
-        Route::post('crtiteria/update', array('before' => 'csrf', 'uses'=>'CriteriaController@update'));
260
-        Route::delete('crtiteria/delete', array('before' => 'csrf', 'uses'=>'CriteriaController@destroy'));
273
+        Route::post('learning-outcomes/update', array('before' => 'csrf', 'uses' => 'OutcomesController@update'));
274
+        Route::post('crtiteria/update', array('before' => 'csrf', 'uses' => 'CriteriaController@update'));
275
+        Route::delete('crtiteria/delete', array('before' => 'csrf', 'uses' => 'CriteriaController@destroy'));
261 276
 
262 277
         Route::get('administrator/users/{query?}', 'UsersController@index');
263 278
 
264
-        Route::post('administrator/updateAccess', array('before' => 'csrf', 'uses'=>'UsersController@updateAccess'));
265
-        Route::post('administrator/users/store', array('before' => 'csrf', 'uses'=>'UsersController@store'));
266
-
279
+        Route::post('administrator/updateAccess', array('before' => 'csrf', 'uses' => 'UsersController@updateAccess'));
280
+        Route::post('administrator/users/store', array('before' => 'csrf', 'uses' => 'UsersController@store'));
267 281
 
282
+        Route::get('criteria', array('uses' => 'CriteriaController@edit'));
283
+        Route::get('objectives', array('uses' => 'Objective2Controller@edit'));
268 284
         Route::get('administrator/semesters', 'SemestersController@edit');
269 285
         Route::post('administrator/semesters/update', 'SemestersController@update');
286
+        Route::post('deleteObjective', 'Objective2Controller@delete');
270 287
 
271 288
         Route::get('assessment-report/{outcome_id}', 'OutcomesController@assessmentReport');
272 289
         // TODO: Change later
@@ -277,51 +294,70 @@ Route::group(array('before' => 'auth|has_access'), function()
277 294
         Route::get('template/{template}', 'TemplatesController@show');
278 295
 
279 296
         Route::get('courses/reassign', 'CoursesController@reassign');
280
-        Route::post('courses/update', array('before' => 'csrf', 'uses'=>'CoursesController@update'));
297
+        Route::post('courses/update', array('before' => 'csrf', 'uses' => 'CoursesController@update'));
281 298
 
282 299
         Route::get('activities/create', 'ActivitiesController@newCreate');
283
-
284 300
     });
285 301
 
286 302
     /**
287 303
      * School Coordinator Routes
288 304
      */
289
-    Route::group( array('before' => 'scoord'), function()
290
-    {
305
+    Route::group(array('before' => 'scoord'), function () {
291 306
         Route::get('school-coordinator', 'SchoolCoordinatorsController@overview');
292 307
         Route::get('school/{id}', 'SchoolsController@show');
293 308
         Route::get('program/{id}', 'ProgramsController@show');
294 309
         Route::post('programs/report', 'ProgramsController@showReport');
310
+        // Route::post('storeTypInfo', 'OutcomesController@storeCycleInfo'); //TODO: where is this route supposed to be placed?
295 311
         Route::get('programs', 'ProgramsController@index');
296 312
         Route::get('template-list', 'TemplatesController@schoolCoordinatorIndex');
297
-
313
+        Route::post('deleteObjective', 'Objective2Controller@delete');
298 314
         // Print school report
299 315
         Route::get('print_school/{id}', 'SchoolsController@print_school');
300 316
 
301 317
         // Assessment reports
302 318
         Route::get('school-assessment-report/{outcome_id}', 'OutcomesController@schoolAssessmentReport');
319
+
320
+        // Gabriel added this, so the school coordinator can add criterias and objectives
321
+        Route::get('school-objective', 'Objective2Controller@editSchool');
322
+        Route::get('school-criteria', 'CriteriaController@editSchool');
323
+
324
+        // Show users plan de tres a~nos
325
+        Route::get('three-years-plan', 'ThreeYearPlanController@threeYearsReport');
326
+        Route::post('fetchThreeYears', array('before' => 'csrf', 'uses'=>'ThreeYearPlanController@fetchThreeYears'));
327
+        Route::post('typ/lookUp', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@lookup_typ_semester_outcome'));
328
+        Route::post('section2_arrive', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@section2_arrive'));
329
+        Route::post('section2_on_change', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@section2_on_change'));
330
+        Route::post('section3_arrive', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@section3_arrive'));
331
+        Route::post('section3_on_change', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@section3_on_change'));
332
+        Route::post('typ/getObjectives', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@getObjectivesForTYP'));
333
+        Route::post('typ/updateOutcomeSemsters', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@typ_update_outcomes_semesters'));
334
+        Route::post('typ/update', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@update_typ_outcomes_semesters'));
335
+
303 336
     });
304 337
 
338
+
305 339
     /**
306 340
      * Program Coordinator Routes
307 341
      */
308
-    Route::group( array('before' => 'pcoord'), function()
309
-    {
342
+    Route::group(array('before' => 'pcoord'), function () {
310 343
         Route::get('program-coordinator', 'ProgramCoordinatorsController@overview');
311
-
344
+        Route::post('deleteObjective', 'Objective2Controller@delete');
312 345
         Route::get('rubrics', 'TemplatesController@newTemplate');
313
-        Route::post('saveTemplate', array('before' => 'csrf', 'uses'=>'TemplatesController@create'));
314
-        Route::post('updateTemplate', array('before' => 'csrf', 'uses'=>'TemplatesController@update'));
315
-        Route::post('deleteTemplate', array('before' => 'csrf', 'uses'=>'TemplatesController@destroy'));
316
-        Route::get('criteria', 'CriteriaController@edit');
346
+        Route::post('saveTemplate', array('before' => 'csrf', 'uses' => 'TemplatesController@create'));
347
+        Route::post('updateTemplate', array('before' => 'csrf', 'uses' => 'TemplatesController@update'));
348
+        Route::post('deleteTemplate', array('before' => 'csrf', 'uses' => 'TemplatesController@destroy'));
317 349
         Route::get('course/{id}', 'CoursesController@showLimited');
318 350
         Route::get('rubrics/{template_id}/download', 'TemplatesController@download');
319
-        Route::post('program/fetch', array('before' => 'csrf', 'uses'=>'ProgramsController@fetch'));
351
+        Route::post('program/fetch', array('before' => 'csrf', 'uses' => 'ProgramsController@fetch'));
320 352
 
321
-        Route::get('printRubric/{id}', 'TemplatesController@printview' );
353
+        Route::get('printRubric/{id}', 'TemplatesController@printview');
322 354
         Route::get('rubric/{rubric_id}', 'RubricsController@show_limited');
323 355
         Route::get('grouped_course/{code}/{number}/{semester_code}', 'CoursesController@showGrouped');
324 356
 
357
+        //Criteria and objectives
358
+        Route::get('program-criteria', 'CriteriaController@editProgram');
359
+        Route::get('program-objective', 'Objective2Controller@editProgram');
360
+
325 361
         // Print program report
326 362
         Route::get('print_program/{id}', 'ProgramsController@print_program');
327 363
 
@@ -334,19 +370,25 @@ Route::group(array('before' => 'auth|has_access'), function()
334 370
 
335 371
         // Learning Objectives
336 372
         Route::get('program/{program}/objectives', 'ObjectivesController@index');
337
-        Route::post('updateObjective', array('before' => 'csrf', 'uses'=>'ObjectivesController@update'));
338
-        Route::post('program/{id}/createObjective', array('before' => 'csrf', 'uses'=>'ObjectivesController@create'));
339
-        Route::post('fetchObjective', array('before' => 'csrf', 'uses'=>'ObjectivesController@fetchObjective'));
340
-        Route::post('fetchObjectivesForCriteria', array('before' => 'csrf', 'uses'=>'ObjectivesController@fetchObjectivesForCriteria'));
341
-
342
-        // Five year plans
373
+        Route::post('updateObjective', array('before' => 'csrf', 'uses' => 'ObjectivesController@update'));
374
+        Route::post('program/{id}/createObjective', array('before' => 'csrf', 'uses' => 'ObjectivesController@create'));
375
+        Route::post('fetchObjective', array('before' => 'csrf', 'uses' => 'ObjectivesController@fetchObjective'));
376
+        Route::post('fetchObjectivesForCriteria', array('before' => 'csrf', 'uses' => 'ObjectivesController@fetchObjectivesForCriteria'));
377
+
378
+        //Objectives por Gabriel
379
+        Route::get('objective', 'Objective2Controller@edit');
380
+        Route::post('createObjective', array('before' => 'csrf', 'uses' => 'Objective2Controller@create'));
381
+        Route::post('updateObjective', array('before' => 'csrf', 'uses' => 'Objective2Controller@update'));
382
+        Route::post('fetchObjectiveWithTrashed', array('before' => 'csrf', 'uses' => 'Objective2Controller@fetchObjectiveWithTrashed'));
383
+
384
+        // Five year plans,
343 385
         Route::get('five-year-plans', 'FiveYearPlansController@index');
344 386
         Route::get('program/{program}/five-year-plans/create', 'FiveYearPlansController@create');
345 387
         Route::get('program/{program}/five-year-plans/{five_year_plan}', 'FiveYearPlansController@show');
346 388
         Route::get('program/{program}/five-year-plans/{five_year_plan}/edit', 'FiveYearPlansController@edit');
347 389
         Route::get('five-year-plans/{five_year_plan}/ms-word', 'FiveYearPlansController@msWord');
348
-        Route::post('five-year-plans/store', array('before' => 'csrf', 'uses'=>'FiveYearPlansController@store'));
349
-        Route::post('five-year-plans/update', array('before' => 'csrf', 'uses'=>'FiveYearPlansController@update'));
390
+        Route::post('five-year-plans/store', array('before' => 'csrf', 'uses' => 'FiveYearPlansController@store'));
391
+        Route::post('five-year-plans/update', array('before' => 'csrf', 'uses' => 'FiveYearPlansController@update'));
350 392
 
351 393
 
352 394
         // Annual plans
@@ -354,8 +396,8 @@ Route::group(array('before' => 'auth|has_access'), function()
354 396
         Route::get('program/{program}/annual-plans/create', 'AnnualPlansController@create');
355 397
         Route::get('program/{program}/annual-plans/{five_year_plan}', 'AnnualPlansController@show');
356 398
         Route::get('program/{program}/annual-plans/{five_year_plan}/edit', 'AnnualPlansController@edit');
357
-        Route::post('annual-plans/store', array('before' => 'csrf', 'uses'=>'AnnualPlansController@store'));
358
-        Route::post('annual-plans/update', array('before' => 'csrf', 'uses'=>'AnnualPlansController@update'));
399
+        Route::post('annual-plans/store', array('before' => 'csrf', 'uses' => 'AnnualPlansController@store'));
400
+        Route::post('annual-plans/update', array('before' => 'csrf', 'uses' => 'AnnualPlansController@update'));
359 401
 
360 402
         Route::get('learning-outcomes/show/{id}', 'OutcomesController@show');
361 403
         // TODO: Change route name
@@ -363,50 +405,63 @@ Route::group(array('before' => 'auth|has_access'), function()
363 405
         Route::get('new-report/{id}', 'OutcomesController@newReport');
364 406
         Route::get('new-report-all', 'OutcomesController@newReportAll');
365 407
         Route::get('courses/{id}', 'CoursesController@newShow');
408
+
409
+        // Transformative Actions
410
+        Route::post('transformativeAction/approveTA', array('before' => 'csrf', 'uses'=>'TransformativeActionsController@approveTA'));
411
+
412
+        // Show users plan de tres a~nos
413
+        Route::get('three-years-plan', 'ThreeYearPlanController@threeYearsReport');
414
+        Route::post('fetchThreeYears', array('before' => 'csrf', 'uses'=>'ThreeYearPlanController@fetchThreeYears'));
415
+        Route::post('typ/lookUp', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@lookup_typ_semester_outcome'));
416
+        Route::post('section2_arrive', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@section2_arrive'));
417
+        Route::post('section2_on_change', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@section2_on_change'));
418
+        Route::post('section3_arrive', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@section3_arrive'));
419
+        Route::post('section3_on_change', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@section3_on_change'));
420
+        Route::post('typ/getObjectives', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@getObjectivesForTYP'));
421
+        Route::post('typ/updateOutcomeSemsters', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@typ_update_outcomes_semesters'));
422
+        Route::post('typ/update', array('before' => 'csrf', 'uses' => 'ThreeYearPlanController@update_typ_outcomes_semesters'));
423
+
366 424
     });
367 425
 
368 426
 
369 427
     /**
370 428
      * Professor Routes
371 429
      */
372
-    Route::group(array('prefix' => 'professor', 'before'=>'prof'), function()
373
-    {
374
-        Route::post('program', array('before' => 'csrf', 'uses'=>'ProfessorsController@program'));
430
+    Route::group(array('prefix' => 'professor', 'before' => 'prof'), function () {
431
+        Route::post('program', array('before' => 'csrf', 'uses' => 'ProfessorsController@program'));
375 432
         Route::get('activities/{activity_id}/rubrics', 'RubricsController@newRubric');
433
+        Route::get('activities/{activity_id}/other_method', 'RubricsController@newOtherMethod');
376 434
         Route::get('activities/{activity_id}/rubric', 'RubricsController@show');
377 435
         Route::get('activities/{activity_id}/rubric/{rubric_id}/download', 'RubricsController@download');
378 436
         Route::get('activities/{activity_id}/rubric/{rubric_id}/print', 'RubricsController@printview');
379 437
         Route::get('activities/{activity_id}/assess', 'ActivitiesController@assess');
380 438
         Route::get('activities/{activity_id}/view_assessment', 'ActivitiesController@viewAssessment');
381 439
         Route::get('activities/{activity_id}/print_assessment', 'ActivitiesController@printAssessment');
382
-        Route::post('activities/saveAssessment', array('before'=>'csrf', 'uses'=>'ActivitiesController@saveAssessment'));
383
-        Route::post('activities/deleteAssessment', array('before'=>'csrf', 'uses'=>'ActivitiesController@deleteAssessment'));
440
+        Route::post('activities/saveAssessment', array('before' => 'csrf', 'uses' => 'ActivitiesController@saveAssessment'));
441
+        Route::post('activities/deleteAssessment', array('before' => 'csrf', 'uses' => 'ActivitiesController@deleteAssessment'));
384 442
         Route::delete('activities/{activity_id}/delete', 'ActivitiesController@destroy');
385
-        Route::post('activities/{activity_id}/update', array('before' => 'csrf', 'uses'=>'ActivitiesController@update'));
443
+        Route::post('activities/{activity_id}/update', array('before' => 'csrf', 'uses' => 'ActivitiesController@update'));
386 444
         Route::get('courses/{id}', 'CoursesController@show');
387 445
         Route::get('courses/{semester}/{id}/students/{number}', 'StudentsController@show');
388 446
         Route::get('courses/{semester}/{id}/students/{number}/print_report', 'StudentsController@printStudentReport');
389 447
         Route::get('activities/{id}', 'ActivitiesController@show');
390
-        Route::post('activities/{id}', array('before' => 'csrf', 'uses'=>'ActivitiesController@create'));
448
+        Route::post('activities/{id}', array('before' => 'csrf', 'uses' => 'ActivitiesController@create'));
391 449
         Route::get('students', 'StudentsController@students');
392 450
         Route::get('program', 'ProfessorsController@program');
393 451
         Route::get('personal-information', 'ProfessorsController@personalInformation');
394 452
         Route::get('manual', 'ProfessorsController@manual');
395
-        Route::post('loadRubric', array('before' => 'csrf', 'uses'=>'RubricsController@fetch'));
396
-        Route::post('saveRubric', array('before' => 'csrf', 'uses'=>'RubricsController@create'));
397
-        Route::post('updateRubric', array('before' => 'csrf', 'uses'=>'RubricsController@update'));
398
-        Route::post('deleteRubric', array('before' => 'csrf', 'uses'=>'RubricsController@destroy'));
453
+        Route::post('loadRubric', array('before' => 'csrf', 'uses' => 'RubricsController@fetch'));
454
+        Route::post('saveRubric', array('before' => 'csrf', 'uses' => 'RubricsController@create'));
455
+        Route::post('updateRubric', array('before' => 'csrf', 'uses' => 'RubricsController@update'));
456
+        Route::post('deleteRubric', array('before' => 'csrf', 'uses' => 'RubricsController@destroy'));
399 457
         Route::get('learning-outcomes-criteria', 'CriteriaController@index');
400 458
         Route::get('learning-objectives-criteria', 'CriteriaController@objectivesIndex');
401 459
         Route::get('export_grades/{id}', 'CoursesController@exportGrades');
402
-
460
+        Route::get('learning-objectives-criteria', 'CriteriaController@objectivesIndex');
403 461
         // Assessment reports
404 462
         Route::get('professor-assessment-report/{outcome_id}', 'OutcomesController@professorAssessmentReport');
405 463
         Route::get('professor-assessment-reports', 'OutcomesController@professorAssessmentReports');
406 464
 
407 465
         Route::get('general-studies-overview', 'ProfessorsController@generalStudiesOverview');
408
-
409
-
410 466
     });
411
-
412 467
 });

+ 803
- 0
app/views/global/view-three-year-plan.blade.php Ver arquivo

@@ -0,0 +1,803 @@
1
+@extends('layouts.master')
2
+
3
+@section('navigation')
4
+    @if(Auth::user()->role==2)
5
+      @include('local.managers.sCoords._navigation')
6
+    @elseif(Auth::user()->role==3)
7
+      @include('local.managers.pCoords._navigation')
8
+    @endif
9
+@stop
10
+
11
+@section('main')
12
+  {{-- TODO: look where to place this script.
13
+          if placed inside .ready() or before it,
14
+            an error that the function is not defined occurs. --}}
15
+  {{-- TODO: no reconoce acentos --}}
16
+  <script type="text/javascript">
17
+    function filterCycles() {
18
+      // Declare variables
19
+      var input, filter, div, li, i, cycleText;
20
+      input = document.getElementById('userInput');
21
+      filter = input.value.toUpperCase();
22
+      div = document.getElementById("list");
23
+      li = div.getElementsByTagName('li');
24
+
25
+      // Loop through all list items, and hide those who don't match the search query
26
+      for (i = 0; i < li.length; i++) {
27
+        cycleText = li[i].textContent;
28
+        if (cycleText.toUpperCase().indexOf(filter) > -1) {
29
+          li[i].style.display = "";
30
+        } else {
31
+          li[i].style.display = "none";
32
+        }
33
+      }
34
+    }
35
+
36
+    // onChange, update selected outcomes-semesters
37
+    function update_outcome_semesters() {
38
+      var outcomeSemesterArray= new Array();
39
+      // For each learning outcome, get selected boxes and put it into an array
40
+      $('#outcome-semesters-body tr').each(function( index )
41
+      {
42
+          var outcomeObject = new Object();
43
+          outcomeObject.id= $(this).data('id');
44
+          var semesters = new Array();
45
+          var temp = new Array();
46
+          temp.push($(this).children(".sem1-box").find("input").attr('name'));
47
+          temp.push($(this).children(".sem1-box").find("input").prop("checked"));
48
+          semesters.push(temp);
49
+
50
+          temp = new Array();
51
+          temp.push($(this).children(".sem2-box").find("input").attr('name'));
52
+          temp.push($(this).children(".sem2-box").find("input").prop("checked"));
53
+          semesters.push(temp);
54
+
55
+          temp = new Array();
56
+          temp.push($(this).children(".sem3-box").find("input").attr('name'));
57
+          temp.push($(this).children(".sem3-box").find("input").prop("checked"));
58
+          semesters.push(temp);
59
+
60
+          temp = new Array();
61
+          temp.push($(this).children(".sem4-box").find("input").attr('name'));
62
+          temp.push($(this).children(".sem4-box").find("input").prop("checked"));
63
+          semesters.push(temp);
64
+
65
+          temp = new Array();
66
+          temp.push($(this).children(".sem5-box").find("input").attr('name'));
67
+          temp.push($(this).children(".sem5-box").find("input").prop("checked"));
68
+          semesters.push(temp);
69
+
70
+          temp = new Array();
71
+          temp.push($(this).children(".sem6-box").find("input").attr('name'));
72
+          temp.push($(this).children(".sem6-box").find("input").prop("checked"));
73
+          semesters.push(temp);
74
+
75
+          outcomeObject.semesters= semesters;
76
+
77
+          var clone = jQuery.extend({}, outcomeObject);
78
+          outcomeSemesterArray.push(clone);
79
+      });
80
+
81
+      var id = $('#table-cycles').data('typ-id');
82
+
83
+      $.post(
84
+          "{{ URL::action('ThreeYearPlanController@update_typ_outcomes_semesters') }}",
85
+          {
86
+            outcomeSemesterArray : JSON.stringify(outcomeSemesterArray),
87
+            typ_id: (id)
88
+          },
89
+          function(data)
90
+          {
91
+              //;
92
+          }
93
+      );
94
+    }
95
+
96
+  </script>
97
+
98
+  <div class="row">
99
+    <div class="col-md-3">
100
+      <input class="form-control" type="text" id="userInput" onkeyup="filterCycles()" placeholder="Search for Cycles..">
101
+      <div class="list-group" id='list'>
102
+        @foreach ($typs as $typ)
103
+          <li data-cycle-id="{{$typ->id}}" class="list-group-item">{{$typ->year_start}}-{{$typ->year_end}}</li>
104
+        @endforeach
105
+      </div>
106
+    </div>
107
+
108
+    <div class="col-md-9">
109
+      <div id="cycle-display" class="panel panel-default">
110
+        <div class="panel-heading">
111
+          <h4 class=" panel-title" style="cursor:auto!important;">
112
+          </h4>
113
+        </div>
114
+        <div class="panel-body" id="section1">
115
+          <p class="section1-description">Select two or more Semesters that will be evaluated by an Outcome.</p>
116
+            <div class="table-responsive">
117
+              {{-- <table class="table table-striped table-condensed datatable"> --}}
118
+              <table data-typ-id="0" class="table table-striped table-condensed" id="table-cycles">
119
+                <style media="screen">
120
+                  input[type=checkbox] {transform: scale(2);}
121
+                </style>
122
+                <thead>
123
+                  <tr style="background-color:#FDD8B5;">
124
+                    {{-- <th rowspan="0" style="background-color:#F5DEDD;" class="text-center">Dominios de aprendizaje</th> --}}
125
+                    <th rowspan="0" style="background-color:#F5DEDD;" class="text-center">Learning Outcomes</th>
126
+                    <th colspan="2" class="text-center" id="cycle1"></th>
127
+                    <th colspan="2" class="text-center" id="cycle2"></th>
128
+                    <th colspan="2" class="text-center" id="cycle3"></th>
129
+                  </tr>
130
+                  <tr class="">
131
+                    <th class="text-center">1er sem</th>
132
+                    <th class="text-center">2do sem</th>
133
+                    <th class="text-center">1er sem</th>
134
+                    <th class="text-center">2do sem</th>
135
+                    <th class="text-center">1er sem</th>
136
+                    <th class="text-center">2do sem</th>
137
+                  </tr>
138
+                </thead>
139
+                <tfoot>
140
+                </tfoot>
141
+                <input type="text" id="cycle_id" name="cycle_id" value="getsReplacedWithJS" hidden>
142
+                      {{-- <label for="profesores">Profesores (pares)</label> --}}
143
+                <tbody id="outcome-semesters-body" onchange="update_outcome_semesters()">
144
+                  @foreach ($outcomes as $outcome)
145
+                    <tr data-id="{{$outcome->id}}">
146
+                      <th>{{$outcome->name}}</th>
147
+                      <th class="text-center sem1-box"><input type="checkbox" id="{{$outcome->id}}-sem1" name="{{$outcome->id}}-sem1" value="checked" /></th>
148
+                      <th class="text-center sem2-box"><input type="checkbox" id="{{$outcome->id}}-sem2" name="{{$outcome->id}}-sem2" value="checked" /></th>
149
+                      <th class="text-center sem3-box"><input type="checkbox" id="{{$outcome->id}}-sem3" name="{{$outcome->id}}-sem3" value="checked" /></th>
150
+                      <th class="text-center sem4-box"><input type="checkbox" id="{{$outcome->id}}-sem4" name="{{$outcome->id}}-sem4" value="checked" /></th>
151
+                      <th class="text-center sem5-box"><input type="checkbox" id="{{$outcome->id}}-sem5" name="{{$outcome->id}}-sem5" value="checked" /></th>
152
+                      <th class="text-center sem6-box"><input type="checkbox" id="{{$outcome->id}}-sem6" name="{{$outcome->id}}-sem6" value="checked" /></th>
153
+                    </tr>
154
+                  @endforeach
155
+                </tbody>
156
+              </table>
157
+              <hr>
158
+              <div class="">
159
+                <button class="btn-lg btn-primary pull-right go-to-2" style="margin:5px;">Select Objectives</button>
160
+              </div>
161
+            </div>
162
+        </div>
163
+        <div class="panel-body" id="section2">
164
+          <p class="section2-description">Select one or more Objectives that will be evaluated in a given Semester.</p>
165
+            <div>
166
+              <div class="objectives-section-0">
167
+              </div>
168
+              <div class="objectives-section">
169
+              </div>
170
+            <hr>
171
+            <div class="">
172
+              <button class="btn-lg btn-primary pull-right go-to-3" style="margin:5px;">Go to Objectives Selection</button>
173
+              <button class="btn-lg btn-primary pull-right back-to-1" style="margin:5px;">Back to Semester Selection</button>
174
+            </div>
175
+            </div>
176
+        </div>
177
+        <div class="panel-body" id="section3">
178
+          <p class="section3-description">Select one or more Courses that will be evaluated by an Objective in a given Semester.</p>
179
+            <div>
180
+              <div class="courses-main-clone-0" hidden>
181
+                <div class="title-course-selection-0">
182
+                  <button class="btn btn-md btn-secondary pull-right hide-course-selection"><span class="glyphicon glyphicon-minus"></span> Hide Outcome Options</button>
183
+                  <button class="btn btn-md btn-secondary pull-right show-course-selection"><span class="glyphicon glyphicon-plus"></span> Show Outcome Options</button>
184
+                  <p class="h3" style="width:100%;max-width:80%;"><b>Outcome: example</b></p>
185
+                </div>
186
+                <div class="semester-course-selection-0" style="margin-left:30px;">
187
+                  <label class="semester-label-course-selection-0" for="">First Semester of 2000-2000</label>
188
+                  <div class="select-course-selection-0" style="margin-left:30px;">
189
+                    <div class="objective-selector-0">
190
+                      <label for="">OBJECTIVE TEMP</label>
191
+                      <select class="select-0" name="" style="width:100%;max-width:55%;">
192
+                        <option class="default-option" value="nothing_selected">Select a course</option>
193
+                      </select>
194
+                      <button class="btn btn-md btn-danger delete-selection-0" style="margin:5px;"><span class="glyphicon glyphicon-minus"></span> remove</button>
195
+                    </div>
196
+                    <div class="clone-objective-course-select-0">
197
+                      <button class="btn btn-md btn-secondary add-objective-course" style="margin:5px;"><span class="glyphicon glyphicon-plus"></span> Choose more Courses</button>
198
+                    </div>
199
+                  </div>
200
+                </div>
201
+                <div class="footer-course-selection-0" style="margin-left:30px;" hidden>
202
+                  <p><b>Course selection for this Outcome is currently hidden</b></p>
203
+                </div>
204
+              </div>
205
+              <div class="courses-section-0">
206
+              </div>
207
+              <div class="courses-section">
208
+              </div>
209
+            <hr>
210
+            <div class="">
211
+              <button class="btn-lg btn-primary pull-right go-to-temp" style="margin:5px;">Go to TYP evaluation page</button>
212
+              <button class="btn-lg btn-primary pull-right back-to-2" style="margin:5px;">Back to Objective Selection</button>
213
+            </div>
214
+            </div>
215
+        </div>
216
+      </div>
217
+    </div>
218
+    <div class="col-md-9">
219
+      <div class="no-cycle alert alert-info">
220
+        <p>Select a Three year cycle to start</p>
221
+      </div>
222
+    </div>
223
+
224
+  </div>
225
+@stop
226
+
227
+@section('included-js')
228
+    @include('global._datatables_js')
229
+@stop
230
+
231
+@section('javascript')
232
+
233
+$(document).ready(function()
234
+{
235
+  // --------------------------------------------------------------------------
236
+  // Page load
237
+  // --------------------------------------------------------------------------
238
+
239
+  // Hide accordion panel contents by default
240
+  var outcomes = {{json_encode($outcomes)}};
241
+
242
+  $('.panel-group .panel-body').hide();
243
+
244
+  $('#cycle-display').parent().hide();
245
+
246
+  $("#clonedOutcome0").hide();;
247
+
248
+  $('.show-course-selection').hide();
249
+
250
+  // --------------------------------------------------------------------------
251
+  // Functions
252
+  // --------------------------------------------------------------------------
253
+
254
+
255
+
256
+(function () {
257
+    var previous;
258
+    $("select").on('focus', function () {
259
+        // Store the current value on focus and on change
260
+        previous = this.value;
261
+    }).change(function() {
262
+
263
+      //comienzo
264
+      var options_values = $(this).parent().find('select').val().split('-');
265
+
266
+      //ifs
267
+      if (options_values.length == 3){
268
+
269
+        var typ_id = $('#table-cycles').data('typ-id');
270
+        var previous_objective_id = previous.split('-')[2];
271
+
272
+        var options_values =this.value.split('-');
273
+        var outcome_id = options_values[0];
274
+        var semester_id = options_values[1];
275
+        var new_objective_id = options_values[2];
276
+
277
+        if (new_objective_id == 'n'){
278
+          new_objective_id = 'nothing_selected';
279
+        }
280
+        if (previous_objective_id == 'n'){
281
+          previous_objective_id = 'nothing_selected';
282
+        }
283
+
284
+        $.post(
285
+        "{{ URL::action('ThreeYearPlanController@section2_on_change') }}",
286
+        {
287
+          typ_id: (typ_id),
288
+          previous_objective_id: (previous_objective_id),
289
+          outcome_id: (outcome_id),
290
+          semester_id: (semester_id),
291
+          new_objective_id: (new_objective_id)
292
+        },
293
+        function(data)
294
+        {
295
+          //
296
+        }
297
+        );
298
+        previous = this.value;
299
+
300
+      }
301
+      else if (options_values.length == 4){
302
+
303
+        var typ_id = $('#table-cycles').data('typ-id');
304
+        var previous_course_id = previous.split('-')[3];
305
+
306
+        var options_values =this.value.split('-');
307
+        var outcome_id = options_values[0];
308
+        var semester_id = options_values[1];
309
+        var objective_id = options_values[2];
310
+        var new_course_id = options_values[3];
311
+
312
+        if (new_course_id == 'n'){
313
+          new_course_id = 'nothing_selected';
314
+        }
315
+        if (previous_course_id == 'n'){
316
+          previous_course_id = 'nothing_selected';
317
+        }
318
+
319
+        $.post(
320
+        "{{ URL::action('ThreeYearPlanController@section3_on_change') }}",
321
+        {
322
+          typ_id: (typ_id),
323
+          previous_course_id: (previous_course_id),
324
+          outcome_id: (outcome_id),
325
+          semester_id: (semester_id),
326
+          objective_id: (objective_id),
327
+          new_course_id: (new_course_id)
328
+        },
329
+        function(data)
330
+        {
331
+          //
332
+        }
333
+        );
334
+        previous = this.value;
335
+
336
+      }
337
+    });
338
+})();
339
+
340
+
341
+  // --------------------------------------------------------------------------
342
+  // Events
343
+  // --------------------------------------------------------------------------
344
+
345
+
346
+
347
+    // When list item is clicked, load corresponding info
348
+    //section 1
349
+    $('.list-group-item').on('click', function()
350
+    {
351
+      var id = $(this).data('cycle-id');
352
+      $('#table-cycles').data('typ-id',id);
353
+      $('#section1').show();
354
+      $('#section2').hide();
355
+      $('#section3').hide();
356
+
357
+      var outcome_id_semester_code_program_id_box_id_typ_id = new Object();
358
+      var outcome_id_semester_code_program_id_box_id_typ_id = Array();
359
+
360
+      $.post(
361
+      "{{ URL::action('ThreeYearPlanController@fetchThreeYears') }}",
362
+      { id: id },
363
+      function(json)
364
+      {
365
+
366
+
367
+          // Retrieve datatable instance
368
+          var table = $('#table-cycles');
369
+
370
+          var typ = json.typ;
371
+          var year_start = json.typ.year_start;
372
+          var year_end = json.typ.year_end;
373
+          var semesters = json.typ.semesters;
374
+          var program_id = {{$program_id}};
375
+          //  var outcomes = already defined
376
+
377
+          $('#cycle-display').parent().show();
378
+          $('.no-cycle').parent().hide();
379
+
380
+          //Display title and definition
381
+          $('#cycle-display .panel-title').html('Planning for the years of ' + year_start + '-' + year_end);
382
+          $('#cycle-display .cycle-definition').html("Select the semesters which you would like to review an outcome in the three year plan of " + year_start + '-' + year_end+".");
383
+
384
+          //Empty table
385
+          //table.clear();
386
+
387
+          // Add new semesters
388
+          //if(typ.length>0)
389
+          //{
390
+          $('table').show();
391
+          $('#cycle1').html((year_start)+"-"+(year_start+1));
392
+          $('#cycle2').html((year_start+1)+"-"+(year_end-1));
393
+          $('#cycle3').html((year_end-1)+"-"+(year_end));
394
+
395
+          $('#cycle_id').val(typ.id);
396
+
397
+          //resets the checkboxes' name, clears marked, and disables them by default.
398
+          $.each(outcomes, function(index, outcome)
399
+          {
400
+            $.each([1,2,3,4,5,6], function(index, semester)
401
+            {
402
+              var id = outcome.id+"-sem"+semester;
403
+              var new_name = id;
404
+              document.getElementById(id).setAttribute("name", new_name);
405
+              $("#"+id).attr("disabled", true);
406
+              $("#"+id).prop("checked", false);
407
+            });
408
+          });
409
+
410
+
411
+          var i = 1;
412
+          $.each(outcomes, function(index, outcome)
413
+          {
414
+            $.each(semesters, function(index, semester)
415
+            {
416
+              var id = outcome.id+"-sem"+i;
417
+              var new_name = outcome.id+"-sem"+semester.code;
418
+
419
+              var checkbox = document.getElementById(id);
420
+              checkbox.setAttribute("name", new_name);
421
+
422
+              //enable the check box
423
+              $("#"+id).removeAttr("disabled");
424
+
425
+              //store checkboxes info in an array to later lookup which are marked
426
+              var temp = Array(outcome.id,semester.code,program_id, id, typ.id);
427
+              outcome_id_semester_code_program_id_box_id_typ_id.push(temp);
428
+              i++;
429
+            });
430
+            i = 1;
431
+          });
432
+
433
+          //search which boxes are marked in the data-base
434
+          $.post(
435
+            "{{ URL::action('ThreeYearPlanController@lookup_typ_semester_outcome'  ) }}",
436
+            {
437
+              info : (outcome_id_semester_code_program_id_box_id_typ_id)
438
+            },
439
+            function(data)
440
+            {
441
+              $.each(data.box_value, function(index, box_id_value)
442
+              {
443
+                var box_id = box_id_value[0];
444
+                var value = box_id_value[1];
445
+                if (1 == value) {
446
+                  $("#"+box_id).prop("checked", true);
447
+                }
448
+              });
449
+            }
450
+          );
451
+      },
452
+      'json'
453
+      );
454
+
455
+
456
+    });
457
+
458
+
459
+  });
460
+
461
+
462
+    // go back to section 1
463
+    $('.back-to-1').on('click', function(e)
464
+    {
465
+      window.scrollTo(0, 0);
466
+      $(".panel-body").hide();
467
+      $("#section1").show();
468
+    });
469
+
470
+
471
+    // go back to section 2
472
+    $('.back-to-2').on('click', function(e)
473
+    {
474
+      window.scrollTo(0, 0);
475
+      $(".panel-body").hide();
476
+      $("#section2").show();
477
+    });
478
+
479
+
480
+  // go to section 2
481
+  $('.go-to-2').on('click', function(e)
482
+  {
483
+    var not_enough = false;
484
+    var i = 0;
485
+    $('#table-cycles tbody tr').each(function() {
486
+      $(this).find('th').each(function() {
487
+        if ($(this).find('input').is(':checked')){
488
+          i = i + 1;
489
+        }
490
+      });
491
+
492
+      if (i < 2){
493
+        not_enough = true;
494
+      }
495
+      i = 0;
496
+    });
497
+
498
+    if (not_enough == true){
499
+      alert("Each Outcome must be evaluated in at least 2 semesters.");
500
+      return true;
501
+    }
502
+
503
+    $(".panel-body").hide();;
504
+    $("#section2").show();;
505
+
506
+    var typ_id = $('#table-cycles').data('typ-id');
507
+    $.post(
508
+        "{{ URL::action('ThreeYearPlanController@section2_arrive') }}",
509
+        {
510
+          typ_id: (typ_id)
511
+        },
512
+        function(data)
513
+        {
514
+          $('.objectives-section').empty();
515
+
516
+          $.each(data, function(index, outcome)
517
+          {
518
+            var outcome_name = outcome.name;
519
+            var outcome_id = outcome.id;
520
+            $('.objectives-section').append('<hr>');
521
+
522
+            var area = $('.courses-section-0').clone(true);
523
+            area.attr('class','');
524
+
525
+            var title = 'Outcome: ' + outcome_name;
526
+            var title_area = $('.title-course-selection-0').clone(true);
527
+            title_area.attr('class','title-course-selection h3');
528
+            title_area.find('p').html(title);
529
+
530
+            area.append(title_area);
531
+
532
+            $.each(outcome.selected_semesters, function(index, semester)
533
+            {
534
+                var semester_name = semester.name;
535
+                var semester_id = semester.semester_id;
536
+
537
+                var select_area = $('.semester-course-selection-0').clone(true);
538
+                select_area.attr('class','semester-course-selection');
539
+                select_area.attr('style',' ');
540
+                select_area.find('.semester-label-course-selection-0').html(semester_name+"'s Objectives");
541
+                var no_option = outcome_id+'-'+semester_id+'-n';
542
+                select_area.find('option').val(no_option).html('Select an Objective');
543
+                select_area.find('.add-objective-course').html('<span class="glyphicon glyphicon-plus"></span> Choose more Objectives');
544
+
545
+                if (semester.available_objectives.length != 0){
546
+                  select_area.find('.objective-selector-0 label').hide();
547
+                  $.each(semester.available_objectives, function(index, objective)
548
+                  {
549
+                    var objective_id = objective.id;
550
+                    var option_value = outcome_id+'-'+semester_id+'-'+objective_id;
551
+
552
+                    var option_name = objective.text;
553
+                    var new_option = select_area.find('.default-option').clone(true);
554
+                    new_option.html(option_name);
555
+                    new_option.val(option_value);
556
+                    new_option.attr('class','select_objective');
557
+
558
+                    select_area.find('select').append(new_option);
559
+                  });
560
+                }
561
+                if (semester.available_objectives.length == 0){
562
+                  select_area.find('select').prop('disabled', 'disabled');
563
+                  select_area.find('.objective-selector-0 label').html('There are no Objectives available for this Outcome and Semester combination');
564
+                  select_area.find('.objective-selector-0 select').hide();
565
+                  select_area.find('button').prop('disabled', 'disabled');
566
+                }
567
+                $.each(semester.selected_objectives, function(index, objective)
568
+                {
569
+                  select_area.find('.objective-selector-0').hide();
570
+                  //si hay objetivos previamente seleccionados, escribirlos
571
+                  var objective_id = objective.id;
572
+                  var option_value = outcome_id+'-'+semester_id+'-'+objective_id;
573
+                  var new_select = select_area.find('.objective-selector-0').clone(true);
574
+                  new_select.attr('class','objective-selector');
575
+                  new_select.find('select').val(option_value);
576
+                  select_area.find('.clone-objective-course-select-0').before(new_select);
577
+                  select_area.find('.objective-selector').show();
578
+                });
579
+                area.append(select_area);
580
+            });
581
+            var footer = $('.footer-course-selection-0').clone(true);
582
+            footer.attr('class','footer-course-selection');
583
+            footer.find('p').html('<b>Objective selection for this Outcome is currently hidden.</b>');
584
+            area.append(footer);
585
+
586
+            area.append('<br>');
587
+            area.show(true);
588
+            $('.objectives-section').append(area);
589
+          });
590
+        }
591
+    );
592
+  });
593
+
594
+
595
+
596
+    // hide the options of an outcome in section 2 and 3
597
+    $('.hide-course-selection').on('click', function(e)
598
+    {
599
+      $(this).parent().find('.show-course-selection').show();;
600
+      $(this).hide();;
601
+      $(this).parent().parent().find('.semester-course-selection').hide(333);
602
+      $(this).parent().parent().find('.footer-course-selection').show(333);
603
+    });
604
+
605
+    // show the options of an outcome in section 2 and 3
606
+    $('.show-course-selection').on('click', function(e)
607
+    {
608
+      $(this).parent().find('.hide-course-selection').show();
609
+      $(this).hide();
610
+      $(this).parent().parent().find('.semester-course-selection').show(333);
611
+      $(this).parent().parent().find('.footer-course-selection').hide(333);
612
+    });
613
+
614
+
615
+    // in section 2 and 3, add selects for choosing more objectives and courses, respectively
616
+    $('.add-objective-course').on('click', function(e)
617
+    {
618
+      var new_select = $(this).parent().parent().find('.objective-selector-0').clone(true);
619
+      new_select.attr('class','objective-selector');
620
+      new_select.show();
621
+      $(this).parent().before(new_select);
622
+    });
623
+
624
+
625
+  // go to section 3
626
+  $('.go-to-3').on('click', function(e)
627
+  {
628
+    window.scrollTo(0, 0);
629
+    $(".panel-body").hide();;
630
+    $("#section3").show();;
631
+
632
+    var typ_id = $('#table-cycles').data('typ-id');
633
+    $.post(
634
+        "{{ URL::action('ThreeYearPlanController@section3_arrive') }}",
635
+        {
636
+          typ_id: (typ_id)
637
+        },
638
+        function(data)
639
+        {
640
+          $('.courses-section').empty();
641
+
642
+          $.each(data, function(index, outcome)
643
+          {
644
+            var outcome_name = outcome.name;
645
+            var outcome_id = outcome.id;
646
+            $('.courses-section').append('<hr>');
647
+
648
+            var area = $('.courses-section-0').clone(true);
649
+            area.attr('class','');
650
+
651
+            var title = 'Outcome: ' + outcome_name;
652
+            var title_area = $('.title-course-selection-0').clone(true);
653
+            title_area.attr('class','title-course-selection h3');
654
+            title_area.find('p').html(title);
655
+
656
+            area.append(title_area);
657
+
658
+            $.each(outcome.selected_semesters, function(index, semester)
659
+            {
660
+                var semester_name = semester.name;
661
+                var semester_id = semester.semester_id;
662
+
663
+                var select_area = $('.semester-course-selection-0').clone(true);
664
+                select_area.attr('class','semester-course-selection');
665
+                select_area.attr('style',' ');
666
+                select_area.find('.semester-label-course-selection-0').html(semester_name);
667
+
668
+
669
+                $.each(semester.selected_objectives, function(index, objective)
670
+                {
671
+                    var objective_id = objective.objective_id;
672
+                    var objective_text = objective.text;
673
+                    var new_select = select_area.find('.select-course-selection-0').clone(true);
674
+                    new_select.attr('class','select-course-selection');
675
+                    new_select.find('label').html('');
676
+                    new_select.find('.objective-selector-0').before('<p>Objective: <b>'+objective_text+'</b></p>');
677
+                    {{-- new_select.find('.objective-selector-0 select').attr('style','width:100%;max-width:25%;'); --}}
678
+                    $.each(objective.available_courses, function(index, course)
679
+                    {
680
+                      var course_id = course.course_id;
681
+
682
+                      var option_value = outcome_id+'-'+semester_id+'-'+objective_id+'-'+course_id;
683
+
684
+                      var option_name = '['+course.code+'] '+course.name;
685
+
686
+                      var new_option = new_select.find('.default-option').clone(true);
687
+                      new_option.html(option_name);
688
+                      new_option.val(option_value);
689
+                      new_option.attr('class','select_course');
690
+                      new_select.find('select').append(new_option);
691
+
692
+                    });
693
+                    if (objective.available_courses.length == 0){
694
+                      new_select.find('.select-course-selection-0').hide();
695
+                      new_select.find('select').prop('disabled', 'disabled');
696
+                      new_select.find('select label').html(' Objective "'+objective_text+'" has no courses available for selection');
697
+                      new_select.find('button').prop('disabled', 'disabled');
698
+                    }
699
+                    $.each(objective.selected_courses, function(index, course)
700
+                    {
701
+                      new_select.find('.objective-selector-0').hide();
702
+                      //si hay objetivos previamente seleccionados, escribirlos
703
+                      var course_id = course.course_id;
704
+                      var option_value = outcome_id+'-'+semester_id+'-'+objective_id+'-'+course_id;
705
+
706
+                      var new_selected_course = new_select.find('.objective-selector-0').clone(true);
707
+                      new_selected_course.attr('class','objective-selector');
708
+                      new_selected_course.find('select').val(option_value);
709
+                      {{-- new_selected_course.find('label').html(''); --}}
710
+                      new_selected_course.show();
711
+                      new_select.find('.clone-objective-course-select-0').before(new_selected_course);
712
+                    });
713
+                    select_area.find('.select-course-selection-0').after(new_select);
714
+                });
715
+                if (semester.selected_objectives.length != 0){
716
+                  select_area.find('.select-course-selection-0').hide();
717
+                }
718
+                else{
719
+                  select_area.find('select').prop('disabled', 'disabled');
720
+                  select_area.find('.objective-selector-0').html('There are no objectives selected for this semester');
721
+                  select_area.find('button').prop('disabled', 'disabled');
722
+                }
723
+                area.append(select_area);
724
+            });
725
+            var footer = $('.footer-course-selection-0').clone(true);
726
+            footer.attr('class','footer-course-selection');
727
+            area.append(footer);
728
+
729
+            area.append('<br>');
730
+            area.show(true);
731
+            $('.courses-section').append(area);
732
+          });
733
+        }
734
+    );
735
+  });
736
+
737
+
738
+  // remove an
739
+  $('.delete-selection-0').on('click', function(e)
740
+  {
741
+    var options_values = $(this).parent().find('select').val().split('-');
742
+
743
+    if (options_values.length == 3){
744
+      var typ_id = $('#table-cycles').data('typ-id');
745
+      var outcome_id = options_values[0];
746
+      var semester_id = options_values[1];
747
+      var new_objective_id = "nothing_selected";
748
+
749
+      var previous_objective_id = options_values[2];
750
+      if (previous_objective_id == 'n'){
751
+        previous_objective_id = "nothing_selected";
752
+        // with the next return, the post shouldnt excecute.
753
+        //  im leaving the assignment in the line before this one just in case.
754
+        $(this).parent().hide();;
755
+        return true;
756
+      }
757
+
758
+      $.post(
759
+        "{{ URL::action('ThreeYearPlanController@section2_on_change') }}",
760
+        {
761
+          typ_id: (typ_id),
762
+          previous_objective_id: (previous_objective_id),
763
+          outcome_id: (outcome_id),
764
+          semester_id: (semester_id),
765
+          new_objective_id: (new_objective_id)
766
+        },
767
+        function(data)
768
+        {
769
+          //
770
+        }
771
+      );
772
+    }
773
+    else if (options_values.length == 4){
774
+
775
+      var typ_id = $('#table-cycles').data('typ-id');
776
+      var outcome_id = options_values[0];
777
+      var semester_id = options_values[1];
778
+      var objective_id = options_values[2];
779
+      var previous_course_id = options_values[3];
780
+      var new_course_id = 'nothing_selected';
781
+
782
+      $.post(
783
+        "{{ URL::action('ThreeYearPlanController@section3_on_change') }}",
784
+        {
785
+          typ_id: (typ_id),
786
+          previous_course_id: (previous_course_id),
787
+          outcome_id: (outcome_id),
788
+          semester_id: (semester_id),
789
+          objective_id: (objective_id),
790
+          new_course_id: (new_course_id)
791
+        },
792
+        function(data)
793
+        {
794
+          //
795
+        }
796
+      );
797
+    }
798
+
799
+    $(this).parent().hide();;
800
+  });
801
+
802
+
803
+@stop

+ 21
- 19
app/views/local/managers/admins/_navigation.blade.php Ver arquivo

@@ -3,11 +3,14 @@
3 3
 
4 4
     <ul class="nav navbar-nav navbar-right">
5 5
       <li>{{ HTML::linkAction('AdministratorsController@overview', 'Overview') }}</li>
6
+      <li>{{ HTML::linkAction('ThreeYearPlanController@threeYearsReport', 'Three Years Plan') }}</li>
7
+      <li>{{ HTML::linkAction('TransformativeActionsController@editTA', 'Transformative Actions') }}</li>
6 8
 
7 9
       <li class="dropdown">
8 10
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Management<span class="caret"></span></a>
9 11
         <ul class="dropdown-menu" role="menu">
10 12
           <li>{{ HTML::linkAction('CoursesController@reassign', 'Courses') }}</li>
13
+          <li>{{ HTML::linkAction('Objective2Controller@edit', 'Objectives')}}</li>
11 14
           <li>{{ HTML::linkAction('CriteriaController@edit', 'Criteria') }}</li>
12 15
           <li>{{ HTML::linkAction('OutcomesController@index', 'Learning Outcomes') }}</li>
13 16
           <li>{{ HTML::linkAction('TemplatesController@newTemplate', 'Rubric Builder') }}</li>
@@ -16,8 +19,6 @@
16 19
           <li>{{ HTML::linkAction('UsersController@index', 'Users') }}</li>
17 20
         </ul>
18 21
       </li>
19
-      {{-- la linea siguiente comentada es lo que habia originalmente. tanto la linea como este comentario se pueden borrar --}}
20
-      {{-- <li>{{ HTML::linkAction('CriteriaController@index', 'Learning Outcomes and Criteria') }}</li> --}}
21 22
       <li class="dropdown">
22 23
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Learning and Criterias<span class="caret"></span></a>
23 24
         <ul class="dropdown-menu" role="menu">
@@ -29,7 +30,7 @@
29 30
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Colleges and Schools<span class="caret"></span></a>
30 31
         <ul class="dropdown-menu" role="menu">
31 32
           @foreach ($schools as $school)
32
-            <li>{{ HTML::linkAction('SchoolsController@show', $school->name, array($school->id)) }}</li>
33
+          <li>{{ HTML::linkAction('SchoolsController@show', $school->name, array($school->id)) }}</li>
33 34
           @endforeach
34 35
         </ul>
35 36
       </li>
@@ -39,9 +40,9 @@
39 40
       <li class="dropdown">
40 41
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Sections<span class="caret"></span></a>
41 42
         <ul class="dropdown-menu" role="menu">
42
-        @foreach ($courses as $course)
43
+          @foreach ($courses as $course)
43 44
           <li> {{ HTML::linkAction('CoursesController@show', $course->code.$course->number.'-'.$course->section.' ('.$course->semester->code.')', array('id'=>$course->id)) }}</li>
44
-        @endforeach
45
+          @endforeach
45 46
         </ul>
46 47
       </li>
47 48
       @endif
@@ -49,37 +50,38 @@
49 50
       <li class="dropdown">
50 51
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Reports<span class="caret"></span></a>
51 52
         <ul class="dropdown-menu" role="menu">
52
-            <li>{{ HTML::linkAction('OutcomesController@managerAssessmentReports', 'Campus Reports') }}</li>
53
-            @if(count(Auth::user()->courses))
54
-              <li>{{ HTML::linkAction('OutcomesController@professorAssessmentReports', 'My Courses\' Reports') }}</li>
55
-            @endif
53
+          <li>{{ HTML::linkAction('OutcomesController@managerAssessmentReports', 'Campus Reports') }}</li>
54
+          @if(count(Auth::user()->courses))
55
+          <li>{{ HTML::linkAction('OutcomesController@professorAssessmentReports', 'My Courses\' Reports') }}</li>
56
+          @endif
56 57
         </ul>
57 58
       </li>
58 59
 
59 60
       <li class="dropdown">
60 61
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Help<span class="caret"></span></a>
61 62
         <ul class="dropdown-menu" role="menu">
62
-            <li>{{ HTML::linkAction('FeedbackController@create', 'Feedback') }}</li>
63
-            <!-- <li><a href="{{ asset('files/OLAS-intro.pdf') }}">Introduction to OLAS</a></li> -->
64
-            <li><a href="{{ asset('files/intro-avaluo.pdf') }}">Introduction to Assessment</a></li>
65
-            <!-- <li><a href="{{ asset('files/OLAS-coords.pdf') }}">OLAS for Coordinators</a></li> -->
66
-            <li><a href="http://oeae.uprrp.edu/wp-content/uploads/2019/01/Brochure-de-OLAS-rev.-agosto-2018.pdf">Brochure</a></li>
63
+          <li>{{ HTML::linkAction('FeedbackController@create', 'Feedback') }}</li>
64
+          <!-- <li><a href="{{ asset('files/OLAS-intro.pdf') }}">Introduction to OLAS</a></li> -->
65
+          <li><a href="{{ asset('files/intro-avaluo.pdf') }}">Introduction to Assessment</a></li>
66
+          <!-- <li><a href="{{ asset('files/OLAS-coords.pdf') }}">OLAS for Coordinators</a></li> -->
67
+          <li><a href="http://oeae.uprrp.edu/wp-content/uploads/2019/01/Brochure-de-OLAS-rev.-agosto-2018.pdf">Brochure</a></li>
67 68
         </ul>
68 69
       </li>
69 70
       <li class="dropdown">
70 71
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Account<span class="caret"></span></a>
71 72
         <ul class="dropdown-menu" role="menu">
72
-            <li>{{ HTML::linkAction('UsersController@edit', 'Profile') }}</li>
73
-            <li>{{ HTML::linkAction('AuthController@logout', 'Log out ('.Auth::user()->email.')') }}</li>
73
+          <li>{{ HTML::linkAction('UsersController@edit', 'Profile') }}</li>
74
+          <li>{{ HTML::linkAction('AuthController@logout', 'Log out ('.Auth::user()->email.')') }}</li>
74 75
         </ul>
75 76
       </li>
76 77
       <li class="dropdown">
77 78
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">NEW<span class="caret"></span></a>
78 79
         <ul class="dropdown-menu" role="menu">
79 80
           <li>{{ HTML::linkAction('OutcomesController@newIndex', 'New Index') }}</li>
80
-{{--          <li>{{ HTML::linkAction('AuthController@logout', 'Log out ('.Auth::user()->email.')') }}</li>--}}
81
-        </ul>
82
-      </li>
81
+          {{-- <li>{{ HTML::linkAction('AuthController@logout', 'Log out ('.Auth::user()->email.')') }}
82
+      </li>--}}
83
+    </ul>
84
+    </li>
83 85
     </ul>
84 86
   </div>
85 87
 </div>

+ 16
- 1
app/views/local/managers/admins/assessment_report.blade.php Ver arquivo

@@ -80,8 +80,23 @@
80 80
                                                 @foreach($section->activities as $activity_index => $activity)
81 81
 
82 82
                                                     <!-- If activity has a rubric and the rubric has the outcome being evaluated -->
83
-                                                    @if(array_key_exists($outcome->id, (array)$activity->o_att_array) && $activity->o_att_array[$outcome->id] >=1)
83
+                                                    @if(array_key_exists($outcome->id, (array)$activity->o_att_array) && $activity->o_att_array[$outcome->id] >=1 && isset($section)&& isset($activity->rubric))
84 84
                                                         <h5>Measure {{ $activity_index + 1 }}</h5>
85
+                                                        <?php
86
+                                                        /*
87
+                                                        var_dump($section->code);
88
+                                                        var_dump($section->number);
89
+                                                        var_dump($section->name);
90
+                                                        var_dump($outcome->name);
91
+                                                        var_dump(date('M Y', strtotime($activity->date)));
92
+                                                        var_dump($activity->name);
93
+                                                        var_dump(count($section->students));
94
+                                                        print"<br>";
95
+                                                        print "A rubric was used in the $section->code-$section->number ($section->name) course (". date('M Y', strtotime($activity->date)).") to assess students’ <u>". strtolower($outcome->name) ."</u> in the activity: '<strong>$activity->name </strong>'. N= ". count($section->students);
96
+                                                        exit();
97
+                                                        */
98
+                                                        ?>
99
+
85 100
 
86 101
                                                         <p>A rubric was used in the {{ $section->code }}-{{ $section->number }} ({{ $section->name }}) course ({{ date('M Y', strtotime($activity->date))}}) to assess students’ <u>{{ strtolower($outcome->name) }}</u> in the activity: "<strong>{{ $activity->name }}</strong>". N= {{ count($section->students) }}. </p>
87 102
                                                         

+ 1040
- 266
app/views/local/managers/admins/criteria.blade.php
Diferenças do arquivo suprimidas por serem muito extensas
Ver arquivo


+ 101
- 0
app/views/local/managers/admins/learning-outcome_new.blade.php Ver arquivo

@@ -0,0 +1,101 @@
1
+@extends('layouts.master')
2
+
3
+@section('navigation')
4
+    @if(Auth::user()->role==1)
5
+        @include('local.managers.admins._navigation')
6
+    @elseif(Auth::user()->role==2)
7
+        @include('local.managers.sCoords._navigation')
8
+    @elseif(Auth::user()->role==3)
9
+        @include('local.managers.pCoords._navigation')
10
+    @endif
11
+@stop
12
+
13
+@section('main')
14
+
15
+<div class="row">
16
+    <div class="col-md-12">
17
+
18
+        <!-- Nav tabs -->
19
+        <ul class="nav nav-tabs" role="tablist">
20
+            <li role="presentation" class="active"><a href="#undergraduate" aria-controls="undergraduate" role="tab" data-toggle="tab"><h4>Undergraduate Program Participation</h4></a></li>
21
+            <li role="presentation"><a href="#graduate" aria-controls="graduate" role="tab" data-toggle="tab"><h4>Graduate Program Participation</h4></a></li>
22
+        </ul>
23
+
24
+        <!-- Tab panes -->
25
+        <div class="tab-content">
26
+            <div role="tabpanel" class="tab-pane active" id="undergraduate">
27
+                <br>
28
+                <table class="table table-striped datatable">
29
+                    <thead>
30
+                        <th>Name</th>
31
+                        <th>School</th>
32
+                        <th>Criteria attempted for the outcome</th>
33
+                        <th>Criteria achieved for the outcome </th>
34
+                        <th>Success rate</th>
35
+                    </thead>
36
+                    <tbody>
37
+                        @foreach($undergradResults["names"] as $id=>$undergradProgramName)
38
+                            <tr>
39
+                                <td>{{{ $undergradProgramName }}}</td>
40
+                                <td>{{{ $undergradResults["schools"][$id] }}}</td>
41
+                                <td>{{{ $undergradResults["attempted"][$id] }}}</td>
42
+                                <td>{{{ $undergradResults["achieved"][$id] }}}</td>
43
+                                <td>{{{ $undergradResults["successRate"][$id] }}}</td>
44
+                            </tr>
45
+                        @endforeach
46
+                    </tbody>
47
+                    <caption>N/M: Not Measured</caption>
48
+                </table>
49
+            </div>
50
+            <div role="tabpanel" class="tab-pane" id="graduate">
51
+                <br>
52
+                <table class="table table-striped datatable">
53
+                    <thead>
54
+                        <th>Name</th>
55
+                        <th>School</th>
56
+                        <th>Sections that attempted outcome</th>
57
+                        <th>Sections that achieved outcome </th>
58
+                        <th>Success rate</th>
59
+                    </thead>
60
+                    <tbody>
61
+                        @foreach($gradResults["names"] as $id=>$gradProgramName)
62
+                            <tr>
63
+                                <td>{{{ $gradProgramName }}}</td>
64
+                                <td>{{{ $gradResults["schools"][$id] }}}</td>
65
+                                <td>{{{ $gradResults["attempted"][$id] }}}</td>
66
+                                <td>{{{ $gradResults["achieved"][$id] }}}</td>
67
+                                <td>{{{ $gradResults["successRate"][$id] }}}</td>
68
+                            </tr>
69
+                        @endforeach
70
+                    </tbody>
71
+                    <caption>N/M: Not Measured</caption>
72
+                </table>
73
+            </div>
74
+
75
+        </div>
76
+    </div>
77
+</div>
78
+
79
+@stop
80
+
81
+@section('included-js')
82
+    @include('global._datatables_js')
83
+@stop
84
+
85
+@section('javascript')
86
+
87
+    // ------------------------------------------------------------------------
88
+    // Page Load
89
+    // ------------------------------------------------------------------------
90
+
91
+    // ------------------------------------------------------------------------
92
+    // Events
93
+    // ------------------------------------------------------------------------
94
+
95
+
96
+
97
+    // ------------------------------------------------------------------------
98
+    // Functions
99
+    // ------------------------------------------------------------------------
100
+
101
+@stop

+ 90
- 0
app/views/local/managers/admins/learning-outcomes_new.blade.php Ver arquivo

@@ -0,0 +1,90 @@
1
+@extends('layouts.master')
2
+
3
+@section('navigation')
4
+    @if(Auth::user()->role==1)
5
+        @include('local.managers.admins._navigation')
6
+    @elseif(Auth::user()->role==2)
7
+        @include('local.managers.sCoords._navigation')
8
+    @elseif(Auth::user()->role==3)
9
+        @include('local.managers.pCoords._navigation')
10
+    @endif
11
+@stop
12
+
13
+@section('main')
14
+
15
+    <div class="row">
16
+        <div class="col-md-12">
17
+            <p>Click on the values you want to change. Invalid values will be rejected automatically. To save your changes, click the 'Save' button at the bottom of the page.</p>
18
+            <table class="table table-striped table-condensed editable-table">
19
+                <thead><tr class="center-text">
20
+                    <th class="col-md-4">Learning Outcome</th>
21
+                    <th class="col-md-7">Definition</th>
22
+                    <th class="col-md-1">Expected Value</th>
23
+
24
+                </thead>
25
+                <tbody>
26
+                @foreach ($outcomes as $outcome)
27
+                    <tr data-id="{{ $outcome->id }}">
28
+                        <td contenteditable="true" class="name col-md-4" >{{ $outcome->name }}</td>
29
+                        <td contenteditable="true" data-type="textarea" class="definition col-md-6" >{{ $outcome->definition }}</td>
30
+                        <td contenteditable="true" class="expected-outcome col-md-1" >{{ $outcome->expected_outcome }}</td>
31
+                    </tr>
32
+                @endforeach
33
+                </tbody>
34
+            </table>
35
+        </div>
36
+    </div>
37
+    <div class="row">
38
+        <div class="col-md-12"><button class="btn btn-lg btn-primary center-block">Save</button></div>
39
+    </div>
40
+@stop
41
+
42
+@section('javascript')
43
+
44
+        $('button').on('click', function(e)
45
+        {
46
+            e.preventDefault();
47
+
48
+            var outcomeArray= new Array();
49
+
50
+            // For each learning outcome, get its value and put it into an array
51
+            $('tbody tr').each(function( index )
52
+            {
53
+                var outcomeObject = new Object();
54
+
55
+                outcomeObject.id= $(this).data('id');
56
+                outcomeObject.name= $(this).children('.name').text();
57
+                outcomeObject.definition= $(this).children('.definition').text();
58
+                outcomeObject.expected_outcome= $(this).children('.expected-outcome').text();
59
+
60
+                if($(this).find('.glyphicon-eye-close').length>0)
61
+                {
62
+                    outcomeObject.delete=1;
63
+                }
64
+
65
+                else
66
+                    outcomeObject.delete=0;
67
+
68
+                var clone = jQuery.extend({}, outcomeObject);
69
+                outcomeArray.push(clone);
70
+            });
71
+
72
+            $.post(
73
+                "{{ URL::action('OutcomesController@update') }}",
74
+                { outcomeArray: JSON.stringify(outcomeArray)},
75
+                function(data)
76
+                {
77
+                    location.reload();
78
+                }
79
+            );
80
+        });
81
+
82
+        $('span').on('click', function()
83
+        {
84
+            if($(this).hasClass('glyphicon-eye-open'))
85
+                $(this).removeClass('glyphicon-eye-open').addClass('glyphicon-eye-close');
86
+            else
87
+                $(this).removeClass('glyphicon-eye-close').addClass('glyphicon-eye-open');
88
+
89
+        });
90
+@stop

+ 1044
- 0
app/views/local/managers/admins/new_criteria.blade.php
Diferenças do arquivo suprimidas por serem muito extensas
Ver arquivo


+ 529
- 0
app/views/local/managers/admins/objectives.blade.php Ver arquivo

@@ -0,0 +1,529 @@
1
+@extends('layouts.master')
2
+
3
+@section('navigation')
4
+@include('local.managers.admins._navigation')
5
+@stop
6
+@section('main')
7
+
8
+<div class="row">
9
+    <div class="col-md-6">
10
+        <!-- Form to add a new objective -->
11
+        <div class="panel panel-default panel-button">
12
+            <div class="panel-heading">
13
+                Create
14
+            </div>
15
+            <div class="panel-body">
16
+                {{ Form::open(array('action' => 'Objective2Controller@create' )) }}
17
+                <div id='outcomeGroup'>
18
+                    <label> Associated Outcome</label>
19
+                    <div class="form-group col-md-11" id='outcomeForm'>
20
+
21
+
22
+                        {{ Form::select('outcome[0]', $outcomes, null, ['class'=>'form-control selectpicker', 'id' =>'outcome[0]']) }}
23
+
24
+                    </div>
25
+
26
+                </div>
27
+                <input type='hidden' name='counter' id='counter' value=1>
28
+                <button id='button-add-outcome' class='btn btn-md btn-secondary' onclick='addOutcomeTest()'>
29
+                    <span class='glyphicon glyphicon-plus'>
30
+
31
+                    </span>
32
+                    Add another Outcome
33
+                </button>
34
+
35
+                <!-- Associated Program -->
36
+
37
+
38
+                <!-- Associated Program -->
39
+                <div class="form-group">
40
+                    {{ Form::label('program_id', 'Associated Program') }}<br>
41
+                    <br>
42
+
43
+                    @foreach ($programs as $program)
44
+
45
+                    <input type="checkbox" id="{{ $program->name }}" name="program_id[]" value="{{$program->id}}">
46
+                    <label for="{{ $program->name }}"> {{ $program->name }} [{{ $program->school->name }}]</label><br>
47
+                    @endforeach
48
+                </div>
49
+
50
+
51
+                <div class="form-group">
52
+                    {{ Form::label('text', 'Text') }}
53
+                    {{ Form::text('text', '', array('class' => 'form-control')) }}
54
+                </div>
55
+
56
+
57
+
58
+                {{ Form::submit('Create', array('class' => 'btn btn-primary btn-block')) }}
59
+                {{ Form::close() }}
60
+            </div>
61
+        </div>
62
+    </div>
63
+
64
+    <div class="col-md-6">
65
+        <div class="panel panel-default panel-button">
66
+            <div class="panel-heading">
67
+                Edit
68
+            </div>
69
+            <div class="panel-body">
70
+
71
+                {{ Form::open(array('action' => 'Objective2Controller@update')) }}
72
+                <div class="form-group">
73
+                    {{ Form::label('program_id2', 'Associated Program')}}
74
+                    <select id='select-program' class="form-control selectpicker" onchange='fetchAllObjectives("select-program", "assoc_outcomes_fetch")'>
75
+                        @foreach ($programs as $program)
76
+                        <option value='{{$program->id}}' data-subtext="{{$program->code}}">{{$program->name}}</option>
77
+                        @endforeach
78
+                    </select>
79
+                </div>
80
+                <div class="form-group">
81
+                    <label>Associated Outcome</label>
82
+                    {{ Form::select('assoc_outcome_fetch', $outcomes, null, ['class'=>'form-control selectpicker', 'id'=>'assoc_outcomes_fetch', 'onchange'=>'fetchAllObjectives("select-program", "assoc_outcomes_fetch")']) }}
83
+
84
+                </div>
85
+                <div class="form-group">
86
+                    {{ Form::label('objective_id', 'Objectives') }}
87
+                    <select id="select-objective" name="id" class="form-control selectpicker">
88
+                        @foreach ($objectives as $objective)
89
+                        <option value="{{ $objective->id }}" data-subtext="
90
+                                        @if($objective->program)
91
+                                            &nbsp;&nbsp;&nbsp;[{{ $objective->program->name }}]
92
+                                        @endif
93
+                                        ">
94
+                            {{ $objective->text }}
95
+
96
+
97
+
98
+                        </option>
99
+                        @endforeach
100
+                    </select>
101
+                </div>
102
+
103
+                <!-- Associated Outcome -->
104
+
105
+                <div class="form-group">
106
+                    <div id='assocOutcomeGroup'>
107
+                        <label>Associated Outcome</label>
108
+
109
+                        {{ Form::select('assoc_outcome[]', $outcomes, null, ['class'=>'form-control selectpicker', 'id'=>'assoc_outcome0']) }}
110
+
111
+                    </div>
112
+                </div>
113
+                <button id='button-add-assoc-outcome' class='btn btn-md btn-secondary' onclick='addAssoc()'>
114
+                    <span class='glyphicon glyphicon-plus'>
115
+
116
+                    </span>
117
+                    Add another Outcome
118
+                </button>
119
+
120
+
121
+                <!-- Associated Program -->
122
+                <!-- Associated Program -->
123
+                <div class="form-group">
124
+
125
+                    {{ Form::label('program_id2', 'Associated Program') }}<br><br>
126
+                    @foreach ($programs as $program)
127
+
128
+                    <input type="checkbox" id="assoc_program_id_{{ $program->id }}" name="program_id[]" value="{{$program->id}}">
129
+                    <label for="assoc_program_id_{{ $program->id }}"> {{ $program->name }} <sub>[{{ $program->school->name }}]</sub></label><br>
130
+                    @endforeach
131
+                </div>
132
+
133
+
134
+                <!-- Status -->
135
+                <div class="form-group">
136
+                    {{ Form::label('status', 'Status') }}
137
+                    <span data-toggle="tooltip" data-placement="top" title="Use this option to deactivate or reactivate objectives. Inactive objective will stay in the system, but will not be available to use in new rubrics." class="glyphicon glyphicon-question-sign"></span>
138
+
139
+                    <select id="status" name="status" class="form-control">
140
+                        <option value="1">Active</option>
141
+                        <option value="0">Inactive</option>
142
+                    </select>
143
+                </div>
144
+
145
+
146
+                <div class="form-group">
147
+                    {{ Form::label('text', 'Text') }}
148
+                    {{ Form::text('text', Input::old('text'), array('class' => 'form-control', 'id'=>'objective-text')) }}
149
+                </div>
150
+                <div id="text">
151
+
152
+                </div>
153
+
154
+                {{ Form::submit('Update', array('class' => 'btn btn-primary btn-block')) }}
155
+                {{ Form::close() }}
156
+                <form action="/deleteObjective" method="POST" id='deleteObj'>
157
+
158
+                </form>
159
+            </div>
160
+
161
+
162
+
163
+
164
+        </div>
165
+    </div>
166
+</div>
167
+<script>
168
+    var outcomeHTML = document.getElementById('outcomeGroup').innerHTML;
169
+    var selectOptions = document.getElementById('outcome[0]').innerHTML;
170
+    fetchAllObjectives("select-program", "assoc_outcomes_fetch")
171
+
172
+    function fetchAllObjectives(program, outcome) {
173
+        var program_id_fetch = $('#' + program).find(':selected').val();
174
+        var outcome_fetch = $('#' + outcome).find(':selected').val();
175
+        $.post(
176
+            "{{URL::action('Objective2Controller@fetchAllObjectives')}}", {
177
+                program_fetch: program_id_fetch,
178
+                outcome_fetch: outcome_fetch
179
+            },
180
+            function(json) {
181
+                json_length = (json.objective.length);
182
+                fullHTML = '';
183
+                for (var i = 0; i < json_length; i++) {
184
+                    fullHTML += '<option value="' + json.objective[i].id + '">' + json.objective[i].text + '</option>';
185
+                }
186
+                $('#select-objective').html(fullHTML);
187
+                $('#select-objective').selectpicker('refresh');
188
+                fetchObjectiveForEditing();
189
+
190
+            },
191
+            'json'
192
+        );
193
+    }
194
+
195
+    var counter = 1;
196
+    var counterAssoc = 1;
197
+    //Add Another Outcome
198
+
199
+    function changeOutcomeHtml() {
200
+        var outcomeHTML = document.getElementById('outcomeGroup').innerHTML;
201
+
202
+        outcomeHTML = outcomeHTML.replace('outcome[' + counter.toString() + ']', 'outcome[' + (counter + 1).toString() + ']');
203
+        counter += 1;
204
+        document.getElementById("outcomeGroup").innerHTML += outcomeHTML;
205
+
206
+
207
+
208
+
209
+        document.getElementById('button-add-outcome').onclick = addOutcome;
210
+    }
211
+
212
+    function addOutcome() {
213
+        outcomeHTML = outcomeHTML.replace('outcome[' + counter.toString() + ']', 'outcome[' + (counter + 1).toString() + ']');
214
+        counter += 1;
215
+
216
+        document.getElementById("outcomeGroup").innerHTML += outcomeHTML;
217
+    }
218
+
219
+
220
+
221
+    function addOutcomeTest() {
222
+        var $select = $('<select/>', {
223
+            'class': "selectpicker form-control",
224
+            'name': "outcome[" + counter.toString() + "]",
225
+            'data-live-search': 'true'
226
+
227
+        });
228
+        var $div = $('<div/>', {
229
+            'id': 'outcomeForm' + counter.toString(),
230
+            'class': 'form-group col-md-11'
231
+        });
232
+        var $divForButton = $('<div/>', {
233
+            'class': 'col-md-1',
234
+            'id': 'close' + counter.toString()
235
+
236
+        });
237
+        var $button = $('<button/>', {
238
+            'type': 'button',
239
+            'class': 'btn btn-primary',
240
+            'onclick': 'deleteLast()'
241
+        });
242
+        $button.append('X');
243
+        $divForButton.append($button);
244
+
245
+        $div.appendTo('#outcomeGroup')
246
+        $select.append(selectOptions);
247
+
248
+        $select.appendTo('#outcomeForm' + counter.toString()).selectpicker('refresh');
249
+        $divForButton.appendTo('#outcomeGroup');
250
+        counter += 1;
251
+        $('#counter').val(counter);
252
+
253
+    }
254
+
255
+    function deleteLast() {
256
+
257
+        div = document.getElementById('outcomeForm' + (counter - 1).toString());
258
+        div.remove();
259
+        button = document.getElementById('close' + (counter - 1).toString());
260
+        button.remove();
261
+        counter -= 1;
262
+        $('#counter').val(counter);
263
+    }
264
+
265
+    function fetchObjectiveForEditing() {
266
+        var id = $('#select-objective').find(':selected').val();
267
+
268
+        $.post(
269
+            "{{ URL::action('Objective2Controller@fetchObjectiveWithTrashed') }}", {
270
+                id: id
271
+            },
272
+            function(json) {
273
+
274
+                var text = json.objective[0].text;
275
+
276
+
277
+                // Display info
278
+                $('#objective-text').val(text);
279
+
280
+
281
+                // Select associated outcome
282
+                for (var i = counterAssoc; i != 1; i--) {
283
+                    deleteLastAssoc(i);
284
+
285
+                }
286
+                $('#assoc_outcome0').val(json.outcome[0].outcome_id);
287
+                $('#assoc_outcome0').selectpicker('refresh');
288
+                counterAssoc = 1;
289
+                for (var i = 1; i < json.outcome.length; i++) {
290
+                    counterAssoc = i + 1;
291
+                    var $select = $('<select />', {
292
+                        'class': "selectpicker form-control",
293
+                        'name': "assoc_outcome[]",
294
+                        'data-live-search': 'true',
295
+                        'id': 'assoc_outcome' + i.toString()
296
+
297
+                    });
298
+                    var $div = $('<div />', {
299
+                        'id': 'assocOutcomeForm' + i.toString(),
300
+                        'class': 'form-group col-md-11'
301
+                    });
302
+                    var $divForButton = $('<div />', {
303
+                        'class': 'col-md-1',
304
+                        'id': 'closeAssoc' + i.toString()
305
+
306
+                    });
307
+                    var $button = $('<button />', {
308
+                        'type': 'button',
309
+                        'class': 'btn btn-primary',
310
+                        'onclick': 'deleteLastAssoc()'
311
+                    });
312
+                    $button.append('X');
313
+                    $divForButton.append($button);
314
+
315
+                    $div.appendTo('#assocOutcomeGroup')
316
+                    $select.append(selectOptions);
317
+
318
+                    $select.appendTo('#assocOutcomeForm' + i.toString()).selectpicker('refresh');
319
+                    $divForButton.appendTo('#assocOutcomeGroup');
320
+
321
+                    $('#assoc_outcome' + i.toString()).val(json.outcome[i].outcome_id);
322
+                    $('#assoc_outcome' + i.toString()).selectpicker('refresh');
323
+
324
+
325
+                }
326
+
327
+
328
+                // Select associated program
329
+                var program_length = json.program.length;
330
+                $('input[type=checkbox]').prop('checked', false);
331
+
332
+                for (var i = 0; i < program_length; i++) {
333
+                    prog = json.program[i].program_id.toString();
334
+                    $('#assoc_program_id_' + prog).prop("checked", true);
335
+                }
336
+
337
+
338
+                // Select status
339
+                if (json.objective[0].deleted_at)
340
+                    $('#status').val(0);
341
+                else
342
+                    $('#status').val(1);
343
+                if (json.assessment.length) {
344
+                    $('#deleteObj').html("<p>This objective is currently participating in an assessment, therefore it cannot be deleted</p>");
345
+                } else if (json.assoc_criteria.length) {
346
+                    modal = '<button type="button" class="btn btn-primary btn-block" data-toggle="modal" data-target="#delete">' +
347
+                        'Delete' +
348
+                        '</button>' +
349
+                        '<input type="hidden" value =' + json.objective[0].id + ' name="deleteObj">' +
350
+
351
+                        '<div class="modal fade" id="delete" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">' +
352
+                        '<div class="modal-dialog" role="document">' +
353
+                        '<div class="modal-content">' +
354
+                        ' <div class="modal-header">' +
355
+                        '<h5 class="modal-title" id="exampleModalLabel">Are you sure?</h5>' +
356
+                        '<button type="button" class="close" data-dismiss="modal" aria-label="Close">' +
357
+                        '<span aria-hidden="true">&times;</span>' +
358
+                        '</button>' +
359
+                        ' </div>' +
360
+                        '<div class="modal-body">' +
361
+                        "<p>This objective is associated to: <p>" +
362
+                        '<ul>';
363
+                    for (var i = 0; i < json.assoc_criteria.length; i++) {
364
+                        modal += "<li>" + json.assoc_criteria[i].name + '</li>';
365
+                    }
366
+                    modal += ' </ul>' +
367
+                        '<p>Do you still want to delete it?</p>' +
368
+                        '</div>' +
369
+                        '<div class="modal-footer">' +
370
+                        '<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>' +
371
+                        '<button type="submit" class="btn btn-primary">Delete</button>' +
372
+                        '</div>' +
373
+                        '</div>' +
374
+                        '</div>' +
375
+                        '</div>';
376
+                    $('#deleteObj').html(modal);
377
+
378
+
379
+                } else {
380
+                    modal = '<button type="button" class="btn btn-primary btn-block" data-toggle="modal" data-target="#delete">' +
381
+                        'Delete' +
382
+                        '</button>' +
383
+                        '<input type="hidden" value =' + json.objective[0].id + ' name="deleteObj">' +
384
+
385
+                        '<div class="modal fade" id="delete" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">' +
386
+                        '<div class="modal-dialog" role="document">' +
387
+                        '<div class="modal-content">' +
388
+                        ' <div class="modal-header">' +
389
+                        '<h5 class="modal-title" id="exampleModalLabel">Are you sure?</h5>' +
390
+                        '<button type="button" class="close" data-dismiss="modal" aria-label="Close">' +
391
+                        '<span aria-hidden="true">&times;</span>' +
392
+                        '</button>' +
393
+                        ' </div>' +
394
+                        '<div class="modal-body">' +
395
+                        "<p> Once deleted, there is no chance of getting it back.</p>";
396
+
397
+                    modal +=
398
+                        '<p>Do you still want to delete it?</p>' +
399
+                        '</div>' +
400
+                        '<div class="modal-footer">' +
401
+                        '<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>' +
402
+                        '<button type="submit" class="btn btn-primary">Delete</button>' +
403
+                        '</div>' +
404
+                        '</div>' +
405
+                        '</div>' +
406
+                        '</div>';
407
+                    $('#deleteObj').html(modal);
408
+                }
409
+            },
410
+            'json'
411
+        );
412
+    }
413
+
414
+    function deleteLastAssoc() {
415
+
416
+        div = document.getElementById('assocOutcomeForm' + (counterAssoc).toString());
417
+        div.remove();
418
+        button = document.getElementById('closeAssoc' + (counterAssoc).toString());
419
+        button.remove();
420
+        counterAssoc -= 1;
421
+
422
+    }
423
+
424
+    function addAssoc() {
425
+
426
+
427
+        var $select = $('<select />', {
428
+            'class': "selectpicker form-control",
429
+            'name': "assoc_outcome[]",
430
+            'data-live-search': 'true',
431
+            'id': 'assoc_outcome' + counterAssoc.toString()
432
+
433
+        });
434
+        var $div = $('<div />', {
435
+            'id': 'assocOutcomeForm' + counterAssoc.toString(),
436
+            'class': 'form-group col-md-11'
437
+        });
438
+        var $divForButton = $('<div />', {
439
+            'class': 'col-md-1',
440
+            'id': 'closeAssoc' + counterAssoc.toString()
441
+
442
+        });
443
+        var $button = $('<button />', {
444
+            'type': 'button',
445
+            'class': 'btn btn-primary',
446
+            'onclick': 'deleteLastAssoc()'
447
+        });
448
+        $button.append('X');
449
+        $divForButton.append($button);
450
+
451
+        $div.appendTo('#assocOutcomeGroup')
452
+        $select.append(selectOptions);
453
+
454
+        $select.appendTo('#assocOutcomeForm' + counterAssoc.toString()).selectpicker('refresh');
455
+        $divForButton.appendTo('#assocOutcomeGroup');
456
+
457
+
458
+
459
+        counterAssoc += 1;
460
+
461
+
462
+    }
463
+</script>
464
+@stop
465
+
466
+@section('javascript')
467
+
468
+// --------------------------------------------------------------------------
469
+// Page load
470
+// --------------------------------------------------------------------------
471
+
472
+// Hide accordion panel contents by default
473
+$('.panel-group .panel-body').hide();
474
+
475
+$('#outcome-display').parent().hide();
476
+
477
+fetchObjectiveForEditing();
478
+// setCriterionStatus();
479
+
480
+
481
+
482
+
483
+// --------------------------------------------------------------------------
484
+// Functions
485
+// --------------------------------------------------------------------------
486
+
487
+// Fetch criterion info for editing
488
+
489
+$('#button-add-outcome').on('click', function(e) {
490
+// Prevent the default action of the clicked item. In this case that is submit
491
+e.preventDefault();
492
+
493
+
494
+return false;
495
+});
496
+$('#button-add-assoc-outcome').on('click', function(e) {
497
+// Prevent the default action of the clicked item. In this case that is submit
498
+e.preventDefault();
499
+
500
+
501
+return false;
502
+});
503
+
504
+// --------------------------------------------------------------------------
505
+// Events
506
+// --------------------------------------------------------------------------
507
+
508
+// When panel heading is clicked, toggle it
509
+$('.panel-group .panel-heading').on('click', function()
510
+{
511
+$(this).next().stop().slideToggle();
512
+})
513
+
514
+
515
+// When list item is clicked, load corresponding info
516
+$('#select-objective').on('change', function()
517
+{
518
+fetchObjectiveForEditing();
519
+$('.selectpicker').selectpicker('refresh');
520
+});
521
+
522
+// When list item is clicked, load corresponding info
523
+$('.selectpicker').on('change', function()
524
+{
525
+//alert($(this).find(':selected').val());
526
+$('.selectpicker').selectpicker('refresh');
527
+});
528
+
529
+@stop

+ 471
- 471
app/views/local/managers/admins/overview.blade.php
Diferenças do arquivo suprimidas por serem muito extensas
Ver arquivo


+ 891
- 0
app/views/local/managers/admins/transformativeAction.blade.php Ver arquivo

@@ -0,0 +1,891 @@
1
+@extends('layouts.master')
2
+
3
+@section('navigation')
4
+    @if($role==2)
5
+        @include('local.managers.sCoords._navigation')
6
+    @elseif($role==3)
7
+        @include('local.managers.pCoords._navigation')
8
+    @else
9
+        @include('local.professors._navigation')
10
+    @endif
11
+@stop
12
+@section('main')
13
+
14
+<div class="row">
15
+    <div class="col-md-6">
16
+        <!-- Form to add a new criterion -->
17
+        <div class="panel panel-default panel-button">
18
+            <div class="panel-heading">
19
+                Create a TA
20
+            </div>
21
+            <div class="panel-body" id="createPanel">
22
+              {{ Form::open(array('action' => 'TransformativeActionsController@createTA')) }}
23
+
24
+              <div class="form-group">
25
+                {{ Form::label('text', 'Name') }}
26
+                {{ Form::text('text', '', array('class' => 'form-control')) }}
27
+              </div>
28
+
29
+              <div class="form-group">
30
+                {{ Form::label('description', 'Description') }}
31
+                {{ Form::textarea('description', '', array('class' => 'form-control')) }}
32
+              </div>
33
+
34
+              <div class="form-group"> </div>
35
+              <div class="form-group" id='dummyApproval'>
36
+                <label>Availability</label>
37
+                <select name="approval" class="form-control">
38
+                  <option value="1">Recommended</option>
39
+                  <option value="0">To be implemented</option>
40
+                </select>
41
+              </div>
42
+
43
+              <label>Courses being Transformed by the Action</label>
44
+              <div class="" id="">
45
+                <div class="form-group col-md-11">
46
+                  <select name="courseid[]" class="form-control createCourses selectpicker">
47
+                    @foreach ($courses_create as $course)
48
+                      <option value="{{$course->id}}">{{$course->name}} [{{$course->code}}]</option>
49
+                    @endforeach
50
+                  </select>
51
+                </div>
52
+                <button type="button" class='btn btn-md btn-primary col-md-1 remove-course'>
53
+                  X
54
+                </button>
55
+              </div>
56
+              <button type="button" class='btn btn-md btn-secondary add-course'>
57
+                <span class='glyphicon glyphicon-plus'>
58
+                </span>
59
+                Add another Course
60
+              </button>
61
+              <div class="form-group"> </div>
62
+
63
+              <div class="form-group" id='createOutcome'>
64
+                <label>Outcome perteneciente</label>
65
+                <select name="outcome" class="form-control selectpicker">
66
+                  @foreach ($outcomes as $outcome)
67
+                    <option value="{{$outcome->id}}">{{$outcome->name}}</option>
68
+                  @endforeach
69
+                </select>
70
+              </div>
71
+
72
+              <label>Associated Objectives</label>
73
+              <div class="" id="">
74
+                <div class="form-group col-md-11">
75
+                  <select name="objectiveid[]" class="form-control createObjectives">
76
+                    <option value="">First, select an Outcome</option>
77
+                  </select>
78
+                </div>
79
+                <button type="button" class='btn btn-md btn-primary col-md-1 remove-objective'>
80
+                  X
81
+                </button>
82
+              </div>
83
+              <button type="button" class='btn btn-md btn-secondary add-objective'>
84
+                <span class='glyphicon glyphicon-plus'>
85
+                </span>
86
+                Add another Objective
87
+              </button>
88
+              <div class="form-group"> </div>
89
+
90
+              {{ Form::submit('Create', array('class' => 'btn btn-primary btn-block')) }}
91
+              {{ Form::close() }}
92
+            </div>
93
+        </div>
94
+        <div class="panel panel-default panel-button">
95
+            <div class="panel-heading">
96
+                Approve a Recommended TA
97
+            </div>
98
+            <div class="panel-body" id="approvePanel">
99
+
100
+              <div class="">
101
+                <button class="btn btn-md btn-secondary filterButton">
102
+                  <span class="glyphicon glyphicon-plus">
103
+                  </span>
104
+                  Filters
105
+                </button>
106
+              </div>
107
+              <div class="filterSection">
108
+                <br>
109
+                <div class="">
110
+                  <div class="">
111
+                    <label>Professor that created the TA</label>
112
+                    <select class="form-control filterProfessor selectpicker">
113
+                      <option value="0">Show All</option>
114
+                      @foreach ($professor_filter_approvePanel as $ta)
115
+                        <option value="{{$ta->id}}">Prof. {{$ta->first_name}} {{$ta->surnames}}</option>
116
+                      @endforeach
117
+                    </select>
118
+                  </div>
119
+                  <br>
120
+                  <div class="">
121
+                    <label>Course evaluated by an Objective of the TA</label>
122
+                    <select class="form-control filterCourse selectpicker">
123
+                      <option value="0">Show All</option>
124
+                      @foreach ($course_filter_approvePanel as $course)
125
+                        <option value="{{$course->id}}">{{$course->name}}[{{$course->code}}]</option>
126
+                      @endforeach
127
+                    </select>
128
+                  </div>
129
+                  <br>
130
+                  <div class="">
131
+                    <label>Outcome of the TA</label>
132
+                    <select class="form-control filterOutcome selectpicker">
133
+                      <option value="0">Show All</option>
134
+                      @foreach ($outcome_filter_approvePanel as $outcome)
135
+                        <option value="{{$outcome->id}}">{{$outcome->name}}</option>
136
+                      @endforeach
137
+                    </select>
138
+                  </div>
139
+                </div>
140
+              </div>
141
+              <hr>
142
+              {{ Form::open(array('action' => 'TransformativeActionsController@approveTA')) }}
143
+
144
+              <div>
145
+                <div class="form-group col-md-11">
146
+                  <label>Select Transformative Action</label>
147
+                  <select name="ta" class="form-control SelectTA selectpicker" id='approvalSelectTA'>
148
+                    @if (count($ta_approval_panel) == 0)
149
+                      <option value="0">No TAs available</option>
150
+                    @else
151
+                    @endif
152
+                    @foreach ($ta_approval_panel as $ta)
153
+                      <option value="{{$ta->id}}">{{$ta->at_text}}</option>
154
+                   @endforeach
155
+                  </select>
156
+                </div>
157
+              </div>
158
+
159
+              <div class="form-group">
160
+                {{ Form::label('approvalDescription', 'Description') }}
161
+                {{ Form::textarea('approvalDescription', '', array('class' => 'form-control')) }}
162
+              </div>
163
+
164
+              <label>Associated Courses</label>
165
+              <div class="approveCourses">
166
+                <div class="form-group col-md-11 approveCourse">
167
+                  <select name="courseid[]" class="form-control selectpicker">
168
+                      <option value="">option</option>
169
+                  </select>
170
+                </div>
171
+                <button type="button" class='btn btn-md btn-primary col-md-1 remove-course'>
172
+                  X
173
+                </button>
174
+              </div>
175
+              <button type="button" class='btn btn-md btn-secondary add-course'>
176
+                <span class='glyphicon glyphicon-plus'>
177
+                </span>
178
+                Add another Course
179
+              </button>
180
+
181
+              <label>Associated Objectives</label>
182
+              <div class="approveObjectives">
183
+                <div class="form-group col-md-11">
184
+                  <select name="objectiveid[]" class="form-control">
185
+                    @foreach ($objectives as $id => $text)
186
+                      <option value="{{$id}}">{{$text}}</option>
187
+                    @endforeach
188
+                  </select>
189
+                </div>
190
+                <button type="button" class='btn btn-md btn-primary col-md-1 remove-objective'>
191
+                  X
192
+                </button>
193
+              </div>
194
+              <button type="button" class='btn btn-md btn-secondary add-objective'>
195
+                <span class='glyphicon glyphicon-plus'>
196
+                </span>
197
+                Add another Objective
198
+              </button>
199
+
200
+              <input type='hidden' name='at_text' class="approvalText">
201
+
202
+              <input type='hidden' name='ta_id' class='updateTA'>
203
+
204
+              {{ Form::submit('Approve', array('class' => 'btn btn-primary btn-block')) }}
205
+              {{ Form::close() }}
206
+            </div>
207
+        </div>
208
+    </div>
209
+
210
+    <div class="col-md-6">
211
+        <div class="panel panel-default panel-button">
212
+            <div class="panel-heading">
213
+                Edit a TA
214
+            </div>
215
+            <div class="panel-body" id="editPanel">
216
+
217
+              <div class="">
218
+                <button class="btn btn-md btn-secondary filterButton">
219
+                  <span class="glyphicon glyphicon-plus">
220
+                  </span>
221
+                  Filters
222
+                </button>
223
+              </div>
224
+              <div class="filterSection">
225
+                <br>
226
+                <div class="">
227
+                  <div class="">
228
+                    <label>Professor that created the TA</label>
229
+                    <select class="form-control filterProfessor selectpicker">
230
+                      <option value="0">Show All</option>
231
+                      @foreach ($professor_filter_editPanel as $user)
232
+                        <option value="{{$user->id}}">Prof. {{$user->first_name}} {{$user->surnames}}</option>
233
+                      @endforeach
234
+                    </select>
235
+                  </div>
236
+                  <br>
237
+                  <div class="">
238
+                    <label>Course evaluated by an Objective of the TA</label>
239
+                    <select class="form-control filterCourse selectpicker">
240
+                      <option value="0">Show All</option>
241
+                      @foreach ($course_filter_editPanel as $course)
242
+                        <option value="{{$course->id}}">{{$course->name}}[{{$course->code}}]</option>
243
+                      @endforeach
244
+                    </select>
245
+                  </div>
246
+                  <br>
247
+                  <div class="">
248
+                    <label>Outcome of the TA</label>
249
+                    <select class="form-control filterOutcome selectpicker">
250
+                      <option value="0">Show All</option>
251
+                      @foreach ($outcome_filter_editPanel as $outcome)
252
+                        <option value="{{$outcome->id}}">{{$outcome->name}}</option>
253
+                      @endforeach
254
+                    </select>
255
+                  </div>
256
+                </div>
257
+              </div>
258
+              <hr>
259
+
260
+              {{ Form::open(array('action' => 'TransformativeActionsController@updateTA')) }}
261
+
262
+              <div>
263
+                <div class="form-group col-md-12">
264
+                  <label>Select Transformative Action</label>
265
+                  <select name="ta" class="form-control SelectTA selectpicker" id='editSelectTA'>
266
+                     @if (count($ta_edit_panel) == 0)
267
+                       <option value="0">No TAs available</option>
268
+                     @else
269
+                     @endif
270
+                     @foreach ($ta_edit_panel as $ta)
271
+                      <option value="{{$ta->id}}">{{$ta->at_text}}</option>
272
+                    @endforeach
273
+                  </select>
274
+                </div>
275
+              </div>
276
+
277
+              <div class="form-group" id="editName">
278
+                {{ Form::label('text', 'Name') }}
279
+                {{ Form::text('text', '', array('class' => 'form-control')) }}
280
+              </div>
281
+              <input type='hidden' name='ta_id' class='updateTA' value="0">
282
+
283
+              <div class="form-group">
284
+                {{ Form::label('description', 'Description') }}
285
+                {{ Form::textarea('description', '', array('class' => 'form-control')) }}
286
+              </div>
287
+
288
+              <div class="form-group"> </div>
289
+              <div class="form-group" id='editApproval'>
290
+                <label>Availability</label>
291
+                <select name="approval" class="form-control selectpicker">
292
+                    <option value="1">Recommended</option>
293
+                    <option value="0">To be implemented</option>
294
+                </select>
295
+              </div>
296
+
297
+              <label>Associated Courses</label>
298
+              <div class="editCourses">
299
+                <div class="form-group col-md-11 editCourse">
300
+                  <select name="courseid[]" class="form-control selectpicker">
301
+                    @foreach ($courses_create as $course)
302
+                      <option value="{{$course->id}}">{{$course->name}}[{{$course->code}}]</option>
303
+                    @endforeach
304
+                  </select>
305
+                </div>
306
+                <button type="button" class='btn btn-md btn-primary col-md-1 remove-course'>
307
+                  X
308
+                </button>
309
+              </div>
310
+              <button type="button" class='btn btn-md btn-secondary add-course'>
311
+                <span class='glyphicon glyphicon-plus'>
312
+                </span>
313
+                Add another Course
314
+              </button>
315
+              <div class="form-group"> </div>
316
+
317
+              <label>Associated Objectives</label>
318
+              <div class="editObjectives">
319
+                <div class="form-group col-md-11">
320
+                  {{-- <select class="form-control selectpicker"> --}}
321
+                  <select name="objectiveid[]" class="form-control">
322
+                    @foreach ($objectives as $id => $text)
323
+                      <option value="{{$id}}">{{$text}}</option>
324
+                    @endforeach
325
+                  </select>
326
+                </div>
327
+                <button type="button" class='btn btn-md btn-primary col-md-1 remove-objective'>
328
+                  X
329
+                </button>
330
+              </div>
331
+              <button type="button" class='btn btn-md btn-secondary add-objective'>
332
+                <span class='glyphicon glyphicon-plus'>
333
+                </span>
334
+                Add another Objective
335
+              </button>
336
+              <div class="form-group"> </div>
337
+
338
+              {{ Form::submit('Update', array('class' => 'btn btn-primary btn-block')) }}
339
+              {{ Form::close() }}
340
+
341
+              {{ Form::open(array('action' => 'TransformativeActionsController@deleteTA')) }}
342
+              <input type='hidden' name='ta_id' id='deleteTA'>
343
+              {{Form::submit("Delete", array('class'=> 'btn btn-primary btn-block', 'id'=>"DeleteButton"))}}
344
+            </div>
345
+        </div>
346
+    </div>
347
+</div>
348
+
349
+@stop
350
+
351
+@section('javascript')
352
+
353
+// --------------------------------------------------------------------------
354
+// Page load
355
+// --------------------------------------------------------------------------
356
+
357
+// Hide accordion panel contents by default
358
+$('.panel-group .panel-body').hide();
359
+
360
+$('#outcome-display').parent().hide();
361
+
362
+$('.remove-objective').hide();
363
+$('.remove-course').hide();
364
+
365
+////createPanel
366
+// remove TA approval section if the user isnt a program coordinator
367
+var dummyApproval = $('#dummyApproval');
368
+dummyApproval.find('select').prop('disabled', 'disabled');
369
+dummyApproval.find('option').remove();
370
+
371
+
372
+var role = {{Auth::user()['role']}};
373
+if (role == 3){
374
+  dummyApproval.find('select').append('<option value="0">To be implemented</option>');
375
+  $('#approvePanel .add-course').hide();
376
+} else if (role == 4){
377
+  dummyApproval.find('select').append('<option value="1">Recommended</option>');
378
+  $('#approvePanel').parent().hide();
379
+
380
+  //hide the select for changin Availability
381
+  $('#editApproval').find('select').prop('disabled', 'disabled');
382
+  //add an input since disabled the form wont recognize it
383
+  $('#editApproval').append('<input type="text" name="approval" value="1" hidden />')
384
+
385
+  // in edit panel, hide the professor filter
386
+  $('.filterProfessor').parent().hide();
387
+  $('.filterProfessor').parent().next().hide(); // hide <br>
388
+}
389
+
390
+$('.createObjectives').prop('disabled', 'disabled');
391
+$('#createPanel .add-objective').prop('disabled', 'disabled');
392
+
393
+
394
+////editPanel
395
+// disable the buttons of the edit section if there are no TA for selection
396
+if(($('#editSelectTA').val() === "")){
397
+  $('#editPanel').find('select').prop('disabled', 'disabled');
398
+  $('#editPanel').find('button').prop('disabled', 'disabled');
399
+  $('#editPanel').find('input').prop('disabled', 'disabled');
400
+}else{
401
+  var ta_id = $('#editSelectTA').val();
402
+  if(ta_id != 0){
403
+    load_ta_info_for_edit(ta_id);
404
+  }
405
+
406
+
407
+}
408
+
409
+////approvePanel
410
+$('#approvePanel .add-objective').hide();
411
+// disable the buttons of the approval section if there are no TA for selection
412
+if(($('#approvalSelectTA').val() === "")){
413
+  $('#approvePanel').find('select').prop('disabled', 'disabled');
414
+  $('#approvePanel').find('button').prop('disabled', 'disabled');
415
+  $('#approvePanel').find('input').prop('disabled', 'disabled');
416
+  $('#approvalDescription').prop('disabled', 'disabled');
417
+}else{
418
+  var ta_id = $('#approvalSelectTA').val();
419
+  if(ta_id != 0){
420
+    load_ta_info_for_approval(ta_id);
421
+  }
422
+
423
+}
424
+
425
+//
426
+$('.filterSection').hide();
427
+
428
+// --------------------------------------------------------------------------
429
+// Functions
430
+// --------------------------------------------------------------------------
431
+
432
+function load_objectives_from_outcome(outcome_id) {
433
+  $.post(
434
+    "{{ URL::action('TransformativeActionsController@objectivesFromOutcome') }}",
435
+    {
436
+      outcome_id: (outcome_id),
437
+    },
438
+    function(data)
439
+    {
440
+      var panel = $('#createPanel');
441
+
442
+      //
443
+      var objectives = data.objectives;
444
+      //delete al current select
445
+      panel.find('.remove-objective').parent().remove();
446
+
447
+      //create select
448
+      var new_div = $('<div/>',{
449
+        'class': 'createObjectives'
450
+      });
451
+      var new_inner_div = $('<div/>',{
452
+        'class': 'form-group col-md-11'
453
+      });
454
+      var new_select = $('<select/>',{
455
+        'class': 'form-control createObjectives selectpicker',
456
+        'data-live-search': 'true',
457
+        'name': 'objectiveid[]'
458
+      });
459
+      var new_button = $('<button/>',{
460
+        'class': 'btn btn-md btn-primary col-md-1 remove-objective',
461
+        'type': 'button',
462
+        'html': 'X'
463
+      });
464
+      new_button.hide();
465
+
466
+      $.each(objectives, function(index, objective)
467
+      {
468
+        new_select.append('<option value="'+ objective.id +'">'+ objective.text +'</option>');
469
+      });
470
+
471
+      panel.find('.add-objective').before(new_div);
472
+      new_div.append(new_button);
473
+      new_div.append(new_inner_div);
474
+      new_inner_div.append(new_select);
475
+      new_select.selectpicker('refresh');
476
+
477
+      //activate the button for adding more objectives
478
+      $('#createPanel .add-objective').prop('disabled', false);
479
+    }
480
+  );
481
+}
482
+
483
+function load_ta_info_for_edit(ta_id) {
484
+  $.post(
485
+    "{{ URL::action('TransformativeActionsController@selectTA') }}",
486
+    {
487
+      ta_id: (ta_id),
488
+    },
489
+    function(data)
490
+    {
491
+      //
492
+      var selected_courses = data.selected_courses;
493
+      var objectives = data.objectives;
494
+      var objectives_from_outcome = data.objectives_from_outcome;
495
+      var status = data.status;
496
+      var name = data.name[0];
497
+      var description = data.description[0];
498
+      var can_be_deleted = data.can_be_deleted;
499
+
500
+      //add objectives button
501
+      var add_button = $('#editPanel .add-objective');
502
+
503
+      //set if the TA is approved or not
504
+      $('#editApproval select').val(status);
505
+
506
+      //delete objectives select
507
+      $('.editObjectives').remove();
508
+
509
+      //create one objective select and populate it
510
+      var panel = $('#editPanel');
511
+
512
+      //
513
+      var objectives = data.objectives;
514
+      //delete al current select
515
+      panel.find('.remove-objective').parent().remove();
516
+
517
+      //create select
518
+      var new_div = $('<div/>',{
519
+        'class': 'editObjectives'
520
+      });
521
+      var new_inner_div = $('<div/>',{
522
+        'class': 'form-group col-md-11'
523
+      });
524
+      var new_select = $('<select/>',{
525
+        'class': 'form-control editObjectives selectpicker',
526
+        'data-live-search': 'true',
527
+        'name': 'objectiveid[]'
528
+      });
529
+      var new_button = $('<button/>',{
530
+        'class': 'btn btn-md btn-primary col-md-1 remove-objective',
531
+        'type': 'button',
532
+        'html': 'X'
533
+      });
534
+      new_button.hide();
535
+
536
+      $.each(objectives_from_outcome, function(index, objective)
537
+      {
538
+        new_select.append('<option value="'+ objective.id +'">'+ objective.text +'</option>');
539
+      });
540
+
541
+      panel.find('.add-objective').before(new_div);
542
+      new_div.append(new_button);
543
+      new_div.append(new_inner_div);
544
+      new_inner_div.append(new_select);
545
+      new_select.selectpicker('refresh');
546
+
547
+
548
+      //change de value of the select
549
+
550
+      //add the other selects
551
+
552
+      var prev_select = new_div;
553
+      $.each(objectives, function(index, objective)
554
+      {
555
+        prev_select.find('select').val(objective.id);
556
+        add_objective_select(add_button);
557
+        {{-- add_button; --}}
558
+        prev_select = add_button.prev();
559
+
560
+      });
561
+      add_button.prev().remove();
562
+
563
+      //set the text box
564
+      $('#editName').find('input').val(name);
565
+      $('#editPanel #description').val(description);
566
+
567
+      //
568
+      $('#deleteTA').val(ta_id);
569
+      $('#editPanel .updateTA').val(ta_id);
570
+
571
+      if(can_be_deleted == false){
572
+        $('#DeleteButton').prop('disabled', 'disabled');
573
+      }else{
574
+        $('#DeleteButton').prop('disabled', false);
575
+      }
576
+
577
+
578
+      //locate de "add course" button on edit panel
579
+      var add_course_button = $('#editPanel .add-course')
580
+
581
+      //save current course selectpickers, add a new one, and delete old ones
582
+      var current_course_selects = $('#editPanel .editCourse');
583
+      add_course_button.click();
584
+      current_course_selects.remove();
585
+
586
+      //populate edit panel with courses previusly selected
587
+      var prev_select = add_course_button.prev();
588
+      prev_select.find('.remove-course').hide();
589
+      $.each(selected_courses, function(index, course)
590
+      {
591
+        prev_select.find('select').val(course.id);
592
+        add_course_button.click();
593
+        prev_select = add_course_button.prev();
594
+      });
595
+      prev_select.remove();
596
+
597
+    }
598
+  );
599
+}
600
+
601
+function load_ta_info_for_approval(ta_id) {
602
+  $.post(
603
+    "{{ URL::action('TransformativeActionsController@selectTA') }}",
604
+    {
605
+      ta_id: (ta_id),
606
+    },
607
+    function(data)
608
+    {
609
+      //
610
+      var selected_courses = data.selected_courses;
611
+      var objectives = data.objectives;
612
+      var status = data.status[0];
613
+      var name = data.name[0];
614
+      var description = data.description[0];
615
+
616
+      //clear the objectives of ony prevoius TA selected for approve
617
+      var add_button = $('#approvePanel .add-objective');
618
+      var select = add_button.prev().clone(true);
619
+
620
+      var first_select = select.clone(true);
621
+      first_select.find('button').hide();
622
+
623
+      $('.approveObjectives').remove();
624
+      add_button.before(first_select);
625
+
626
+      var prev_select = first_select;
627
+      $.each(objectives, function(index, objective)
628
+      {
629
+
630
+        // save the new select in a var
631
+        var new_select = select.clone(true);
632
+
633
+        // set only one option on the select
634
+        prev_select.find('option').remove();
635
+        prev_select.find('select').append('<option value="'+ objective.id +'">'+objective.text +'</option>');
636
+        prev_select = new_select;
637
+        // add the copy of the select
638
+        add_button.before(new_select);
639
+      });
640
+      // remove the last objective select, since it isnt one of the saved objectives
641
+      add_button.prev().remove();
642
+
643
+      //
644
+      $('#approvalDescription').val(description);
645
+      $('.approvalText').val(name);
646
+      $('#approvePanel .updateTA').val(ta_id);
647
+
648
+
649
+      //locate de "add course" button on approve panel
650
+      var add_course_button = $('#approvePanel .add-course')
651
+
652
+      //save current course selectpickers, add a new one, and delete old ones
653
+      var current_course_selects = $('#approvePanel .approveCourse');
654
+      add_course_button.click();
655
+      current_course_selects.remove();
656
+
657
+      //populate approve panel with courses previusly selected
658
+      var prev_select = add_course_button.prev();
659
+      prev_select.find('.remove-course').hide();
660
+      $.each(selected_courses, function(index, course)
661
+      {
662
+        var new_option = $('<option/>',{
663
+          'value': course.id,
664
+          'type': 'button',
665
+          'html': course.name+' ['+course.code+']'
666
+        });
667
+        prev_select.find('select option').remove();
668
+        prev_select.find('select').append(new_option);
669
+        prev_select.find('.remove-course').hide();
670
+        add_course_button.click();
671
+        prev_select = add_course_button.prev();
672
+      });
673
+      prev_select.remove();
674
+
675
+    }
676
+  );
677
+}
678
+
679
+function add_objective_select(element) {
680
+  var prev_select = $(element).prev();
681
+
682
+  var parent_panel = $(element).parent().parent().attr('id');
683
+  var select_class = '';
684
+  if(parent_panel == 'editPanel'){
685
+    select_class = 'editObjectives';
686
+  }else{
687
+    select_class = 'createObjectives';
688
+  }
689
+
690
+  //create select
691
+  var new_div = $('<div/>',{
692
+    'class': select_class
693
+  });
694
+  var new_inner_div = $('<div/>',{
695
+    'class': 'form-group col-md-11'
696
+  });
697
+  var new_select = $('<select/>',{
698
+    'class': 'form-control createObjectives selectpicker',
699
+    'data-live-search': 'true',
700
+    'name': 'objectiveid[]'
701
+  });
702
+  var new_button = $('<button/>',{
703
+    'class': 'btn btn-md btn-primary col-md-1 remove-objective',
704
+    'type': 'button',
705
+    'html': 'X'
706
+  });
707
+
708
+
709
+  $.each(prev_select.find('option'), function(index, option)
710
+  {
711
+    var new_option = $('<option/>',{
712
+      'value': $(option).val(),
713
+      'html': $(option).html()
714
+    });
715
+    new_select.append(new_option);
716
+  });
717
+
718
+
719
+  $(element).before(new_div);
720
+  new_div.append(new_inner_div);
721
+  new_div.append(new_button);
722
+  new_inner_div.append(new_select);
723
+  $(element).parent().find('.selectpicker').selectpicker('refresh');
724
+  new_select.selectpicker('refresh');
725
+
726
+}
727
+
728
+function add_course_select(element) {
729
+  var prev_select = $(element).prev();
730
+
731
+  var parent_panel = $(element).parent().parent().attr('id');
732
+  var select_class = '';
733
+  if(parent_panel == 'editPanel'){
734
+    select_class = 'editCourse';
735
+  }else{
736
+    select_class = 'createCourse';
737
+  }
738
+
739
+  //create select
740
+  var new_div = $('<div/>',{
741
+    'class': select_class+' approveCourse'
742
+  });
743
+  var new_inner_div = $('<div/>',{
744
+    'class': 'form-group col-md-11'
745
+  });
746
+  var new_select = $('<select/>',{
747
+    'class': 'form-control createCourses selectpicker',
748
+    'data-live-search': 'true',
749
+    'name': 'courseid[]'
750
+  });
751
+  var new_button = $('<button/>',{
752
+    'class': 'btn btn-md btn-primary col-md-1 remove-course',
753
+    'type': 'button',
754
+    'html': 'X'
755
+  });
756
+
757
+
758
+  $.each(prev_select.find('option'), function(index, option)
759
+  {
760
+    var new_option = $('<option/>',{
761
+      'value': $(option).val(),
762
+      'html': $(option).html()
763
+    });
764
+    new_select.append(new_option);
765
+  });
766
+
767
+
768
+  $(element).before(new_div);
769
+  new_div.append(new_inner_div);
770
+  new_div.append(new_button);
771
+  new_inner_div.append(new_select);
772
+  $(element).parent().find('.selectpicker').selectpicker('refresh');
773
+  new_select.selectpicker('refresh');
774
+
775
+}
776
+
777
+// --------------------------------------------------------------------------
778
+// Events
779
+// --------------------------------------------------------------------------
780
+
781
+// When a TA is selected for edit, load the TA info
782
+$('#createOutcome').on('change', function()
783
+{
784
+  var outcome_id = $(this).find('select').val();
785
+
786
+  load_objectives_from_outcome(outcome_id);
787
+});
788
+
789
+// When a TA is selected for edit, load the TA info
790
+$('#editSelectTA').parent().on('change', function()
791
+{
792
+  var ta_id = $(this).find('select').val();
793
+  if(ta_id != 0){
794
+    load_ta_info_for_edit(ta_id);
795
+  }
796
+});
797
+
798
+// When a TA is selected for approval, load the TA info
799
+$('#approvalSelectTA').parent().on('change', function()
800
+{
801
+  var ta_id = $(this).find('select').val();
802
+  if(ta_id != 0){
803
+    load_ta_info_for_approval(ta_id);
804
+    }
805
+});
806
+
807
+
808
+// Add an objective Select picker
809
+$('.add-objective').on('click', function()
810
+{
811
+  add_objective_select(this);
812
+});
813
+// Add an course Select picker
814
+$('.add-course').on('click', function()
815
+{
816
+  add_course_select(this);
817
+});
818
+
819
+// Remove an objective Select picker
820
+$('.panel').on('click', '.remove-objective', function()
821
+{
822
+  $(this).parent().remove();
823
+});
824
+// Remove an course Select picker
825
+$('.panel').on('click', '.remove-course', function()
826
+{
827
+  $(this).parent().remove();
828
+});
829
+
830
+// Remove an objective Select picker
831
+$('.filterButton').on('click', function()
832
+{
833
+  var span = $(this).find('span');
834
+  if(span.attr('class') == 'glyphicon glyphicon-plus'){
835
+    span.attr('class','glyphicon glyphicon-minus');
836
+  } else{
837
+    span.attr('class','glyphicon glyphicon-plus');
838
+  }
839
+  $(this).parent().next().toggle(533);
840
+});
841
+
842
+//
843
+$('.filterSection').on('change', function()
844
+{
845
+
846
+  var professor_id = $(this).find('.filterProfessor select').val();
847
+  var course_id = $(this).find('.filterCourse select').val();
848
+  var outcome_id = $(this).find('.filterOutcome select').val();
849
+  var panel_id = $(this).parent().attr('id');
850
+
851
+  var select = $('#'+panel_id+' .SelectTA select');
852
+
853
+
854
+  $.post(
855
+    "{{ URL::action('TransformativeActionsController@filterTA') }}",
856
+    {
857
+      professor_id: (professor_id),
858
+      course_id: (course_id),
859
+      outcome_id: (outcome_id),
860
+      panel_id: (panel_id),
861
+    },
862
+    function(data)
863
+    {
864
+      //
865
+      select.find('option').remove();
866
+      $.each(data, function(index, ta)
867
+      {
868
+        var ta_id = ta.id;
869
+        var ta_text = ta.at_text;
870
+        var new_option = '<option value="'+ ta_id +'">'+ ta_text +'</option>';
871
+        select.append(new_option);
872
+      });
873
+
874
+      select.selectpicker('refresh');
875
+
876
+      if(data.length != 0){
877
+        var ta_id = data[0].id;
878
+
879
+        if(panel_id=='editPanel'){
880
+          load_ta_info_for_edit(ta_id);
881
+        }
882
+        if(panel_id=='approvePanel'){
883
+          load_ta_info_for_approval(ta_id);
884
+        }
885
+      }
886
+    }
887
+  );
888
+
889
+});
890
+
891
+@stop

+ 18
- 15
app/views/local/managers/pCoords/_navigation.blade.php Ver arquivo

@@ -6,8 +6,11 @@
6 6
     <ul class="nav navbar-nav navbar-right">
7 7
       <li>{{ HTML::linkAction('ProgramCoordinatorsController@overview', 'Overview') }}</li>
8 8
       <li>{{ HTML::linkAction('TemplatesController@newTemplate', 'Rubrics') }}</li>
9
-      {{-- la linea siguiente comentada es lo que habia originalmente. tanto la linea como este comentario se pueden borrar --}}
10
-      {{-- <li>{{ HTML::linkAction('CriteriaController@index', 'Learning Outcomes and Criteria') }}</li> --}}
9
+      <li>{{ HTML::linkAction('ThreeYearPlanController@threeYearsReport', 'Three Years Plan') }}</li>
10
+      <li>{{ HTML::linkAction('TransformativeActionsController@editTA', 'Transformative Actions') }}</li>
11
+
12
+      <li>{{ HTML::linkAction('Objective2Controller@editProgram', 'Objectives')}}</li>
13
+      <li>{{ HTML::linkAction('CriteriaController@editProgram', 'Criteria') }}</li>
11 14
       <li class="dropdown">
12 15
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Learning and Criterias<span class="caret"></span></a>
13 16
         <ul class="dropdown-menu" role="menu">
@@ -20,9 +23,9 @@
20 23
       <li class="dropdown">
21 24
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Sections<span class="caret"></span></a>
22 25
         <ul class="dropdown-menu" role="menu">
23
-        @foreach ($courses as $course)
26
+          @foreach ($courses as $course)
24 27
           <li> {{ HTML::linkAction('CoursesController@show', $course->code.$course->number.'-'.$course->section.' ('.$course->semester->code.')', array('id'=>$course->id)) }}</li>
25
-        @endforeach
28
+          @endforeach
26 29
         </ul>
27 30
       </li>
28 31
       @endif
@@ -30,28 +33,28 @@
30 33
       <li class="dropdown">
31 34
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Reports<span class="caret"></span></a>
32 35
         <ul class="dropdown-menu" role="menu">
33
-            <li>{{ HTML::linkAction('OutcomesController@managerAssessmentReports', 'Program Reports') }}</li>
34
-            @if(count(Auth::user()->courses))
35
-              <li>{{ HTML::linkAction('OutcomesController@professorAssessmentReports', 'My Courses\' Reports') }}</li>
36
-            @endif
36
+          <li>{{ HTML::linkAction('OutcomesController@managerAssessmentReports', 'Program Reports') }}</li>
37
+          @if(count(Auth::user()->courses))
38
+          <li>{{ HTML::linkAction('OutcomesController@professorAssessmentReports', 'My Courses\' Reports') }}</li>
39
+          @endif
37 40
         </ul>
38 41
       </li>
39 42
 
40 43
       <li class="dropdown">
41 44
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Help<span class="caret"></span></a>
42 45
         <ul class="dropdown-menu" role="menu">
43
-            <li>{{ HTML::linkAction('FeedbackController@create', 'Feedback') }}</li>
44
-            <!-- <li><a href="{{ asset('files/OLAS-intro.pdf') }}">Introduction to OLAS</a></li> -->
45
-            <li><a href="{{ asset('files/intro-avaluo.pdf') }}">Introduction to Assessment</a></li>
46
-            <!-- <li><a href="{{ asset('files/OLAS-coords.pdf') }}">OLAS for Coordinators</a></li> -->
47
-            <li><a href="http://oeae.uprrp.edu/wp-content/uploads/2019/01/Brochure-de-OLAS-rev.-agosto-2018.pdf">Brochure</a></li>
46
+          <li>{{ HTML::linkAction('FeedbackController@create', 'Feedback') }}</li>
47
+          <!-- <li><a href="{{ asset('files/OLAS-intro.pdf') }}">Introduction to OLAS</a></li> -->
48
+          <li><a href="{{ asset('files/intro-avaluo.pdf') }}">Introduction to Assessment</a></li>
49
+          <!-- <li><a href="{{ asset('files/OLAS-coords.pdf') }}">OLAS for Coordinators</a></li> -->
50
+          <li><a href="http://oeae.uprrp.edu/wp-content/uploads/2019/01/Brochure-de-OLAS-rev.-agosto-2018.pdf">Brochure</a></li>
48 51
         </ul>
49 52
       </li>
50 53
       <li class="dropdown">
51 54
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Account<span class="caret"></span></a>
52 55
         <ul class="dropdown-menu" role="menu">
53
-            <li>{{ HTML::linkAction('UsersController@edit', 'Profile') }}</li>
54
-            <li>{{ HTML::linkAction('AuthController@logout', 'Log out ('.Auth::user()->email.')') }}</li>
56
+          <li>{{ HTML::linkAction('UsersController@edit', 'Profile') }}</li>
57
+          <li>{{ HTML::linkAction('AuthController@logout', 'Log out ('.Auth::user()->email.')') }}</li>
55 58
         </ul>
56 59
       </li>
57 60
     </ul>

+ 0
- 0
app/views/local/managers/pCoords/criteria.blade.php Ver arquivo


Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff