Kaynağa Gözat

New outcome mapping added

José Quiñones Flores 4 yıl önce
ebeveyn
işleme
ea9ab67d51

+ 32
- 7
app/controllers/ActivitiesController.php Dosyayı Görüntüle

@@ -1,5 +1,7 @@
1 1
 <?php
2 2
 
3
+use Illuminate\Database\Eloquent\Collection;
4
+
3 5
 class ActivitiesController extends \BaseController {
4 6
 
5 7
     /**
@@ -67,20 +69,43 @@ class ActivitiesController extends \BaseController {
67 69
         }
68 70
     }
69 71
 
70
-    public function newCreate($course = null)
72
+    public function newCreate($course_id = null)
71 73
     {
72 74
         $title = 'Create Activity';
73 75
         $activity_types = [];
74
-        $instruments = [];
76
+        $instruments = Rubric::all();
75 77
         $courses = Course::where('user_id', Auth::user()->id)->get();
76 78
         $outcomes = Outcome::with('objectives')->get();
77
-        $objectives = [];
78
-        $outcomes->each(function($outcome) {
79
-            $objectives[$outcome->id] = $outcome->objectives;
79
+//        var_dump($outcomes[0]->objectives);
80
+        $objectives_by_outcome = Collection::make([]);
81
+        $outcomes->each(function($outcome) use (&$objectives_by_outcome) {
82
+//            var_dump($outcome->objectives);
83
+            $objectives_by_outcome->put($outcome->id, $outcome->objectives);
84
+//            var_dump($objectives);
85
+        });
86
+        $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) {
89
+                $criteria_by_objective->put($objective->id, $objective->criteria);
90
+            });
80 91
         });
81 92
         $transforming_actions = [];
82
-//        var_dump($objectives['1']);
83
-        return View::make('local.managers.admins.new-activity-create', compact('title', 'activity_types', 'instruments', 'courses', 'outcomes', 'objectives', 'transforming_actions'));
93
+        $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',
97
+            compact(
98
+                'title',
99
+                'course',
100
+                'activity_types',
101
+                'instruments',
102
+                'courses',
103
+                'outcomes',
104
+                'objectives_by_outcome',
105
+                'criteria_by_objective',
106
+                'transforming_actions'
107
+            )
108
+        );
84 109
     }
85 110
 
86 111
     /**

+ 4
- 2
app/controllers/OutcomesController.php Dosyayı Görüntüle

@@ -17,15 +17,17 @@ class OutcomesController extends \BaseController {
17 17
 
18 18
         return View::make('local.managers.admins.learning-outcomes', compact('title', 'outcomes', 'schools'));
19 19
     }
20
+
20 21
     // TODO: Change to home page
21 22
     public function newIndex()
22 23
     {
23 24
         $title = "Learning Outcomes";
24
-        $outcomes = Outcome::withTrashed()->orderBy('name', 'ASC')->get();
25
+//        TODO: Check when semester doesnt exist or session is empty
26
+        $selected_semester = Semester::find(Session::get('semesters_ids')[0]);
27
+        $outcomes = Outcome::withTrashed()->where('deactivation_date', '>=', $selected_semester->start)->orWhere('deactivation_date', null)->orderBy('name', 'ASC')->get();
25 28
         $schools = School::orderBy('name', 'ASC')->get();
26 29
 
27 30
         return View::make('local.managers.admins.new-learning-outcomes', compact('title', 'outcomes', 'schools'));
28
-//        return View::make('local.managers.admins.learning-outcomes', compact('title', 'outcomes', 'schools'));
29 31
     }
30 32
 
31 33
     public function show($id)

+ 36
- 0
app/database/migrations/2020_05_15_123430_create_new_outcomes_table.php Dosyayı Görüntüle

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

+ 41
- 0
app/database/migrations/2020_05_15_123902_add_mapping_columns_to_outcomes_table.php Dosyayı Görüntüle

@@ -0,0 +1,41 @@
1
+<?php
2
+
3
+use Illuminate\Database\Migrations\Migration;
4
+use Illuminate\Database\Schema\Blueprint;
5
+
6
+class AddMappingColumnsToOutcomesTable 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->integer('new_outcome_id')->unsigned()->nullable();
18
+			$table->date('deactivation_date')->nullable();
19
+
20
+			$table->foreign('new_outcome_id')->references('id')->on('outcomes');
21
+		});
22
+	}
23
+
24
+
25
+	/**
26
+	 * Reverse the migrations.
27
+	 *
28
+	 * @return void
29
+	 */
30
+	public function down()
31
+	{
32
+		Schema::table('outcomes', function(Blueprint $table)
33
+		{
34
+			$table->dropForeign(['new_outcome_id']);
35
+
36
+			$table->dropColumn('deactivation_date');
37
+			$table->dropColumn('new_outcome_id');
38
+		});
39
+	}
40
+
41
+}

