Ver código fonte

New pages for activities and courses

José Quiñones Flores 4 anos atrás
pai
commit
5124c66cb3

+ 16
- 0
app/controllers/ActivitiesController.php Ver arquivo

@@ -67,6 +67,22 @@ class ActivitiesController extends \BaseController {
67 67
         }
68 68
     }
69 69
 
70
+    public function newCreate($course = null)
71
+    {
72
+        $title = 'Create Activity';
73
+        $activity_types = [];
74
+        $instruments = [];
75
+        $courses = Course::where('user_id', Auth::user()->id)->get();
76
+        $outcomes = Outcome::with('objectives')->get();
77
+        $objectives = [];
78
+        $outcomes->each(function($outcome) {
79
+            $objectives[$outcome->id] = $outcome->objectives;
80
+        });
81
+        $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'));
84
+    }
85
+
70 86
     /**
71 87
      *
72 88
      */

+ 17
- 1
app/controllers/CoursesController.php Ver arquivo

@@ -1,6 +1,7 @@
1 1
 <?php
2 2
 
3
-class CoursesController extends \BaseController {
3
+class
4
+CoursesController extends \BaseController {
4 5
 
5 6
 	/**
6 7
 	 * Display the specified resource.
@@ -40,7 +41,22 @@ class CoursesController extends \BaseController {
40 41
 		return View::make('local.professors.course', compact('title', 'course', 'activities', 'students', 'outcomes', 'outcomes_achieved', 'outcomes_attempted', 'active_semesters'));
41 42
 	}
42 43
 
44
+	public function newShow($id)
45
+    {
46
+        $course = Course::findOrFail($id);
47
+        $title = $course->name;
48
+        $semesters = Semester::where('is_visible', '1')->orderBy('start', 'asc')->get();
49
+        $is_active_semester = $semesters->filter(function($semester) {
50
+            return Semester::where('is_visible', 1)->where('start', '<=', date('Y-m-d H:i:s'))->where('end', '>=', date('Y-m-d H:i:s'))->get()->has($semester->id);
51
+        });
52
+//        $active_semesters = 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()->toArray()[0];
53
+        $activities = $course->activities;
43 54
 
55
+//        var_dump($active_semesters);
56
+//        var_dump($course->semester->id);
57
+
58
+        return View::make('local.managers.admins.new-course-show', compact('title','course', 'semesters', 'activities', 'is_active_semester'));
59
+    }
44 60
 
45 61
 	/**
46 62
 	 * Display the specified course, but with limited information.

+ 35
- 40
app/controllers/OutcomesController.php Ver arquivo

@@ -1,5 +1,7 @@
1 1
 <?php
2 2
 
3
+use Illuminate\Database\Eloquent\Collection;
4
+
3 5
 class OutcomesController extends \BaseController {
4 6
 
5 7
 
@@ -158,48 +160,41 @@ class OutcomesController extends \BaseController {
158 160
     public function newShow($id)
159 161
     {
160 162
 //        DB::disableQueryLog();
161
-        $outcome = Outcome::find($id);
162
-        $title = $outcome->name;
163
-        $objectives = $outcome->objectives;
164
-        $criteria = $outcome->criteria;
165
-        $programs = $objectives->map(function ($objective) { return $objective->program; })
166
-            ->merge($criteria->map(function ($criteria) { return $criteria->program; }))
167
-            ->filter(function ($program) { return $program->users->contains(Auth::user()); });
168
-        $courses = $programs->reduce(function ($carry, $program) {
169
-            return $carry->merge($program->courses);
170
-        }, new \Illuminate\Database\Eloquent\Collection);
171
-        $activities = $programs->reduce(function ($carry, $course) {
172
-            return $carry->merge(Activity::where('course_id', '=', $course->id)->get());
173
-        }, new \Illuminate\Database\Eloquent\Collection);
174
-
175
-        $report_link = URL::action('OutcomesController@newReport', ['id' => $outcome->id]);
176
-
177
-        return View::make('local.managers.admins.new-learning-outcome', compact('title', 'outcome', 'courses', 'activities', 'report_link'));
178
-    }
179
-    public function newShowAll()
180
-    {
181
-//        DB::disableQueryLog();
182
-        $title = 'All Domains';
183
-        $outcome = Outcome::with('objectives', 'criteria')->get();
184
-        $objectives = $outcome->reduce(function ($carry, $outcome) {
185
-            return $carry->merge($outcome->objectives);
186
-        }, new \Illuminate\Database\Eloquent\Collection);
187
-        $criteria = $outcome->reduce(function ($carry, $outcome) {
188
-            return $carry->merge($outcome->criteria);
189
-        }, new \Illuminate\Database\Eloquent\Collection);
190
-        $programs = $objectives->map(function ($objective) { return $objective->program; })
191
-            ->merge($criteria->map(function ($criteria) { return $criteria->program; }))
192
-            ->filter(function ($program) { return $program->users->contains(Auth::user()); });
193
-
194
-        $courses = $programs->reduce(function ($carry, $program) {
195
-            return $carry->merge($program->courses);
196
-        }, new \Illuminate\Database\Eloquent\Collection);
197
-        $activities = $programs->reduce(function ($carry, $course) {
198
-            return $carry->merge(Activity::where('course_id', '=', $course->id)->get());
199
-        }, new \Illuminate\Database\Eloquent\Collection);
163
+//        $outcome = null;
164
+        if ($id === 'all') {
165
+            $outcome = Outcome::with('objectives.criteria')->get();
166
+            $title = 'All Outcomes';
167
+            $criteria = $outcome->reduce(function($carry, $outcome) {
168
+                return $carry->merge($outcome->criteria);
169
+            }, Collection::make([]));
170
+            $report_link = URL::action('OutcomesController@newReportAll');
171
+        } else {
172
+            $outcome = Outcome::with(['objectives.criteria'])->find($id);
173
+            $title = $outcome->name;
174
+            $criteria = $outcome->criteria->load('rubrics');
175
+            $report_link = URL::action('OutcomesController@newReport', ['id' => $outcome->id]);
176
+        }
200 177
 
201
-        $report_link = URL::action('OutcomesController@newReportAll');
178
+//        $objectives = $outcome->objectives;
179
+//        var_dump(get_class_methods($criteria));
180
+//        var_dump($criteria);
181
+        $rubrics = $criteria->reduce(function($carry, $crit) {
182
+            return $carry->merge($crit->rubrics);
183
+        }, Collection::make([]))->load('activities');
184
+        $activities = $rubrics->reduce(function($carry, $rubric) {
185
+            return $carry->merge($rubric->activities);
186
+        }, Collection::make([]));
187
+        $courses = $activities->reduce(function($carry, $activity) {
188
+            if ($activity->course !== null) {
189
+                $carry->push($activity->course);
190
+            }
191
+            return $carry;
192
+        }, Collection::make([]));
193
+        $activities = $activities->filter(function($activity) {
194
+            return ($activity->course === null);
195
+        });
202 196
 
197
+//        var_dump(DB::getQueryLog());
203 198
         return View::make('local.managers.admins.new-learning-outcome', compact('title', 'outcome', 'courses', 'activities', 'report_link'));
204 199
     }
205 200
 

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

@@ -20,11 +20,17 @@ class Course extends Eloquent
20 20
     return $this->belongsTo('User')->orderBy('surnames', 'asc')->orderBy('first_name', 'asc');
21 21
   }
22 22
 
23
+  // TODO: Remove
23 24
   public function activities()
24 25
   {
25 26
     return $this->hasMany('Activity')->orderBy('date', 'asc');
26 27
   }
27 28
 
29
+  public function activity()
30
+  {
31
+      return $this->belongsTo('Activity');
32
+  }
33
+
28 34
   public function assessedActivities()
29 35
   {
30 36
     return $this->hasMany('Activity')->whereNotNull('activities.outcomes_attempted')->orderBy('date', 'asc');

+ 20
- 7
app/models/Criterion.php Ver arquivo

@@ -4,15 +4,28 @@ use Illuminate\Database\Eloquent\SoftDeletingTrait;
4 4
 
5 5
 class Criterion extends Eloquent
6 6
 {
7
-	use SoftDeletingTrait;
8
-	protected $dates = ['deleted_at'];
7
+    use SoftDeletingTrait;
8
+    protected $dates = ['deleted_at'];
9 9
 
10
-	protected $table = 'criteria';
10
+    protected $table = 'new_criteria';
11 11
 
12
-	public function outcomes()
13
-	{
14
-		return $this->belongs('Outcome');
15
-	}
12
+    public function outcomes()
13
+    {
14
+//	    return $this->belongs('Objective')->belongs('Outcome');
15
+//	    TODO: Changes here
16
+//		return $this->belongs('Outcome');
17
+        return $this->hasManyThrough('Outcome', 'Objective');
18
+    }
19
+
20
+    public function objectives()
21
+    {
22
+        return $this->belongsToMany('Objective');
23
+    }
24
+
25
+    public function rubrics()
26
+    {
27
+        return $this->belongsToMany('Rubric', 'new_criterion_rubric');
28
+    }
16 29
 
17 30
 	/**
18 31
 	 * Return the program that the criterion belongs to

+ 10
- 0
app/models/Objective.php Ver arquivo

@@ -25,4 +25,14 @@ class Objective extends Eloquent
25 25
   	return $this->belongsToMany('Outcome', 'objective_outcome', 'objective_id', 'outcome_id');
26 26
   }
27 27
 
28
+    /**
29
+     * Return the program that the objective belongs to
30
+     *
31
+     * @return Illuminate\Database\Eloquent\Model
32
+     */
33
+    public function criteria()
34
+    {
35
+        return $this->hasMany('Criterion');
36
+    }
37
+
28 38
 }

+ 3
- 2
app/models/Outcome.php Ver arquivo

@@ -11,7 +11,7 @@ class Outcome extends Eloquent
11 11
 
12 12
 	public function criteria()
13 13
 	{
14
-	   return $this->hasMany('Criterion')->orderBy('name');
14
+	   return $this->hasManyThrough('Criterion', 'Objective')->orderBy('name');
15 15
 	}
16 16
 
17 17
 	/**
@@ -21,6 +21,7 @@ class Outcome extends Eloquent
21 21
 	 */
22 22
 	public function objectives()
23 23
 	{
24
-		return $this->belongsToMany('Objective', 'objective_outcome');
24
+	    return $this->hasMany('Objective');
25
+//		return $this->belongsToMany('Objective', 'objective_outcome');
25 26
 	}
26 27
 }

