|
@@ -102,20 +102,52 @@ class CriteriaController extends \BaseController
|
102
|
102
|
public function fetchObjectivesForSelect()
|
103
|
103
|
{
|
104
|
104
|
$json = array();
|
|
105
|
+ $role = Auth::user()->role;
|
|
106
|
+ switch ($role) {
|
|
107
|
+ case 1:
|
|
108
|
+
|
|
109
|
+ $program_ids = DB::table('programs')->lists('id');
|
|
110
|
+
|
|
111
|
+ break;
|
|
112
|
+ case 2:
|
|
113
|
+
|
|
114
|
+ $program_ids = DB::table('programs')
|
|
115
|
+ ->where('school_id', Auth::user()->school_id)
|
|
116
|
+ ->lists('id');
|
|
117
|
+
|
|
118
|
+ break;
|
|
119
|
+
|
|
120
|
+ case 3:
|
|
121
|
+
|
|
122
|
+ $program_ids = DB::table('program_user')
|
|
123
|
+ ->where('user_id', Auth::user()->id)
|
|
124
|
+ ->lists('id');
|
105
|
125
|
|
|
126
|
+ break;
|
|
127
|
+ }
|
106
|
128
|
$outcome_id = Input::get('outcomeID');
|
107
|
129
|
|
108
|
130
|
$json = DB::table('objectives')
|
109
|
131
|
->join('objective_outcome', 'objective_outcome.objective_id', '=', 'objectives.id')
|
|
132
|
+ ->join('objective_program', 'objective_program.objective_id', '=', 'objectives.id')
|
110
|
133
|
->where('outcome_id', '=', $outcome_id)
|
|
134
|
+ ->whereIn('program_id', $program_ids)
|
|
135
|
+ ->select('objectives.*', 'objective_outcome.*')
|
|
136
|
+ ->distinct()
|
111
|
137
|
->get();
|
|
138
|
+ foreach ($json as $objective) {
|
|
139
|
+ $objective->program_ids = json_encode(DB::table('objective_program')
|
|
140
|
+ ->where('objective_id', $objective->objective_id)
|
|
141
|
+ ->lists('program_id'));
|
|
142
|
+ }
|
|
143
|
+
|
112
|
144
|
|
113
|
145
|
return json_encode($json);
|
114
|
146
|
}
|
115
|
147
|
public function fetchCriterionWithTrashed()
|
116
|
148
|
{
|
117
|
149
|
|
118
|
|
- $json = array();
|
|
150
|
+ /* $json = array();
|
119
|
151
|
$json['criteria'] = DB::table('criteria')->where('id', Input::get('id'))->get();
|
120
|
152
|
|
121
|
153
|
|
|
@@ -133,6 +165,11 @@ class CriteriaController extends \BaseController
|
133
|
165
|
->join('objective_outcome', 'objective_outcome.objective_id', '=', 'objectives.id')
|
134
|
166
|
->where('outcome_id', $id)
|
135
|
167
|
->get();
|
|
168
|
+ foreach ($json['objectives_assoc'][$id] as $objective) {
|
|
169
|
+ $objective->program_ids = json_encode(DB::table('objective_program')
|
|
170
|
+ ->where('objective_id', $objective->objective_id)
|
|
171
|
+ ->lists('program_id'));
|
|
172
|
+ }
|
136
|
173
|
}
|
137
|
174
|
$json['program'] = DB::table('program_criterion')->where('criterion_id', $criteria_id)->get();
|
138
|
175
|
$json['activity_criterion'] = DB::table('assessments')
|
|
@@ -159,7 +196,7 @@ class CriteriaController extends \BaseController
|
159
|
196
|
$json['outcomes_assoc'][$outId] = DB::select("select name from outcomes where id = {$outId}");
|
160
|
197
|
$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");
|
161
|
198
|
}*/
|
162
|
|
-
|
|
199
|
+ $criteria_id = Input::get('id');
|
163
|
200
|
$criterion = DB::table('criteria')->where('id', Input::get('id'))->first();
|
164
|
201
|
if (!$criterion) return $criterion;
|
165
|
202
|
$criterion->outcomes = DB::table('criterion_objective_outcome')
|
|
@@ -179,6 +216,11 @@ class CriteriaController extends \BaseController
|
179
|
216
|
->where('criterion_id', $criterion->id)
|
180
|
217
|
->where('outcome_id', $outcome->id)
|
181
|
218
|
->get();
|
|
219
|
+ foreach ($outcome->assoc_objectives as $objective) {
|
|
220
|
+ $objective->program_ids = json_encode(DB::table('objective_program')
|
|
221
|
+ ->where('objective_id', $objective->objective_id)
|
|
222
|
+ ->lists('program_id'));
|
|
223
|
+ }
|
182
|
224
|
}
|
183
|
225
|
$criterion->scales = DB::table('criterion_scale')
|
184
|
226
|
->join('scales', 'criterion_scale.scale_id', '=', 'scales.id')
|
|
@@ -218,20 +260,43 @@ class CriteriaController extends \BaseController
|
218
|
260
|
else
|
219
|
261
|
$program_id = NULL;
|
220
|
262
|
|
|
263
|
+ $outcomes = [];
|
|
264
|
+ $objectives = [];
|
|
265
|
+ foreach ($input['objective_id'] as $objective) {
|
|
266
|
+ $parentesis = array('(', ')');
|
|
267
|
+ $outcome_objective = str_replace($parentesis, '', $objective);
|
|
268
|
+ $outcomes[] = $outcome_objective[0];
|
|
269
|
+ $objectives[] = $outcome_objective[1];
|
|
270
|
+ }
|
|
271
|
+ $scales = [];
|
|
272
|
+ foreach ($input['scale_description'] as $scale) {
|
|
273
|
+ $existing_scale = DB::table('scales')->where('description', $scale)
|
|
274
|
+ ->first();
|
|
275
|
+ if (!$existing_scale) return true;
|
|
276
|
+ $scales[] = $existing_scale->id;
|
|
277
|
+ }
|
|
278
|
+
|
|
279
|
+
|
221
|
280
|
$saved_criterion = DB::table('criteria')
|
222
|
281
|
->join('program_criterion', 'program_criterion.criterion_id', '=', 'criteria.id')
|
223
|
282
|
->join('criterion_objective_outcome', 'criterion_objective_outcome.criterion_id', '=', 'criteria.id')
|
|
283
|
+ ->join('criterion_scale', 'criterion_scale.criterion_id', '=', 'criteria.id')
|
224
|
284
|
->whereIn('program_id', $input['program_id'])
|
225
|
|
- ->whereIn('objective_id', $input['objective_id'])
|
226
|
|
- ->whereIn('outcome_id', $input['outcome_id'])
|
|
285
|
+ ->whereIn('objective_id', $objectives)
|
|
286
|
+ ->whereIn('outcome_id', $outcomes)
|
227
|
287
|
->where('name', '=', $input['name'])
|
228
|
288
|
->where('subcriteria', '=', $input['subcriteria'])
|
|
289
|
+ ->whereIn('scale_id', $scales)
|
|
290
|
+ ->where('num_scales', $input['number_of_scales'])
|
|
291
|
+ ->where('max_score', $input['maximum_score'])
|
|
292
|
+
|
229
|
293
|
->first();
|
230
|
294
|
|
231
|
295
|
|
232
|
296
|
|
233
|
297
|
|
234
|
298
|
|
|
299
|
+
|
235
|
300
|
if ($saved_criterion)
|
236
|
301
|
return false;
|
237
|
302
|
else
|
|
@@ -265,9 +330,7 @@ class CriteriaController extends \BaseController
|
265
|
330
|
|
266
|
331
|
|
267
|
332
|
$clean_input['objective_id'] = Input::get('objective');
|
268
|
|
- //Log::info('PA los periqueros');
|
269
|
|
- //Log::info(Input::get('objective'));
|
270
|
|
- //Log::info($clean_input['objective_id']);
|
|
333
|
+
|
271
|
334
|
|
272
|
335
|
|
273
|
336
|
|
|
@@ -277,10 +340,9 @@ class CriteriaController extends \BaseController
|
277
|
340
|
$clean_input['copyright'] = trim(preg_replace('/\t+/', '', Input::get('copyright')));
|
278
|
341
|
$clean_input['notes'] = trim(preg_replace('/\t+/', '', Input::get('notes')));
|
279
|
342
|
$clean_input['maximum_score'] = (int) Input::get('maximum_score');
|
280
|
|
- // $clean_input['scale_title'] = Input::get('title');
|
|
343
|
+
|
281
|
344
|
$clean_input['scale_description'] = Input::get('Scales');
|
282
|
|
- // $clean_input['min_score'] = Input::get('min');
|
283
|
|
- //$clean_input['max_score'] = Input::get('max');
|
|
345
|
+
|
284
|
346
|
|
285
|
347
|
$clean_input['number_of_scales'] = sizeof($clean_input['scale_description']);
|
286
|
348
|
|
|
@@ -290,27 +352,45 @@ class CriteriaController extends \BaseController
|
290
|
352
|
|
291
|
353
|
private function makeValidator($clean_input)
|
292
|
354
|
{
|
293
|
|
- /** Validation rules */
|
|
355
|
+ if (isset($clean_input['scale_description'][0])) {
|
|
356
|
+ $scale = $clean_input['scale_description'][0];
|
|
357
|
+ } else {
|
|
358
|
+ $scale = 0;
|
|
359
|
+ }
|
|
360
|
+ if (isset($clean_input['program_id'][0])) {
|
|
361
|
+ $program_id = $clean_input['program_id'][0];
|
|
362
|
+ } else {
|
|
363
|
+ $program_id = NULL;
|
|
364
|
+ }
|
|
365
|
+
|
|
366
|
+ if (isset($clean_input['objective_id'][0]) && $clean_input['objective_id'][0] != '0') {
|
|
367
|
+ $objective_id = $clean_input['objective_id'][0];
|
|
368
|
+ Log::info('Estamos');
|
|
369
|
+ } else {
|
|
370
|
+ $objective_id = NULL;
|
|
371
|
+ }
|
294
|
372
|
return Validator::make(
|
295
|
373
|
array(
|
296
|
374
|
'name' => $clean_input['name'],
|
297
|
375
|
'subcriteria' => $clean_input['subcriteria'],
|
298
|
|
- 'outcome_id' => $clean_input['outcome_id'],
|
|
376
|
+ // 'outcome_id' => $clean_input['outcome_id'],
|
299
|
377
|
'notes' => $clean_input['notes'],
|
300
|
378
|
'copyright' => $clean_input['copyright'],
|
301
|
379
|
'maximum_score' => $clean_input['maximum_score'],
|
302
|
|
- 'scales' => $clean_input['scale_description'],
|
303
|
|
- 'objective_id' => $clean_input['objective_id']
|
|
380
|
+ 'scales' => $scale,
|
|
381
|
+ 'objective_id' => $objective_id,
|
|
382
|
+ 'program_id' => $program_id,
|
304
|
383
|
),
|
305
|
384
|
array(
|
306
|
385
|
'name' => 'required|string',
|
307
|
386
|
'subcriteria' => 'string',
|
308
|
|
- 'outcome_id' => 'required|array',
|
309
|
|
- 'scales' => 'required|array',
|
|
387
|
+ // 'outcome_id' => 'required|array',
|
|
388
|
+ 'scales' => 'required|string',
|
310
|
389
|
'notes' => 'string',
|
311
|
390
|
'copyright' => 'string',
|
312
|
391
|
'maximum_score' => 'required|integer',
|
313
|
|
- 'objective_id' => 'required|array'
|
|
392
|
+ 'objective_id' => 'required|string',
|
|
393
|
+ 'program_id' => 'required|integer'
|
314
|
394
|
)
|
315
|
395
|
|
316
|
396
|
);
|
|
@@ -324,15 +404,15 @@ class CriteriaController extends \BaseController
|
324
|
404
|
public function create()
|
325
|
405
|
{
|
326
|
406
|
$clean_input = $this->cleanInput();
|
327
|
|
- Log::info("POG???");
|
|
407
|
+
|
328
|
408
|
|
329
|
409
|
/** Validation rules */
|
330
|
|
- //$validator = $this->makeValidator($clean_input);
|
|
410
|
+ $validator = $this->makeValidator($clean_input);
|
331
|
411
|
|
332
|
412
|
/** If validation fails */
|
333
|
|
- //if ($validator->fails()) {
|
334
|
|
- /** Prepare error message */
|
335
|
|
- /* $message = '<p>Error(s) creating a new Criterion:</p><ul>';
|
|
413
|
+ if ($validator->fails()) {
|
|
414
|
+ /** Prepare error message */
|
|
415
|
+ $message = '<p>Error(s) creating a new Criterion:</p><ul>';
|
336
|
416
|
|
337
|
417
|
foreach ($validator->messages()->all('<li>:message</li>') as $validationError) {
|
338
|
418
|
$message .= $validationError;
|
|
@@ -341,7 +421,7 @@ class CriteriaController extends \BaseController
|
341
|
421
|
$message .= '</ul>';
|
342
|
422
|
|
343
|
423
|
/** Send error message and old data */
|
344
|
|
- /* Session::flash('status', 'danger');
|
|
424
|
+ Session::flash('status', 'danger');
|
345
|
425
|
Session::flash('message', $message);
|
346
|
426
|
$role = Auth::user()['role'];
|
347
|
427
|
switch ($role) {
|
|
@@ -358,7 +438,7 @@ class CriteriaController extends \BaseController
|
358
|
438
|
// Check criterion uniqueness
|
359
|
439
|
if (!$this->isCriterionUnique($clean_input)) {
|
360
|
440
|
/** Send error message and old data*/
|
361
|
|
- /*Session::flash('status', 'danger');
|
|
441
|
+ Session::flash('status', 'danger');
|
362
|
442
|
Session::flash('message', 'This criterion is a duplicate of an already saved criterion because its name and associated program are the same.');
|
363
|
443
|
|
364
|
444
|
$role = Auth::user()['role'];
|
|
@@ -373,114 +453,146 @@ class CriteriaController extends \BaseController
|
373
|
453
|
return Redirect::to('program-criteria')->withInput();
|
374
|
454
|
}
|
375
|
455
|
}
|
376
|
|
-*/
|
377
|
|
- /** Instantiate new criterion */
|
378
|
|
- $criterion = new Criterion;
|
379
|
|
- $criterion->name = $clean_input['name'];
|
380
|
|
- $criterion->subcriteria = $clean_input['subcriteria'];
|
381
|
456
|
|
|
457
|
+ /** Instantiate new criterion */
|
|
458
|
+ $criterion = new Criterion;
|
|
459
|
+ $criterion->name = $clean_input['name'];
|
|
460
|
+ $criterion->subcriteria = $clean_input['subcriteria'];
|
382
|
461
|
|
383
|
|
- //gabriel añadió aqui
|
384
|
462
|
|
385
|
|
- $criterion->num_scales = sizeof($clean_input['scale_description']);
|
386
|
|
- $criterion->max_score = $clean_input['maximum_score'];
|
|
463
|
+ //gabriel añadió aqui
|
387
|
464
|
|
388
|
|
- if (Input::get('copyright'))
|
389
|
|
- $criterion->copyright = $clean_input['copyright'];
|
|
465
|
+ $criterion->num_scales = sizeof($clean_input['scale_description']);
|
|
466
|
+ $criterion->max_score = $clean_input['maximum_score'];
|
390
|
467
|
|
391
|
|
- if (Input::get('notes'))
|
392
|
|
- $criterion->notes = $clean_input['notes'];
|
|
468
|
+ if (Input::get('copyright'))
|
|
469
|
+ $criterion->copyright = $clean_input['copyright'];
|
393
|
470
|
|
|
471
|
+ if (Input::get('notes'))
|
|
472
|
+ $criterion->notes = $clean_input['notes'];
|
394
|
473
|
|
395
|
474
|
|
396
|
|
- /** If criterion is saved, send success message */
|
397
|
|
- if ($criterion->save()) {
|
398
|
475
|
|
399
|
|
- $criterionId = $criterion->id;
|
400
|
|
- $parentesis = array('(', ')');
|
|
476
|
+ /** If criterion is saved, send success message */
|
|
477
|
+ if ($criterion->save()) {
|
401
|
478
|
|
402
|
|
- foreach ($clean_input['objective_id'] as $objective_id) {
|
|
479
|
+ $criterionId = $criterion->id;
|
|
480
|
+ $parentesis = array('(', ')');
|
403
|
481
|
|
404
|
|
- $outcome_objective = str_replace($parentesis, '', $objective_id);
|
|
482
|
+ foreach ($clean_input['objective_id'] as $objective_id) {
|
405
|
483
|
|
406
|
|
- $outcome_objective = explode(',', $outcome_objective);
|
407
|
|
- DB::insert("insert into `criterion_objective_outcome` (`objective_id`, `outcome_id`, `criterion_id`) values ({$outcome_objective[1]},{$outcome_objective[0]}, {$criterionId})");
|
408
|
|
- }
|
|
484
|
+ $outcome_objective = str_replace($parentesis, '', $objective_id);
|
409
|
485
|
|
|
486
|
+ $outcome_objective = explode(',', $outcome_objective);
|
|
487
|
+ DB::insert("insert into `criterion_objective_outcome` (`objective_id`, `outcome_id`, `criterion_id`) values ({$outcome_objective[1]},{$outcome_objective[0]}, {$criterionId})");
|
|
488
|
+ }
|
410
|
489
|
|
411
|
|
- for ($i = 0; $i < sizeof($clean_input['scale_description']); $i++) {
|
412
|
490
|
|
413
|
|
- $existing_scale = DB::table('scales')->where('description', $clean_input['scale_description'][$i])
|
414
|
|
- ->first();
|
415
|
|
- if ($existing_scale) {
|
416
|
|
- DB::insert("insert into `criterion_scale` (`criterion_id`, `scale_id`, `position`) values({$criterionId},{$existing_scale->id},{$i})");
|
417
|
|
- } else {
|
418
|
|
- $scale = new Scale;
|
|
491
|
+ for ($i = 0; $i < sizeof($clean_input['scale_description']); $i++) {
|
419
|
492
|
|
420
|
|
- $position = $i;
|
421
|
|
- $scale->description = $clean_input['scale_description'][$i];
|
|
493
|
+ $existing_scale = DB::table('scales')->where('description', $clean_input['scale_description'][$i])
|
|
494
|
+ ->first();
|
|
495
|
+ if ($existing_scale) {
|
|
496
|
+ DB::insert("insert into `criterion_scale` (`criterion_id`, `scale_id`, `position`) values({$criterionId},{$existing_scale->id},{$i})");
|
|
497
|
+ } else {
|
|
498
|
+ $scale = new Scale;
|
422
|
499
|
|
|
500
|
+ $position = $i;
|
|
501
|
+ $scale->description = $clean_input['scale_description'][$i];
|
423
|
502
|
|
424
|
|
- if ($scale->save()) {
|
425
|
|
- DB::insert("insert into `criterion_scale` (`criterion_id`, `scale_id`, `position`) values({$criterionId},{$scale->id}, {$position})");
|
426
|
|
- } else {
|
427
|
|
- Session::flash('status', 'danger');
|
428
|
|
- Session::flash('message', '<p>Error creating the Scales</p>');
|
429
|
|
- $role = Auth::user()['role'];
|
430
|
|
- switch ($role) {
|
431
|
|
- case 1:
|
432
|
|
- return Redirect::to('criteria')->withInput();
|
433
|
|
-
|
434
|
|
- case 2:
|
435
|
|
- return Redirect::to('school-criteria')->withInput();
|
436
|
|
-
|
437
|
|
- case 3:
|
438
|
|
- return Redirect::to('program-criteria')->withInput();
|
|
503
|
+
|
|
504
|
+ if ($scale->save()) {
|
|
505
|
+ DB::insert("insert into `criterion_scale` (`criterion_id`, `scale_id`, `position`) values({$criterionId},{$scale->id}, {$position})");
|
|
506
|
+ } else {
|
|
507
|
+ Session::flash('status', 'danger');
|
|
508
|
+ Session::flash('message', '<p>Error creating the Scales</p>');
|
|
509
|
+ $role = Auth::user()['role'];
|
|
510
|
+ switch ($role) {
|
|
511
|
+ case 1:
|
|
512
|
+ return Redirect::to('criteria')->withInput();
|
|
513
|
+
|
|
514
|
+ case 2:
|
|
515
|
+ return Redirect::to('school-criteria')->withInput();
|
|
516
|
+
|
|
517
|
+ case 3:
|
|
518
|
+ return Redirect::to('program-criteria')->withInput();
|
|
519
|
+ }
|
439
|
520
|
}
|
440
|
521
|
}
|
441
|
522
|
}
|
442
|
|
- }
|
443
|
523
|
|
444
|
|
- foreach ($clean_input['program_id'] as $program_id) {
|
445
|
|
- DB::insert("insert into `program_criterion` (`criterion_id`, `program_id`) values({$criterionId},{$program_id})");
|
446
|
|
- }
|
|
524
|
+ /* $role = Auth::user()->role;
|
|
525
|
+ switch ($role) {
|
|
526
|
+ case 1:
|
|
527
|
+ $program_ids = DB::table('criterion_objective_outcome')
|
|
528
|
+ ->join('objective_program', 'criterion_objective_outcome.objective_id', '=', 'objective_program.program_id')
|
|
529
|
+ ->where('criterion_id', $criterionId)
|
|
530
|
+ ->select('program_id')
|
|
531
|
+ ->distinct()
|
|
532
|
+ ->lists('program_id');
|
|
533
|
+ break;
|
|
534
|
+ case 2:
|
|
535
|
+ $program_ids = DB::table('criterion_objective_outcome')
|
|
536
|
+ ->join('objective_program', 'criterion_objective_outcome.objective_id', '=', 'objective_program.program_id')
|
|
537
|
+ ->join('programs', 'programs.id', '=', 'objective_program.program_id')
|
|
538
|
+ ->where('criterion_id', $criterionId)
|
|
539
|
+ ->where('programs.school_id', Auth::user()->school_id)
|
|
540
|
+ ->select('program_id')
|
|
541
|
+ ->distinct()
|
|
542
|
+ ->lists('program_id');
|
447
|
543
|
|
448
|
|
- Session::flash('status', 'success');
|
449
|
|
- Session::flash('message', 'Criterion created: "' . $criterion->name . '".');
|
450
|
|
- $role = Auth::user()['role'];
|
451
|
|
- switch ($role) {
|
452
|
|
- case 1:
|
453
|
|
- return Redirect::to('criteria')->withInput();
|
|
544
|
+ break;
|
454
|
545
|
|
455
|
|
- case 2:
|
456
|
|
- return Redirect::to('school-criteria')->withInput();
|
|
546
|
+ case 3:
|
457
|
547
|
|
458
|
|
- case 3:
|
459
|
|
- return Redirect::to('program-criteria')->withInput();
|
|
548
|
+ $program_ids = DB::table('program_user')
|
|
549
|
+ ->where('user_id', Auth::user()->id)
|
|
550
|
+ ->lists('program_id');
|
|
551
|
+
|
|
552
|
+ break;
|
|
553
|
+ }*/
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+ foreach ($clean_input['program_id'] as $program_id) {
|
|
557
|
+ DB::insert("insert into `program_criterion` (`criterion_id`, `program_id`) values({$criterionId},{$program_id})");
|
|
558
|
+ }
|
|
559
|
+
|
|
560
|
+ Session::flash('status', 'success');
|
|
561
|
+ Session::flash('message', 'Criterion created: "' . $criterion->name . '".');
|
|
562
|
+ $role = Auth::user()['role'];
|
|
563
|
+ switch ($role) {
|
|
564
|
+ case 1:
|
|
565
|
+ return Redirect::to('criteria')->withInput();
|
|
566
|
+
|
|
567
|
+ case 2:
|
|
568
|
+ return Redirect::to('school-criteria')->withInput();
|
|
569
|
+
|
|
570
|
+ case 3:
|
|
571
|
+ return Redirect::to('program-criteria')->withInput();
|
|
572
|
+ }
|
460
|
573
|
}
|
461
|
|
- }
|
462
|
574
|
|
463
|
|
- /** If saving fails, send error message and old data */
|
464
|
|
- else {
|
465
|
|
- Session::flash('status', 'danger');
|
466
|
|
- Session::flash('message', '<p>Error creating Criterion. Please try again later.</p>');
|
467
|
|
- $role = Auth::user()['role'];
|
468
|
|
- switch ($role) {
|
469
|
|
- case 1:
|
470
|
|
- return Redirect::to('criteria')->withInput();
|
|
575
|
+ /** If saving fails, send error message and old data */
|
|
576
|
+ else {
|
|
577
|
+ Session::flash('status', 'danger');
|
|
578
|
+ Session::flash('message', '<p>Error creating Criterion. Please try again later.</p>');
|
|
579
|
+ $role = Auth::user()['role'];
|
|
580
|
+ switch ($role) {
|
|
581
|
+ case 1:
|
|
582
|
+ return Redirect::to('criteria')->withInput();
|
471
|
583
|
|
472
|
|
- case 2:
|
473
|
|
- return Redirect::to('school-criteria')->withInput();
|
|
584
|
+ case 2:
|
|
585
|
+ return Redirect::to('school-criteria')->withInput();
|
474
|
586
|
|
475
|
|
- case 3:
|
476
|
|
- return Redirect::to('program-criteria')->withInput();
|
|
587
|
+ case 3:
|
|
588
|
+ return Redirect::to('program-criteria')->withInput();
|
|
589
|
+ }
|
477
|
590
|
}
|
478
|
591
|
}
|
479
|
592
|
}
|
480
|
593
|
|
481
|
594
|
|
482
|
595
|
|
483
|
|
-
|
484
|
596
|
public function edit()
|
485
|
597
|
{
|
486
|
598
|
$title = "Criteria";
|
|
@@ -696,7 +808,36 @@ class CriteriaController extends \BaseController
|
696
|
808
|
}
|
697
|
809
|
}
|
698
|
810
|
}
|
699
|
|
- }
|
|
811
|
+ }/*
|
|
812
|
+ switch ($role) {
|
|
813
|
+ case 1:
|
|
814
|
+ $program_ids = DB::table('criterion_objective_outcome')
|
|
815
|
+ ->join('objective_program', 'criterion_objective_outcome.objective_id', '=', 'objective_program.program_id')
|
|
816
|
+ ->where('criterion_id', $criterionId)
|
|
817
|
+ ->select('program_id')
|
|
818
|
+ ->distinct()
|
|
819
|
+ ->lists('program_id');
|
|
820
|
+ break;
|
|
821
|
+ case 2:
|
|
822
|
+ $program_ids = DB::table('criterion_objective_outcome')
|
|
823
|
+ ->join('objective_program', 'criterion_objective_outcome.objective_id', '=', 'objective_program.program_id')
|
|
824
|
+ ->join('programs', 'programs.id', '=', 'objective_program.program_id')
|
|
825
|
+ ->where('criterion_id', $criterionId)
|
|
826
|
+ ->where('programs.school_id', Auth::user()->school_id)
|
|
827
|
+ ->select('program_id')
|
|
828
|
+ ->distinct()
|
|
829
|
+ ->lists('program_id');
|
|
830
|
+
|
|
831
|
+ break;
|
|
832
|
+
|
|
833
|
+ case 3:
|
|
834
|
+
|
|
835
|
+ $program_ids = DB::table('program_user')
|
|
836
|
+ ->where('user_id', Auth::user()->id)
|
|
837
|
+ ->lists('program_id');
|
|
838
|
+
|
|
839
|
+ break;
|
|
840
|
+ }*/
|
700
|
841
|
foreach ($clean_input['program_id'] as $program_id) {
|
701
|
842
|
DB::insert("insert into `program_criterion` (`criterion_id`, `program_id`) values({$criterionId},{$program_id})");
|
702
|
843
|
}
|