Przeglądaj źródła

Merge branch 'gabriel_branch' into oniel-progreso

onielm 3 lat temu
rodzic
commit
b74b618bdd
89 zmienionych plików z 11922 dodań i 2661 usunięć
  1. BIN
      Documentacion.docx
  2. 8
    5
      app/config/app.php
  3. 6
    5
      app/config/database.php
  4. 73
    0
      app/config/packages/cornford/backup/config.php
  5. 172
    262
      app/controllers/ActivitiesController.php
  6. 273
    174
      app/controllers/AdministratorsController.php
  7. 76
    27
      app/controllers/CoursesController.php
  8. 442
    168
      app/controllers/CriteriaController.php
  9. 465
    0
      app/controllers/Objective2Controller.php
  10. 86
    0
      app/controllers/Objective_OutcomeController.php
  11. 336
    264
      app/controllers/OutcomesController.php
  12. 146
    23
      app/controllers/ProgramsController.php
  13. 70
    66
      app/controllers/RubricsController.php
  14. 360
    358
      app/controllers/UsersController.php
  15. 12
    13
      app/database/migrations/2018_08_28_140328_remove_outcome_id_from_objectives_table.php
  16. 9
    10
      app/database/migrations/2020_04_04_005817_add_outcome_id_to_objectives_table.php
  17. 0
    43
      app/database/migrations/2020_04_22_122910_add_criteria_id_to_assessments_table.php
  18. 47
    0
      app/database/migrations/2020_10_04_142756_create_new_assessments_table.php
  19. 52
    0
      app/database/migrations/2020_10_05_124915_create_activity_criterion_table.php
  20. 35
    0
      app/database/migrations/2020_10_05_130252_add_max_score_num_scales_new_criteria_table.php
  21. 35
    0
      app/database/migrations/2020_10_05_142424_create_scales_table.php
  22. 47
    0
      app/database/migrations/2020_10_05_142912_create_criterion_scale_table.php
  23. 34
    0
      app/database/migrations/2020_10_05_232429_add_assessment_comments_to_activity_criterion.php
  24. 36
    0
      app/database/migrations/2020_10_09_131800_add_level_activation_date_to_outcomes.php
  25. 53
    0
      app/database/migrations/2020_10_16_190923_create_criterion_objective_outcome_table.php
  26. 57
    0
      app/database/migrations/2020_10_18_145108_create_outcome_performance_table.php
  27. 30
    0
      app/database/migrations/2020_10_29_122332_MakeOutcomeNullable.php
  28. 30
    0
      app/database/migrations/2020_10_29_195413_MakeObjectiveNullable.php
  29. 30
    0
      app/database/migrations/2020_10_29_224846_Make_criterion_objective_outcome_changeForeignKey.php
  30. 35
    0
      app/database/migrations/2020_11_06_011242_changeCriteriaObjOutcome.php
  31. 35
    0
      app/database/migrations/2020_12_04_111708_dropDescriptionInCriteria.php
  32. 44
    0
      app/database/migrations/2020_12_10_175517_createProgramCriterion2.php
  33. 34
    0
      app/database/migrations/2020_12_10_223135_addMinMaxInScales.php
  34. 47
    0
      app/database/migrations/2021_01_28_160558_ObjectiveProgramMigrate.php
  35. 33
    0
      app/database/migrations/2021_01_28_174905_fixObjectivesTable.php
  36. 39
    0
      app/database/migrations/2021_02_16_142747_create_cycles_table.php
  37. 50
    0
      app/database/migrations/2021_02_16_142832_create_cycles_semesters_table.php
  38. 30
    0
      app/database/migrations/emails/feedback-email-copy.blade.php
  39. 125
    0
      app/database/seeds/FillNewAssessmentActivityCriterion.php
  40. 94
    0
      app/database/seeds/FillNewCriterionRubric.php
  41. 59
    0
      app/database/seeds/FillScalesCriteria.php
  42. 43
    0
      app/database/unusedMigrations/2018_08_28_140328_remove_outcome_id_from_objectives_table.php
  43. 39
    0
      app/database/unusedMigrations/2020_04_04_005817_add_outcome_id_to_objectives_table.php
  44. 46
    0
      app/database/unusedMigrations/2020_10_04_141759_create_activity_criterion_table.php
  45. 52
    0
      app/database/unusedMigrations/2020_10_05_124915_create_activity_criterion_table.php
  46. 35
    0
      app/database/unusedMigrations/2020_10_05_130252_add_max_score_num_scales_new_criteria_table.php
  47. 35
    0
      app/database/unusedMigrations/2020_10_05_142424_create_scales_table.php
  48. 47
    0
      app/database/unusedMigrations/2020_10_05_142912_create_criterion_scale_table.php
  49. 34
    0
      app/database/unusedMigrations/2020_10_05_232429_add_assessment_comments_to_activity_criterion.php
  50. 36
    0
      app/database/unusedMigrations/2020_10_08_203557_create_new_criteria_table2.php
  51. 33
    0
      app/database/unusedMigrations/2020_10_08_215013_drop_objective_id_new_criteria.php
  52. 34
    0
      app/database/unusedMigrations/2020_10_09_085334_add_activities_rubric_id.php
  53. 35
    0
      app/database/unusedMigrations/2020_10_09_092810_drop_assessment_criteria.php
  54. 35
    0
      app/database/unusedMigrations/2020_10_09_094503_add_criterion_to_assessment.php
  55. 29
    0
      app/database/unusedMigrations/2020_10_09_095246_drop_foreign_assesment_criterion.php
  56. 36
    0
      app/database/unusedMigrations/2020_10_09_131800_add_level_activation_date_to_outcomes.php
  57. 30
    55
      app/filters.php
  58. 2
    1
      app/models/Activity.php
  59. 52
    0
      app/models/Course.php
  60. 56
    0
      app/models/Criterion.php
  61. 29
    26
      app/models/Objective.php
  62. 38
    0
      app/models/Objective_Outcome.php
  63. 315
    0
      app/models/Outcome.php
  64. 210
    0
      app/models/Program.php
  65. 17
    0
      app/models/Scale.php
  66. 13
    12
      app/models/User.php
  67. 178
    123
      app/routes.php
  68. 19
    19
      app/views/local/managers/admins/_navigation.blade.php
  69. 16
    1
      app/views/local/managers/admins/assessment_report.blade.php
  70. 1040
    266
      app/views/local/managers/admins/criteria.blade.php
  71. 101
    0
      app/views/local/managers/admins/learning-outcome_new.blade.php
  72. 90
    0
      app/views/local/managers/admins/learning-outcomes_new.blade.php
  73. 1044
    0
      app/views/local/managers/admins/new_criteria.blade.php
  74. 529
    0
      app/views/local/managers/admins/objectives.blade.php
  75. 471
    471
      app/views/local/managers/admins/overview.blade.php
  76. 16
    15
      app/views/local/managers/pCoords/_navigation.blade.php
  77. 1023
    0
      app/views/local/managers/pCoords/criteria.blade.php
  78. 482
    0
      app/views/local/managers/pCoords/objectives.blade.php
  79. 15
    15
      app/views/local/managers/sCoords/_navigation.blade.php
  80. 1029
    0
      app/views/local/managers/sCoords/criteria.blade.php
  81. 485
    0
      app/views/local/managers/sCoords/objectives.blade.php
  82. 235
    227
      app/views/local/managers/shared/program.blade.php
  83. 7
    7
      app/views/local/professors/_navigation.blade.php
  84. 1
    0
      app/views/local/professors/activity.blade.php
  85. 1
    1
      bootstrap/start.php
  86. 7
    4
      composer.json
  87. 53
    0
      drop_tables.sql
  88. 1
    0
      public/.htaccess
  89. 103
    0
      seed.sql