+ 5
- 0
app/models/Objective.php Dosyayı Görüntüle

@@ -25,6 +25,11 @@ class Objective extends Eloquent
25 25
   	return $this->belongsToMany('Outcome', 'objective_outcome', 'objective_id', 'outcome_id');
26 26
   }
27 27
 
28
+  public function outcome()
29
+  {
30
+      return $this->belongsTo('Outcome');
31
+  }
32
+
28 33
     /**
29 34
      * Return the program that the objective belongs to
30 35
      *

+ 85
- 44
app/views/local/managers/admins/new-activity-create.blade.php Dosyayı Görüntüle

@@ -5,6 +5,36 @@
5 5
 @stop
6 6
 @section('main')
7 7
 
8
+    <!-- New Rubric Modal -->
9
+    <div class="modal fade" id="newRubricModal" tabindex="-1" role="dialog" aria-labelledby="newRubricModalLabel" aria-hidden="true">
10
+        <div class="modal-dialog modal-sm">
11
+            <div class="modal-content">
12
+                <div class="modal-header">
13
+                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
14
+                    <h4 class="modal-title" id="newRubricModalLabel">New Instrument</h4>
15
+                </div>
16
+                <div class="modal-body">
17
+                    {{ Form::open(array('action' => array('RubricsController@create'))) }}
18
+                    <div class="form-group">
19
+                        {{ Form::label('name', 'Name') }}
20
+                        {{ Form::text('name', Input::old('name'), array('class' => 'form-control')) }}
21
+                    </div>
22
+                    <div class="form-group">
23
+                        {{ Form::label('criteria', 'Criteria') }}
24
+                        <select id="criteria" name="criteria" class="form-control" multiple required>
25
+                        </select>
26
+                        {{ Form::textarea('criteria', Input::old('description'), array('class' => 'form-control', 'rows'=> 5, 'placeholder'=>'Minimum 10 characters')) }}
27
+                    </div>
28
+                    <div class="btn-group" role="group">
29
+                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
30
+                        <button type="submit" class="btn btn-default btn-primary">Submit</button>
31
+                    </div>
32
+                    {{ Form::close() }}
33
+                </div>
34
+            </div>
35
+        </div>
36
+    </div>
37
+
8 38
     <div class="row">
9 39
         <div class="col-md-12">
10 40
             <div class="panel panel-default panel-button">
@@ -12,10 +42,7 @@
12 42
                     Create new activity
13 43
                 </div>
14 44
                 <div class="panel-body">
15
-
16
-
17
-                    {{ Form::open(array('action' => 'CoursesController@update')) }}
18
-
45
+                    {{ Form::open(array('action' => 'ActivitiesController@update')) }}
19 46
                     <div class="form-group">
20 47
                         {{ Form::label('activity_type', 'Activity Type') }}
21 48
                         <select id="activity_type" name="activity_type" class="form-control">
@@ -30,25 +57,13 @@
30 57
 {{--                        {{ Form::text('activity_type', Input::old('activity_Type'), array('class' => 'form-control', 'placeholder'=>'TEST', 'maxLength'=>5)) }}--}}
31 58
                     </div>
32 59
                     
33
-                    <div class="form-group">
34
-                        {{ Form::label('instrument', 'Instrument') }}
35
-                        <select id="instrument" name="instrument" class="form-control">
36
-                            @foreach ($instruments as $instrument)
37
-                                {{--                                @if(Input::old('instrument')!=$instrument)--}}
38
-                                {{--                                    <option value="{{ $instrument }}">{{ $instrument }} ({{ $program->school->name }})</option>--}}
39
-                                {{--                                @else--}}
40
-                                {{--                                    <option selected value="{{ $program->id }}">{{ $program->name }} ({{ $program->school->name }})</option>--}}
41
-                                {{--                                @endif--}}
42
-                            @endforeach
43
-                        </select>
44
-                        {{--                        {{ Form::text('instrument', Input::old('instrument'), array('class' => 'form-control', 'placeholder'=>'TEST', 'maxLength'=>5)) }}--}}
45
-                    </div>
60
+
46 61
                     <div class="form-group">
47 62
                         {{ Form::label('outcome', 'Learning Outcome') }}
48 63
                         <select id="outcome" name="outcome" class="form-control">
49 64
                             @foreach ($outcomes as $outcome)
50 65
                                 @if(Input::old('outcome')!=$outcome->id)
51
-                                    <option value="{{ $outcome->id }}">{{ $outcome->name }})</option>
66
+                                    <option value="{{ $outcome->id }}">{{ $outcome->name }}</option>
52 67
                                 @else
53 68
                                     <option selected value="{{ $outcome->id }}">{{ $outcome->name }}</option>
54 69
                                 @endif
@@ -57,17 +72,38 @@
57 72
                     </div>
58 73
                     <div class="form-group">
59 74
                         {{ Form::label('objective', 'Learning Objective') }}
60
-                        <select id="objective" name="objective[]" class="form-control" multiple>
61
-                            @foreach ($objectives as $objective)
62
-                                @if(Input::old('objective')!=$objective->id)
63
-                                    <option value="{{ $objective->id }}">{{ $objective->name }}</option>
75
+                        <select id="objective" name="objective[]" class="form-control" multiple required>
76
+                            @if(Input::old('outcome')!=null)
77
+                                @foreach ($objectives_by_outcome[Input::old('outcome')] as $objective)
78
+                                    @if(Input::old('objective')!=$objective->id)
79
+                                        <option value="{{ $objective->id }}">{{ $objective->text }}</option>
80
+                                    @else
81
+                                        <option selected value="{{ $objective->id }}">{{ $objective->text }}</option>
82
+                                    @endif
83
+                                @endforeach
84
+                            @else
85
+                                @foreach ($objectives_by_outcome[$outcomes->first()->id] as $objective)
86
+                                    <option value="{{ $objective->id }}">{{ $objective->text }}</option>
87
+                                @endforeach
88
+                            @endif
89
+                        </select>
90
+                    </div>
91
+                    <div class="form-group">
92
+                        {{ Form::label('instrument', 'Instrument') }}
93
+                        <select id="instrument" name="instrument" class="form-control">
94
+                            @foreach ($instruments as $instrument)
95
+                                @if(Input::old('instrument')!=$instrument->id)
96
+                                    <option value="{{ $instrument->id }}">{{ $instrument->name }}</option>
64 97
                                 @else
65
-                                    <option selected value="{{ $objective->id }}">{{ $objective->name }}</option>
98
+                                    <option selected value="{{ $instrument->id }}">{{ $instrument->name }}</option>
66 99
                                 @endif
67 100
                             @endforeach
68 101
                         </select>
69 102
                     </div>
70 103
                     <div class="form-group">
104
+                        <button type="button" data-toggle="modal" data-target="#newRubricModal" class="btn btn-sm btn-default">New Instrument</button>
105
+                    </div>
106
+                    <div class="form-group">
71 107
                         {{ Form::label('transforming_action', 'Transforming Actions') }}
72 108
                         <select id="transforming_action" name="transforming_action[]" class="form-control" multiple>
73 109
                             @foreach ($transforming_actions as $transforming_action)
@@ -84,24 +120,6 @@
84 120
 
85 121
                     {{ Form::submit('Submit', array('class' => 'btn btn-primary btn-block', 'name'=>'create_activity')) }}
86 122
                     {{ Form::close() }}
87
-
88
-                    <br>
89
-
90
-                    @if(Session::has('courses'))
91
-                        <p><strong>The following courses were updated:</strong></p>
92
-                        <ul>
93
-                            @foreach(json_decode(Session::get('courses')) as $course)
94
-                                <li>
95
-
96
-                                    @if(Session::has('show_sections'))
97
-                                        {{ $course->code }}{{ $course->number }}-{{ $course->section }}
98
-                                    @else
99
-                                        {{ $course->code }}{{ $course->number }}
100
-                                    @endif
101
-                                </li>
102
-                            @endforeach
103
-                        </ul>
104
-                    @endif
105 123
                 </div>
106 124
             </div>
107 125
         </div>
@@ -115,16 +133,39 @@
115 133
     // --------------------------------------------------------------------------
116 134
     // Page load
117 135
     // --------------------------------------------------------------------------
118
-
136
+    const objectives = {{ $objectives_by_outcome->toJson() }};
137
+    const criteria = {{ $criteria_by_objective->toJson() }};
138
+    const outcomesSelect = document.getElementById('outcome');
139
+    const objectivesSelect = document.getElementById('objective');
140
+    const criteriaSelect = document.getElementById('criteria');
119 141
 
120 142
     // --------------------------------------------------------------------------
121 143
     // Functions
122 144
     // --------------------------------------------------------------------------
123 145
 
124
-
125
-
126 146
     // --------------------------------------------------------------------------
127 147
     // Events
128 148
     // --------------------------------------------------------------------------
149
+    outcomesSelect.addEventListener('change', (event) => {
150
+        var objectivesSelectOptions = [];
151
+        objectives[event.target.value].forEach((objective) => {
152
+            objectivesSelectOptions.push(`<option value="${objective.id}">${objective.text}</option>`);
153
+        });
154
+        objectivesSelect.innerHTML = objectivesSelectOptions.join();
155
+    });
156
+
157
+    objectivesSelect.addEventListener('change', (event) => {
158
+        var criteriaSelectOptions = [];
159
+        var selectedObjectives = Array.from(objectivesSelect.selectedOptions).map(v => value);
160
+        selectedObjectives.forEach((objectiveId) => {
161
+            criteria[objectiveId].forEach((criteriaArray) => {
162
+                criteriaArray.forEach((criteria) => {
163
+                    criteriaSelectOptions.push(`<option value="${criteria.id}">${criteria.name}</option>`);
164
+                });
165
+            });
166
+        });
167
+        criteriaSelect.innerHTML = criteriaSelectOptions.join();
168
+    });
169
+
129 170
 
130 171
 @stop

+ 1
- 29
app/views/local/managers/admins/new-course-show.blade.php Dosyayı Görüntüle

@@ -28,7 +28,7 @@
28 28
             @if(!$activities->isEmpty())
29 29
 
30 30
                 @if ($is_active_semester)
31
-                    <button data-toggle="modal" data-target="#newActivityModal" class="btn btn-sm btn-default pull-right"> New Activity</button>
31
+                    <a href="{{ URL::action('ActivitiesController@newCreate', ['course_id' => $course->id]) }}" class="btn btn-sm btn-default pull-right">New Activity</a>
32 32
                 @endif
33 33
 
34 34
                 <table class="table table-striped table-condensed">
@@ -89,34 +89,6 @@
89 89
 @stop
90 90
 
91 91
 @section('included-js')
92
-
93
-    <!-- New Activity Modal -->
94
-    <div class="modal fade" id="newActivityModal" tabindex="-1" role="dialog" aria-labelledby="newActivityModalLabel" aria-hidden="true">
95
-        <div class="modal-dialog modal-sm">
96
-            <div class="modal-content">
97
-                <div class="modal-header">
98
-                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
99
-                    <h4 class="modal-title" id="newActivityModalLabel">New Activity</h4>
100
-                </div>
101
-                <div class="modal-body">
102
-                    {{ Form::open(array('action' => array('ActivitiesController@create', $course->id))) }}
103
-                    <div class="form-group">
104
-                        {{ Form::label('name', 'Name') }}
105
-                        {{ Form::text('name', Input::old('name'), array('class' => 'form-control')) }}
106
-                    </div>
107
-                    <div class="form-group">
108
-                        {{ Form::label('description', 'Description') }}
109
-                        {{ Form::textarea('description', Input::old('description'), array('class' => 'form-control', 'rows'=> 5, 'placeholder'=>'Minimum 10 characters')) }}
110
-                    </div>
111
-                    <div class="btn-group" role="group">
112
-                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
113
-                        <button type="submit" class="btn btn-default btn-primary">Submit</button>
114
-                    </div>
115
-                    {{ Form::close() }}
116
-                </div>
117
-            </div>
118
-        </div>
119
-    </div>
120 92
     <!-- HighCharts -->
121 93
     <script src="{{ asset('vendor/highcharts/highcharts.js') }}"></script>
122 94
     <!--script src="http://code.highcharts.com/modules/exporting.js"></script -->