+ 1
- 4
app/models/Rubric.php Ver arquivo

@@ -19,12 +19,9 @@ class Rubric extends Eloquent
19 19
     return $this->belongsTo('User')->orderBy('created_at');
20 20
   }
21 21
 
22
-  /*
23
-   * TODO Check if this is true later.
24
-  */
25 22
   public function activities()
26 23
   {
27
-    return $this->hasMany('Activity');
24
+    return $this->belongsToMany('Activity', 'new_rubric_activity');
28 25
   }
29 26
 
30 27
   public function getCriterion($id, $criterion_id)

+ 2
- 3
app/routes.php Ver arquivo

@@ -275,7 +275,7 @@ Route::group(array('before' => 'auth|has_access'), function()
275 275
         Route::get('courses/reassign', 'CoursesController@reassign');
276 276
         Route::post('courses/update', array('before' => 'csrf', 'uses'=>'CoursesController@update'));
277 277
 
278
-
278
+        Route::get('activities/create', 'ActivitiesController@newCreate');
279 279
 
280 280
     });
281 281
 
@@ -355,10 +355,9 @@ Route::group(array('before' => 'auth|has_access'), function()
355 355
         Route::get('learning-outcomes/show/{id}', 'OutcomesController@show');
356 356
         // TODO: Change route name
357 357
         Route::get('learning-outcomes/newshow/{id}', 'OutcomesController@newShow');
358
-        Route::get('learning-outcomes/newshowall', 'OutcomesController@newShowAll');
359 358
         Route::get('new-report/{id}', 'OutcomesController@newReport');
360 359
         Route::get('new-report-all', 'OutcomesController@newReportAll');
361
-
360
+        Route::get('courses/{id}', 'CoursesController@newShow');
362 361
     });