BIN
Documentacion.docx Wyświetl plik


+ 8
- 5
app/config/app.php Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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
 }

+ 360
- 358
app/controllers/UsersController.php Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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
+}

+ 39
- 0
app/database/migrations/2021_02_16_142747_create_cycles_table.php Wyświetl plik

@@ -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 Wyświetl plik

@@ -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
+}

+ 30
- 0
app/database/migrations/emails/feedback-email-copy.blade.php Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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
 });

+ 19
- 19
app/views/local/managers/admins/_navigation.blade.php Wyświetl plik

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

+ 16
- 1
app/views/local/managers/admins/assessment_report.blade.php Wyświetl plik

@@ -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
Plik diff jest za duży
Wyświetl plik


+ 101
- 0
app/views/local/managers/admins/learning-outcome_new.blade.php Wyświetl plik

@@ -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 Wyświetl plik

@@ -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
Plik diff jest za duży
Wyświetl plik


+ 529
- 0
app/views/local/managers/admins/objectives.blade.php Wyświetl plik

@@ -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
Plik diff jest za duży
Wyświetl plik


+ 16
- 15
app/views/local/managers/pCoords/_navigation.blade.php Wyświetl plik

@@ -6,8 +6,9 @@
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
+
10
+      <li>{{ HTML::linkAction('Objective2Controller@editProgram', 'Objectives')}}</li>
11
+      <li>{{ HTML::linkAction('CriteriaController@editProgram', 'Criteria') }}</li>
11 12
       <li class="dropdown">
12 13
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Learning and Criterias<span class="caret"></span></a>
13 14
         <ul class="dropdown-menu" role="menu">
@@ -20,9 +21,9 @@
20 21
       <li class="dropdown">
21 22
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Sections<span class="caret"></span></a>
22 23
         <ul class="dropdown-menu" role="menu">
23
-        @foreach ($courses as $course)
24
+          @foreach ($courses as $course)
24 25
           <li> {{ HTML::linkAction('CoursesController@show', $course->code.$course->number.'-'.$course->section.' ('.$course->semester->code.')', array('id'=>$course->id)) }}</li>
25
-        @endforeach
26
+          @endforeach
26 27
         </ul>
27 28
       </li>
28 29
       @endif
@@ -30,28 +31,28 @@
30 31
       <li class="dropdown">
31 32
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Reports<span class="caret"></span></a>
32 33
         <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
34
+          <li>{{ HTML::linkAction('OutcomesController@managerAssessmentReports', 'Program Reports') }}</li>
35
+          @if(count(Auth::user()->courses))
36
+          <li>{{ HTML::linkAction('OutcomesController@professorAssessmentReports', 'My Courses\' Reports') }}</li>
37
+          @endif
37 38
         </ul>
38 39
       </li>
39 40
 
40 41
       <li class="dropdown">
41 42
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Help<span class="caret"></span></a>
42 43
         <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>
44
+          <li>{{ HTML::linkAction('FeedbackController@create', 'Feedback') }}</li>
45
+          <!-- <li><a href="{{ asset('files/OLAS-intro.pdf') }}">Introduction to OLAS</a></li> -->
46
+          <li><a href="{{ asset('files/intro-avaluo.pdf') }}">Introduction to Assessment</a></li>
47
+          <!-- <li><a href="{{ asset('files/OLAS-coords.pdf') }}">OLAS for Coordinators</a></li> -->
48
+          <li><a href="http://oeae.uprrp.edu/wp-content/uploads/2019/01/Brochure-de-OLAS-rev.-agosto-2018.pdf">Brochure</a></li>
48 49
         </ul>
49 50
       </li>
50 51
       <li class="dropdown">
51 52
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Account<span class="caret"></span></a>
52 53
         <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>
54
+          <li>{{ HTML::linkAction('UsersController@edit', 'Profile') }}</li>
55
+          <li>{{ HTML::linkAction('AuthController@logout', 'Log out ('.Auth::user()->email.')') }}</li>
55 56
         </ul>
56 57
       </li>
57 58
     </ul>

+ 1023
- 0
app/views/local/managers/pCoords/criteria.blade.php
Plik diff jest za duży
Wyświetl plik


+ 482
- 0
app/views/local/managers/pCoords/objectives.blade.php Wyświetl plik

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

+ 15
- 15
app/views/local/managers/sCoords/_navigation.blade.php Wyświetl plik

@@ -6,8 +6,6 @@
6 6
     <ul class="nav navbar-nav navbar-right">
7 7
       <li>{{ HTML::linkAction('SchoolCoordinatorsController@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> --}}
11 9
       <li class="dropdown">
12 10
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Learning and Criterias<span class="caret"></span></a>
13 11
         <ul class="dropdown-menu" role="menu">
@@ -15,14 +13,16 @@
15 13
           <li>{{ HTML::linkAction('CriteriaController@objectivesIndex', 'Objectives and Criteria') }}</li>
16 14
         </ul>
17 15
       </li>
16
+      <li>{{ HTML::linkAction('Objective2Controller@editSchool', 'Objectives')}}</li>
17
+      <li>{{ HTML::linkAction('CriteriaController@editSchool', 'Criteria') }}</li>
18 18
       @if(count(Auth::user()->courses))
19 19
       <li> {{ HTML::linkAction('ProfessorsController@overview', 'My Courses', NULL) }}</li>
20 20
       <li class="dropdown">
21 21
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Sections<span class="caret"></span></a>
22 22
         <ul class="dropdown-menu" role="menu">
23
-        @foreach ($courses as $course)
23
+          @foreach ($courses as $course)
24 24
           <li> {{ HTML::linkAction('CoursesController@show', $course->code.$course->number.'-'.$course->section.' ('.$course->semester->code.')', array('id'=>$course->id)) }}</li>
25
-        @endforeach
25
+          @endforeach
26 26
         </ul>
27 27
       </li>
28 28
       @endif
@@ -30,28 +30,28 @@
30 30
       <li class="dropdown">
31 31
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Reports<span class="caret"></span></a>
32 32
         <ul class="dropdown-menu" role="menu">
33
-            <li>{{ HTML::linkAction('OutcomesController@managerAssessmentReports', 'School Reports') }}</li>
34
-            @if(count(Auth::user()->courses))
35
-              <li>{{ HTML::linkAction('OutcomesController@professorAssessmentReports', 'My Courses\' Reports') }}</li>
36
-            @endif
33
+          <li>{{ HTML::linkAction('OutcomesController@managerAssessmentReports', 'School Reports') }}</li>
34
+          @if(count(Auth::user()->courses))
35
+          <li>{{ HTML::linkAction('OutcomesController@professorAssessmentReports', 'My Courses\' Reports') }}</li>
36
+          @endif
37 37
         </ul>
38 38
       </li>
39 39
 
40 40
       <li class="dropdown">
41 41
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Help<span class="caret"></span></a>
42 42
         <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>
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>
48 48
         </ul>
49 49
       </li>
50 50
       <li class="dropdown">
51 51
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Account<span class="caret"></span></a>
52 52
         <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>
53
+          <li>{{ HTML::linkAction('UsersController@edit', 'Profile') }}</li>
54
+          <li>{{ HTML::linkAction('AuthController@logout', 'Log out ('.Auth::user()->email.')') }}</li>
55 55
         </ul>
56 56
       </li>
57 57
     </ul>

+ 1029
- 0
app/views/local/managers/sCoords/criteria.blade.php
Plik diff jest za duży
Wyświetl plik


+ 485
- 0
app/views/local/managers/sCoords/objectives.blade.php Wyświetl plik

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

+ 235
- 227
app/views/local/managers/shared/program.blade.php Wyświetl plik

@@ -1,13 +1,13 @@
1 1
 @extends('layouts.master')
2 2
 
3 3
 @section('navigation')
4
-    @if($role==1)
5
-        @include('local.managers.admins._navigation')
6
-    @elseif($role==2)
7
-        @include('local.managers.sCoords._navigation')
8
-    @elseif($role==3)
9
-        @include('local.managers.pCoords._navigation')
10
-    @endif
4
+@if($role==1)
5
+@include('local.managers.admins._navigation')
6
+@elseif($role==2)
7
+@include('local.managers.sCoords._navigation')
8
+@elseif($role==3)
9
+@include('local.managers.pCoords._navigation')
10
+@endif
11 11
 @stop
12 12
 
13 13
 @section('main')
@@ -36,42 +36,44 @@
36 36
                 <div class="col-md-12">
37 37
                     <h3>Courses in this program</h3>
38 38
                     @if($program_courses->count()>0)
39
-                        <table class="table table-striped table-condensed datatable">
40
-                            <thead>
41
-                                <tr>
42
-                                    <th>Identifier</th>
43
-                                    <th>Name</th>
44
-                                    <th>Program</th>
45
-                                    <th>Assessed</th>
46
-                                </tr>
47
-                            </thead>
48
-                            <tfoot>
49
-                                <tr class="column-search">
50
-                                    <th><input class="column-search-bar form-control" type="text" placeholder="Search"/></th>
51
-                                    <th><input class="column-search-bar form-control" type="text" placeholder="Search"/></th>
52
-                                    <th><input class="column-search-bar form-control" type="text" placeholder="Search"/></th>
53
-                                    <th><select class="column-search-select form-control"><option value=""></option></select></th>
54
-                                </tr>
55
-                            </tfoot>
56
-                            <tbody>
57
-                                @foreach($grouped_courses as $grouped_course)
58
-                                    <tr>
59
-                                        <td class="col-md-1">{{ HTML::linkAction('CoursesController@showGrouped', $grouped_course->code.$grouped_course->number.' ('.$grouped_course->semester->code.')', array($grouped_course->code, $grouped_course->number, $grouped_course->semester->code)) }}</td>
60
-                                        <td class="col-md-4">{{{ $grouped_course->name}}}</td>
61
-                                        <td class="col-md-3">{{{ $grouped_course->program->name }}}</td>
62
-                                        <td class="col-md-1">
63
-                                            @if($grouped_course->outcomes_attempted!=NULL)
64
-                                                Yes
65
-                                            @else
66
-                                                No
67
-                                            @endif
68
-                                        </td>
69
-                                    </tr>
70
-                                @endforeach
71
-                            </tbody>
72
-                        </table>
39
+                    <table class="table table-striped table-condensed datatable">
40
+                        <thead>
41
+                            <tr>
42
+                                <th>Identifier</th>
43
+                                <th>Name</th>
44
+                                <th>Program</th>
45
+                                <th>Assessed</th>
46
+                            </tr>
47
+                        </thead>
48
+                        <tfoot>
49
+                            <tr class="column-search">
50
+                                <th><input class="column-search-bar form-control" type="text" placeholder="Search" /></th>
51
+                                <th><input class="column-search-bar form-control" type="text" placeholder="Search" /></th>
52
+                                <th><input class="column-search-bar form-control" type="text" placeholder="Search" /></th>
53
+                                <th><select class="column-search-select form-control">
54
+                                        <option value=""></option>
55
+                                    </select></th>
56
+                            </tr>
57
+                        </tfoot>
58
+                        <tbody>
59
+                            @foreach($grouped_courses as $grouped_course)
60
+                            <tr>
61
+                                <td class="col-md-1">{{ HTML::linkAction('CoursesController@showGrouped', $grouped_course->code.$grouped_course->number.' ('.$grouped_course->semester->code.')', array($grouped_course->code, $grouped_course->number, $grouped_course->semester->code)) }}</td>
62
+                                <td class="col-md-4">{{{ $grouped_course->name}}}</td>
63
+                                <td class="col-md-3">{{{ $grouped_course->program->name }}}</td>
64
+                                <td class="col-md-1">
65
+                                    @if($grouped_course->outcomes_attempted!=NULL)
66
+                                    Yes
67
+                                    @else
68
+                                    No
69
+                                    @endif
70
+                                </td>
71
+                            </tr>
72
+                            @endforeach
73
+                        </tbody>
74
+                    </table>
73 75
                     @else
74
-                        <p class="lead"> No courses assigned.</p>
76
+                    <p class="lead"> No courses assigned.</p>
75 77
                     @endif
76 78
                 </div>
77 79
             </div>
@@ -82,43 +84,45 @@
82 84
                 <div class="col-md-12">
83 85
                     <h3>Sections in this program</h3>
84 86
                     @if($program_courses->count()>0)
85
-                        <p class="lead"> {{{ $assessed_courses_count }}} out of {{{ $program_courses->count() }}} section(s) doing Assessment ({{{ round($assessed_courses_count/$program_courses->count()*100, 2) }}}%)</p>
86
-                        <table class="table table-striped table-condensed datatable">
87
-                            <thead>
88
-                                <tr>
89
-                                    <th>Identifier</th>
90
-                                    <th>Name</th>
91
-                                    <th>Professor</th>
92
-                                    <th>Assessed</th>
93
-                                </tr>
94
-                            </thead>
95
-                            <tfoot>
96
-                                <tr class="column-search">
97
-                                    <th><input class="column-search-bar form-control" type="text" placeholder="Buscar"/></th>
98
-                                    <th><input class="column-search-bar form-control" type="text" placeholder="Buscar"/></th>
99
-                                    <th><input class="column-search-bar form-control" type="text" placeholder="Buscar"/></th>
100
-                                    <th><select class="column-search-select form-control"><option value=""></option></select></th>
101
-                                </tr>
102
-                            </tfoot>
103
-                            <tbody>
104
-                                @foreach($program_courses as $course)
105
-                                <tr>
106
-                                    <td>{{ HTML::linkAction('CoursesController@showLimited', $course->code.$course->number.'-'.$course->section.' ('.$course->semester->code.')', array('id'=>$course->id)) }}</td>
107
-                                    <td>{{{ $course->name}}}</td>
108
-                                    <td>{{{ $course->user->surnames }}}, {{{ $course->user->first_name }}}</td>
109
-                                    <td>
110
-                                        @if($course->outcomes_attempted!=NULL)
111
-                                            Yes
112
-                                        @else
113
-                                            No
114
-                                        @endif
115
-                                    </td>
116
-                                </tr>
117
-                                @endforeach
118
-                            </tbody>
119
-                        </table>
87
+                    <p class="lead"> {{{ $assessed_courses_count }}} out of {{{ $program_courses->count() }}} section(s) doing Assessment ({{{ round($assessed_courses_count/$program_courses->count()*100, 2) }}}%)</p>
88
+                    <table class="table table-striped table-condensed datatable">
89
+                        <thead>
90
+                            <tr>
91
+                                <th>Identifier</th>
92
+                                <th>Name</th>
93
+                                <th>Professor</th>
94
+                                <th>Assessed</th>
95
+                            </tr>
96
+                        </thead>
97
+                        <tfoot>
98
+                            <tr class="column-search">
99
+                                <th><input class="column-search-bar form-control" type="text" placeholder="Buscar" /></th>
100
+                                <th><input class="column-search-bar form-control" type="text" placeholder="Buscar" /></th>
101
+                                <th><input class="column-search-bar form-control" type="text" placeholder="Buscar" /></th>
102
+                                <th><select class="column-search-select form-control">
103
+                                        <option value=""></option>
104
+                                    </select></th>
105
+                            </tr>
106
+                        </tfoot>
107
+                        <tbody>
108
+                            @foreach($program_courses as $course)
109
+                            <tr>
110
+                                <td>{{ HTML::linkAction('CoursesController@showLimited', $course->code.$course->number.'-'.$course->section.' ('.$course->semester->code.')', array('id'=>$course->id)) }}</td>
111
+                                <td>{{{ $course->name}}}</td>
112
+                                <td>{{{ $course->user->surnames }}}, {{{ $course->user->first_name }}}</td>
113
+                                <td>
114
+                                    @if($course->outcomes_attempted!=NULL)
115
+                                    Yes
116
+                                    @else
117
+                                    No
118
+                                    @endif
119
+                                </td>
120
+                            </tr>
121
+                            @endforeach
122
+                        </tbody>
123
+                    </table>
120 124
                     @else
121
-                        <p class="lead"> No sections assigned.</p>
125
+                    <p class="lead"> No sections assigned.</p>
122 126
                     @endif
123 127
                 </div>
124 128
             </div>
@@ -140,55 +144,59 @@
140 144
                         </thead>
141 145
                         <tfoot>
142 146
                             <tr class="column-search">
143
-                                <th><input class="column-search-bar form-control" type="text" placeholder="Search"/></th>
144
-                                <th><select class="column-search-select form-control"><option value=""></option></select></th>
145
-                                <th><select class="column-search-select form-control"><option value=""></option></select></th>
146
-                                <th><input class="column-search-bar form-control" type="text" placeholder="Search"/></th>
147
-                                <th><input class="column-search-bar form-control" type="text" placeholder="Search"/></th>
147
+                                <th><input class="column-search-bar form-control" type="text" placeholder="Search" /></th>
148
+                                <th><select class="column-search-select form-control">
149
+                                        <option value=""></option>
150
+                                    </select></th>
151
+                                <th><select class="column-search-select form-control">
152
+                                        <option value=""></option>
153
+                                    </select></th>
154
+                                <th><input class="column-search-bar form-control" type="text" placeholder="Search" /></th>
155
+                                <th><input class="column-search-bar form-control" type="text" placeholder="Search" /></th>
148 156
                             </tr>
149 157
                         </tfoot>
150 158
                         <tbody>
151 159
                             @foreach($users as $user)
152
-                                <tr>
153
-                                    <td>{{ $user->surnames }}, {{ $user->first_name }}</td>
160
+                            <tr>
161
+                                <td>{{ $user->surnames }}, {{ $user->first_name }}</td>
154 162
 
155
-                                    @if($user->role == 1)
156
-                                        <td>Administrator</td>
157
-                                        <td>All</td>
158
-                                    @elseif($user->role == 2)
159
-                                        <td>School Coordinator</td>
160
-                                        <td>All in {{ $program->school->name }}</td>
161
-                                    @elseif($user->role == 3)
162
-                                        <td>Program Coordinator</td>
163
-                                        <td>
164
-                                            @foreach ($user->programs as $program)
165
-                                                {{ $program->name }}&nbsp;
166
-                                            @endforeach
167
-                                        </td>
168
-                                    @else
169
-                                        <td>Professor</td>
170
-                                        <td>
171
-                                            @foreach ($user->programs as $program)
172
-                                                {{ $program->name }}&nbsp;
173
-                                            @endforeach
174
-                                        </td>
175
-                                    @endif
163
+                                @if($user->role == 1)
164
+                                <td>Administrator</td>
165
+                                <td>All</td>
166
+                                @elseif($user->role == 2)
167
+                                <td>School Coordinator</td>
168
+                                <td>All in {{ $program->school->name }}</td>
169
+                                @elseif($user->role == 3)
170
+                                <td>Program Coordinator</td>
171
+                                <td>
172
+                                    @foreach ($user->programs as $program)
173
+                                    {{ $program->name }}&nbsp;
174
+                                    @endforeach
175
+                                </td>
176
+                                @else
177
+                                <td>Professor</td>
178
+                                <td>
179
+                                    @foreach ($user->programs as $program)
180
+                                    {{ $program->name }}&nbsp;
181
+                                    @endforeach
182
+                                </td>
183
+                                @endif
176 184
 
177
-                                    <td>
178
-                                        <a href="mailto:{{ $user->email }}">{{ $user->email }}</a>
179
-                                    </td>
180
-                                    <td>
181
-                                        @if($user->office_phone)
182
-                                            {{{ $user->office_phone }}}
185
+                                <td>
186
+                                    <a href="mailto:{{ $user->email }}">{{ $user->email }}</a>
187
+                                </td>
188
+                                <td>
189
+                                    @if($user->office_phone)
190
+                                    {{{ $user->office_phone }}}
183 191
 
184
-                                            @if($user->office_extension)
185
-                                                <span>ext.</span> {{{ $user->office_extension }}}
186
-                                            @endif
187
-                                        @else
188
-                                            Not set
189
-                                        @endif
190
-                                    </td>
191
-                                </tr>
192
+                                    @if($user->office_extension)
193
+                                    <span>ext.</span> {{{ $user->office_extension }}}
194
+                                    @endif
195
+                                    @else
196
+                                    Not set
197
+                                    @endif
198
+                                </td>
199
+                            </tr>
192 200
                             @endforeach
193 201
                         </tbody>
194 202
                     </table>
@@ -215,118 +223,118 @@
215 223
 @section('javascript')
216 224
 
217 225
 $('#programTabs a').click(function (e) {
218
-    e.preventDefault()
219
-    $(this).tab('show');
226
+e.preventDefault()
227
+$(this).tab('show');
220 228
 });
221 229
 
222 230
 
223 231
 $('#graph').highcharts({
224
-    chart: {
225
-        type: 'bar'
226
-    },
227
-    title: {
228
-        text: 'Performance by Learning Outcome Criteria in {{ $program->name }} Program'
229
-    },
230
-    legend: {
231
-                reversed: true,
232
-            },
233
-    xAxis: {
234
-        categories: [
235
-            @foreach($outcomes as $outcome)
236
-                "{{{ $outcome->name }}}",
237
-            @endforeach
238
-        ],
239
-        labels: {
240
-            style: {
241
-                fontSize:'11px'
242
-            },
243
-            step:1,
244
-            useHTML:true,
245
-            formatter: function() {
246
-                return '<div style="width:200px; word-break:break; text-overflow:ellipsis; overflow:hidden;">'+this.value+'</div>';
247
-            },
248
-        }
249
-    },
250
-    yAxis: {
251
-        min: 0,
252
-        max: 100,
253
-        title: {
254
-            text: 'Percentage'
255
-        }
256
-    },
257
-    tooltip: {
258
-        headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
259
-        pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
260
-            '<td style="padding:0"><b>{point.y:.2f}</b></td></tr>',
261
-        footerFormat: '</table>',
262
-        shared: true,
263
-        useHTML: true
264
-    },
265
-    plotOptions: {
266
-        bar: {
267
-            //grouping: false,
268
-            shadow: false,
269
-            borderWidth: 0,
270
-        },
271
-        series: {
272
-        pointPadding: 0,
273
-        groupPadding: 0.075
274
-        },
275
-    },
276
-    series: [{
277
-        name: 'Expected Value',
278
-        color: '#555555',
279
-        dataLabels: {
280
-            enabled: true,
281
-            fontSize: 8,
282
-            color: '#fff',
283
-            align: 'right',
284
-            format: '{y:.1f}%',
285
-            style: {
286
-                //fontWeight: 'bold'
287
-            },
288
-            y:-1
289
-        },
290
-        data: [
291
-            @foreach($outcomes as $index => $outcome)
292
-                @if(
293
-                    is_array($outcomes_attempted)
294
-                    && array_key_exists($outcome->id, $outcomes_attempted)
295
-                    && $outcomes_attempted[$outcome->id]!=0)
296
-                    {{{ $outcome->expected_outcome }}},
297
-                @else
298
-                    0,
299
-                @endif
300
-            @endforeach
301
-        ]
232
+chart: {
233
+type: 'bar'
234
+},
235
+title: {
236
+text: 'Performance by Learning Outcome Criteria in {{ $program->name }} Program'
237
+},
238
+legend: {
239
+reversed: true,
240
+},
241
+xAxis: {
242
+categories: [
243
+@foreach($outcomes as $outcome)
244
+"{{{ $outcome->name }}}",
245
+@endforeach
246
+],
247
+labels: {
248
+style: {
249
+fontSize:'11px'
250
+},
251
+step:1,
252
+useHTML:true,
253
+formatter: function() {
254
+return '<div style="width:200px; word-break:break; text-overflow:ellipsis; overflow:hidden;">'+this.value+'</div>';
255
+},
256
+}
257
+},
258
+yAxis: {
259
+min: 0,
260
+max: 100,
261
+title: {
262
+text: 'Percentage'
263
+}
264
+},
265
+tooltip: {
266
+headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
267
+    pointFormat: '<tr><td style="color:{series.color};padding : 0">{series.name}: </td>' +
268
+        '<td style="padding:0"><b>{point.y:.2f}</b></td></tr>',
269
+    footerFormat: '</table>',
270
+shared: true,
271
+useHTML: true
272
+},
273
+plotOptions: {
274
+bar: {
275
+//grouping: false,
276
+shadow: false,
277
+borderWidth: 0,
278
+},
279
+series: {
280
+pointPadding: 0,
281
+groupPadding: 0.075
282
+},
283
+},
284
+series: [{
285
+name: 'Expected Value',
286
+color: '#555555',
287
+dataLabels: {
288
+enabled: true,
289
+fontSize: 8,
290
+color: '#fff',
291
+align: 'right',
292
+format: '{y:.1f}%',
293
+style: {
294
+//fontWeight: 'bold'
295
+},
296
+y:-1
297
+},
298
+data: [
299
+@foreach($outcomes as $index => $outcome)
300
+@if(
301
+is_array($outcomes_attempted)
302
+&& array_key_exists($outcome->id, $outcomes_attempted)
303
+&& $outcomes_attempted[$outcome->id]!=0)
304
+{{{ $outcome->expected_outcome }}},
305
+@else
306
+0,
307
+@endif
308
+@endforeach
309
+]
302 310
 
303
-    },{
304
-        name: 'Obtained Value',
305
-        color: '#e70033',
306
-        dataLabels: {
307
-            enabled: true,
308
-            fontSize: 8,
309
-            color: '#fff',
310
-            align: 'right',
311
-            format: '{y:.1f}%',
312
-            style: {
313
-                //fontWeight: 'bold'
314
-            },
315
-            y:-1
316
-        },
317
-        data:[
318
-            @foreach($outcomes as $index => $outcome)
319
-                @if(
320
-                    is_array($outcomes_attempted)
321
-                    && array_key_exists($outcome->id, $outcomes_attempted)
322
-                    && $outcomes_attempted[$outcome->id]!=0)
323
-                    {{{ ($outcomes_achieved[$outcome->id]/$outcomes_attempted[$outcome->id])*100 }}},
324
-                @else
325
-                    0,
326
-                @endif
327
-            @endforeach
328
-        ]
329
-    }]
311
+},{
312
+name: 'Obtained Value',
313
+color: '#e70033',
314
+dataLabels: {
315
+enabled: true,
316
+fontSize: 8,
317
+color: '#fff',
318
+align: 'right',
319
+format: '{y:.1f}%',
320
+style: {
321
+//fontWeight: 'bold'
322
+},
323
+y:-1
324
+},
325
+data:[
326
+@foreach($outcomes as $index => $outcome)
327
+@if(
328
+is_array($outcomes_attempted)
329
+&& array_key_exists($outcome->id, $outcomes_attempted)
330
+&& $outcomes_attempted[$outcome->id]!=0)
331
+{{{ ($outcomes_achieved[$outcome->id]/$outcomes_attempted[$outcome->id])*100 }}},
332
+@else
333
+0,
334
+@endif
335
+@endforeach
336
+]
337
+}]
330 338
 });
331 339
 
332 340
 // Include dummy graph for outcomes

+ 7
- 7
app/views/local/professors/_navigation.blade.php Wyświetl plik

@@ -16,14 +16,14 @@
16 16
         </ul>
17 17
       </li>
18 18
       @if(count(Auth::user()->courses))
19
-        <li class="dropdown">
20
-          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Sections<span class="caret"></span></a>
21
-          <ul class="dropdown-menu" role="menu">
19
+      <li class="dropdown">
20
+        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Sections<span class="caret"></span></a>
21
+        <ul class="dropdown-menu" role="menu">
22 22
           @foreach ($courses as $course)
23
-            <li> {{ HTML::linkAction('CoursesController@show', $course->code.$course->number.'-'.$course->section.' ('.$course->semester->code.')', array('id'=>$course->id)) }}</li>
23
+          <li> {{ HTML::linkAction('CoursesController@show', $course->code.$course->number.'-'.$course->section.' ('.$course->semester->code.')', array('id'=>$course->id)) }}</li>
24 24
           @endforeach
25
-          </ul>
26
-        </li>
25
+        </ul>
26
+      </li>
27 27
       @endif
28 28
       <li> {{ HTML::linkAction('ProfessorsController@program', 'Program') }}</li>
29 29
       <li>{{ HTML::linkAction('OutcomesController@professorAssessmentReports', 'Reports') }}</li>
@@ -45,4 +45,4 @@
45 45
       </li>
46 46
     </ul>
47 47
   </div>
48
-</div>
48
+</div>

+ 1
- 0
app/views/local/professors/activity.blade.php Wyświetl plik

@@ -166,6 +166,7 @@
166 166
             <!-- If no rubric is assigned and the semester is active -->
167 167
             @if($activity->rubric == NULL && in_array($course->semester->id, $active_semesters))
168 168
                 {{ HTML::linkAction('RubricsController@newRubric', 'Assign Rubric', array($activity->id), array('class'=>'btn btn-primary btn-sm btn-block')) }}
169
+                {{ HTML::linkAction('RubricsController@newOtherMethod', 'Assign Other Assessment Method', array($activity->id), array('class'=>'btn btn-primary btn-sm btn-block')) }}
169 170
             @else
170 171
 
171 172
                 {{ HTML::linkAction('RubricsController@show', 'View Rubric', array($activity->id), array('class'=>'btn btn-primary btn-sm btn-block')) }}

+ 1
- 1
bootstrap/start.php Wyświetl plik

@@ -26,7 +26,7 @@ $app = new Illuminate\Foundation\Application;
26 26
 
27 27
 $env = $app->detectEnvironment(array(
28 28
 
29
-	'local' => array(gethostname(), 'ubuntu', 'RPV20111.rrp.campus', 'homestead'),
29
+	'local' => array(gethostname(), 'RPV20111.rrp.campus', 'homestead'),
30 30
     'production' => array('*.com', '*.edu', '*.org'),
31 31
 
32 32
 ));

+ 7
- 4
composer.json Wyświetl plik

@@ -1,20 +1,23 @@
1 1
 {
2 2
 	"name": "laravel/laravel",
3 3
 	"description": "The Laravel Framework.",
4
-	"keywords": ["framework", "laravel"],
4
+	"keywords": [
5
+		"framework",
6
+		"laravel"
7
+	],
5 8
 	"license": "MIT",
6 9
 	"type": "project",
7 10
 	"require": {
8 11
 		"laravel/framework": "4.2.*",
9 12
 		"pda/pheanstalk": "~2.0",
10 13
 		"barryvdh/laravel-dompdf": "0.4.*",
11
-		 "zizaco/entrust": "1.2.*@dev"
14
+		"zizaco/entrust": "1.2.*@dev"
12 15
 	},
13 16
 	"require-dev": {
14 17
 		"way/generators": "~2.0",
15 18
 		"fzaninotto/faker": "1.5.*@dev",
16 19
 		"barryvdh/laravel-ide-helper": "1.11"
17
-		},
20
+	},
18 21
 	"autoload": {
19 22
 		"classmap": [
20 23
 			"app/commands",
@@ -42,4 +45,4 @@
42 45
 		"preferred-install": "dist"
43 46
 	},
44 47
 	"minimum-stability": "stable"
45
-}
48
+}

+ 53
- 0
drop_tables.sql Wyświetl plik

@@ -0,0 +1,53 @@
1
+Set foreign_key_checks =0;
2
+drop table if exists `VIEW_participating_programs`...
3
+
4
+drop table if exists `activities`;
5
+
6
+drop table if exists `annual_plan_outcomes`;
7
+
8
+drop table if exists `annual_plans`;
9
+
10
+drop table if exists `assessments`;
11
+
12
+drop table if exists `course_student`;
13
+
14
+drop table if exists `courses`;
15
+
16
+drop table if exists `criteria`;
17
+
18
+drop table if exists `criterion_objective`;
19
+
20
+drop table if exists `five_year_plans`;
21
+
22
+drop table if exists `fyp_part_outcomes`;
23
+
24
+drop table if exists `fyp_parts`;
25
+
26
+drop table if exists `migrations`;
27
+
28
+drop table if exists `objectives`;
29
+
30
+drop table if exists `outcomes`;
31
+
32
+drop table if exists `password_reminders`;
33
+
34
+drop table if exists `password_resets`;
35
+
36
+drop table if exists `program_user`;
37
+
38
+drop table if exists `programs`;
39
+
40
+drop table if exists `quinquenniums`;
41
+
42
+drop table if exists `rubrics`;
43
+
44
+drop table if exists `schools`;
45
+
46
+drop table if exists `semesters`;
47
+
48
+drop table if exists `students`;
49
+
50
+drop table if exists `templates`;
51
+
52
+
53
+set foreign_key_checks =1;

+ 1
- 0
public/.htaccess Wyświetl plik

@@ -12,4 +12,5 @@
12 12
     RewriteCond %{REQUEST_FILENAME} !-d
13 13
     RewriteCond %{REQUEST_FILENAME} !-f
14 14
     RewriteRule ^ index.php [L]
15
+
15 16
 </IfModule>

+ 103
- 0
seed.sql Wyświetl plik

@@ -0,0 +1,103 @@
1
+SET FOREIGN_KEY_CHECKS=0;
2
+INSERT INTO activities (id, name, description, course_id, date, draft, created_at, updated_at, criteria_achieved, criteria_weights, outcomes_achieved, outcomes_attempted, transforming_actions, assessment_comments, criteria_achieved_percentage, criteria_participant_count, criteria_achiever_count) VALUES (1, 'act1', 'abc', null, '2020-01-01', 0, '2020-01-01 00:00:00', '2020-01-01 00:00:00', null, null, null, null, null, null, null, null, null);
3
+INSERT INTO activities (id, name, description, course_id, date, draft, created_at, updated_at, criteria_achieved, criteria_weights, outcomes_achieved, outcomes_attempted, transforming_actions, assessment_comments, criteria_achieved_percentage, criteria_participant_count, criteria_achiever_count) VALUES (3, 'act2', 'from course1', 1, '2020-01-01', 0, '2020-01-01 00:00:00', '2020-01-01 00:00:00', null, null, null, null, null, null, null, null, null);INSERT INTO courses (id, name, code, section, program_id, user_id, semester_id, created_at, updated_at, criteria_achieved, outcomes_achieved, outcomes_attempted, number) VALUES (1, 'course1', 'CURS0001', '001', 1, 1, 1, '2020-01-01 00:00:00', '2020-01-01 00:00:00', null, null, null, '0000');INSERT INTO criteria (id, name, subcriteria, description12, description34, description56, description78, outcome_id, created_at, updated_at, user_id, program_id, deleted_at, copyright, notes) VALUES (1, 'crit1', null, 'a', 'b', 'c', 'd', 1, '2020-01-01 00:00:00', '2020-01-01 00:00:00', 1, 1, null, null, null);INSERT INTO migrations (migration, batch) VALUES ('2014_10_05_052350_create_schools_table', 1);
4
+INSERT INTO migrations (migration, batch) VALUES ('2014_10_05_055013_create_programs_table', 1);
5
+INSERT INTO migrations (migration, batch) VALUES ('2014_10_06_050335_create_users_table', 1);
6
+INSERT INTO migrations (migration, batch) VALUES ('2014_10_12_100000_create_password_resets_table', 1);
7
+INSERT INTO migrations (migration, batch) VALUES ('2014_11_10_035949_create_rubrics_table', 1);
8
+INSERT INTO migrations (migration, batch) VALUES ('2014_11_29_210957_create_templates_table', 1);
9
+INSERT INTO migrations (migration, batch) VALUES ('2014_11_29_211309_create_courses_table', 1);
10
+INSERT INTO migrations (migration, batch) VALUES ('2014_11_29_211310_create_activities_table', 1);
11
+INSERT INTO migrations (migration, batch) VALUES ('2014_11_29_212240_create_outcomes_table', 1);
12
+INSERT INTO migrations (migration, batch) VALUES ('2014_11_29_212341_create_criteria_table', 1);
13
+INSERT INTO migrations (migration, batch) VALUES ('2014_11_29_214028_create_semesters_table', 1);
14
+INSERT INTO migrations (migration, batch) VALUES ('2014_11_30_134022_create_students_table', 1);
15
+INSERT INTO migrations (migration, batch) VALUES ('2014_12_07_214036_create_course_student_table', 1);
16
+INSERT INTO migrations (migration, batch) VALUES ('2015_01_09_171350_create_assessments_table', 1);
17
+INSERT INTO migrations (migration, batch) VALUES ('2015_01_12_204310_add_columns_to_activities_table', 1);
18
+INSERT INTO migrations (migration, batch) VALUES ('2015_01_12_222859_add_columns_to_assessments_table', 1);
19
+INSERT INTO migrations (migration, batch) VALUES ('2015_01_13_010052_add_index_to_assessments_table', 1);
20
+INSERT INTO migrations (migration, batch) VALUES ('2015_01_13_142849_add_column_to_criteria_table', 1);
21
+INSERT INTO migrations (migration, batch) VALUES ('2015_01_14_140724_add_columns_to_courses_table', 1);
22
+INSERT INTO migrations (migration, batch) VALUES ('2015_01_21_124809_add_column_to_courses_table', 1);
23
+INSERT INTO migrations (migration, batch) VALUES ('2015_01_22_195515_add_column_to_templates_table', 1);
24
+INSERT INTO migrations (migration, batch) VALUES ('2015_01_23_175455_remove_total_from_assessments_table', 1);
25
+INSERT INTO migrations (migration, batch) VALUES ('2015_01_23_175923_rename_average_in_assessments_table', 1);
26
+INSERT INTO migrations (migration, batch) VALUES ('2015_01_28_121848_add_index_to_course_student_table', 1);
27
+INSERT INTO migrations (migration, batch) VALUES ('2015_01_28_133036_add_criteria_achieved_count_to_activities_table', 1);
28
+INSERT INTO migrations (migration, batch) VALUES ('2015_02_05_133245_add_transforming_actions_to_activities_table', 1);
29
+INSERT INTO migrations (migration, batch) VALUES ('2015_02_05_143641_add_assessment_comments_to_activities_table', 1);
30
+INSERT INTO migrations (migration, batch) VALUES ('2015_02_06_145359_create_password_reminders_table', 1);
31
+INSERT INTO migrations (migration, batch) VALUES ('2015_02_19_143311_add_is_graduate_to_programs_table', 1);
32
+INSERT INTO migrations (migration, batch) VALUES ('2015_02_25_170516_add_deleted_at_to_outcomes_table', 1);
33
+INSERT INTO migrations (migration, batch) VALUES ('2015_02_25_170529_add_deleted_at_to_criteria_table', 1);
34
+INSERT INTO migrations (migration, batch) VALUES ('2015_02_27_201953_add_criteria_achieved_percentage_to_activities_table', 1);
35
+INSERT INTO migrations (migration, batch) VALUES ('2015_03_04_132321_add_copyright_and_notes_to_criteria_table', 1);
36
+INSERT INTO migrations (migration, batch) VALUES ('2015_04_13_183730_add_program_id_to_templates_table', 1);
37
+INSERT INTO migrations (migration, batch) VALUES ('2015_04_28_141931_add_is_visible_to_templates_table', 1);
38
+INSERT INTO migrations (migration, batch) VALUES ('2015_05_04_162918_remove_expected_outcome_from_outcomes_table', 1);
39
+INSERT INTO migrations (migration, batch) VALUES ('2015_05_05_083800_add_decimal_expected_outcome_to_outcomes_table', 1);
40
+INSERT INTO migrations (migration, batch) VALUES ('2015_05_18_095002_add_first_login_to_users_table', 1);
41
+INSERT INTO migrations (migration, batch) VALUES ('2015_05_18_131259_add_columns_to_semesters_table', 1);
42
+INSERT INTO migrations (migration, batch) VALUES ('2015_05_18_134926_add_semester_id_to_courses', 1);
43
+INSERT INTO migrations (migration, batch) VALUES ('2015_06_10_092319_add_name_to_semesters_table', 1);
44
+INSERT INTO migrations (migration, batch) VALUES ('2015_06_12_085247_add_visibility_to_semesters_table', 1);
45
+INSERT INTO migrations (migration, batch) VALUES ('2015_06_16_092223_add_has_access_to_users', 1);
46
+INSERT INTO migrations (migration, batch) VALUES ('2015_06_18_103255_add_expected_percentage_and_points_to_templates_table', 1);
47
+INSERT INTO migrations (migration, batch) VALUES ('2015_07_10_150430_add_email_to_students_table', 1);
48
+INSERT INTO migrations (migration, batch) VALUES ('2015_07_13_111726_add_code_to_programs_table', 1);
49
+INSERT INTO migrations (migration, batch) VALUES ('2015_07_13_132620_add_ssn_and_employee_number_to_users_table', 1);
50
+INSERT INTO migrations (migration, batch) VALUES ('2015_08_19_130733_add_semester_id_to_course_student_table', 1);
51
+INSERT INTO migrations (migration, batch) VALUES ('2015_12_10_145451_add_criteria_weights_to_activities_table', 1);
52
+INSERT INTO migrations (migration, batch) VALUES ('2016_01_12_132034_add_program_id_to_criteria_table', 1);
53
+INSERT INTO migrations (migration, batch) VALUES ('2016_01_27_093808_add_date_to_activities_table', 1);
54
+INSERT INTO migrations (migration, batch) VALUES ('2016_01_27_134306_add_draft_to_activities_table', 1);
55
+INSERT INTO migrations (migration, batch) VALUES ('2016_03_11_085258_add_school_and_concentration_codes_to_students_table', 1);
56
+INSERT INTO migrations (migration, batch) VALUES ('2016_05_09_145427_create_program_user_table', 1);
57
+INSERT INTO migrations (migration, batch) VALUES ('2016_05_10_091847_remove_program_id_from_users_table', 1);
58
+INSERT INTO migrations (migration, batch) VALUES ('2016_05_23_153434_create_objectives_table', 1);
59
+INSERT INTO migrations (migration, batch) VALUES ('2016_05_25_090412_add_active_to_objectives_table', 1);
60
+INSERT INTO migrations (migration, batch) VALUES ('2016_05_26_092328_create_criterion_objective_table', 1);
61
+INSERT INTO migrations (migration, batch) VALUES ('2016_07_15_084546_create_quinquenniums_table', 1);
62
+INSERT INTO migrations (migration, batch) VALUES ('2016_07_15_084751_create_five_year_plans_table', 1);
63
+INSERT INTO migrations (migration, batch) VALUES ('2016_07_15_084851_create_annual_plans_table', 1);
64
+INSERT INTO migrations (migration, batch) VALUES ('2016_07_15_090133_create_fyp_parts_table', 1);
65
+INSERT INTO migrations (migration, batch) VALUES ('2016_07_15_090203_create_fyp_part_outcomes_table', 1);
66
+INSERT INTO migrations (migration, batch) VALUES ('2016_07_15_090217_create_annual_plan_outcomes_table', 1);
67
+INSERT INTO migrations (migration, batch) VALUES ('2016_08_03_120016_remove_methods_from_fyp_part_outcomes_table', 1);
68
+INSERT INTO migrations (migration, batch) VALUES ('2016_08_03_140525_add_unique_index_to_five_year_plans_table', 1);
69
+INSERT INTO migrations (migration, batch) VALUES ('2016_08_11_150848_remove_semester_id_from_annual_plans_table', 2);
70
+INSERT INTO migrations (migration, batch) VALUES ('2016_08_11_151247_add_year_start_and_year_end_to_annual_plans_table', 2);
71
+INSERT INTO migrations (migration, batch) VALUES ('2017_02_03_150052_add_comments_to_assessments_table', 2);
72
+INSERT INTO migrations (migration, batch) VALUES ('2018_02_12_144827_add_subcriteria_to_criteria_table', 2);
73
+INSERT INTO migrations (migration, batch) VALUES ('2018_07_26_132933_add_last_login_to_users_table', 2);
74
+INSERT INTO migrations (migration, batch) VALUES ('2018_07_26_134316_add_phone_numbers_and_extension_to_users_table', 2);
75
+INSERT INTO migrations (migration, batch) VALUES ('2018_08_09_110432_remove_password_from_users_table', 2);
76
+INSERT INTO migrations (migration, batch) VALUES ('2018_08_09_110813_remove_password_updated_and_remember_token_from_users_table', 2);
77
+INSERT INTO migrations (migration, batch) VALUES ('2018_08_10_083743_add_remember_token_to_users_table', 2);
78
+INSERT INTO migrations (migration, batch) VALUES ('2018_08_28_140328_remove_outcome_id_from_objectives_table', 2);
79
+INSERT INTO migrations (migration, batch) VALUES ('2018_08_28_141547_drop_criterion_objective_table', 2);
80
+INSERT INTO migrations (migration, batch) VALUES ('2018_08_28_142111_create_objective_outcome_table', 2);
81
+INSERT INTO migrations (migration, batch) VALUES ('2018_09_13_134104_entrust_setup_tables', 2);
82
+INSERT INTO migrations (migration, batch) VALUES ('2019_08_07_100303_add_participants_achievers_counts_to_activities_table', 2);
83
+INSERT INTO migrations (migration, batch) VALUES ('2020_03_06_122426_create_participating_programs_view', 2);
84
+INSERT INTO migrations (migration, batch) VALUES ('2020_04_04_002657_create_new_criteria_table', 2);
85
+INSERT INTO migrations (migration, batch) VALUES ('2020_04_04_005817_add_outcome_id_to_objectives_table', 2);
86
+INSERT INTO migrations (migration, batch) VALUES ('2020_04_22_090200_alter_activities_table', 2);
87
+INSERT INTO migrations (migration, batch) VALUES ('2020_04_22_095649_create_new_criterion_rubric_table', 2);
88
+INSERT INTO migrations (migration, batch) VALUES ('2020_04_22_101110_create_new_rubric_activity_table', 2);
89
+INSERT INTO migrations (migration, batch) VALUES ('2020_04_22_105537_create_new_activity_course_table', 2);
90
+INSERT INTO migrations (migration, batch) VALUES ('2020_04_22_122910_add_criteria_id_to_assessments_table', 2);INSERT INTO new_criteria (id, name, subcriteria, description12, description34, description56, description78, objective_id, program_id, user_id, copyright, notes, created_at, updated_at, deleted_at) VALUES (2, 'crit1', null, '12', '34', '56', '78', 1, 1, 1, null, null, '2020-01-01 00:00:00', '2020-01-01 00:00:00', null);INSERT INTO new_criterion_rubric (id, criterion_id, rubric_id, created_at, updated_at) VALUES (2, 2, 1, '2020-01-01 00:00:00', '2020-01-01 00:00:00');INSERT INTO new_rubric_activity (id, rubric_id, activity_id, created_at, updated_at) VALUES (1, 1, 1, '2020-01-01 00:00:00', '2020-01-01 00:00:00');
91
+INSERT INTO new_rubric_activity (id, rubric_id, activity_id, created_at, updated_at) VALUES (2, 1, 3, '2020-01-01 00:00:00', '2020-01-01 00:00:00');INSERT INTO objective_outcome (id, objective_id, outcome_id, created_at, updated_at) VALUES (1, 1, 1, '2020-01-01 00:00:00', '2020-01-01 00:00:00');INSERT INTO objectives (id, program_id, text, active, created_at, updated_at, outcome_id) VALUES (1, 1, 'obj1', 1, '2020-01-01 00:00:00', '2020-01-01 00:00:00', 1);INSERT INTO outcomes (id, name, definition, expected_outcome, created_at, updated_at, deleted_at, new_outcome_id, deactivation_date) VALUES (1, 'outcome1', 'outcome1', 66.66, '2020-01-01 00:00:00', '2020-01-01 00:00:00', null, 1, null);
92
+INSERT INTO outcomes (id, name, definition, expected_outcome, created_at, updated_at, deleted_at, new_outcome_id, deactivation_date) VALUES (2, 'outcome2', 'outcome2', 66.66, '2020-01-01 00:00:00', '2020-01-01 00:00:00', null, 2, null);
93
+INSERT INTO outcomes (id, name, definition, expected_outcome, created_at, updated_at, deleted_at, new_outcome_id, deactivation_date) VALUES (3, 'outcome3', 'outcome3', 66.66, '2020-01-01 00:00:00', '2020-01-01 00:00:00', null, 3, null);
94
+INSERT INTO outcomes (id, name, definition, expected_outcome, created_at, updated_at, deleted_at, new_outcome_id, deactivation_date) VALUES (4, 'outcome4', 'outcome4', 66.66, '2020-01-01 00:00:00', '2020-01-01 00:00:00', null, 4, null);
95
+INSERT INTO outcomes (id, name, definition, expected_outcome, created_at, updated_at, deleted_at, new_outcome_id, deactivation_date) VALUES (5, 'outcome5', 'outcome5', 66.66, '2020-01-01 00:00:00', '2020-01-01 00:00:00', null, 5, null);
96
+INSERT INTO outcomes (id, name, definition, expected_outcome, created_at, updated_at, deleted_at, new_outcome_id, deactivation_date) VALUES (6, 'outcome6', 'outcome6', 66.66, '2020-01-01 00:00:00', '2020-01-01 00:00:00', null, 6, null);
97
+INSERT INTO outcomes (id, name, definition, expected_outcome, created_at, updated_at, deleted_at, new_outcome_id, deactivation_date) VALUES (7, 'outcome7', 'outcome7', 66.66, '2020-01-01 00:00:00', '2020-01-01 00:00:00', null, 7, null);
98
+INSERT INTO outcomes (id, name, definition, expected_outcome, created_at, updated_at, deleted_at, new_outcome_id, deactivation_date) VALUES (8, 'outcome8', 'outcome8', 66.66, '2020-01-01 00:00:00', '2020-01-01 00:00:00', null, 8, null);
99
+INSERT INTO outcomes (id, name, definition, expected_outcome, created_at, updated_at, deleted_at, new_outcome_id, deactivation_date) VALUES (9, 'old_outcome1', 'deactivates on 2015-01-01', 66.66, '2020-01-01 00:00:00', '2020-01-01 00:00:00', null, 1, '2015-01-01');INSERT INTO programs (id, name, code, school_id, restrict_rubrics, created_at, updated_at, is_graduate) VALUES (1, 'TEST', 'TEST', 1, 0, '2020-01-01 00:00:00', '2020-01-01 00:00:00', 0);
100
+INSERT INTO programs (id, name, code, school_id, restrict_rubrics, created_at, updated_at, is_graduate) VALUES (2, 'UHS', 'UHS', 2, 0, '2020-01-01 00:00:00', '2020-01-01 00:00:00', 0);INSERT INTO program_user (id, program_id, user_id, created_at, updated_at) VALUES (1, 1, 1, '2020-01-01 00:00:00', '2020-01-01 00:00:00');INSERT INTO rubrics (id, name, contents, expected_percentage, expected_points, user_id, created_at, updated_at) VALUES (1, 'rubric1', 'abcd', 50, 50, 1, '2020-01-01 00:00:00', '2020-01-01 00:00:00');INSERT INTO schools (id, name, created_at, updated_at) VALUES (1, 'school1', '2020-01-01 00:00:00', '2020-01-01 00:00:00');
101
+INSERT INTO schools (id, name, created_at, updated_at) VALUES (2, 'UHS', '2020-01-01 00:00:00', '2020-01-01 00:00:00');INSERT INTO semesters (id, code, name, start, end, is_visible) VALUES (1, 'B92', 'SEM 2 2019-2020', '2019-01-01 00:00:00', '2020-06-01 00:00:00', 1);
102
+INSERT INTO semesters (id, code, name, start, end, is_visible) VALUES (2, 'B01', 'SEM 1 2010-2011', '2010-01-01 00:00:00', '2010-01-01 00:00:00', 1);INSERT INTO users (id, ssn, number, first_name, surnames, email, alternate_email, office_phone, office_extension, cell_phone, role, school_id, has_access, created_at, updated_at, last_login, remember_token) VALUES (1, '000000000', '0000000000', 'test', 'test', 'test@upr.edu', null, null, null, null, 1, 1, 1, '2020-01-01 00:00:00', '2020-05-15 11:03:31', '2020-05-15 15:03:31', null);
103
+SET FOREIGN_KEY_CHECKS=1;