363 362
 
364 363
 

+ 130
- 0
app/views/local/managers/admins/new-activity-create.blade.php Ver arquivo

@@ -0,0 +1,130 @@
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-12">
10
+            <div class="panel panel-default panel-button">
11
+                <div class="panel-heading">
12
+                    Create new activity
13
+                </div>
14
+                <div class="panel-body">
15
+
16
+
17
+                    {{ Form::open(array('action' => 'CoursesController@update')) }}
18
+
19
+                    <div class="form-group">
20
+                        {{ Form::label('activity_type', 'Activity Type') }}
21
+                        <select id="activity_type" name="activity_type" class="form-control">
22
+                            @foreach ($activity_types as $activity_type)
23
+{{--                                @if(Input::old('activity_type')!=$activity_type)--}}
24
+{{--                                    <option value="{{ $activity_type }}">{{ $activity_type }} ({{ $program->school->name }})</option>--}}
25
+{{--                                @else--}}
26
+{{--                                    <option selected value="{{ $program->id }}">{{ $program->name }} ({{ $program->school->name }})</option>--}}
27
+{{--                                @endif--}}
28
+                            @endforeach
29
+                        </select>
30
+{{--                        {{ Form::text('activity_type', Input::old('activity_Type'), array('class' => 'form-control', 'placeholder'=>'TEST', 'maxLength'=>5)) }}--}}
31
+                    </div>
32
+                    
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>
46
+                    <div class="form-group">
47
+                        {{ Form::label('outcome', 'Learning Outcome') }}
48
+                        <select id="outcome" name="outcome" class="form-control">
49
+                            @foreach ($outcomes as $outcome)
50
+                                @if(Input::old('outcome')!=$outcome->id)
51
+                                    <option value="{{ $outcome->id }}">{{ $outcome->name }})</option>
52
+                                @else
53
+                                    <option selected value="{{ $outcome->id }}">{{ $outcome->name }}</option>
54
+                                @endif
55
+                            @endforeach
56
+                        </select>
57
+                    </div>
58
+                    <div class="form-group">
59
+                        {{ 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>
64
+                                @else
65
+                                    <option selected value="{{ $objective->id }}">{{ $objective->name }}</option>
66
+                                @endif
67
+                            @endforeach
68
+                        </select>
69
+                    </div>
70
+                    <div class="form-group">
71
+                        {{ Form::label('transforming_action', 'Transforming Actions') }}
72
+                        <select id="transforming_action" name="transforming_action[]" class="form-control" multiple>
73
+                            @foreach ($transforming_actions as $transforming_action)
74
+{{--                                @if(Input::old('transforming_action')!=$transforming_action->id)--}}
75
+{{--                                    <option value="{{ $transforming_action->id }}">{{ $transforming_action->name }}</option>--}}
76
+{{--                                @else--}}
77
+{{--                                    <option selected value="{{ $transforming_action->id }}">{{ $transforming_action->name }}</option>--}}
78
+{{--                                @endif--}}
79
+                            @endforeach
80
+                        </select>
81
+                    </div>
82
+
83
+                    <br>
84
+
85
+                    {{ Form::submit('Submit', array('class' => 'btn btn-primary btn-block', 'name'=>'create_activity')) }}
86
+                    {{ 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
+                </div>
106
+            </div>
107
+        </div>
108
+
109
+
110
+    </div>
111
+@stop
112
+
113
+@section('javascript')
114
+
115
+    // --------------------------------------------------------------------------
116
+    // Page load
117
+    // --------------------------------------------------------------------------
118
+
119
+
120
+    // --------------------------------------------------------------------------
121
+    // Functions
122
+    // --------------------------------------------------------------------------
123
+
124
+
125
+
126
+    // --------------------------------------------------------------------------
127
+    // Events
128
+    // --------------------------------------------------------------------------
129
+
130
+@stop

+ 103
- 0
app/views/local/managers/admins/new-course-show.blade.php Ver arquivo

@@ -0,0 +1,103 @@
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
+    @else
11
+        @include('local.professors._navigation')
12
+    @endif
13
+@stop
14
+
15
+@section('main')
16
+
17
+    <div class="row">
18
+        <div class="col-md-12">
19
+            <p>{{$course->name}}</p>
20
+        </div>
21
+    </div>
22
+
23
+
24
+    <div class="row">
25
+        <div class="col-md-12">
26
+            <h3>Activities</h3>
27
+
28
+            @if(!$activities->isEmpty())
29
+
30
+                @if ($is_active_semester)
31
+                    <button data-toggle="modal" data-target="#newActivityModal" class="btn btn-sm btn-default pull-right"> New Activity</button>
32
+                @endif
33
+
34
+                <table class="table table-striped table-condensed">
35
+                    <thead>
36
+                    <tr>
37
+                        <th>Name</th>
38
+                        <th>Date</th>
39
+                        <th>Updated</th>
40
+                        <th>Assessed</th>
41
+                        <th>Published</th>
42
+                    </tr>
43
+                    </thead>
44
+                    <tbody>
45
+                    @foreach ($activities as $activity)
46
+                        <tr>
47
+                            <td>{{ link_to_action('ActivitiesController@show', $activity->name, $parameters = array('id'=>$activity->id)) }}</td>
48
+                            <td>{{ date('M d, Y', strtotime($activity->date)) }}</td>
49
+                            <td>{{ date('M d, Y', strtotime($activity->updated_at)) }}</td>
50
+                            <td>
51
+                                @if($activity->outcomes_attempted!=NULL)
52
+                                    <span class="glyphicon glyphicon-ok"></span>
53
+                                @endif
54
+                            </td>
55
+                            <td>
56
+                                @if($activity->outcomes_attempted!=NULL && !$activity->draft)
57
+                                    <span class="glyphicon glyphicon-ok"></span>
58
+                                @endif
59
+                            </td>
60
+                        </tr>
61
+                    @endforeach
62
+
63
+                    @if (!$is_active_semester)
64
+                        <tr>
65
+                            <td colspan="3"><div class="alert alert-info">The semester for this course is inactive. You cannot create any more activities.</div></td>
66
+                        </tr>
67
+                    @endif
68
+                    </tbody>
69
+                </table>
70
+
71
+                <p>Unplublished activity results are <strong>not considered</strong> in the graph above.</p>
72
+
73
+            @else
74
+                <div class="alert alert-info">
75
+                    @if($is_active_semester)
76
+                        <p>
77
+                            No activities.
78
+                            <a data-toggle="modal" data-target="#newActivityModal">
79
+                                Create one.
80
+                            </a>
81
+                        </p>
82
+                    @else
83
+                        <p>The semester for this course is inactive. You cannot create any activities.</p>
84
+                    @endif
85
+                </div>
86
+            @endif
87
+        </div>
88
+    </div>
89
+@stop
90
+
91
+@section('included-js')
92
+
93
+    <!-- HighCharts -->
94
+    <script src="{{ asset('vendor/highcharts/highcharts.js') }}"></script>
95
+    <!--script src="http://code.highcharts.com/modules/exporting.js"></script -->
96
+
97
+@stop
98
+
99
+@section('javascript')
100
+
101
+
102
+@stop
103
+

+ 1
- 1
app/views/local/managers/admins/new-learning-outcome.blade.php Ver arquivo

@@ -24,7 +24,7 @@
24 24
         @foreach($courses as $course)
25 25
             <div class="col-md-2">
26 26
 {{--                TODO: Add href --}}
27
-                <a href="" style="text-decoration: none">
27
+                <a href="{{ URL::action('CoursesController@newShow', ['id' => $course->id]) }}" style="text-decoration: none">
28 28
                     <div class="panel panel-default" style="height: 10rem">
29 29
                         <div class="panel-heading">
30 30
                             <h5 class="panel-title">{{ $course->code }}</h5>

+ 1
- 1
app/views/local/managers/admins/new-learning-outcomes.blade.php Ver arquivo

@@ -14,7 +14,7 @@
14 14
 
15 15
     <div class="row">
16 16
         <div class="col-md-6">
17
-            <a href="{{ URL::action('OutcomesController@newShowAll') }}" class="btn btn-lg btn-default">Show all domains</a>
17
+            <a href="{{ URL::action('OutcomesController@newShow', ['id' => 'all']) }}" class="btn btn-lg btn-default">Show courses and activities for all domains</a>
18 18
         </div>
19 19
     </div>
20 20
     <br>