ソースを参照

Added Laravel project and removed sensitive data

コミット
4564da0130
共有100 個のファイルを変更した9201 個の追加0 個の削除を含む
  1. 3
    0
      .bowerrc
  2. 3
    0
      CONTRIBUTING.md
  3. 106
    0
      Gruntfile.js
  4. 0
    0
      app/commands/.gitkeep
  5. 201
    0
      app/config/app.php
  6. 71
    0
      app/config/auth.php
  7. 89
    0
      app/config/cache.php
  8. 18
    0
      app/config/compile.php
  9. 97
    0
      app/config/database.php
  10. 124
    0
      app/config/mail.php
  11. 0
    0
      app/config/packages/.gitkeep
  12. 85
    0
      app/config/queue.php
  13. 59
    0
      app/config/remote.php
  14. 31
    0
      app/config/services.php
  15. 140
    0
      app/config/session.php
  16. 20
    0
      app/config/testing/cache.php
  17. 21
    0
      app/config/testing/session.php
  18. 31
    0
      app/config/view.php
  19. 31
    0
      app/config/workbench.php
  20. 0
    0
      app/controllers/.gitkeep
  21. 763
    0
      app/controllers/ActivitiesController.php
  22. 207
    0
      app/controllers/AdministratorsController.php
  23. 112
    0
      app/controllers/AnnualPlansController.php
  24. 184
    0
      app/controllers/AuthController.php
  25. 18
    0
      app/controllers/BaseController.php
  26. 10
    0
      app/controllers/Controller.php
  27. 470
    0
      app/controllers/CoursesController.php
  28. 397
    0
      app/controllers/CriteriaController.php
  29. 93
    0
      app/controllers/FeedbackController.php
  30. 568
    0
      app/controllers/FiveYearPlansController.php
  31. 112
    0
      app/controllers/HomeController.php
  32. 237
    0
      app/controllers/ObjectivesController.php
  33. 547
    0
      app/controllers/OutcomesController.php
  34. 122
    0
      app/controllers/ProfessorsController.php
  35. 109
    0
      app/controllers/ProgramCoordinatorsController.php
  36. 156
    0
      app/controllers/ProgramsController.php
  37. 316
    0
      app/controllers/RubricsController.php
  38. 287
    0
      app/controllers/SchoolCoordinatorsController.php
  39. 409
    0
      app/controllers/SchoolsController.php
  40. 82
    0
      app/controllers/SectionsController.php
  41. 101
    0
      app/controllers/SemestersController.php
  42. 138
    0
      app/controllers/StudentsController.php
  43. 248
    0
      app/controllers/TemplatesController.php
  44. 416
    0
      app/controllers/UsersController.php
  45. 1
    0
      app/database/.gitignore
  46. 0
    0
      app/database/migrations/.gitkeep
  47. 34
    0
      app/database/migrations/2014_10_05_052350_create_schools_table.php
  48. 41
    0
      app/database/migrations/2014_10_05_055013_create_programs_table.php
  49. 43
    0
      app/database/migrations/2014_10_06_050335_create_users_table.php
  50. 33
    0
      app/database/migrations/2014_10_12_100000_create_password_resets_table.php
  51. 43
    0
      app/database/migrations/2014_11_10_035949_create_rubrics_table.php
  52. 34
    0
      app/database/migrations/2014_11_29_210957_create_templates_table.php
  53. 43
    0
      app/database/migrations/2014_11_29_211309_create_courses_table.php
  54. 42
    0
      app/database/migrations/2014_11_29_211310_create_activities_table.php
  55. 36
    0
      app/database/migrations/2014_11_29_212240_create_outcomes_table.php
  56. 45
    0
      app/database/migrations/2014_11_29_212341_create_criteria_table.php
  57. 33
    0
      app/database/migrations/2014_11_29_214028_create_semesters_table.php
  58. 43
    0
      app/database/migrations/2014_11_30_134022_create_students_table.php
  59. 41
    0
      app/database/migrations/2014_12_07_214036_create_course_student_table.php
  60. 41
    0
      app/database/migrations/2015_01_09_171350_create_assessments_table.php
  61. 37
    0
      app/database/migrations/2015_01_12_204310_add_columns_to_activities_table.php
  62. 37
    0
      app/database/migrations/2015_01_12_222859_add_columns_to_assessments_table.php
  63. 35
    0
      app/database/migrations/2015_01_13_010052_add_index_to_assessments_table.php
  64. 37
    0
      app/database/migrations/2015_01_13_142849_add_column_to_criteria_table.php
  65. 37
    0
      app/database/migrations/2015_01_14_140724_add_columns_to_courses_table.php
  66. 35
    0
      app/database/migrations/2015_01_21_124809_add_column_to_courses_table.php
  67. 45
    0
      app/database/migrations/2015_01_22_195515_add_column_to_templates_table.php
  68. 35
    0
      app/database/migrations/2015_01_23_175455_remove_total_from_assessments_table.php
  69. 40
    0
      app/database/migrations/2015_01_23_175923_rename_average_in_assessments_table.php
  70. 35
    0
      app/database/migrations/2015_01_28_121848_add_index_to_course_student_table.php
  71. 35
    0
      app/database/migrations/2015_01_28_133036_add_criteria_achieved_count_to_activities_table.php
  72. 35
    0
      app/database/migrations/2015_02_05_133245_add_transforming_actions_to_activities_table.php
  73. 35
    0
      app/database/migrations/2015_02_05_143641_add_assessment_comments_to_activities_table.php
  74. 33
    0
      app/database/migrations/2015_02_06_145359_create_password_reminders_table.php
  75. 35
    0
      app/database/migrations/2015_02_19_143311_add_is_graduate_to_programs_table.php
  76. 35
    0
      app/database/migrations/2015_02_25_170516_add_deleted_at_to_outcomes_table.php
  77. 35
    0
      app/database/migrations/2015_02_25_170529_add_deleted_at_to_criteria_table.php
  78. 37
    0
      app/database/migrations/2015_02_27_201953_add_criteria_achieved_percentage_to_activities_table.php
  79. 37
    0
      app/database/migrations/2015_03_04_132321_add_copyright_and_notes_to_criteria_table.php
  80. 41
    0
      app/database/migrations/2015_04_13_183730_add_program_id_to_templates_table.php
  81. 34
    0
      app/database/migrations/2015_04_28_141931_add_is_visible_to_templates_table.php
  82. 35
    0
      app/database/migrations/2015_05_04_162918_remove_expected_outcome_from_outcomes_table.php
  83. 35
    0
      app/database/migrations/2015_05_05_083800_add_decimal_expected_outcome_to_outcomes_table.php
  84. 35
    0
      app/database/migrations/2015_05_18_095002_add_first_login_to_users_table.php
  85. 40
    0
      app/database/migrations/2015_05_18_131259_add_columns_to_semesters_table.php
  86. 41
    0
      app/database/migrations/2015_05_18_134926_add_semester_id_to_courses.php
  87. 35
    0
      app/database/migrations/2015_06_10_092319_add_name_to_semesters_table.php
  88. 35
    0
      app/database/migrations/2015_06_12_085247_add_visibility_to_semesters_table.php
  89. 35
    0
      app/database/migrations/2015_06_16_092223_add_has_access_to_users.php
  90. 36
    0
      app/database/migrations/2015_06_18_103255_add_expected_percentage_and_points_to_templates_table.php
  91. 34
    0
      app/database/migrations/2015_07_10_150430_add_email_to_students_table.php
  92. 35
    0
      app/database/migrations/2015_07_13_111726_add_code_to_programs_table.php
  93. 36
    0
      app/database/migrations/2015_07_13_132620_add_ssn_and_employee_number_to_users_table.php
  94. 41
    0
      app/database/migrations/2015_08_19_130733_add_semester_id_to_course_student_table.php
  95. 34
    0
      app/database/migrations/2015_12_10_145451_add_criteria_weights_to_activities_table.php
  96. 37
    0
      app/database/migrations/2016_01_12_132034_add_program_id_to_criteria_table.php
  97. 35
    0
      app/database/migrations/2016_01_27_093808_add_date_to_activities_table.php
  98. 35
    0
      app/database/migrations/2016_01_27_134306_add_draft_to_activities_table.php
  99. 37
    0
      app/database/migrations/2016_03_11_085258_add_school_and_concentration_codes_to_students_table.php
  100. 0
    0
      app/database/migrations/2016_05_09_145427_create_program_user_table.php

+ 3
- 0
.bowerrc ファイルの表示

@@ -0,0 +1,3 @@
1
+{
2
+  "directory": "public/vendor/bower_components"
3
+}

+ 3
- 0
CONTRIBUTING.md ファイルの表示

@@ -0,0 +1,3 @@
1
+# Contribution Guidelines
2
+
3
+Please submit all issues and pull requests to the [laravel/framework](http://github.com/laravel/framework) repository!

+ 106
- 0
Gruntfile.js ファイルの表示

@@ -0,0 +1,106 @@
1
+'use strict';
2
+
3
+module.exports = function(grunt) {
4
+
5
+    //Paths to folders
6
+    var paths = {
7
+        app: 'app',
8
+        assets: 'assets',
9
+        css: 'public/css',
10
+        js: 'public/js',
11
+        fonts: 'public/fonts',
12
+        views: 'app/views'
13
+    };
14
+
15
+    //Load tasks in Gruntfile
16
+    require('jit-grunt')(grunt);
17
+
18
+
19
+    // Project configuration.
20
+	grunt.initConfig({
21
+		pkg: grunt.file.readJSON('package.json'),
22
+        paths: paths,
23
+        autoprefixer: {
24
+            options: {
25
+                map: true
26
+            },
27
+            css: {
28
+                expand: true,
29
+                flatten: true,
30
+                src: '<%= paths.css %>/*.css',
31
+                dest: '<%= paths.css %>'
32
+            },
33
+        },
34
+        concat: {
35
+            options: {
36
+                separator: ';',
37
+                stripBanners: true,
38
+                banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - '
39
+                    + '<%= grunt.template.today("yyyy-mm-dd") %> */',
40
+                sourceMap: true
41
+            },
42
+            js: {
43
+                files: {
44
+                    '<%= paths.js %>/main.js %>': '<%= paths.assets %>/js/*.js %>'
45
+                }
46
+            }
47
+
48
+        },
49
+        clean: {
50
+            js: ['<%= paths.js%>'],
51
+            css: ['<%= paths.css%>']
52
+        },
53
+        cssmin: {
54
+            minify: {
55
+                expand: true,
56
+                cwd: '<%= paths.css %>',
57
+                src: ['*.css', '!*.min.css'],
58
+                dest: '',
59
+                ext: '.min.css'
60
+            }
61
+        },
62
+        jshint: {
63
+            all: ['Gruntfile.js']
64
+        },
65
+        sass: {
66
+            dist: {
67
+                files: [{
68
+                    src: ['<%= paths.assets %>/sass/master.scss'],
69
+                    dest: '<%= paths.css %>/master.css'
70
+                }],
71
+
72
+                options: {
73
+                    loadPath: [
74
+                        'vendor/bower_components/bourbon/dist',
75
+                        'vendor/bower_components/neat/app/assets/stylesheets'
76
+                    ]
77
+                }
78
+            }
79
+        },
80
+        uglify: {
81
+			options: {
82
+				banner: '/*! <%= pkg.name %> - <%= pkg.author %> -<%= grunt.template.today("yyyy-mm-dd") %> */\n'
83
+			},
84
+			build: {
85
+				src: 'src/<%= pkg.name %>.js',
86
+				dest: 'build/<%= pkg.name %>.min.js'
87
+			}
88
+		},
89
+        watch: {
90
+            sass: {
91
+                files: '<%= paths.assets %>/sass/**/*.scss',
92
+                tasks: ['sass']
93
+            }
94
+        }
95
+	});
96
+
97
+	// Default task(s).
98
+	grunt.registerTask('default', [
99
+        'clean',
100
+        'sass',
101
+        'autoprefixer',
102
+        'cssmin',
103
+        'jshint',
104
+        'concat',
105
+        'uglify']);
106
+};

+ 0
- 0
app/commands/.gitkeep ファイルの表示


+ 201
- 0
app/config/app.php ファイルの表示

@@ -0,0 +1,201 @@
1
+<?php
2
+error_reporting(error_reporting() & ~E_DEPRECATED);
3
+return array(
4
+
5
+	/*
6
+	|--------------------------------------------------------------------------
7
+	| Application Debug Mode
8
+	|--------------------------------------------------------------------------
9
+	|
10
+	| When your application is in debug mode, detailed error messages with
11
+	| stack traces will be shown on every error that occurs within your
12
+	| application. If disabled, a simple generic error page is shown.
13
+	|
14
+	*/
15
+
16
+	'debug' => $_ENV['APP_DEBUG'] ?: false,
17
+
18
+	/*
19
+	|--------------------------------------------------------------------------
20
+	| Application URL
21
+	|--------------------------------------------------------------------------
22
+	|
23
+	| This URL is used by the console to properly generate URLs when using
24
+	| the Artisan command line tool. You should set this to the root of
25
+	| your application so that it is used when running Artisan tasks.
26
+	|
27
+	*/
28
+
29
+	'url' => $_ENV['APP_URL'] ?: 'http://localhost',
30
+
31
+	/*
32
+	|--------------------------------------------------------------------------
33
+	| Application Timezone
34
+	|--------------------------------------------------------------------------
35
+	|
36
+	| Here you may specify the default timezone for your application, which
37
+	| will be used by the PHP date and date-time functions. We have gone
38
+	| ahead and set this to a sensible default for you out of the box.
39
+	|
40
+	*/
41
+
42
+	'timezone' => 'America/Puerto_Rico',
43
+
44
+	/*
45
+	|--------------------------------------------------------------------------
46
+	| Application Locale Configuration
47
+	|--------------------------------------------------------------------------
48
+	|
49
+	| The application locale determines the default locale that will be used
50
+	| by the translation service provider. You are free to set this value
51
+	| to any of the locales which will be supported by the application.
52
+	|
53
+	*/
54
+
55
+	'locale' => 'en',
56
+
57
+	/*
58
+	|--------------------------------------------------------------------------
59
+	| Application Fallback Locale
60
+	|--------------------------------------------------------------------------
61
+	|
62
+	| The fallback locale determines the locale to use when the current one
63
+	| is not available. You may change the value to correspond to any of
64
+	| the language folders that are provided through your application.
65
+	|
66
+	*/
67
+
68
+	'fallback_locale' => 'en',
69
+
70
+	/*
71
+	|--------------------------------------------------------------------------
72
+	| Encryption Key
73
+	|--------------------------------------------------------------------------
74
+	|
75
+	| This key is used by the Illuminate encrypter service and should be set
76
+	| to a random, 32 character string, otherwise these encrypted strings
77
+	| will not be safe. Please do this before deploying an application!
78
+	|
79
+	*/
80
+
81
+	// 'key' => 'YourSecretKey!!!',
82
+	'key' => 'JozBz0yQBrZ5kEcPvgxch3RR3E3INSGs',
83
+
84
+	'cipher' => MCRYPT_RIJNDAEL_256,
85
+
86
+	/*
87
+	|--------------------------------------------------------------------------
88
+	| Autoloaded Service Providers
89
+	|--------------------------------------------------------------------------
90
+	|
91
+	| The service providers listed here will be automatically loaded on the
92
+	| request to your application. Feel free to add your own services to
93
+	| this array to grant expanded functionality to your applications.
94
+	|
95
+	*/
96
+
97
+	'providers' => array(
98
+
99
+		'Illuminate\Foundation\Providers\ArtisanServiceProvider',
100
+		'Illuminate\Auth\AuthServiceProvider',
101
+		'Illuminate\Cache\CacheServiceProvider',
102
+		'Illuminate\Session\CommandsServiceProvider',
103
+		'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider',
104
+		'Illuminate\Routing\ControllerServiceProvider',
105
+		'Illuminate\Cookie\CookieServiceProvider',
106
+		'Illuminate\Database\DatabaseServiceProvider',
107
+		'Illuminate\Encryption\EncryptionServiceProvider',
108
+		'Illuminate\Filesystem\FilesystemServiceProvider',
109
+		'Illuminate\Hashing\HashServiceProvider',
110
+		'Illuminate\Html\HtmlServiceProvider',
111
+		'Illuminate\Log\LogServiceProvider',
112
+		'Illuminate\Mail\MailServiceProvider',
113
+		'Illuminate\Database\MigrationServiceProvider',
114
+		'Illuminate\Pagination\PaginationServiceProvider',
115
+		'Illuminate\Queue\QueueServiceProvider',
116
+		'Illuminate\Redis\RedisServiceProvider',
117
+		'Illuminate\Remote\RemoteServiceProvider',
118
+		'Illuminate\Auth\Reminders\ReminderServiceProvider',
119
+		'Illuminate\Database\SeedServiceProvider',
120
+		'Illuminate\Session\SessionServiceProvider',
121
+		'Illuminate\Translation\TranslationServiceProvider',
122
+		'Illuminate\Validation\ValidationServiceProvider',
123
+		'Illuminate\View\ViewServiceProvider',
124
+		'Illuminate\Workbench\WorkbenchServiceProvider',
125
+		'Way\Generators\GeneratorsServiceProvider',
126
+		'Barryvdh\DomPDF\ServiceProvider',
127
+		'Zizaco\Entrust\EntrustServiceProvider'
128
+
129
+	),
130
+
131
+	/*
132
+	|--------------------------------------------------------------------------
133
+	| Service Provider Manifest
134
+	|--------------------------------------------------------------------------
135
+	|
136
+	| The service provider manifest is used by Laravel to lazy load service
137
+	| providers which are not needed for each request, as well to keep a
138
+	| list of all of the services. Here, you may set its storage spot.
139
+	|
140
+	*/
141
+
142
+	'manifest' => storage_path().'/meta',
143
+
144
+	/*
145
+	|--------------------------------------------------------------------------
146
+	| Class Aliases
147
+	|--------------------------------------------------------------------------
148
+	|
149
+	| This array of class aliases will be registered when this application
150
+	| is started. However, feel free to register as many as you wish as
151
+	| the aliases are "lazy" loaded so they don't hinder performance.
152
+	|
153
+	*/
154
+
155
+	'aliases' => array(
156
+
157
+		'App'               => 'Illuminate\Support\Facades\App',
158
+		'Artisan'           => 'Illuminate\Support\Facades\Artisan',
159
+		'Auth'              => 'Illuminate\Support\Facades\Auth',
160
+		'Blade'             => 'Illuminate\Support\Facades\Blade',
161
+		'Cache'             => 'Illuminate\Support\Facades\Cache',
162
+		'ClassLoader'       => 'Illuminate\Support\ClassLoader',
163
+		'Config'            => 'Illuminate\Support\Facades\Config',
164
+		'Controller'        => 'Illuminate\Routing\Controller',
165
+		'Cookie'            => 'Illuminate\Support\Facades\Cookie',
166
+		'Crypt'             => 'Illuminate\Support\Facades\Crypt',
167
+		'DB'                => 'Illuminate\Support\Facades\DB',
168
+		'Eloquent'          => 'Illuminate\Database\Eloquent\Model',
169
+		'Event'             => 'Illuminate\Support\Facades\Event',
170
+		'File'              => 'Illuminate\Support\Facades\File',
171
+		'Form'              => 'Illuminate\Support\Facades\Form',
172
+		'Hash'              => 'Illuminate\Support\Facades\Hash',
173
+		'HTML'              => 'Illuminate\Support\Facades\HTML',
174
+		'Input'             => 'Illuminate\Support\Facades\Input',
175
+		'Lang'              => 'Illuminate\Support\Facades\Lang',
176
+		'Log'               => 'Illuminate\Support\Facades\Log',
177
+		'Mail'              => 'Illuminate\Support\Facades\Mail',
178
+		'Paginator'         => 'Illuminate\Support\Facades\Paginator',
179
+		'Password'          => 'Illuminate\Support\Facades\Password',
180
+		'Queue'             => 'Illuminate\Support\Facades\Queue',
181
+		'Redirect'          => 'Illuminate\Support\Facades\Redirect',
182
+		'Redis'             => 'Illuminate\Support\Facades\Redis',
183
+		'Request'           => 'Illuminate\Support\Facades\Request',
184
+		'Response'          => 'Illuminate\Support\Facades\Response',
185
+		'Route'             => 'Illuminate\Support\Facades\Route',
186
+		'Schema'            => 'Illuminate\Support\Facades\Schema',
187
+		'Seeder'            => 'Illuminate\Database\Seeder',
188
+		'Session'           => 'Illuminate\Support\Facades\Session',
189
+		'SoftDeletingTrait' => 'Illuminate\Database\Eloquent\SoftDeletingTrait',
190
+		'SSH'               => 'Illuminate\Support\Facades\SSH',
191
+		'Str'               => 'Illuminate\Support\Str',
192
+		'URL'               => 'Illuminate\Support\Facades\URL',
193
+		'Validator'         => 'Illuminate\Support\Facades\Validator',
194
+		'View'              => 'Illuminate\Support\Facades\View',
195
+		'PDF'				=> 'Barryvdh\DomPDF\Facade',
196
+        'Entrust' => 'Zizaco\Entrust\EntrustFacade'
197
+
198
+
199
+	),
200
+
201
+);

+ 71
- 0
app/config/auth.php ファイルの表示

@@ -0,0 +1,71 @@
1
+<?php
2
+
3
+return array(
4
+
5
+	/*
6
+	|--------------------------------------------------------------------------
7
+	| Default Authentication Driver
8
+	|--------------------------------------------------------------------------
9
+	|
10
+	| This option controls the authentication driver that will be utilized.
11
+	| This driver manages the retrieval and authentication of the users
12
+	| attempting to get access to protected areas of your application.
13
+	|
14
+	| Supported: "database", "eloquent"
15
+	|
16
+	*/
17
+
18
+	'driver' => 'eloquent',
19
+
20
+	/*
21
+	|--------------------------------------------------------------------------
22
+	| Authentication Model
23
+	|--------------------------------------------------------------------------
24
+	|
25
+	| When using the "Eloquent" authentication driver, we need to know which
26
+	| Eloquent model should be used to retrieve your users. Of course, it
27
+	| is often just the "User" model but you may use whatever you like.
28
+	|
29
+	*/
30
+
31
+	'model' => 'User',
32
+
33
+	/*
34
+	|--------------------------------------------------------------------------
35
+	| Authentication Table
36
+	|--------------------------------------------------------------------------
37
+	|
38
+	| When using the "Database" authentication driver, we need to know which
39
+	| table should be used to retrieve your users. We have chosen a basic
40
+	| default value but you may easily change it to any table you like.
41
+	|
42
+	*/
43
+
44
+	'table' => 'users',
45
+
46
+	/*
47
+	|--------------------------------------------------------------------------
48
+	| Password Reminder Settings
49
+	|--------------------------------------------------------------------------
50
+	|
51
+	| Here you may set the settings for password reminders, including a view
52
+	| that should be used as your password reminder e-mail. You will also
53
+	| be able to set the name of the table that holds the reset tokens.
54
+	|
55
+	| The "expire" time is the number of minutes that the reminder should be
56
+	| considered valid. This security feature keeps tokens short-lived so
57
+	| they have less time to be guessed. You may change this as needed.
58
+	|
59
+	*/
60
+
61
+	'reminder' => array(
62
+
63
+		'email' => 'emails.auth.reminder',
64
+
65
+		'table' => 'password_reminders',
66
+
67
+		'expire' => 60,
68
+
69
+	),
70
+
71
+);

+ 89
- 0
app/config/cache.php ファイルの表示

@@ -0,0 +1,89 @@
1
+<?php
2
+
3
+return array(
4
+
5
+	/*
6
+	|--------------------------------------------------------------------------
7
+	| Default Cache Driver
8
+	|--------------------------------------------------------------------------
9
+	|
10
+	| This option controls the default cache "driver" that will be used when
11
+	| using the Caching library. Of course, you may use other drivers any
12
+	| time you wish. This is the default when another is not specified.
13
+	|
14
+	| Supported: "file", "database", "apc", "memcached", "redis", "array"
15
+	|
16
+	*/
17
+
18
+	'driver' => 'file',
19
+
20
+	/*
21
+	|--------------------------------------------------------------------------
22
+	| File Cache Location
23
+	|--------------------------------------------------------------------------
24
+	|
25
+	| When using the "file" cache driver, we need a location where the cache
26
+	| files may be stored. A sensible default has been specified, but you
27
+	| are free to change it to any other place on disk that you desire.
28
+	|
29
+	*/
30
+
31
+	'path' => storage_path().'/cache',
32
+
33
+	/*
34
+	|--------------------------------------------------------------------------
35
+	| Database Cache Connection
36
+	|--------------------------------------------------------------------------
37
+	|
38
+	| When using the "database" cache driver you may specify the connection
39
+	| that should be used to store the cached items. When this option is
40
+	| null the default database connection will be utilized for cache.
41
+	|
42
+	*/
43
+
44
+	'connection' => null,
45
+
46
+	/*
47
+	|--------------------------------------------------------------------------
48
+	| Database Cache Table
49
+	|--------------------------------------------------------------------------
50
+	|
51
+	| When using the "database" cache driver we need to know the table that
52
+	| should be used to store the cached items. A default table name has
53
+	| been provided but you're free to change it however you deem fit.
54
+	|
55
+	*/
56
+
57
+	'table' => 'cache',
58
+
59
+	/*
60
+	|--------------------------------------------------------------------------
61
+	| Memcached Servers
62
+	|--------------------------------------------------------------------------
63
+	|
64
+	| Now you may specify an array of your Memcached servers that should be
65
+	| used when utilizing the Memcached cache driver. All of the servers
66
+	| should contain a value for "host", "port", and "weight" options.
67
+	|
68
+	*/
69
+
70
+	'memcached' => array(
71
+
72
+		array('host' => '127.0.0.1', 'port' => 11211, 'weight' => 100),
73
+
74
+	),
75
+
76
+	/*
77
+	|--------------------------------------------------------------------------
78
+	| Cache Key Prefix
79
+	|--------------------------------------------------------------------------
80
+	|
81
+	| When utilizing a RAM based store such as APC or Memcached, there might
82
+	| be other applications utilizing the same cache. So, we'll specify a
83
+	| value to get prefixed to all our keys so we can avoid collisions.
84
+	|
85
+	*/
86
+
87
+	'prefix' => 'laravel',
88
+
89
+);

+ 18
- 0
app/config/compile.php ファイルの表示

@@ -0,0 +1,18 @@
1
+<?php
2
+
3
+return array(
4
+
5
+	/*
6
+	|--------------------------------------------------------------------------
7
+	| Additional Compiled Classes
8
+	|--------------------------------------------------------------------------
9
+	|
10
+	| Here you may specify additional classes to include in the compiled file
11
+	| generated by the `artisan optimize` command. These should be classes
12
+	| that are included on basically every request into the application.
13
+	|
14
+	*/
15
+
16
+
17
+
18
+);

+ 97
- 0
app/config/database.php ファイルの表示

@@ -0,0 +1,97 @@
1
+<?php
2
+
3
+return array(
4
+
5
+	/*
6
+	|--------------------------------------------------------------------------
7
+	| PDO Fetch Style
8
+	|--------------------------------------------------------------------------
9
+	|
10
+	| By default, database results will be returned as instances of the PHP
11
+	| stdClass object; however, you may desire to retrieve records in an
12
+	| array format for simplicity. Here you can tweak the fetch style.
13
+	|
14
+	*/
15
+
16
+	'fetch' => PDO::FETCH_CLASS,
17
+
18
+	/*
19
+	|--------------------------------------------------------------------------
20
+	| Default Database Connection Name
21
+	|--------------------------------------------------------------------------
22
+	|
23
+	| Here you may specify which of the database connections below you wish
24
+	| to use as your default connection for all database work. Of course
25
+	| you may use many connections at once using the Database library.
26
+	|
27
+	*/
28
+
29
+	'default' => 'mysql',
30
+
31
+	/*
32
+	|--------------------------------------------------------------------------
33
+	| Database Connections
34
+	|--------------------------------------------------------------------------
35
+	|
36
+	| Here are each of the database connections setup for your application.
37
+	| Of course, examples of configuring each database platform that is
38
+	| supported by Laravel is shown below to make development simple.
39
+	|
40
+	|
41
+	| All database work in Laravel is done through the PHP PDO facilities
42
+	| so make sure you have the driver for your particular database of
43
+	| choice installed on your machine before you begin development.
44
+	|
45
+	*/
46
+
47
+	'connections' => array(
48
+
49
+		'mysql' => array(
50
+			'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'] ?: '',
55
+			'charset'   => 'utf8',
56
+			'collation' => 'utf8_unicode_ci',
57
+			'prefix'    => '',
58
+		),
59
+	),
60
+
61
+	/*
62
+	|--------------------------------------------------------------------------
63
+	| Migration Repository Table
64
+	|--------------------------------------------------------------------------
65
+	|
66
+	| This table keeps track of all the migrations that have already run for
67
+	| your application. Using this information, we can determine which of
68
+	| the migrations on disk haven't actually been run in the database.
69
+	|
70
+	*/
71
+
72
+	'migrations' => 'migrations',
73
+
74
+	/*
75
+	|--------------------------------------------------------------------------
76
+	| Redis Databases
77
+	|--------------------------------------------------------------------------
78
+	|
79
+	| Redis is an open source, fast, and advanced key-value store that also
80
+	| provides a richer set of commands than a typical key-value systems
81
+	| such as APC or Memcached. Laravel makes it easy to dig right in.
82
+	|
83
+	*/
84
+
85
+	'redis' => array(
86
+
87
+		'cluster' => false,
88
+
89
+		'default' => array(
90
+			'host'     => '127.0.0.1',
91
+			'port'     => 6379,
92
+			'database' => 0,
93
+		),
94
+
95
+	),
96
+
97
+);

+ 124
- 0
app/config/mail.php ファイルの表示

@@ -0,0 +1,124 @@
1
+<?php
2
+
3
+return array(
4
+
5
+	/*
6
+	|--------------------------------------------------------------------------
7
+	| Mail Driver
8
+	|--------------------------------------------------------------------------
9
+	|
10
+	| Laravel supports both SMTP and PHP's "mail" function as drivers for the
11
+	| sending of e-mail. You may specify which one you're using throughout
12
+	| your application here. By default, Laravel is setup for SMTP mail.
13
+	|
14
+	| Supported: "smtp", "mail", "sendmail", "mailgun", "mandrill", "log"
15
+	|
16
+	*/
17
+
18
+	'driver' => 'smtp',
19
+
20
+	/*
21
+	|--------------------------------------------------------------------------
22
+	| SMTP Host Address
23
+	|--------------------------------------------------------------------------
24
+	|
25
+	| Here you may provide the host address of the SMTP server used by your
26
+	| applications. A default option is provided that is compatible with
27
+	| the Mailgun mail service which will provide reliable deliveries.
28
+	|
29
+	*/
30
+
31
+	'host' => 'smtp.gmail.com',
32
+
33
+	/*
34
+	|--------------------------------------------------------------------------
35
+	| SMTP Host Port
36
+	|--------------------------------------------------------------------------
37
+	|
38
+	| This is the SMTP port used by your application to deliver e-mails to
39
+	| users of the application. Like the host we have set this value to
40
+	| stay compatible with the Mailgun e-mail application by default.
41
+	|
42
+	*/
43
+
44
+	'port' => 465,
45
+
46
+	/*
47
+	|--------------------------------------------------------------------------
48
+	| Global "From" Address
49
+	|--------------------------------------------------------------------------
50
+	|
51
+	| You may wish for all e-mails sent by your application to be sent from
52
+	| the same address. Here, you may specify a name and address that is
53
+	| used globally for all e-mails that are sent by your application.
54
+	|
55
+	*/
56
+
57
+	'from' => array('address' => 'olas.rrp@upr.edu', 'name' => 'OLAS Mail'),
58
+
59
+	/*
60
+	|--------------------------------------------------------------------------
61
+	| E-Mail Encryption Protocol
62
+	|--------------------------------------------------------------------------
63
+	|
64
+	| Here you may specify the encryption protocol that should be used when
65
+	| the application send e-mail messages. A sensible default using the
66
+	| transport layer security protocol should provide great security.
67
+	|
68
+	*/
69
+
70
+	'encryption' => 'ssl',
71
+
72
+	/*
73
+	|--------------------------------------------------------------------------
74
+	| SMTP Server Username
75
+	|--------------------------------------------------------------------------
76
+	|
77
+	| If your SMTP server requires a username for authentication, you should
78
+	| set it here. This will get used to authenticate with your server on
79
+	| connection. You may also set the "password" value below this one.
80
+	|
81
+	*/
82
+
83
+	'username' => 'olas.rrp@upr.edu',
84
+
85
+	/*
86
+	|--------------------------------------------------------------------------
87
+	| SMTP Server Password
88
+	|--------------------------------------------------------------------------
89
+	|
90
+	| Here you may set the password required by your SMTP server to send out
91
+	| messages from your application. This will be given to the server on
92
+	| connection so that the application will be able to send messages.
93
+	|
94
+	*/
95
+
96
+	'password' => 'rectoria2015',
97
+
98
+	/*
99
+	|--------------------------------------------------------------------------
100
+	| Sendmail System Path
101
+	|--------------------------------------------------------------------------
102
+	|
103
+	| When using the "sendmail" driver to send e-mails, we will need to know
104
+	| the path to where Sendmail lives on this server. A default path has
105
+	| been provided here, which will work well on most of your systems.
106
+	|
107
+	*/
108
+
109
+	'sendmail' => '/usr/sbin/sendmail -bs',
110
+
111
+	/*
112
+	|--------------------------------------------------------------------------
113
+	| Mail "Pretend"
114
+	|--------------------------------------------------------------------------
115
+	|
116
+	| When this option is enabled, e-mail will not actually be sent over the
117
+	| web and will instead be written to your application's logs files so
118
+	| you may inspect the message. This is great for local development.
119
+	|
120
+	*/
121
+
122
+	'pretend' => false,
123
+
124
+);

+ 0
- 0
app/config/packages/.gitkeep ファイルの表示


+ 85
- 0
app/config/queue.php ファイルの表示

@@ -0,0 +1,85 @@
1
+<?php
2
+
3
+return array(
4
+
5
+	/*
6
+	|--------------------------------------------------------------------------
7
+	| Default Queue Driver
8
+	|--------------------------------------------------------------------------
9
+	|
10
+	| The Laravel queue API supports a variety of back-ends via an unified
11
+	| API, giving you convenient access to each back-end using the same
12
+	| syntax for each one. Here you may set the default queue driver.
13
+	|
14
+	| Supported: "sync", "beanstalkd", "sqs", "iron", "redis"
15
+	|
16
+	*/
17
+
18
+	'default' => 'sync',
19
+
20
+	/*
21
+	|--------------------------------------------------------------------------
22
+	| Queue Connections
23
+	|--------------------------------------------------------------------------
24
+	|
25
+	| Here you may configure the connection information for each server that
26
+	| is used by your application. A default configuration has been added
27
+	| for each back-end shipped with Laravel. You are free to add more.
28
+	|
29
+	*/
30
+
31
+	'connections' => array(
32
+
33
+		'sync' => array(
34
+			'driver' => 'sync',
35
+		),
36
+
37
+		'beanstalkd' => array(
38
+			'driver' => 'beanstalkd',
39
+			'host'   => 'localhost',
40
+			'queue'  => 'default',
41
+			'ttr'    => 60,
42
+		),
43
+
44
+		'sqs' => array(
45
+			'driver' => 'sqs',
46
+			'key'    => 'your-public-key',
47
+			'secret' => 'your-secret-key',
48
+			'queue'  => 'your-queue-url',
49
+			'region' => 'us-east-1',
50
+		),
51
+
52
+		'iron' => array(
53
+			'driver'  => 'iron',
54
+			'host'    => 'mq-aws-us-east-1.iron.io',
55
+			'token'   => 'your-token',
56
+			'project' => 'your-project-id',
57
+			'queue'   => 'your-queue-name',
58
+			'encrypt' => true,
59
+		),
60
+
61
+		'redis' => array(
62
+			'driver' => 'redis',
63
+			'queue'  => 'default',
64
+		),
65
+
66
+	),
67
+
68
+	/*
69
+	|--------------------------------------------------------------------------
70
+	| Failed Queue Jobs
71
+	|--------------------------------------------------------------------------
72
+	|
73
+	| These options configure the behavior of failed queue job logging so you
74
+	| can control which database and table are used to store the jobs that
75
+	| have failed. You may change them to any database / table you wish.
76
+	|
77
+	*/
78
+
79
+	'failed' => array(
80
+
81
+		'database' => 'mysql', 'table' => 'failed_jobs',
82
+
83
+	),
84
+
85
+);

+ 59
- 0
app/config/remote.php ファイルの表示

@@ -0,0 +1,59 @@
1
+<?php
2
+
3
+return array(
4
+
5
+	/*
6
+	|--------------------------------------------------------------------------
7
+	| Default Remote Connection Name
8
+	|--------------------------------------------------------------------------
9
+	|
10
+	| Here you may specify the default connection that will be used for SSH
11
+	| operations. This name should correspond to a connection name below
12
+	| in the server list. Each connection will be manually accessible.
13
+	|
14
+	*/
15
+
16
+	'default' => 'production',
17
+
18
+	/*
19
+	|--------------------------------------------------------------------------
20
+	| Remote Server Connections
21
+	|--------------------------------------------------------------------------
22
+	|
23
+	| These are the servers that will be accessible via the SSH task runner
24
+	| facilities of Laravel. This feature radically simplifies executing
25
+	| tasks on your servers, such as deploying out these applications.
26
+	|
27
+	*/
28
+
29
+	'connections' => array(
30
+
31
+		'production' => array(
32
+			'host'      => '',
33
+			'username'  => '',
34
+			'password'  => '',
35
+			'key'       => '',
36
+			'keyphrase' => '',
37
+			'root'      => '/var/www',
38
+		),
39
+
40
+	),
41
+
42
+	/*
43
+	|--------------------------------------------------------------------------
44
+	| Remote Server Groups
45
+	|--------------------------------------------------------------------------
46
+	|
47
+	| Here you may list connections under a single group name, which allows
48
+	| you to easily access all of the servers at once using a short name
49
+	| that is extremely easy to remember, such as "web" or "database".
50
+	|
51
+	*/
52
+
53
+	'groups' => array(
54
+
55
+		'web' => array('production')
56
+
57
+	),
58
+
59
+);

+ 31
- 0
app/config/services.php ファイルの表示

@@ -0,0 +1,31 @@
1
+<?php
2
+
3
+return array(
4
+
5
+	/*
6
+	|--------------------------------------------------------------------------
7
+	| Third Party Services
8
+	|--------------------------------------------------------------------------
9
+	|
10
+	| This file is for storing the credentials for third party services such
11
+	| as Stripe, Mailgun, Mandrill, and others. This file provides a sane
12
+	| default location for this type of information, allowing packages
13
+	| to have a conventional place to find your various credentials.
14
+	|
15
+	*/
16
+
17
+	'mailgun' => array(
18
+		'domain' => '',
19
+		'secret' => '',
20
+	),
21
+
22
+	'mandrill' => array(
23
+		'secret' => '',
24
+	),
25
+
26
+	'stripe' => array(
27
+		'model'  => 'User',
28
+		'secret' => '',
29
+	),
30
+
31
+);

+ 140
- 0
app/config/session.php ファイルの表示

@@ -0,0 +1,140 @@
1
+<?php
2
+
3
+return array(
4
+
5
+	/*
6
+	|--------------------------------------------------------------------------
7
+	| Default Session Driver
8
+	|--------------------------------------------------------------------------
9
+	|
10
+	| This option controls the default session "driver" that will be used on
11
+	| requests. By default, we will use the lightweight native driver but
12
+	| you may specify any of the other wonderful drivers provided here.
13
+	|
14
+	| Supported: "file", "cookie", "database", "apc",
15
+	|            "memcached", "redis", "array"
16
+	|
17
+	*/
18
+
19
+	'driver' => 'file',
20
+
21
+	/*
22
+	|--------------------------------------------------------------------------
23
+	| Session Lifetime
24
+	|--------------------------------------------------------------------------
25
+	|
26
+	| Here you may specify the number of minutes that you wish the session
27
+	| to be allowed to remain idle before it expires. If you want them
28
+	| to immediately expire on the browser closing, set that option.
29
+	|
30
+	*/
31
+
32
+	'lifetime' => 120,
33
+
34
+	'expire_on_close' => false,
35
+
36
+	/*
37
+	|--------------------------------------------------------------------------
38
+	| Session File Location
39
+	|--------------------------------------------------------------------------
40
+	|
41
+	| When using the native session driver, we need a location where session
42
+	| files may be stored. A default has been set for you but a different
43
+	| location may be specified. This is only needed for file sessions.
44
+	|
45
+	*/
46
+
47
+	'files' => storage_path().'/sessions',
48
+
49
+	/*
50
+	|--------------------------------------------------------------------------
51
+	| Session Database Connection
52
+	|--------------------------------------------------------------------------
53
+	|
54
+	| When using the "database" or "redis" session drivers, you may specify a
55
+	| connection that should be used to manage these sessions. This should
56
+	| correspond to a connection in your database configuration options.
57
+	|
58
+	*/
59
+
60
+	'connection' => null,
61
+
62
+	/*
63
+	|--------------------------------------------------------------------------
64
+	| Session Database Table
65
+	|--------------------------------------------------------------------------
66
+	|
67
+	| When using the "database" session driver, you may specify the table we
68
+	| should use to manage the sessions. Of course, a sensible default is
69
+	| provided for you; however, you are free to change this as needed.
70
+	|
71
+	*/
72
+
73
+	'table' => 'sessions',
74
+
75
+	/*
76
+	|--------------------------------------------------------------------------
77
+	| Session Sweeping Lottery
78
+	|--------------------------------------------------------------------------
79
+	|
80
+	| Some session drivers must manually sweep their storage location to get
81
+	| rid of old sessions from storage. Here are the chances that it will
82
+	| happen on a given request. By default, the odds are 2 out of 100.
83
+	|
84
+	*/
85
+
86
+	'lottery' => array(2, 100),
87
+
88
+	/*
89
+	|--------------------------------------------------------------------------
90
+	| Session Cookie Name
91
+	|--------------------------------------------------------------------------
92
+	|
93
+	| Here you may change the name of the cookie used to identify a session
94
+	| instance by ID. The name specified here will get used every time a
95
+	| new session cookie is created by the framework for every driver.
96
+	|
97
+	*/
98
+
99
+	'cookie' => 'olas_session',
100
+
101
+	/*
102
+	|--------------------------------------------------------------------------
103
+	| Session Cookie Path
104
+	|--------------------------------------------------------------------------
105
+	|
106
+	| The session cookie path determines the path for which the cookie will
107
+	| be regarded as available. Typically, this will be the root path of
108
+	| your application but you are free to change this when necessary.
109
+	|
110
+	*/
111
+
112
+	'path' => '/',
113
+
114
+	/*
115
+	|--------------------------------------------------------------------------
116
+	| Session Cookie Domain
117
+	|--------------------------------------------------------------------------
118
+	|
119
+	| Here you may change the domain of the cookie used to identify a session
120
+	| in your application. This will determine which domains the cookie is
121
+	| available to in your application. A sensible default has been set.
122
+	|
123
+	*/
124
+
125
+	'domain' => null,
126
+
127
+	/*
128
+	|--------------------------------------------------------------------------
129
+	| HTTPS Only Cookies
130
+	|--------------------------------------------------------------------------
131
+	|
132
+	| By setting this option to true, session cookies will only be sent back
133
+	| to the server if the browser has a HTTPS connection. This will keep
134
+	| the cookie from being sent to you if it can not be done securely.
135
+	|
136
+	*/
137
+
138
+	'secure' => false,
139
+
140
+);

+ 20
- 0
app/config/testing/cache.php ファイルの表示

@@ -0,0 +1,20 @@
1
+<?php
2
+
3
+return array(
4
+
5
+	/*
6
+	|--------------------------------------------------------------------------
7
+	| Default Cache Driver
8
+	|--------------------------------------------------------------------------
9
+	|
10
+	| This option controls the default cache "driver" that will be used when
11
+	| using the Caching library. Of course, you may use other drivers any
12
+	| time you wish. This is the default when another is not specified.
13
+	|
14
+	| Supported: "file", "database", "apc", "memcached", "redis", "array"
15
+	|
16
+	*/
17
+
18
+	'driver' => 'array',
19
+
20
+);

+ 21
- 0
app/config/testing/session.php ファイルの表示

@@ -0,0 +1,21 @@
1
+<?php
2
+
3
+return array(
4
+
5
+	/*
6
+	|--------------------------------------------------------------------------
7
+	| Default Session Driver
8
+	|--------------------------------------------------------------------------
9
+	|
10
+	| This option controls the default session "driver" that will be used on
11
+	| requests. By default, we will use the lightweight native driver but
12
+	| you may specify any of the other wonderful drivers provided here.
13
+	|
14
+	| Supported: "native", "cookie", "database", "apc",
15
+	|            "memcached", "redis", "array"
16
+	|
17
+	*/
18
+
19
+	'driver' => 'array',
20
+
21
+);

+ 31
- 0
app/config/view.php ファイルの表示

@@ -0,0 +1,31 @@
1
+<?php
2
+
3
+return array(
4
+
5
+	/*
6
+	|--------------------------------------------------------------------------
7
+	| View Storage Paths
8
+	|--------------------------------------------------------------------------
9
+	|
10
+	| Most templating systems load templates from disk. Here you may specify
11
+	| an array of paths that should be checked for your views. Of course
12
+	| the usual Laravel view path has already been registered for you.
13
+	|
14
+	*/
15
+
16
+	'paths' => array(__DIR__.'/../views'),
17
+
18
+	/*
19
+	|--------------------------------------------------------------------------
20
+	| Pagination View
21
+	|--------------------------------------------------------------------------
22
+	|
23
+	| This view will be used to render the pagination link output, and can
24
+	| be easily customized here to show any view you like. A clean view
25
+	| compatible with Twitter's Bootstrap is given to you by default.
26
+	|
27
+	*/
28
+
29
+	'pagination' => 'pagination::slider-3',
30
+
31
+);

+ 31
- 0
app/config/workbench.php ファイルの表示

@@ -0,0 +1,31 @@
1
+<?php
2
+
3
+return array(
4
+
5
+	/*
6
+	|--------------------------------------------------------------------------
7
+	| Workbench Author Name
8
+	|--------------------------------------------------------------------------
9
+	|
10
+	| When you create new packages via the Artisan "workbench" command your
11
+	| name is needed to generate the composer.json file for your package.
12
+	| You may specify it now so it is used for all of your workbenches.
13
+	|
14
+	*/
15
+
16
+	'name' => '',
17
+
18
+	/*
19
+	|--------------------------------------------------------------------------
20
+	| Workbench Author E-Mail Address
21
+	|--------------------------------------------------------------------------
22
+	|
23
+	| Like the option above, your e-mail address is used when generating new
24
+	| workbench packages. The e-mail is placed in your composer.json file
25
+	| automatically after the package is created by the workbench tool.
26
+	|
27
+	*/
28
+
29
+	'email' => '',
30
+
31
+);

+ 0
- 0
app/controllers/.gitkeep ファイルの表示


+ 763
- 0
app/controllers/ActivitiesController.php ファイルの表示

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

+ 207
- 0
app/controllers/AdministratorsController.php ファイルの表示

@@ -0,0 +1,207 @@
1
+<?php
2
+
3
+class AdministratorsController extends \BaseController
4
+{
5
+    public function overview()
6
+    {
7
+        //Total amount of learning outcomes
8
+        $outcomeCount = Outcome::withTrashed()->count();
9
+
10
+        // Id for excluding UHS from records
11
+        $uhs_school_id = School::where('name', 'LIKE', '%UHS%')->first()->id;
12
+        $uhs_program_id = Program::where('name', 'LIKE', '%UHS%')->first()->id;
13
+
14
+        $schools = School::where('id', '!=', $uhs_school_id)->orderBy('name', 'asc')->get();
15
+        $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
+
23
+        /**
24
+         * Calculate campus wide outcome performance
25
+         */
26
+
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
+        }
58
+
59
+        /**
60
+         * Calculate how many programs achieved and attempted each outcome
61
+         */
62
+
63
+        // Number of programs that achieved a particular learning outcome
64
+        $achievedUndergradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
65
+
66
+        // Number of programs that attempted a particular learning outcome
67
+        $attemptedUndergradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
68
+
69
+        // Names of programs doing assessment
70
+        // 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
+
132
+
133
+        /**
134
+         * Calculate how many programs achieved and attempted each outcome
135
+         */
136
+
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
+
143
+        // 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'));
206
+    }
207
+}

+ 112
- 0
app/controllers/AnnualPlansController.php ファイルの表示

@@ -0,0 +1,112 @@
1
+<?php
2
+
3
+class AnnualPlansController extends \BaseController {
4
+
5
+  /**
6
+   * Checks whether a user has permission to view a page in this controller
7
+   *
8
+   * @var User $user        Authenticated user
9
+   */
10
+  private function userHasAccess($program_id)
11
+  {
12
+    $user = Auth::user();
13
+
14
+    switch ($user->role) {
15
+      case '3':
16
+        $programs = $user->programs->lists('id');
17
+
18
+        // If program does not belong to user, show 403
19
+        if(!in_array($program_id, $programs))
20
+          return false;
21
+
22
+        break;
23
+
24
+      case '2':
25
+        $programs = Program::where('school_id', $user->school_id)->lists('id');
26
+
27
+        // If program is not in user's school, show 403
28
+        if(!in_array($program_id, $programs))
29
+          return false;
30
+
31
+        break;
32
+      case '4':
33
+        return false;
34
+    }
35
+
36
+    return true;
37
+  }
38
+
39
+  /**
40
+   * Lists annual plans by year and program
41
+   * @var string $title     Title for page
42
+   * @var Program $programs Collection of programs user has access to
43
+   * @var User $user        Authenticated user
44
+   * @var Quinquennium $quinquenniums      All current or past quinquenniums
45
+   * @var Quinquennium $current_quinquennium      Current quinquennium
46
+   */
47
+  public function index()
48
+  {
49
+    $title = 'Annual Plans';
50
+    $user = Auth::user();
51
+    $quinquenniums = Quinquennium::where('start_date','<=', date('Y-m-d'))->get();
52
+    $current_quinquennium = Quinquennium::
53
+      where('start_date', '<=', date('Y-m-d'))
54
+      ->where('end_date', '>=', date('Y-m-d'))
55
+      ->first();
56
+
57
+    switch ($user->role) {
58
+      case '1':
59
+        $programs = Program::all();
60
+        break;
61
+      case '2':
62
+        $programs = Program::where('school_id', $user->school_id)->get();
63
+        break;
64
+      case 3:
65
+        $programs = $user->programs;
66
+        break;
67
+      default:
68
+        App::abort('404');
69
+        break;
70
+    }
71
+
72
+    return View::make('local.managers.shared.index_annual_plans', compact('title', 'quinquenniums', 'programs', 'current_quinquennium'));
73
+  }
74
+
75
+  /**
76
+   * Page to create a new plan for the current quinquennium
77
+   * @var string $title     Title for page
78
+   * @var Program $programs Collection of programs user has access to
79
+   * @var Outcome $outcomes      List of outcomes ordered by name
80
+   * @var User $user      Currently logged user
81
+   * @var Course $courses      Courses for a particular program
82
+   */
83
+  public function create(Program $program)
84
+  {
85
+    $title = 'New Annual Plan for '.$program->name;
86
+    $user = Auth::user();
87
+    $outcomes = Outcome::orderBy('name')->get();
88
+
89
+    $current_quinquennium = Quinquennium::
90
+      where('start_date', '<=', date('Y-m-d'))
91
+      ->where('end_date', '>=', date('Y-m-d'))
92
+      ->first();
93
+
94
+    $courses = Course::
95
+      select('id', 'code', 'number', 'name')
96
+      ->where('program_id', $program->id)
97
+      ->groupBy('name')
98
+      ->orderBy('code','ASC')
99
+      ->orderBy('number','ASC')
100
+      ->orderBy('name','ASC')
101
+      ->get();
102
+
103
+    // Check if user can create a plan
104
+    if(!$this->userHasAccess($program->id))
105
+    {
106
+      return View::make('global.403');
107
+    }
108
+
109
+    return View::make('local.managers.shared.create_annual_plan', compact('title', 'program', 'current_quinquennium', 'outcomes', 'courses'));
110
+  }
111
+
112
+}

+ 184
- 0
app/controllers/AuthController.php ファイルの表示

@@ -0,0 +1,184 @@
1
+<?php
2
+
3
+class AuthController extends \BaseController {
4
+
5
+	/**
6
+	 * Display a listing of the resource.
7
+	 * GET /auth
8
+	 *
9
+	 * @return Response
10
+	 */
11
+	public function showLogin()
12
+	{
13
+		$title ="Online Learning Assessment System";
14
+		return View::make('global.login', compact('title'));
15
+	}
16
+
17
+	public function login()
18
+	{
19
+		/** Validate data */
20
+		$validator = Validator::make(
21
+			Input::all(),
22
+			array(
23
+				'email'=>'required|email',
24
+    			'password'=>'required|min:4|max:16'
25
+			)
26
+		);
27
+
28
+		if(!$validator->fails())
29
+		{
30
+//			TODO: Remove this for production environment
31
+            if (App::environment('local', 'staging')) {
32
+			    return $this->processLogin();
33
+            }
34
+			try {
35
+				// User input
36
+				$username = str_replace('@upr.edu', '', Input::get('email'));
37
+				$password = Input::get('password');
38
+
39
+				// Radius connection info
40
+				$radius = radius_auth_open();
41
+				$radius_ip = '136.145.223.27';
42
+				$radius_secret = '8reC6ujatArecHe63spech5Wa';
43
+
44
+				radius_add_server($radius, $radius_ip, 1812, $radius_secret, 5, 3);
45
+
46
+				// Create radius request and add params
47
+				radius_create_request($radius, RADIUS_ACCESS_REQUEST);
48
+				radius_put_attr($radius, RADIUS_USER_NAME, $username);
49
+				radius_put_attr($radius, RADIUS_USER_PASSWORD, $password);
50
+
51
+				$result = radius_send_request($radius);
52
+
53
+				switch ($result) {
54
+					// Credentials are correct
55
+					case RADIUS_ACCESS_ACCEPT:
56
+
57
+						return $this->processLogin();
58
+						break;
59
+					case RADIUS_ACCESS_REJECT:
60
+						// If email is a workshop email,
61
+						if(Input::get('email') == 'taller1@upr.edu' && Input::get('password') == 'o34eAvaluo'){
62
+							return $this->processLogin();
63
+						}
64
+
65
+						// Tell user credentials are incorrect
66
+						Session::flash('status', 'danger');
67
+						Session::flash('message', 'Incorrect email/password combination.');
68
+						return Redirect::action('AuthController@showLogin');
69
+						break;
70
+					// Throw exception in case of any other error
71
+					default:
72
+						throw new Exception("-", 1);
73
+						break;
74
+				}
75
+
76
+			}
77
+			catch(Exception $e){
78
+				// Tell user access is denied and return to login page.
79
+				Session::flash('status', 'danger');
80
+				Session::flash('message', 'An error occurred while connecting to the authentication service. Please try again later. If the problem persists, contact the help desk at x. 80400 or the administrators at oeae.uprrp.edu.');
81
+				return Redirect::action('AuthController@showLogin');
82
+			}
83
+			return Redirect::route('login');
84
+		}
85
+		else
86
+		{
87
+            /** Prepare error message */
88
+            $message = '<ul>';
89
+
90
+            foreach ($validator->messages()->all('<li>:message</li>') as $validationError)
91
+            {
92
+                $message.=$validationError;
93
+            }
94
+
95
+            $message.='</ul>';
96
+
97
+			Session::flash('status', 'danger');
98
+			Session::flash('message', $message);
99
+			return Redirect::action('AuthController@showLogin');
100
+		}
101
+	}
102
+
103
+	private function processLogin(){
104
+		// Get user record in OLAS database, if it exists
105
+		$user = User::where('email', Input::get('email'))->first();
106
+
107
+		// If user exists in the database AND is authorized
108
+		if($user and $user->has_access)
109
+		{
110
+			// Log in user and direct to main page
111
+			Auth::login($user);
112
+
113
+			// Get last visible AND running term;
114
+			$semester = Semester::
115
+				where('is_visible', 1)
116
+				->where('start', '<=', date('Y-m-d H:i:s'))
117
+				->orderBy('start', 'DESC')
118
+				->first();
119
+
120
+			Session::forget('current_semester');
121
+			Session::put('current_semester', $semester);
122
+
123
+			// Push into semesters variable
124
+			$semesters_id = array();
125
+			$semesters_info = array();
126
+
127
+			$semesters_ids[] = $semester->id;
128
+			$semesters_info[] = $semester->name.' ('.$semester->code.')';
129
+
130
+			// Put semesters information arrays into Session
131
+			Session::forget('semesters_ids');
132
+			Session::put('semesters_ids', $semesters_ids);
133
+
134
+			Session::forget('semesters_info');
135
+			Session::put('semesters_info', $semesters_info);
136
+
137
+			// Record last login
138
+			User::where('id', Auth::user()->id)
139
+				->update(array(
140
+					'last_login' => DB::raw('NOW()')
141
+				)
142
+			);
143
+
144
+			if(!Auth::user()->office_phone){
145
+				return Redirect::action('UsersController@edit');
146
+			}
147
+
148
+			// Redirect depending on user
149
+			switch (Auth::user()->role) {
150
+				case 1:
151
+					return Redirect::intended('administrator');
152
+					break;
153
+
154
+				case 2:
155
+					return Redirect::intended('school-coordinator');
156
+					break;
157
+
158
+				case 3:
159
+					return Redirect::intended('program-coordinator');
160
+					break;
161
+
162
+				case 4:
163
+					return Redirect::intended('professor');
164
+					break;
165
+			}
166
+		}
167
+		else
168
+		{
169
+			// Tell user access is denied and return to login page.
170
+			Session::flash('status', 'danger');
171
+			Session::flash('message', 'You are not an authorized user. You may request access by contacting oeae.uprrp.edu.');
172
+			return Redirect::action('AuthController@showLogin');
173
+		}
174
+	}
175
+
176
+	public function logout()
177
+	{
178
+		Auth::logout();
179
+		Session::flush();
180
+		return Redirect::action('AuthController@showLogin');
181
+
182
+	}
183
+
184
+}

+ 18
- 0
app/controllers/BaseController.php ファイルの表示

@@ -0,0 +1,18 @@
1
+<?php
2
+
3
+class BaseController extends Controller {
4
+
5
+	/**
6
+	 * Setup the layout used by the controller.
7
+	 *
8
+	 * @return void
9
+	 */
10
+	protected function setupLayout()
11
+	{
12
+		if ( ! is_null($this->layout))
13
+		{
14
+			$this->layout = View::make($this->layout);
15
+		}
16
+	}
17
+
18
+}

+ 10
- 0
app/controllers/Controller.php ファイルの表示

@@ -0,0 +1,10 @@
1
+<?php namespace App\Http\Controllers;
2
+
3
+use Illuminate\Routing\Controller as BaseController;
4
+use Illuminate\Foundation\Validation\ValidatesRequests;
5
+
6
+abstract class Controller extends BaseController {
7
+
8
+	use ValidatesRequests;
9
+
10
+}

+ 470
- 0
app/controllers/CoursesController.php ファイルの表示

@@ -0,0 +1,470 @@
1
+<?php
2
+
3
+class CoursesController extends \BaseController {
4
+
5
+	/**
6
+	 * Display the specified resource.
7
+	 *
8
+	 * @param  int  $id
9
+	 * @return Response
10
+	 */
11
+	public function show($id)
12
+	{
13
+
14
+		$course = Course::with('semester')->where('id', $id)->first();
15
+		$title=$course->code.$course->number.'-'.$course->section.' <span class="small attention">('.$course->semester->code.')</span>';
16
+
17
+		// If course does not exist, display 404
18
+		if(!$course)
19
+            App::abort('404');
20
+
21
+        // If course does not belong to the person
22
+        if ($course->user_id != Auth::id())
23
+        	App::abort('403', 'Access forbidden.');
24
+
25
+		$activities = $course->activities;
26
+		$students = $course->students;
27
+
28
+		$outcomes = Outcome::orderBy('name', 'asc')->get();
29
+		$outcomes_achieved = json_decode($course->outcomes_achieved, true);
30
+        $outcomes_attempted = json_decode($course->outcomes_attempted, true);
31
+
32
+        // Get active semesters
33
+        $active_semesters= array();
34
+        $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();
35
+        foreach ($active_semesters_collection as $active_semester)
36
+        {
37
+        	$active_semesters[]=$active_semester->id;
38
+        }
39
+
40
+		return View::make('local.professors.course', compact('title', 'course', 'activities', 'students', 'outcomes', 'outcomes_achieved', 'outcomes_attempted', 'active_semesters'));
41
+	}
42
+
43
+
44
+
45
+	/**
46
+	 * Display the specified course, but with limited information.
47
+	 *
48
+	 * @param  int  $id
49
+	 * @return Response
50
+	 */
51
+	public function showLimited($id)
52
+	{
53
+		$course = Course::with('semester')->where('id', $id)->first();
54
+		$students = $course->students;
55
+		$title=$course->code.$course->number.'-'.$course->section.' <span class="small attention">('.$course->semester->code.')</span>';
56
+
57
+		// If course does not exist, display 404
58
+		if(!$course)
59
+            App::abort('404');
60
+
61
+		$activities = $course->activities;
62
+		$students = $course->students;
63
+
64
+		$outcomes = Outcome::orderBy('name', 'asc')->get();
65
+		$outcomes_achieved = json_decode($course->outcomes_achieved, true);
66
+        $outcomes_attempted = json_decode($course->outcomes_attempted, true);
67
+
68
+        $schools = School::all();
69
+
70
+        $rubrics = array();
71
+        foreach ($activities as $activity )
72
+        {
73
+        	if($activity->rubric_id!=NULL)
74
+    		{
75
+    			$rubrics[]=$activity->rubric;
76
+    		}
77
+        }
78
+
79
+		return View::make('local.managers.shared.limited-course', compact('title', 'course', 'activities', 'students', 'outcomes', 'outcomes_achieved', 'outcomes_attempted', 'schools', 'rubrics', 'students'));
80
+	}
81
+
82
+
83
+	/**
84
+	 * Show grouped sections of a course
85
+	 */
86
+
87
+	public function showGrouped($code, $number, $semester_code)
88
+	{
89
+        $title=$code.$number.' ('.$semester_code.')';
90
+        $semester = Semester::where('code', $semester_code)->first();
91
+        $role = Auth::user()->role;
92
+
93
+        $grouped_courses = Course::
94
+        	where('code', $code)
95
+        	->where('number', $number)
96
+        	->where('semester_id', $semester->id)
97
+        	->groupBy(array('code', 'number'))->get();
98
+
99
+        $outcomes = Outcome::orderBy('name', 'asc')->get();
100
+        $outcomeCount = Outcome::all()->count();
101
+
102
+        foreach ($grouped_courses as $index => $grouped_course)
103
+        {
104
+            // Blank outcomes for one course
105
+            $outcomes_achieved = array_fill(1, $outcomeCount, 0);
106
+            $outcomes_attempted = array_fill(1, $outcomeCount, 0);
107
+
108
+            // Find sections for this course
109
+            $sections = Course::
110
+            	where('code', $grouped_course->code)
111
+            	->where('number', $grouped_course->number)
112
+            	->where('semester_id', $grouped_course->semester_id)
113
+            	->get();
114
+
115
+            // For each of the sections, add the attempted and achieved criteria per outcome
116
+            foreach ($sections as $section)
117
+            {
118
+                if($section->outcomes_achieved!=NULL)
119
+                {
120
+                    $section_outcomes_achieved =json_decode($section->outcomes_achieved, true);
121
+                    $section_outcomes_attempted =json_decode($section->outcomes_attempted, true);
122
+                    for($i=1; $i<=count($outcomes_attempted); $i++)
123
+                    {
124
+                        $outcomes_achieved[$i]+=$section_outcomes_achieved[$i];
125
+                        $outcomes_attempted[$i]+=$section_outcomes_attempted[$i];
126
+                    }
127
+                }
128
+            }
129
+        }
130
+
131
+        $section_ids = Course::
132
+        	where('code', $code)
133
+        	->where('number', $number)
134
+        	->where('semester_id', $semester->id)
135
+        	->lists('id');
136
+
137
+            $activities = Activity::with('course')->whereNotNull('transforming_actions')->whereIn('course_id', $section_ids)->orderBy('name')->groupBy('transforming_actions')->get();
138
+
139
+		return View::make('local.managers.shared.grouped_course', compact('role', 'title', 'grouped_courses', 'outcomes', 'outcomes_attempted', 'outcomes_achieved', 'sections', 'transforming_actions', 'activities'));
140
+	}
141
+
142
+	/**
143
+	 * Printable version for a course (grouped sections)
144
+	 */
145
+
146
+	public function print_course($code, $number, $semester_code)
147
+	{
148
+        $title=$code.$number.' ('.$semester_code.')';
149
+        $semester = Semester::where('code', $semester_code)->first();
150
+        $role = Auth::user()->role;
151
+
152
+        $grouped_courses = Course::
153
+        	where('code', $code)
154
+        	->where('number', $number)
155
+        	->where('semester_id', $semester->id)
156
+        	->groupBy(array('code', 'number'))->get();
157
+
158
+        $outcomes = Outcome::orderBy('name', 'asc')->get();
159
+        $outcomeCount = Outcome::all()->count();
160
+
161
+        foreach ($grouped_courses as $index => $grouped_course)
162
+        {
163
+            // Blank outcomes for one course
164
+            $outcomes_achieved = array_fill(1, $outcomeCount, 0);
165
+            $outcomes_attempted = array_fill(1, $outcomeCount, 0);
166
+
167
+            // Find sections for this course
168
+            $sections = Course::
169
+            	where('code', $grouped_course->code)
170
+            	->where('number', $grouped_course->number)
171
+            	->where('semester_id', $grouped_course->semester_id)
172
+            	->get();
173
+
174
+            // For each of the sections, add the attempted and achieved criteria per outcome
175
+            foreach ($sections as $section)
176
+            {
177
+                if($section->outcomes_achieved!=NULL)
178
+                {
179
+                    $section_outcomes_achieved =json_decode($section->outcomes_achieved, true);
180
+                    $section_outcomes_attempted =json_decode($section->outcomes_attempted, true);
181
+                    for($i=1; $i<=count($outcomes_attempted); $i++)
182
+                    {
183
+                        $outcomes_achieved[$i]+=$section_outcomes_achieved[$i];
184
+                        $outcomes_attempted[$i]+=$section_outcomes_attempted[$i];
185
+                    }
186
+                }
187
+            }
188
+        }
189
+
190
+        $section_ids = Course::
191
+        	where('code', $code)
192
+        	->where('number', $number)
193
+        	->where('semester_id', $semester->id)
194
+        	->lists('id');
195
+
196
+        // Activities with transforming actions
197
+       	$activities = Activity::with('course')->whereNotNull('transforming_actions')->whereIn('course_id', $section_ids)->orderBy('name')->groupBy('transforming_actions')->get();
198
+
199
+		return View::make('local.managers.shared.print_course', compact('role', 'title', 'grouped_courses', 'outcomes', 'outcomes_attempted', 'outcomes_achieved', 'sections', 'activities'));
200
+	}
201
+
202
+
203
+    private function excelConv(&$value, $key)
204
+    {
205
+        Log::debug('CoursesController@excelConv');
206
+
207
+        $value = iconv('UTF-8', 'Windows-1252//IGNORE', $value);
208
+
209
+    }
210
+
211
+
212
+
213
+
214
+    public function exportGrades($id)
215
+    {
216
+        // Find course
217
+        $course = Course::find($id);
218
+
219
+        // Set file name and open file
220
+        $filename = 'olas_student_grades_'.$course->code.$course->number.$course->section.$course->semester->code.'_'.time().'.csv';
221
+        $file= fopen('exports/'.$filename, 'w');
222
+
223
+        // To add an empty line to the csv
224
+        $empty_line = array(' ');
225
+
226
+        // Set section name at the top
227
+        fputcsv($file, array($course->code.$course->number.$course->section.' ('.$course->semester->code.')'));
228
+        fputcsv($file, $empty_line);
229
+
230
+        // Individual activity tables -----------------------------------------
231
+
232
+        // For each activity
233
+        foreach($course->assessedActivities as $activity) {
234
+            // Set name
235
+
236
+            $activity_name = iconv('UTF-8', 'Windows-1252//IGNORE', $activity->name);
237
+            fputcsv($file, array($activity_name));
238
+
239
+            // Get assessments
240
+            $assessments = DB::table('assessments')->join('students', 'assessments.student_id','=','students.id')->where('activity_id', '=', $activity->id)->orderBy('assessments.id', 'asc')->get();
241
+
242
+            // Get rubric contents
243
+            $rubric_contents = json_decode($activity->rubric->contents);
244
+
245
+            $criterion_list = array('#', 'Name', 'School', 'Major');
246
+
247
+            // Set criterion names
248
+            foreach ($rubric_contents as $criterion) {
249
+                $criterion_list[] = $criterion->name;
250
+            }
251
+            $criterion_list[] = 'Percentage';
252
+            $criterion_list[] = 'Comments';
253
+
254
+            // Change encoding to be compatible with Excel
255
+            array_walk($criterion_list, array($this,'excelConv'));
256
+
257
+            fputcsv($file, $criterion_list);
258
+
259
+            // Set student info and scores for each criterion
260
+            foreach ($assessments as $assessment) {
261
+                $student = Student::find($assessment->student_id);
262
+                $scores = json_decode($assessment->scores, true);
263
+                fputcsv($file, array_merge(
264
+                    array($student->number, $student->name, $student->school_code, $student->conc_code),
265
+                    $scores,
266
+                    array($assessment->percentage, $assessment->comments)));
267
+            }
268
+            fputcsv($file, $empty_line);
269
+        }
270
+
271
+        // Table with all activities and grades
272
+
273
+        // Set headers for table
274
+        $activity_list = array('#', 'Name', 'School', 'Major');
275
+        foreach($course->assessedActivities as $activity) {
276
+            $activity_list[]=$activity->name;
277
+        }
278
+        $activity_list[] = 'Average';
279
+
280
+        fputcsv($file, $empty_line);
281
+        fputcsv($file, array('All Activities'));
282
+
283
+        // Change encoding to be compatible with Excel
284
+        array_walk($activity_list, array($this,'excelConv'));
285
+
286
+        fputcsv($file, $activity_list);
287
+
288
+        // For each student, set info
289
+        foreach ($activity->course->students as $student) {
290
+            $student_record= array($student->number, $student->name, $student->school_code, $student->conc_code);
291
+
292
+            $assessed_activities = $course->assessedActivities;
293
+            // Iterate over activities, get percentages and add them to the record array
294
+            foreach ($assessed_activities as $activity) {
295
+                $percentage = DB::table('assessments')
296
+                    ->select('percentage')
297
+                    ->where('student_id', '=', $student->id)
298
+                    ->where('activity_id', '=', $activity->id)->first();
299
+
300
+                $student_record[] = $percentage->percentage;
301
+            }
302
+
303
+            // Average
304
+            $student_record[] = array_sum(
305
+                                    array_slice(
306
+                                        $student_record,
307
+                                        4,
308
+                                        count($assessed_activities)
309
+                                    )
310
+                                )/count($assessed_activities);
311
+
312
+            fputcsv($file, $student_record);
313
+        }
314
+
315
+        // Close the file
316
+        fclose($file);
317
+
318
+        // Return response for download
319
+        return Response::download('exports/'.$filename);
320
+    }
321
+
322
+    public function reassign()
323
+    {
324
+        $title = 'Course Management';
325
+        $programs = Program::with('school')->orderBy('name', 'asc')->get();
326
+        $users = User::select(array('id', 'first_name', 'surnames'))->orderBy('surnames', 'asc')->orderBy('first_name', 'asc')->get();
327
+        $semesters = Semester::where('is_visible', '1')->orderBy('start', 'asc')->get();
328
+        return View::make('local.managers.admins.reassign', compact('title', 'programs', 'users', 'semesters'));
329
+    }
330
+
331
+    public function update()
332
+    {
333
+        if(Input::get('reassign_program'))
334
+        {
335
+            $code = strtoupper(trim(str_replace('*', '%', Input::get('code'))));
336
+            $number = strtoupper(trim(str_replace('*', '%', Input::get('number'))));
337
+            $section = strtoupper(trim(str_replace('*', '%', Input::get('section'))));
338
+
339
+            if(!$code && !$number && !$section)
340
+            {
341
+                Session::flash('status','danger');
342
+                Session::flash('message','At least one field is required.');
343
+
344
+                return Redirect::back()->withInput();
345
+            }
346
+
347
+            $update_query = Course::orderBy('code', 'asc')->orderBy('number', 'asc')->orderBy('section', 'asc');
348
+            $fetch_query = Course::orderBy('code', 'asc')->orderBy('number', 'asc')->orderBy('section', 'asc');
349
+
350
+            if($code)
351
+            {
352
+                $update_query->where('code', 'LIKE', $code);
353
+                $fetch_query->where('code', 'LIKE', $code);
354
+            }
355
+
356
+            if($number)
357
+            {
358
+                $update_query->where('number', 'LIKE', $number);
359
+                $fetch_query->where('number', 'LIKE', $number);
360
+            }
361
+
362
+            if($section)
363
+            {
364
+                $update_query->where('section', 'LIKE', $section);
365
+                $fetch_query->where('section', 'LIKE', $section);
366
+            }
367
+            // If section is blank, results can be grouped by code and number
368
+            else
369
+            {
370
+                $fetch_query->groupBy(array('code', 'number'));
371
+            }
372
+
373
+            $affected_rows = $fetch_query->get();
374
+
375
+            // If there are results
376
+            if(!$affected_rows->isEmpty())
377
+            {
378
+                // Try updating and flash success message if successful
379
+                if($update_query->update(array('program_id'=>Input::get('program'))))
380
+                {
381
+                    Session::flash('courses', json_encode($affected_rows));
382
+                    Session::flash('status', 'success');
383
+                    Session::flash('message', 'Courses succesfully updated.');
384
+
385
+                    if($section)
386
+                    {
387
+                        Session::flash('show_sections', true);
388
+                    }
389
+
390
+                }
391
+                else
392
+                {
393
+                    Session::flash('status', 'danger');
394
+                    Session::flash('message', 'Error reassigning courses to a program. Try again later.');
395
+                }
396
+            }
397
+            else
398
+            {
399
+                Session::flash('status', 'warning');
400
+                Session::flash('message', 'No courses matched your criteria. Try to broaden your search.');
401
+            }
402
+
403
+            return Redirect::back()->withInput();
404
+        }
405
+        elseif(Input::get('reassign_professor'))
406
+        {
407
+
408
+            $code = strtoupper(trim(str_replace('*', '%', Input::get('code_prof'))));
409
+            $number = strtoupper(trim(str_replace('*', '%', Input::get('number_prof'))));
410
+            $section = strtoupper(trim(str_replace('*', '%', Input::get('section_prof'))));
411
+            $user = Input::get('user_prof');
412
+            $semester = Input::get('semester_prof');
413
+
414
+
415
+            if(!$code || !$number || !$section)
416
+            {
417
+                Session::flash('status','danger');
418
+                Session::flash('message','Error assigning professor to a course. All fields are required.');
419
+
420
+                return Redirect::back()->withInput();
421
+            }
422
+
423
+            $update_query = Course::
424
+                where('code', '=', $code)
425
+                ->where('number', '=', $number)
426
+                ->where('section', '=', $section)
427
+                ->where('semester_id', '=', $semester);
428
+            $fetch_query = Course::
429
+                where('code', '=', $code)
430
+                ->where('number', '=', $number)
431
+                ->where('section', '=', $section)
432
+                ->orderBy('code', 'asc')
433
+                ->orderBy('number', 'asc')
434
+                ->orderBy('section', 'asc');
435
+
436
+            $affected_rows = $fetch_query->get();
437
+
438
+            // If there are results
439
+            if(!$affected_rows->isEmpty())
440
+            {
441
+                try
442
+                {
443
+                    // Try updating and flash success message if successful
444
+                    $update_query->update(array('user_id'=>$user));
445
+
446
+                    Session::flash('status', 'success');
447
+                    Session::flash('message', 'Successfully changed professor for '.$code.$number.'-'.$section);
448
+                }
449
+                catch(Exception $e)
450
+                {
451
+                    Session::flash('status', 'danger');
452
+                    Session::flash('message', 'An error occurred when changing professor for '.$code.$number.'-'.$section).'.';
453
+                }
454
+            }
455
+            else
456
+            {
457
+                Session::flash('status', 'warning');
458
+                Session::flash('message', 'No course matches your criteria. Try again with different values.');
459
+            }
460
+
461
+            return Redirect::back()->withInput();
462
+        }
463
+        else
464
+        {
465
+
466
+        }
467
+    }
468
+
469
+
470
+}

+ 397
- 0
app/controllers/CriteriaController.php ファイルの表示

@@ -0,0 +1,397 @@
1
+<?php
2
+
3
+class CriteriaController extends \BaseController {
4
+
5
+    /**
6
+     * Display a listing of the resource.
7
+     *
8
+     * @return Response
9
+     */
10
+    public function fetchCriterion()
11
+    {
12
+        return Criterion::find(Input::get('id'));
13
+    }
14
+
15
+    public function fetchCriterionWithTrashed()
16
+    {
17
+        return Criterion::withTrashed()->find(Input::get('id'));
18
+    }
19
+
20
+
21
+    public function isCriterionUnique($input, $existing_criterion = NULL)
22
+    {
23
+        // dd($input);
24
+        Log::info('isCriterionUnique');
25
+
26
+        if(Input::get('program_id')!=0)
27
+            $program_id = $input['program_id'];
28
+        else
29
+            $program_id = NULL;
30
+
31
+        $saved_criterion = Criterion::
32
+            withTrashed()
33
+            ->where('name', '=', $input['name'])
34
+            ->where('outcome_id', '=', $input['outcome_id'])
35
+            ->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
+            ->first();
41
+
42
+    
43
+
44
+        if($saved_criterion)
45
+            return false;
46
+        else
47
+            return true;
48
+    }
49
+
50
+    private function cleanInput()
51
+    {
52
+        $clean_input = array();
53
+
54
+        $clean_input['name'] = trim(preg_replace('/\t+/', '', Input::get('name')));
55
+
56
+
57
+        $trimmed = trim(preg_replace('/\t+/', '', Input::get('subcriteria')));
58
+
59
+        Log::info('trimmed 1 -->'.$trimmed.'<--');
60
+
61
+
62
+        if($trimmed ==''){
63
+            $trimmed = NULL;
64
+        }
65
+        else{
66
+            $trimmed = json_encode(preg_split('/\r\n/', $trimmed));
67
+        }
68
+
69
+        Log::info('trimmed 2 -->'.$trimmed.'<--');
70
+
71
+
72
+        $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')));
79
+        $clean_input['copyright'] = trim(preg_replace('/\t+/', '', Input::get('copyright')));
80
+        $clean_input['notes'] = trim(preg_replace('/\t+/', '', Input::get('notes')));
81
+
82
+        return $clean_input;
83
+    }
84
+
85
+    private function makeValidator($clean_input)
86
+    {
87
+        /** Validation rules */
88
+        return Validator::make(
89
+            array(
90
+                'name' => $clean_input['name'],
91
+                'subcriteria' => $clean_input['subcriteria'],
92
+                '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
+                'notes' => $clean_input['notes'],
98
+                'copyright' => $clean_input['copyright'],
99
+            ),
100
+            array(
101
+                'name' => 'required|string',
102
+                'subcriteria' => 'string',
103
+                'outcome_id' => 'required|numeric|integer',
104
+                'description12' => 'required|string',
105
+                'description34' => 'required|string',
106
+                'description56' => 'required|string',
107
+                'description78' => 'required|string',
108
+                'notes' => 'string',
109
+                '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.',
116
+            )
117
+        );
118
+    }
119
+
120
+    /**
121
+     * Create a new criterion.
122
+     *
123
+     * @return Redirect Redirect back to form page
124
+     */
125
+    public function create()
126
+    {
127
+        $clean_input = $this->cleanInput();
128
+
129
+        /** Validation rules */
130
+        $validator = $this->makeValidator($clean_input);
131
+
132
+        /** If validation fails */
133
+        if ($validator->fails())
134
+        {
135
+            /** Prepare error message */
136
+            $message = '<p>Error(s) creating a new Criterion:</p><ul>';
137
+
138
+            foreach ($validator->messages()->all('<li>:message</li>') as $validationError)
139
+            {
140
+                $message.=$validationError;
141
+            }
142
+
143
+            $message.='</ul>';
144
+
145
+            /** Send error message and old data */
146
+            Session::flash('status', 'danger');
147
+            Session::flash('message', $message);
148
+            return Redirect::to('criteria')->withInput();
149
+        }
150
+        else
151
+        {
152
+            // Check criterion uniqueness
153
+            if(!$this->isCriterionUnique($clean_input))
154
+            {
155
+                /** Send error message and old data */
156
+                Session::flash('status', 'danger');
157
+                Session::flash('message', 'This criterion is a duplicate of an already saved criterion because its name and associated program are the same.');
158
+                return Redirect::to('criteria')->withInput();
159
+            }
160
+
161
+            /** Instantiate new criterion */
162
+            $criterion = new Criterion;
163
+            $criterion->name= $clean_input['name'];
164
+            $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
+
171
+            if(Input::get('copyright'))
172
+                $criterion->copyright = $clean_input['copyright'];
173
+
174
+            if(Input::get('notes'))
175
+                $criterion->notes = $clean_input['notes'];
176
+
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
+
183
+
184
+            /** If criterion is saved, send success message */
185
+            if($criterion->save())
186
+            {
187
+                Session::flash('status', 'success');
188
+                Session::flash('message', 'Criterion created: "'.$criterion->name.'".');
189
+                return Redirect::to('criteria')->withInput(Input::only('outcome_id'));
190
+            }
191
+
192
+            /** If saving fails, send error message and old data */
193
+            else
194
+            {
195
+                Session::flash('status', 'danger');
196
+                Session::flash('message', '<p>Error creating Criterion. Please try again later.</p>');
197
+                return Redirect::to('learning-outcomes-criteria')->withInput();
198
+            }
199
+        }
200
+    }
201
+
202
+    public function edit()
203
+    {
204
+        $title = "Criteria";
205
+        $outcomes = Outcome::orderBy('name', 'ASC')->get();
206
+        $schools = School::orderBy('name', 'ASC')->get();
207
+        $criteria = Criterion::withTrashed()->orderBy('name', 'ASC')->get();
208
+        $programs = Program::orderBy('name', 'ASC')->get();
209
+
210
+        return View::make('local.managers.admins.criteria', compact('title', 'outcomes', 'schools', 'criteria', 'programs'));
211
+    }
212
+
213
+    public function update()
214
+    {
215
+        $criterion = Criterion::withTrashed()->find(Input::get('id'));
216
+
217
+        $clean_input = $this->cleanInput();
218
+
219
+        /** Validation rules */
220
+        $validator = $this->makeValidator($clean_input);
221
+
222
+        /** If validation fails */
223
+        if ($validator->fails())
224
+        {
225
+            /** Prepare error message */
226
+            $message = 'Error(s) updating the Criterion: <ul>';
227
+
228
+            foreach ($validator->messages()->all('<li>:message</li>') as $validationError)
229
+            {
230
+                $message.=$validationError;
231
+            }
232
+
233
+            $message.='</ul>';
234
+
235
+            /** Send error message and old data */
236
+            Session::flash('status', 'danger');
237
+            Session::flash('message', $message);
238
+            return Redirect::back()->withInput();
239
+        }
240
+        else
241
+        {
242
+
243
+            // // Check criterion uniqueness
244
+            // if(!$this->isCriterionUnique($clean_input, $criterion))
245
+            // {
246
+            //     /** Send error message and old data */
247
+            //     Session::flash('status', 'danger');
248
+            //     Session::flash('message', 'This criterion is a duplicate of an already saved criterion because its name, assoaciated school or program, and progress indicators are the same.');
249
+            //     return Redirect::to('criteria')->withInput();
250
+            // }
251
+
252
+            /** Set info */
253
+            $criterion->name= $clean_input['name'];
254
+            $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'];
260
+
261
+            // Set program
262
+            if(Input::get('program_id')!=0)
263
+                $criterion->program_id = Input::get('program_id');
264
+            else
265
+                $criterion->program_id = NULL;
266
+
267
+            // Set status
268
+            if(Input::get('status')==0)
269
+                $criterion->deleted_at = date('Y-m-d H:i:s');
270
+            else
271
+                $criterion->deleted_at = NULL;
272
+
273
+            if(Input::get('copyright'))
274
+                $criterion->copyright = $clean_input['copyright'];
275
+            else
276
+                $criterion->copyright=NULL;
277
+
278
+            if(Input::get('notes'))
279
+                $criterion->notes = $clean_input['notes'];
280
+            else
281
+                $criterion->notes=NULL;
282
+
283
+            /** If criterion is updated, send success message */
284
+            if($criterion->save())
285
+            {
286
+                Session::flash('status', 'success');
287
+                Session::flash('message', 'Updated criterion: "'.$criterion->name.'"');
288
+                return Redirect::back();
289
+            }
290
+
291
+            /** If saving fails, send error message and old data */
292
+            else
293
+            {
294
+                Session::flash('status', 'danger');
295
+                Session::flash('message', 'Error updating the Criterion. Please try again later.');
296
+                return Redirect::back()->withInput();
297
+            }
298
+        }
299
+    }
300
+
301
+    public function index()
302
+    {
303
+        $title = "Learning Outcomes and Criteria";
304
+        $outcomes = Outcome::orderBy('name', 'ASC')->get();
305
+        $schools = School::orderBy('name', 'ASC')->get();
306
+        $criteria = Criterion::withTrashed()->orderBy('name', 'ASC')->get();
307
+
308
+        return View::make('global.view-learning-outcomes-criteria', compact('title', 'outcomes', 'schools', 'criteria'));
309
+
310
+    }
311
+
312
+    public function destroy()
313
+    {
314
+        $criterion = Criterion::withTrashed()->find(Input::get('id'));
315
+        if(!$criterion->trashed())
316
+        {
317
+            try
318
+            {
319
+                $criterion->delete();
320
+                Session::flash('status', 'success');
321
+                Session::flash('message', 'Deactivated criterion: "'.$criterion->name.'"');
322
+            }
323
+            catch (Exception $e)
324
+            {
325
+                Session::flash('status', 'danger');
326
+                Session::flash('message', 'Error deactivating criterion."'.$criterion->name.'"');
327
+            }
328
+            return Redirect::back();
329
+        }
330
+        else
331
+        {
332
+            try
333
+            {
334
+                $criterion->restore();
335
+                Session::flash('status', 'success');
336
+                Session::flash('message', 'Reactivated criterion: "'.$criterion->name.'"');
337
+            }
338
+            catch (Exception $e)
339
+            {
340
+                Session::flash('status', 'danger');
341
+                Session::flash('message', 'Error reactivating criterion: "'.$criterion->name.'".');
342
+            }
343
+            return Redirect::back();
344
+
345
+        }
346
+    }
347
+
348
+    public function filterCriteria()
349
+    {
350
+        switch (Input::get('filter'))
351
+        {
352
+            case 'all':
353
+                return Criteria::all();
354
+                break;
355
+
356
+            case 'school':
357
+                // If scoord
358
+                if(Auth::user()->role == '2')
359
+                {
360
+
361
+                    // Fetch all the programs whose school is the user's
362
+                    $program_ids = DB::table('programs')->where('school_id', Auth::user()->school_id)->lists('id');
363
+
364
+                    // Return all criteria belonging to any of those programs
365
+                    return Criterion::
366
+                        whereIn('program_id', $program_ids)
367
+                        ->orderBy('name', 'ASC')
368
+                        ->get();
369
+                }
370
+
371
+                // If pcoord
372
+                else
373
+                {
374
+                    // Fetch all the programs from the user's school;
375
+                    $program_ids = DB::table('programs')->where('school_id', Auth::user()->programs[0]->school->id)->lists('id');
376
+
377
+                    return Criterion::
378
+                        whereIn('program_id', $program_ids)
379
+                        ->orderBy('name', 'ASC')
380
+                        ->get();
381
+                }
382
+
383
+                break;
384
+
385
+            case 'program':
386
+                return Criterion::
387
+                    whereIn('program_id', Auth::user()->programs->lists('id'))
388
+                    ->orderBy('name', 'ASC')
389
+                    ->get();
390
+                break;
391
+
392
+            default:
393
+                return Criteria::all();
394
+                break;
395
+        }
396
+    }
397
+}

+ 93
- 0
app/controllers/FeedbackController.php ファイルの表示

@@ -0,0 +1,93 @@
1
+<?php
2
+
3
+class FeedbackController extends \BaseController {
4
+
5
+	/**
6
+	 * Show the form for creating a new resource.
7
+	 *
8
+	 * @return Response
9
+	 */
10
+	public function create()
11
+	{
12
+		$title = "Feedback Form";
13
+		$schools = School::orderBy('name','asc');
14
+		$user = Auth::user();
15
+		return View::make('global.feedback', compact('title', 'schools', 'user'));
16
+	}
17
+
18
+	public function send()
19
+	{
20
+        /** Validation rules */
21
+        $validator = Validator::make(
22
+            array(
23
+                'type' => Input::get('type'),
24
+                'email' => Input::get('email'),
25
+                'comment' => Input::get('comment')
26
+            ),
27
+            array(
28
+                'type' => 'required|numeric|integer',
29
+                'email' => 'required|email',
30
+                'comment' => 'required'
31
+            )
32
+        );
33
+
34
+        /** If validation fails */
35
+        if ($validator->fails())
36
+        {
37
+            /** Prepare error message */
38
+            $message = '<p>Error(s) in the form</p><ul>';
39
+
40
+            foreach ($validator->messages()->all('<li>:message</li>') as $validationError)
41
+            {
42
+                $message.=$validationError;
43
+            }
44
+
45
+            $message.='</ul>';
46
+
47
+            /** Send error message and old data */
48
+            Session::flash('status', 'warning');
49
+            Session::flash('message', $message);
50
+            return Redirect::back()->withInput();
51
+        }
52
+        else
53
+        {
54
+        	$data = array('type'=>'', 'comment'=>'', 'email'=>'');
55
+        	$data['comment']=Input::get('comment');
56
+        	$data['email']=Input::get('email');
57
+
58
+        	switch (Input::get('type')) {
59
+        		case '0':
60
+        			$data['type']='Error Report';
61
+        			break;
62
+
63
+        		case '1':
64
+        			$data['type']='Question';
65
+        			break;
66
+
67
+        		case '2':
68
+        			$data['type']='Suggestion';
69
+        			break;
70
+
71
+        		case '3':
72
+        			$data['type']='Other';
73
+        			break;
74
+
75
+        		default:
76
+        			$data['type']='Other';
77
+        			break;
78
+        	}
79
+
80
+          	Mail::send('emails.feedback-email-copy', $data, function($message){
81
+        		$message
82
+        		->to(Input::get('email'), Auth::user()->first_name.' '.Auth::user()->surnames)
83
+                ->cc('oeae.uprrp@upr.edu')
84
+        		->subject('Feedback for OLAS');
85
+    		});
86
+
87
+            Session::flash('status', 'success');
88
+            Session::flash('message', '<p>Success! Check your email for a copy of your message. Thank you for your feedback. </p>');
89
+            return Redirect::back();
90
+        }
91
+	}
92
+
93
+}

+ 568
- 0
app/controllers/FiveYearPlansController.php ファイルの表示

@@ -0,0 +1,568 @@
1
+<?php
2
+
3
+class FiveYearPlansController extends \BaseController {
4
+
5
+	/**
6
+	 * Checks whether a user has permission to view a page in this controller
7
+	 *
8
+	 * @var User $user				Authenticated user
9
+	 */
10
+	private function userHasAccess($program_id)
11
+	{
12
+		$user = Auth::user();
13
+
14
+		switch ($user->role) {
15
+			case '3':
16
+				$programs = $user->programs->lists('id');
17
+
18
+				// If program does not belong to user, show 403
19
+				if(!in_array($program_id, $programs))
20
+					return false;
21
+
22
+				break;
23
+
24
+			case '2':
25
+				$programs = Program::where('school_id', $user->school_id)->lists('id');
26
+
27
+				// If program is not in user's school, show 403
28
+				if(!in_array($program_id, $programs))
29
+					return false;
30
+
31
+				break;
32
+			case '4':
33
+				return false;
34
+		}
35
+
36
+		return true;
37
+	}
38
+
39
+	/**
40
+	 * Page to create a new plan for the current quinquennium
41
+	 * @var string $title			Title for page
42
+	 * @var Program $programs	Collection of programs user has access to
43
+	 * @var Outcome $outcomes      List of outcomes ordered by name
44
+	 * @var User $user      Currently logged user
45
+	 * @var Course $courses      Courses for a particular program
46
+	 */
47
+	public function create(Program $program)
48
+	{
49
+		$title = 'New Five Year Plan for '.$program->name;
50
+		$user = Auth::user();
51
+		$outcomes = Outcome::orderBy('name')->get();
52
+
53
+		$current_quinquennium = Quinquennium::
54
+			where('start_date', '<=', date('Y-m-d'))
55
+			->where('end_date', '>=', date('Y-m-d'))
56
+			->first();
57
+
58
+		$courses = Course::
59
+			select('id', 'code', 'number', 'name')
60
+			->where('program_id', $program->id)
61
+			->groupBy('name')
62
+			->orderBy('code','ASC')
63
+			->orderBy('number','ASC')
64
+			->orderBy('name','ASC')
65
+			->get();
66
+
67
+		// Check if user can create a plan
68
+		if(!$this->userHasAccess($program->id))
69
+		{
70
+			return View::make('global.403');
71
+		}
72
+
73
+		return View::make('local.managers.shared.create_five_year_plan', compact('title', 'program', 'current_quinquennium', 'outcomes', 'courses'));
74
+	}
75
+
76
+	/**
77
+	 * Lists five year plans by quinquennium and program
78
+	 * @var string $title			Title for page
79
+	 * @var Program $programs	Collection of programs user has access to
80
+	 * @var User $user				Authenticated user
81
+	 */
82
+	public function index()
83
+	{
84
+		$title = 'Five Year Plans';
85
+		$user = Auth::user();
86
+		$quinquenniums = Quinquennium::all();
87
+		$current_quinquennium = Quinquennium::
88
+			where('start_date', '<=', date('Y-m-d'))
89
+			->where('end_date', '>=', date('Y-m-d'))
90
+			->first();
91
+
92
+		switch ($user->role) {
93
+			case '1':
94
+				$programs = Program::all();
95
+				break;
96
+			case '2':
97
+				$programs = Program::where('school_id', $user->school_id)->get();
98
+				break;
99
+			case 3:
100
+				$programs = $user->programs;
101
+				break;
102
+			default:
103
+				App::abort('404');
104
+				break;
105
+		}
106
+
107
+		return View::make('local.managers.shared.index_five_year_plans', compact('title', 'quinquenniums', 'programs', 'current_quinquennium'));
108
+	}
109
+
110
+	/**
111
+	 * Processes and stores five year plan for a particular program
112
+	 *
113
+	 * @var array $input			JSON object containing new plan information
114
+	 * @var FiveYearPlan $plan			Instance of newly created plan
115
+	 * @var FypPart $mini_plan			Instance of limited annual plan belonging to five year plan
116
+	 * @var string response			Encoded JSON string containing response for the browser
117
+	 * @return string 			Encoded JSON string
118
+	 */
119
+	public function store()
120
+	{
121
+		header('Content-Type: application/json');
122
+
123
+		$input = json_decode(Input::get('five_year_plan')); // Get plan as string
124
+
125
+		DB::beginTransaction();
126
+
127
+		try {
128
+
129
+			// Create five year plan base structure
130
+			$plan = FiveYearPlan::create(array(
131
+					'program_id' => $input->program_id,
132
+					'quinquennium_id' => $input->quinquennium_id,
133
+				)
134
+			);
135
+
136
+			foreach ($input->mini_plans as $mini_plan_input) {
137
+
138
+				$mini_plan_validator = Validator::make(
139
+				    array(
140
+				        'year_start' => $mini_plan_input->year_start,
141
+						'year_end' => $mini_plan_input->year_end
142
+				    ),
143
+				    array(
144
+				        'year_start' => 'required|integer|digits:4',
145
+				        'year_end' => 'required|integer|digits:4'
146
+				    )
147
+				);
148
+
149
+				/** If validation fails */
150
+				if ($mini_plan_validator->fails())
151
+				{
152
+				    $response = array(
153
+						'status' => 'danger',
154
+					);
155
+				}
156
+
157
+
158
+				$mini_plan = FypPart::create(array(
159
+						'five_year_plan_id' => $plan->id,
160
+						'year_start' => $mini_plan_input->year_start,
161
+						'year_end' => $mini_plan_input->year_end,
162
+					)
163
+				);
164
+
165
+				foreach ($mini_plan_input->outcomes as $index => $outcome_input) {
166
+
167
+					$outcomes_validator = Validator::make(
168
+					    array(
169
+					        'fyp_part_id'=> $mini_plan->id,
170
+					        'outcome_id'=> $outcome_input->id,
171
+					        'objectives'=> json_encode($outcome_input->objectives),
172
+					        'courses'=> json_encode($outcome_input->courses),
173
+					    ),
174
+					    array(
175
+					        'fyp_part_id'=> 'required|integer',
176
+					        'outcome_id'=> 'required|integer',
177
+					        'objectives'=> 'required',
178
+					        'courses'=> 'required',
179
+					    )
180
+					);
181
+
182
+					/** If validation fails */
183
+					if ($outcomes_validator->fails())
184
+					{
185
+					    $response = array(
186
+							'status' => 'danger',
187
+						);
188
+					}
189
+
190
+					FypPartOutcome::create(array(
191
+							'fyp_part_id'=> $mini_plan->id,
192
+							'outcome_id'=> $outcome_input->id,
193
+							'objectives'=> json_encode($outcome_input->objectives),
194
+							'courses'=> json_encode($outcome_input->courses),
195
+							'display_order'=> $index + 1,
196
+						)
197
+					);
198
+				}
199
+			}
200
+
201
+
202
+			DB::commit();
203
+
204
+			Session::flash('status', 'success');
205
+			Session::flash('message', 'Five Year Plan created. You can review it below. Click the Edit button if you want to make any changes. To submit your plan, click the Submit button. Please note that submitted plans are final.');
206
+
207
+			$response = array(
208
+				'status' => 'success',
209
+				'message' => $input->quinquennium_id,
210
+				'redirect_url' => URL::action('FiveYearPlansController@show', array('program'=> $plan->program_id, 'five_year_plan'=> $plan->id))
211
+			);
212
+
213
+			echo json_encode($response);
214
+			return;
215
+
216
+		} catch (Exception $e) {
217
+
218
+			DB::rollBack();
219
+
220
+			$response = array(
221
+				'status' => 'danger',
222
+				'message' => $e->getMessage()
223
+			);
224
+
225
+			echo json_encode($response);
226
+
227
+		}
228
+	}
229
+
230
+
231
+	/**
232
+	 * Shows five year plan
233
+	 *
234
+	 * @param Program $program			Program to which the plan belongs to
235
+	 * @param FiveYearPlan $plan			An instance of the Five Year Plan to show
236
+	 * @var string $quinquennium_start_date		Year when the quinquennium starts
237
+	 * @var string $quinquennium_end_date		Year when the quinquennium ends
238
+	 * @var string title			Title of the page
239
+	 * @var Program $programs			Logged user's program(s)
240
+	 * @var Outcome $outcomes			List of all outcomes
241
+	 */
242
+	public function show(Program $program, FiveYearPlan $plan)
243
+	{
244
+
245
+		$outcomes = Outcome::orderBy('name')->get();
246
+
247
+		$quinquennium_start_date = date('Y', strtotime($plan->quinquennium->start_date));
248
+		$quinquennium_end_date = date('Y', strtotime($plan->quinquennium->end_date));
249
+
250
+		$title = $quinquennium_start_date.'-'.$quinquennium_end_date.' Five Year Plan for '.$program->name;
251
+
252
+		// Check if user can create a plan
253
+		if(!$this->userHasAccess($program->id))
254
+		{
255
+			return View::make('global.403');
256
+		}
257
+
258
+		return View::make('local.managers.shared.show_five_year_plan', compact('title', 'program', 'plan', 'outcomes'));
259
+	}
260
+
261
+	/**
262
+	 * Page to edit a plan for the current quinquennium
263
+	 * @var string $title			Title for page
264
+	 * @var Program $programs	Collection of programs user has access to
265
+	 * @var User $user				Authenticated user
266
+	 */
267
+	public function edit(Program $program, FiveYearPlan $plan)
268
+	{
269
+		$title = 'Edit Five Year Plan for '.$program->name;
270
+		$user = Auth::user();
271
+		$outcomes = Outcome::orderBy('name')->get();
272
+
273
+		$current_quinquennium = Quinquennium::
274
+			where('start_date', '<=', date('Y-m-d'))
275
+			->where('end_date', '>=', date('Y-m-d'))
276
+			->first();
277
+
278
+		$courses = Course::
279
+			select('id', 'code', 'number', 'name')
280
+			->where('program_id', $program->id)
281
+			->groupBy('name')
282
+			->orderBy('code','ASC')
283
+			->orderBy('number','ASC')
284
+			->orderBy('name','ASC')
285
+			->get();
286
+
287
+		// Check if user can create a plan
288
+		if(!$this->userHasAccess($program->id))
289
+		{
290
+			return View::make('global.403');
291
+		}
292
+
293
+		return View::make('local.managers.shared.edit_five_year_plan', compact('title', 'program', 'current_quinquennium', 'outcomes', 'courses', 'plan'));
294
+	}
295
+
296
+	/**
297
+	 * Processes and stores five year plan for a particular program
298
+	 *
299
+	 * @var array $input			JSON object containing new plan information
300
+	 * @var FiveYearPlan $plan			Instance of newly created plan
301
+	 * @var FypPart $mini_plan			Instance of limited annual plan belonging to five year plan
302
+	 * @var string response			Encoded JSON string containing response for the browser
303
+	 * @return string 			Encoded JSON string
304
+	 */
305
+	public function update()
306
+	{
307
+		if(Input::get('submit'))
308
+		{
309
+
310
+		}
311
+		elseif(Input::get('revert'))
312
+		{
313
+
314
+		}
315
+		else
316
+		{
317
+			header('Content-Type: application/json');
318
+
319
+			$input = json_decode(Input::get('five_year_plan')); // Get plan as string
320
+
321
+			DB::beginTransaction();
322
+
323
+			try {
324
+
325
+				$plan = FiveYearPlan::find($input->plan_id);
326
+				$plan->updated_at = date('Y-m-d H:i:s');
327
+				$plan->save();
328
+
329
+				// Delete all annual (mini) plans and consequently, all their outcomes
330
+				FypPart::where('five_year_plan_id', $plan->id)->delete();
331
+
332
+				foreach ($input->mini_plans as $mini_plan_input) {
333
+
334
+					$mini_plan_validator = Validator::make(
335
+					    array(
336
+					        'year_start' => $mini_plan_input->year_start,
337
+							'year_end' => $mini_plan_input->year_end
338
+					    ),
339
+					    array(
340
+					        'year_start' => 'required|integer|digits:4',
341
+					        'year_end' => 'required|integer|digits:4'
342
+					    )
343
+					);
344
+
345
+					/** If validation fails */
346
+					if ($mini_plan_validator->fails())
347
+					{
348
+					    $response = array(
349
+							'status' => 'danger',
350
+						);
351
+					}
352
+
353
+
354
+					$mini_plan = FypPart::create(array(
355
+							'five_year_plan_id' => $plan->id,
356
+							'year_start' => $mini_plan_input->year_start,
357
+							'year_end' => $mini_plan_input->year_end,
358
+						)
359
+					);
360
+
361
+					foreach ($mini_plan_input->outcomes as $index => $outcome_input) {
362
+
363
+						$outcomes_validator = Validator::make(
364
+						    array(
365
+						        'fyp_part_id'=> $mini_plan->id,
366
+						        'outcome_id'=> $outcome_input->id,
367
+						        'objectives'=> json_encode($outcome_input->objectives),
368
+						        'courses'=> json_encode($outcome_input->courses),
369
+						    ),
370
+						    array(
371
+						        'fyp_part_id'=> 'required|integer',
372
+						        'outcome_id'=> 'required|integer',
373
+						        'objectives'=> 'required',
374
+						        'courses'=> 'required',
375
+						    )
376
+						);
377
+
378
+						/** If validation fails */
379
+						if ($outcomes_validator->fails())
380
+						{
381
+						    $response = array(
382
+								'status' => 'danger',
383
+							);
384
+						}
385
+
386
+						FypPartOutcome::create(array(
387
+								'fyp_part_id'=> $mini_plan->id,
388
+								'outcome_id'=> $outcome_input->id,
389
+								'objectives'=> json_encode($outcome_input->objectives),
390
+								'courses'=> json_encode($outcome_input->courses),
391
+								'display_order'=> $index + 1,
392
+							)
393
+						);
394
+					}
395
+				}
396
+
397
+
398
+				DB::commit();
399
+
400
+				Session::flash('status', 'success');
401
+				Session::flash('message', 'Five Year Plan updated.');
402
+
403
+				$response = array(
404
+					'status' => 'success',
405
+					'message' => $input->quinquennium_id,
406
+					'redirect_url' => URL::action('FiveYearPlansController@show', array('program'=> $plan->program_id, 'five_year_plan'=> $plan->id))
407
+				);
408
+
409
+				echo json_encode($response);
410
+				return;
411
+
412
+			} catch (Exception $e) {
413
+
414
+				DB::rollBack();
415
+
416
+				$response = array(
417
+					'status' => 'danger',
418
+					'message' => $e->getMessage().' '.$e->getLine()
419
+				);
420
+
421
+				echo json_encode($response);
422
+
423
+			}
424
+		}
425
+	}
426
+
427
+
428
+	public function msWord(FiveYearPlan $plan)
429
+	{
430
+		try {
431
+
432
+			$filename = 'OLAS Five Year Plan for '.$plan->program->name.' ('.date('d-m-Y').').docx';
433
+			require_once 'PHPWord-0.12.1/src/PhpWord/Autoloader.php';
434
+			\PhpOffice\PhpWord\Autoloader::register();
435
+
436
+			// Instantiate new document
437
+			$phpWord = new \PhpOffice\PhpWord\PhpWord();
438
+
439
+			// -----------------
440
+
441
+
442
+			// $styleTable = array(
443
+			// 	'borderColor'=>'006699',
444
+			   //           	'borderSize'=>6,
445
+			   //          	'cellMargin'=>50);
446
+			// $styleFirstRow = array('bgColor'=>'DD0026');
447
+			// $phpWord->addTableStyle('table', $styleTable, $styleFirstRow);
448
+
449
+			/* Note: any element you append to a document must reside inside of a Section. */
450
+
451
+			// // Adding an empty Section to the document...
452
+			// $section = $phpWord->addSection();
453
+
454
+
455
+			// $table = $section->addTable('table');
456
+			// $table->addRow(3);
457
+			// $table->addCell(3300)->addText("Col 1");
458
+			// $table->addCell(3300)->addText("Col 2");
459
+			// $table->addCell(3300)
460
+			// ->addTable('table')
461
+			// ->addRow(2)->addCell(3300)
462
+			// ->addText("Col 1");
463
+
464
+			// ----------------
465
+
466
+
467
+			// Add new section. All elements must be inside a section
468
+			$section_style = array(
469
+			    'orientation' => 'landscape',
470
+			    'lineNumbering' => array(
471
+			    	'start' => 1
472
+			    ),
473
+			);
474
+			$section = $phpWord->addSection($section_style);
475
+
476
+
477
+			// Table styles
478
+			$table_styles = $tableStyle = array(
479
+			    'borderColor' => 'd0d0d0',
480
+			    'borderSize'  => 6,
481
+			    'cellMargin'  => 500
482
+			);
483
+			$header_styles = array(
484
+				'bgColor' => 'FDFBE2',
485
+				'valign' => 'center',
486
+				'bold' => true,
487
+			);
488
+
489
+			$first_column_styles = array(
490
+				'bgColor' => 'F5F5F5',
491
+				'valign' => 'center',
492
+				'bold' => true,
493
+			);
494
+
495
+			$rowspan_restart = array('vMerge' => 'restart');
496
+			$rowspan_continue = array('vMerge' => 'continue');
497
+
498
+
499
+			foreach($plan->fypParts as $number => $mini_plan)
500
+			{
501
+				$table = $section->addTable('table'.$number, $table_styles);
502
+
503
+				// Header row
504
+				$table->addRow(700, array('exactHeight'=>true));
505
+				$table->addCell(3300, $header_styles)->addText("Academic Year");
506
+				$table->addCell(3300, $header_styles)->addText("Learning Outcome to be assessed");
507
+				$table->addCell(3300, $header_styles)->addText("Learning Objectives");
508
+				$table->addCell(3300, $header_styles)->addText("Courses to use for assessment");
509
+
510
+				// Body
511
+				foreach($mini_plan->fypPartOutcomes as $index => $outcome)
512
+				{
513
+					$table->addRow();
514
+
515
+					// If outcome is the first, include multi-row year column
516
+					if($index == 0)
517
+					{
518
+						$table->addCell(3300, array_merge($first_column_styles, $rowspan_restart))->addText($mini_plan->year_start.'-'.$mini_plan->year_end);
519
+					}
520
+					else
521
+					{
522
+						$table->addCell(3300, array_merge($first_column_styles, $rowspan_continue))->addText('');
523
+					}
524
+
525
+					// Outcome name
526
+					$table->addCell(3300)->addText($outcome->outcome->name);
527
+
528
+					// Objectives
529
+					$cell = $table->addCell(3300);
530
+
531
+					foreach(json_decode($outcome->objectives) as $objective)
532
+					{
533
+						$cell->addText('• '.$objective->text);
534
+					}
535
+
536
+					// Courses
537
+					$cell = $table->addCell(3300);
538
+
539
+					foreach(json_decode($outcome->courses) as $course)
540
+					{
541
+						$cell->addText(trim('• '.$course->code.$course->number.': '.$course->name));
542
+					}
543
+				}
544
+
545
+				$section->addTextBreak(2);
546
+			}
547
+
548
+
549
+
550
+			// Saving the document as OOXML file...
551
+			$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
552
+
553
+
554
+			$objWriter->save('exports/'.$filename);
555
+
556
+			return Response::download('exports/'.$filename);
557
+
558
+		}
559
+		catch(Exception $e)
560
+		{
561
+			Session::flash('status', 'danger');
562
+			Session::flash('message', 'An error occurred while generating the document. Try again later or contact an administrator.');
563
+
564
+			return Redirect::back();
565
+		}
566
+	}
567
+
568
+}

+ 112
- 0
app/controllers/HomeController.php ファイルの表示

@@ -0,0 +1,112 @@
1
+<?php
2
+
3
+class HomeController extends BaseController {
4
+
5
+	/*
6
+	|--------------------------------------------------------------------------
7
+	| Default Home Controller
8
+	|--------------------------------------------------------------------------
9
+	|
10
+	| You may wish to use controllers instead of, or in addition to, Closure
11
+	| based routes. That's great! Here is an example controller method to
12
+	| get you started. To route to this controller, just add the route:
13
+	|
14
+	|	Route::get('/', 'HomeController@showWelcome');
15
+	|
16
+	*/
17
+
18
+	public function showWelcome()
19
+	{
20
+		try {
21
+			require_once 'PHPWord-0.12.1/src/PhpWord/Autoloader.php';
22
+			\PhpOffice\PhpWord\Autoloader::register();
23
+
24
+			// Creating the new document...
25
+			$phpWord = new \PhpOffice\PhpWord\PhpWord();
26
+
27
+			$styleTable = array('borderColor'=>'006699',
28
+              'borderSize'=>6,
29
+              'cellMargin'=>50);
30
+			$styleFirstRow = array('bgColor'=>'66BBFF');
31
+			$phpWord->addTableStyle('myTable', $styleTable, $styleFirstRow);
32
+
33
+			/* Note: any element you append to a document must reside inside of a Section. */
34
+
35
+			// Adding an empty Section to the document...
36
+			$section = $phpWord->addSection();
37
+			// Adding Text element to the Section having font styled by default...
38
+			$section->addText(
39
+			    htmlspecialchars(
40
+			        '"Learn from yesterday, live for today, hope for tomorrow. '
41
+			            . 'The important thing is not to stop questioning." '
42
+			            . '(Albert Einstein)'
43
+			    )
44
+			);
45
+
46
+			$table = $section->addTable('myTable');
47
+			$table->addRow(3);
48
+			$table->addCell(1200)->addText("Col 1");
49
+			$table->addCell(1200)->addText("Col 2");
50
+			$table->addCell(1200)
51
+			->addTable('myTable')
52
+			->addRow(2)->addCell(1200)
53
+			->addText("Col 1");
54
+
55
+			/*
56
+			 * Note: it's possible to customize font style of the Text element you add in three ways:
57
+			 * - inline;
58
+			 * - using named font style (new font style object will be implicitly created);
59
+			 * - using explicitly created font style object.
60
+			 */
61
+
62
+			// Adding Text element with font customized inline...
63
+			$section->addText(
64
+			    htmlspecialchars(
65
+			        '"Great achievement is usually born of great sacrifice, '
66
+			            . 'and is never the result of selfishness." '
67
+			            . '(Napoleon Hill)'
68
+			    ),
69
+			    array('name' => 'Tahoma', 'size' => 10)
70
+			);
71
+
72
+
73
+			// Adding Text element with font customized using named font style...
74
+			$fontStyleName = 'oneUserDefinedStyle';
75
+			$phpWord->addFontStyle(
76
+			    $fontStyleName,
77
+			    array('name' => 'Tahoma', 'size' => 10, 'color' => '1B2232', 'bold' => true)
78
+			);
79
+			$section->addText(
80
+			    htmlspecialchars(
81
+			        '"The greatest accomplishment is not in never falling, '
82
+			            . 'but in rising again after you fall." '
83
+			            . '(Vince Lombardi)'
84
+			    ),
85
+			    $fontStyleName
86
+			);
87
+
88
+
89
+			// Adding Text element with font customized using explicitly created font style object...
90
+			$fontStyle = new \PhpOffice\PhpWord\Style\Font();
91
+			$fontStyle->setBold(true);
92
+			$fontStyle->setName('Tahoma');
93
+			$fontStyle->setSize(13);
94
+			$myTextElement = $section->addText(
95
+			    htmlspecialchars('"Believe you can and you\'re halfway there." (Theodor Roosevelt)')
96
+			);
97
+			$myTextElement->setFontStyle($fontStyle);
98
+
99
+			// Saving the document as OOXML file...
100
+			$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
101
+			
102
+
103
+			$objWriter->save('helloWorld2.docx');
104
+
105
+			return Response::download('helloWorld2.docx');
106
+			
107
+		}
108
+		catch(Exception $e)
109
+		{
110
+		}
111
+	}
112
+}

+ 237
- 0
app/controllers/ObjectivesController.php ファイルの表示

@@ -0,0 +1,237 @@
1
+<?php
2
+
3
+class ObjectivesController extends \BaseController {
4
+
5
+    /**
6
+     * Display a listing of the resource.
7
+     *
8
+     * @return Response
9
+     */
10
+    public function fetch()
11
+    {
12
+        try
13
+        {
14
+            $outcome_id = Input::get('outcome_id');
15
+            $program_id = Input::get('program_id');
16
+            $format = Input::get('format');
17
+
18
+
19
+            $objectives = Objective::select('id', 'outcome_id', 'program_id', 'text');
20
+
21
+            if($outcome_id)
22
+            {
23
+                $objectives->where('outcome_id', $outcome_id);
24
+            }
25
+
26
+            if($program_id)
27
+            {
28
+                $objectives->where('program_id', $program_id);
29
+            }
30
+
31
+            if($format == 'select')
32
+            {
33
+                $string = '';
34
+                foreach ($objectives->get() as $objective)
35
+                {
36
+                    $string.='<option value="'.$objective->id.'">'.$objective->text.'</option>';
37
+                }
38
+
39
+                echo $string;
40
+                return;
41
+            }
42
+            else
43
+            {
44
+                return $objectives->get();
45
+            }
46
+        }
47
+        catch (Exception $e)
48
+        {
49
+            echo $e->getMessage();
50
+            return;
51
+        }
52
+
53
+    }
54
+
55
+  /**
56
+   * Edit the learning objectives per learning outcome for a program
57
+   */
58
+  public function index($program)
59
+  {
60
+    $role = Auth::user()->role;
61
+
62
+    // Redirect users if they try to access forbidden page
63
+  	if($role == 2 && $program->school_id != Auth::user()->school_id)
64
+  	{
65
+		return Redirect::to('/');
66
+  	}
67
+  	else if($role == 3 && !in_array($program->id, Auth::user()->programs->lists('id')))
68
+  	{
69
+		return Redirect::to('/');
70
+  	}
71
+  	else if($role == 4)
72
+  	{
73
+		return Redirect::to('/');
74
+  	}
75
+
76
+    $title = 'Learning Objectives ('.$program->name.')';
77
+    $objectives = $program->objectives;
78
+
79
+    // Eager load outcomes related to objectives
80
+    // $program->load('outcomes');
81
+    //
82
+    $outcomes = Outcome::select('id', 'name')->get();
83
+
84
+    return View::make('local.managers.shared.objectives.index', compact('title', 'objectives', 'role', 'program', 'outcomes'));
85
+  }
86
+
87
+  public function create()
88
+  {
89
+    try
90
+    {
91
+      $outcome_id = Input::get('outcome_id');
92
+      $program_id = Input::get('program_id');
93
+      $learning_objective = trim(Input::get('learning_objective'));
94
+
95
+
96
+      $validator = Validator::make(
97
+          array(
98
+              'outcome_id' => $outcome_id,
99
+              'program_id' => $program_id,
100
+              'learning_objective' => $learning_objective
101
+          ),
102
+          array(
103
+              'outcome_id' => 'required|integer',
104
+              'program_id' => 'required|integer',
105
+              'learning_objective' => 'required|min:1',
106
+          )
107
+      );
108
+
109
+      if($validator->fails())
110
+      {
111
+        /** Prepare error message */
112
+        $message = '<p>Error(s) creating a new Learning Objective: </p><ul>';
113
+
114
+        foreach ($validator->messages()->all('<li>:message</li>') as $validationError)
115
+        {
116
+            $message.=$validationError;
117
+        }
118
+
119
+        $message.='</ul>';
120
+
121
+        /** Send error message and old data */
122
+        Session::flash('status', 'danger');
123
+        Session::flash('message', $message);
124
+        return Redirect::back()->withInput();
125
+      }
126
+
127
+      DB::table('objectives')->insert(array(
128
+        'outcome_id' => $outcome_id,
129
+        'program_id' => $program_id,
130
+        'text' => $learning_objective
131
+      ));
132
+
133
+      /** Send success message */
134
+        Session::flash('status', 'success');
135
+        Session::flash('message', 'New Learning Objective successfully created.');
136
+        return Redirect::back();
137
+    }
138
+    catch(Exception $e)
139
+    {
140
+      /** Send error message and old data */
141
+        Session::flash('status', 'danger');
142
+        Session::flash('message', 'An error ocurred trying to create a new Learning Objective. Please try again later.'.$e->getMessage());
143
+        return Redirect::back()->withInput();
144
+    }
145
+  }
146
+
147
+  /**
148
+   * Update objective
149
+   */
150
+  public function update()
151
+  {
152
+    try
153
+    {
154
+      $outcome_id = Input::get('edit_outcome_id');
155
+      $objective_id = Input::get('edit_objective_id');
156
+      $active = Input::get('edit_active');
157
+      $learning_objective = trim(Input::get('edit_learning_objective'));
158
+
159
+      $validator = Validator::make(
160
+          array(
161
+            'outcome_id' => $outcome_id,
162
+            'objective_id' => $objective_id,
163
+            'active' => $active,
164
+            'learning_objective' => $learning_objective
165
+          ),
166
+          array(
167
+            'outcome_id' => 'required|integer',
168
+            'objective_id' => 'required|integer',
169
+            'active' => 'required|integer|boolean',
170
+            'learning_objective' => 'required|min:1',
171
+          )
172
+      );
173
+
174
+      if($validator->fails())
175
+      {
176
+        /** Prepare error message */
177
+        $message = '<p>Error(s) updating the Learning Objective: </p><ul>';
178
+
179
+        foreach ($validator->messages()->all('<li>:message</li>') as $validationError)
180
+        {
181
+            $message.=$validationError;
182
+        }
183
+
184
+        $message.='</ul>';
185
+
186
+        /** Send error message and old data */
187
+        Session::flash('status', 'danger');
188
+        Session::flash('message', $message);
189
+        return Redirect::back()->withInput();
190
+      }
191
+
192
+      DB::table('objectives')
193
+        ->where('id', $objective_id)
194
+        ->update(array(
195
+          'outcome_id' => $outcome_id,
196
+          'text' => $learning_objective,
197
+          'active' => $active,
198
+      ));
199
+
200
+      /** Send success message */
201
+        Session::flash('status', 'success');
202
+        Session::flash('message', 'Learning Objective successfully updated.');
203
+        return Redirect::back();
204
+    }
205
+    catch(Exception $e)
206
+    {
207
+      	/** Send error message and old data */
208
+        Session::flash('status', 'danger');
209
+        Session::flash('message', 'An error ocurred trying to create a new Learning Objective. Please try again later.'.$e->getMessage());
210
+        return Redirect::back()->withInput();
211
+    }
212
+  }
213
+
214
+  /**
215
+   * Check what this was for
216
+   * @return [type] [description]
217
+   */
218
+  public function fetchObjective()
219
+  {
220
+    $validator = Validator::make(
221
+      array(
222
+        'objective_id' => Input::get('objective_id')
223
+      ),
224
+      array(
225
+        'objective_id' => 'required|integer',
226
+      )
227
+    );
228
+
229
+    if($validator->fails())
230
+    {
231
+      return '';
232
+    }
233
+    $res = DB::table('objectives')->where('id', Input::get('objective_id'))->first();
234
+
235
+    return json_encode($res);
236
+  }
237
+}

+ 547
- 0
app/controllers/OutcomesController.php ファイルの表示

@@ -0,0 +1,547 @@
1
+<?php
2
+
3
+class OutcomesController extends \BaseController {
4
+
5
+
6
+    /**
7
+     * Show all Learning Outcomes and expected values
8
+     *
9
+     */
10
+    public function index()
11
+    {
12
+        $title = "Learning Outcomes";
13
+        $outcomes = Outcome::withTrashed()->orderBy('name', 'ASC')->get();
14
+        $schools = School::orderBy('name', 'ASC')->get();
15
+
16
+        return View::make('local.managers.admins.learning-outcomes', compact('title', 'outcomes', 'schools'));
17
+    }
18
+    // TODO: Change to home page
19
+    public function newIndex()
20
+    {
21
+        $title = "Learning Outcomes";
22
+        $outcomes = Outcome::withTrashed()->orderBy('name', 'ASC')->get();
23
+        $schools = School::orderBy('name', 'ASC')->get();
24
+
25
+        return View::make('local.managers.admins.new-learning-outcomes', compact('title', 'outcomes', 'schools'));
26
+//        return View::make('local.managers.admins.learning-outcomes', compact('title', 'outcomes', 'schools'));
27
+    }
28
+
29
+    public function show($id)
30
+    {
31
+        DB::disableQueryLog();
32
+        $outcome = Outcome::find($id);
33
+
34
+        $undergradResults=array("names"=>array(), "schools"=>array(), "achieved"=>array(), "attempted"=>array(), "successRate"=>array());
35
+        $gradResults = array("names"=>array(), "schools"=>array(), "achieved"=>array(), "attempted"=>array(), "successRate"=>array());
36
+
37
+        //Calculate performance for this outcome for each undergrad program
38
+        $undergradPrograms = Program::where('is_graduate','=', 0)
39
+            ->where(function($query)
40
+            {
41
+                if(Auth::user()->school_id)
42
+                {
43
+                    $query->where('school_id', Auth::user()->school_id);
44
+                }
45
+            })
46
+            ->with('courses')
47
+            ->orderBy('name', 'asc')->get();
48
+
49
+        foreach($undergradPrograms as $program)
50
+        {
51
+            $undergradResults["names"][$program->id]=$program->name;
52
+            $undergradResults["schools"][$program->id]=$program->school->name;
53
+            $programAssessed=false;
54
+
55
+            $undergradResults["attempted"][$program->id]=0;
56
+            $undergradResults["achieved"][$program->id]=0;
57
+
58
+            foreach($program->courses as $course)
59
+            {
60
+                $course_outcomes_achieved = json_decode($course->outcomes_achieved, true);
61
+                $course_outcomes_attempted = json_decode($course->outcomes_attempted, true);
62
+
63
+                $attemptedCriteriaCount=0;
64
+                $achievedCriteriaCount=0;
65
+
66
+                // If this outcome was evaluated
67
+                if(
68
+                    $course_outcomes_attempted
69
+                    && array_key_exists($outcome->id, $course_outcomes_attempted)
70
+                    && $course_outcomes_attempted[$outcome->id]!=0)
71
+                {
72
+                    // Count +1 for attempted and achieved in the program
73
+                    $attemptedCriteriaCount+=$course_outcomes_attempted[$outcome->id];
74
+                    $achievedCriteriaCount+=$course_outcomes_achieved[$outcome->id];
75
+                    $programAssessed=true;
76
+
77
+                    if($attemptedCriteriaCount>0  &&(float)$achievedCriteriaCount/$attemptedCriteriaCount*100 > $outcome->expected_outcome)
78
+                    {
79
+                        $undergradResults["achieved"][$program->id]+=1;
80
+                    }
81
+                    $undergradResults["attempted"][$program->id]+=1;
82
+                }
83
+            }
84
+
85
+            // Calculate success rate for this program
86
+            if($programAssessed && $undergradResults["attempted"][$program->id]>0)
87
+                $undergradResults["successRate"][$program->id]= round((float)$undergradResults["achieved"][$program->id]/$undergradResults["attempted"][$program->id]*100, 2).'%';
88
+            else
89
+                $undergradResults["successRate"][$program->id]= 'N/M';
90
+        }
91
+
92
+
93
+        //Calculate performance for this outcome for each grad program
94
+        $gradPrograms = Program::where('is_graduate','=', 1)
95
+            ->where(function($query)
96
+            {
97
+                if(Auth::user()->school_id)
98
+                {
99
+                    $query->where('school_id', Auth::user()->school_id);
100
+                }
101
+            })
102
+            ->with(array('courses'=>function($query)
103
+            {
104
+                $query->whereNotNull('outcomes_attempted');
105
+            }))
106
+            ->orderBy('name', 'asc')->get();
107
+
108
+        foreach($gradPrograms as $program)
109
+        {
110
+            $gradResults["names"][$program->id]=$program->name;
111
+            $gradResults["schools"][$program->id]=$program->school->name;
112
+
113
+            $programAssessed=false;
114
+
115
+            $gradResults["attempted"][$program->id]=0;
116
+            $gradResults["achieved"][$program->id]=0;
117
+
118
+            foreach($program->courses as $course)
119
+            {
120
+                $course_outcomes_achieved = json_decode($course->outcomes_achieved, true);
121
+                $course_outcomes_attempted = json_decode($course->outcomes_attempted, true);
122
+
123
+                $attemptedCriteriaCount=0;
124
+                $achievedCriteriaCount=0;
125
+
126
+                // If this outcome was evaluated
127
+                if(
128
+                    $course_outcomes_attempted
129
+                    && array_key_exists($outcome->id, $course_outcomes_attempted)
130
+                    && $course_outcomes_attempted[$outcome->id]!=0)
131
+                {
132
+                    // Count +1 for attempted and achieved in the program
133
+                    $attemptedCriteriaCount+=$course_outcomes_attempted[$outcome->id];
134
+                    $achievedCriteriaCount+=$course_outcomes_achieved[$outcome->id];
135
+                    $programAssessed=true;
136
+
137
+                    if($attemptedCriteriaCount>0  &&(float)$achievedCriteriaCount/$attemptedCriteriaCount*100 > $outcome->expected_outcome)
138
+                    {
139
+                        $gradResults["achieved"][$program->id]+=1;
140
+                    }
141
+                    $gradResults["attempted"][$program->id]+=1;
142
+                }
143
+            }
144
+
145
+            // Calculate success rate for this program
146
+            if($programAssessed && $gradResults["attempted"][$program->id]>0)
147
+                $gradResults["successRate"][$program->id]= round((float)$gradResults["achieved"][$program->id]/$gradResults["attempted"][$program->id]*100, 2).'%';
148
+            else
149
+                $gradResults["successRate"][$program->id]= 'N/M';
150
+        }
151
+
152
+        $title = "Outcome Results: ".$outcome->name;
153
+
154
+        return View::make('local.managers.admins.learning-outcome', compact('title', 'outcome', 'undergradResults', 'gradResults'));
155
+    }
156
+
157
+    public function newShow($id)
158
+    {
159
+//        DB::disableQueryLog();
160
+        $outcome = Outcome::find($id);
161
+        $title = $outcome->name;
162
+
163
+        return View::make('local.managers.admins.new-learning-outcome', compact('title', 'outcome'));
164
+    }
165
+
166
+    public function update()
167
+    {
168
+        $outcomeArray = json_decode(Input::get('outcomeArray'), true);
169
+        Session::flash('status', 'success');
170
+        Session::flash('message', 'Learning Outcomes updated.');
171
+
172
+        foreach ($outcomeArray as $outcomeObject)
173
+        {
174
+
175
+
176
+            $validator = Validator::make(
177
+                array(
178
+                    'name' => $outcomeObject['name'],
179
+                    'definition' => $outcomeObject['definition'],
180
+                    'expected_outcome' => $outcomeObject['expected_outcome']
181
+                ),
182
+                array(
183
+                    'name' => 'required',
184
+                    'definition' => 'required',
185
+                    'expected_outcome' => 'required|numeric'
186
+                )
187
+            );
188
+
189
+            if(!$validator->fails())
190
+            {
191
+                try
192
+                {
193
+                    $outcome = Outcome::withTrashed()
194
+                        ->where('id','=', $outcomeObject['id'])
195
+                        ->firstOrFail();
196
+                    $outcome->name = $outcomeObject['name'];
197
+                    $outcome->definition = $outcomeObject['definition'];
198
+                    $outcome->expected_outcome = $outcomeObject['expected_outcome'];
199
+                    $outcome->save();
200
+
201
+                    // If delete is 1, and outcome isn't already trashed, delete
202
+                    if($outcomeObject['delete']==1 && !$outcome->trashed())
203
+                        $outcome->delete();
204
+                    // If delete is 0, and outcome is already trashed, restore
205
+                    elseif($outcomeObject['delete']==0 && $outcome->trashed())
206
+                        $outcome->restore();
207
+                }
208
+
209
+                catch(Exception $e)
210
+                {
211
+
212
+                    Session::flash('message', $e->getMessage());
213
+                }
214
+            }
215
+            else
216
+            {
217
+                /** Prepare error message */
218
+                $message = 'Error(s) updating the Learning Outcomes: <ul>';
219
+
220
+                foreach ($validator->messages()->all('<li>:message</li>') as $validationError)
221
+                {
222
+                    $message.=$validationError;
223
+                }
224
+
225
+                $message.='</ul>';
226
+
227
+                /** Send error message and old data */
228
+                Session::flash('status', 'danger');
229
+                Session::flash('message', $message);
230
+                return;
231
+            }
232
+        }
233
+
234
+        return;
235
+    }
236
+
237
+    public function fetchCriteria()
238
+    {
239
+
240
+        if(Input::get('filter'))
241
+        {
242
+            switch (Input::get('filter'))
243
+            {
244
+                case 'all':
245
+                    return Outcome::find(Input::get('id'))->criteria;
246
+                    break;
247
+
248
+                case 'school':
249
+                    // If scoord
250
+                    if(Auth::user()->role == '2')
251
+                    {
252
+
253
+                        // Fetch all the programs whose school is the user's
254
+                        $program_ids = DB::table('programs')->where('school_id', Auth::user()->school_id)->lists('id');
255
+
256
+                        // Return all criteria belonging to any of those programs
257
+                        return Criterion::
258
+                            where('outcome_id', Input::get('id'))
259
+                            ->whereIn('program_id', $program_ids)
260
+                            ->orderBy('name', 'ASC')
261
+                            ->get();
262
+
263
+                    }
264
+
265
+                    // If pcoord
266
+                    else
267
+                    {
268
+
269
+                        // Fetch all the programs from the user's school;
270
+                        $program_ids = DB::table('programs')->where('school_id', Auth::user()->programs[0]->school->id)->lists('id');
271
+
272
+                        return Criterion::
273
+                            where('outcome_id', Input::get('id'))
274
+                            ->whereIn('program_id', $program_ids)
275
+                            ->orderBy('name', 'ASC')
276
+                            ->get();
277
+                    }
278
+
279
+                    break;
280
+
281
+                case 'program':
282
+                    return Criterion::
283
+                        where('outcome_id', Input::get('id'))
284
+                        ->whereIn('program_id', Auth::user()->programs->lists('id'))
285
+                        ->orderBy('name', 'ASC')
286
+                        ->get();
287
+                    break;
288
+
289
+                default:
290
+                    return Outcome::find(Input::get('id'))->criteria;
291
+                    break;
292
+            }
293
+        }
294
+        else
295
+        {
296
+            return Outcome::find(Input::get('id'))->criteria;
297
+        }
298
+    }
299
+
300
+    /**
301
+     * Create a new learning outcome.
302
+     */
303
+    public function create()
304
+    {
305
+        /** Validation rules */
306
+        $validator = Validator::make(
307
+            array(
308
+                'name' => Input::get('name'),
309
+                'definition' => Input::get('definition')
310
+            ),
311
+            array(
312
+                'name' => 'required|unique:outcomes',
313
+                'definition' => 'required|min:10'
314
+            )
315
+        );
316
+
317
+        /** If validation fails */
318
+        if ($validator->fails())
319
+        {
320
+            /** Prepare error message */
321
+            $message = '<p>Error(s) creating a new Learning Outcome</p><ul>';
322
+
323
+            foreach ($validator->messages()->all('<li>:message</li>') as $validationError)
324
+            {
325
+                $message.=$validationError;
326
+            }
327
+
328
+            $message.='</ul>';
329
+
330
+            /** Send error message and old data */
331
+            Session::flash('status', 'warning');
332
+            Session::flash('message', $message);
333
+            return Redirect::to('learning-outcomes-criteria')->withInput();
334
+        }
335
+        else
336
+        {
337
+            /** Instantiate new outcome */
338
+            $outcome = new Outcome;
339
+            $outcome->name= Input::get('name');
340
+            $outcome->definition = Input::get('definition');
341
+
342
+            /** If outcome is saved, send success message */
343
+            if($outcome->save())
344
+            {
345
+                Session::flash('status', 'success');
346
+                Session::flash('message', '<p>Learning Outcome added.</p>');
347
+                return Redirect::to('learning-outcomes-criteria');
348
+            }
349
+
350
+            /** If saving fails, send error message and old data */
351
+            else
352
+            {
353
+                Session::flash('status', 'warning');
354
+                Session::flash('message', '<p>Error adding Learning Outcome. Please try again later.</p>');
355
+                return Redirect::to('learning-outcomes-criteria')->withInput();
356
+            }
357
+        }
358
+    }
359
+
360
+    public function fetchOutcome()
361
+    {
362
+        $id = Input::get('id');
363
+
364
+        $outcome = Outcome::find($id);
365
+
366
+        $outcome->criteria;
367
+
368
+        return array
369
+        (
370
+            'outcome' => $outcome
371
+        );
372
+    }
373
+
374
+    public function managerAssessmentReports()
375
+    {
376
+        $outcomes = Outcome::select(array('id', 'name', 'expected_outcome'))->orderBy('name', 'ASC')->get();
377
+
378
+        switch (Auth::user()->role) {
379
+            case 1:
380
+                $title = "Campus Assessment Reports";
381
+                return View::make('local.managers.admins.assessment_reports', compact('title', 'outcomes'));
382
+                break;
383
+            case 2:
384
+                $title = "School Assessment Reports";
385
+                return View::make('local.managers.sCoords.assessment_reports', compact('title', 'outcomes'));
386
+                break;
387
+            case 3:
388
+                $title = "Program Assessment Reports";
389
+                $programs  = Auth::user()->programs;
390
+                return View::make('local.managers.pCoords.assessment_reports', compact('title', 'outcomes', 'programs'));
391
+                break;
392
+            default:
393
+                App::abort('404');
394
+                break;
395
+        }
396
+
397
+    }
398
+
399
+    /**
400
+     * Campus Assessment Reports
401
+     */
402
+    public function assessmentReport($outcome_id)
403
+    {
404
+        $outcome = Outcome::find($outcome_id);
405
+
406
+        if(!$outcome)
407
+            App::abort('404');
408
+        $title = "Assessment Report: ".$outcome->name;
409
+
410
+
411
+        $schools = School::
412
+            has('courses')
413
+            ->with(array('programs'=>function($query) use($outcome_id){
414
+                $query
415
+                ->has('courses')
416
+                ->with(array('courses'=>function($query2) use($outcome_id){
417
+                    $query2
418
+                    ->has('activities')
419
+                    ->whereNotNull('outcomes_attempted')
420
+                    // ->where('outcomes_attempted', 'NOT LIKE', '%"'.$outcome_id.'":0%')
421
+                    ->whereIn('semester_id', Session::get('semesters_ids'))
422
+                    ->groupBy(array('code', 'number'));
423
+                }));
424
+            }))
425
+         ->get();
426
+
427
+        return View::make('local.managers.admins.assessment_report', compact('title', 'outcome', 'schools'));
428
+    }
429
+
430
+    // TODO: Change later
431
+    public function newAssessmentReport($outcome_id)
432
+    {
433
+        $outcome = Outcome::find($outcome_id);
434
+
435
+        if(!$outcome)
436
+            App::abort('404');
437
+        $title = "Assessment Report: ".$outcome->name;
438
+
439
+        $schools = School::
440
+        has('courses')
441
+            ->with(array('programs'=>function($query) use($outcome_id){
442
+                $query
443
+                    ->has('courses')
444
+                    ->with(array('courses'=>function($query2) use($outcome_id){
445
+                        $query2
446
+                            ->has('activities')
447
+                            ->whereNotNull('outcomes_attempted')
448
+                            // ->where('outcomes_attempted', 'NOT LIKE', '%"'.$outcome_id.'":0%')
449
+                            ->whereIn('semester_id', Session::get('semesters_ids'))
450
+                            ->groupBy(array('code', 'number'));
451
+                    }));
452
+            }))
453
+            ->get();
454
+
455
+        return View::make('local.managers.admins.assessment_report', compact('title', 'outcome', 'schools'));
456
+    }
457
+
458
+    /**
459
+     * School Assessment Reports
460
+     */
461
+    public function schoolAssessmentReport($outcome_id)
462
+    {
463
+        $outcome = Outcome::find($outcome_id);
464
+
465
+        if(!$outcome)
466
+            App::abort('404');
467
+        $title = "Assessment Report: ".$outcome->name;
468
+
469
+
470
+        $school = School::
471
+            where('id', Auth::user()->school_id)
472
+            ->has('courses')
473
+            ->with(array('programs'=>function($query){
474
+            $query
475
+            ->has('courses')
476
+            ->with(array('courses'=>function($query2){
477
+                $query2
478
+                ->has('activities')
479
+                ->whereNotNull('outcomes_attempted')
480
+                ->whereIn('semester_id', Session::get('semesters_ids'))
481
+                ->groupBy(array('code', 'number'));
482
+            }));
483
+         }))
484
+         ->first();
485
+
486
+        return View::make('local.managers.sCoords.assessment_report', compact('title', 'outcome', 'school'));
487
+    }
488
+
489
+    /**
490
+     *    Program Assessment Reports
491
+     */
492
+    public function programAssessmentReport($outcome_id, $program_id)
493
+    {
494
+        $outcome = Outcome::find($outcome_id);
495
+
496
+        if(!$outcome)
497
+            App::abort('404');
498
+        $title = "Assessment Report: ".$outcome->name;
499
+
500
+
501
+        $program = Program::
502
+            where('id', $program_id)
503
+            ->has('courses')
504
+            ->with(array('courses'=>function($query){
505
+                $query
506
+                ->has('activities')
507
+                ->whereNotNull('outcomes_attempted')
508
+                ->whereIn('semester_id', Session::get('semesters_ids'))
509
+                ->groupBy(array('code', 'number'));
510
+            }))
511
+            ->first();
512
+
513
+        return View::make('local.managers.pCoords.assessment_report', compact('title', 'outcome', 'program'));
514
+    }
515
+
516
+
517
+    public function professorAssessmentReports()
518
+    {
519
+        $outcomes = Outcome::select(array('id', 'name', 'expected_outcome'))->orderBy('name', 'ASC')->get();
520
+        $title = "My Courses' Assessment Reports";
521
+
522
+        return View::make('local.professors.assessment_reports', compact('title', 'outcomes'));
523
+
524
+    }
525
+
526
+
527
+    // Report for a single professor with a single learning outcome
528
+    public function professorAssessmentReport($outcome_id)
529
+    {
530
+        $outcome = Outcome::find($outcome_id);
531
+
532
+        if(!$outcome)
533
+            App::abort('404');
534
+        $title = "My Courses' Assessment Report: ".$outcome->name;
535
+
536
+
537
+        $courses = Course::
538
+            where('user_id', Auth::user()->id)
539
+            ->has('activities')
540
+            ->whereNotNull('outcomes_attempted')
541
+            ->whereIn('semester_id', Session::get('semesters_ids'))
542
+            ->groupBy(array('code', 'number'))
543
+            ->get();
544
+
545
+        return View::make('local.professors.assessment_report', compact('title', 'outcome', 'courses'));
546
+    }
547
+}

+ 122
- 0
app/controllers/ProfessorsController.php ファイルの表示

@@ -0,0 +1,122 @@
1
+<?php
2
+
3
+class ProfessorsController extends \BaseController
4
+{
5
+
6
+	private $grouped_courses;
7
+
8
+	public function __construct()
9
+    {
10
+        $this->courses = Auth::user()->courses;
11
+    }
12
+
13
+	public function overview()
14
+	{
15
+        $title='My Courses';
16
+        $grouped_courses = Course::where('user_id', Auth::user()->id)->whereIn('semester_id', Session::get('semesters_ids'))->groupBy(array('code', 'number', 'semester_id'))->get();
17
+        $outcomes = Outcome::orderBy('name', 'asc')->get();
18
+        $outcomeCount = Outcome::all()->count();
19
+
20
+
21
+        $grouped_outcomes_achieved_results = array();
22
+        $grouped_outcomes_attempted_results = array();
23
+        $grouped_sections = array();
24
+
25
+        foreach ($grouped_courses as $index => $grouped_course)
26
+        {
27
+            // Blank outcomes for one course
28
+            $outcomes_achieved = array_fill(1, $outcomeCount, 0);
29
+            $outcomes_attempted = array_fill(1, $outcomeCount, 0);
30
+
31
+            // Find sections belonging to user with identifier of one course
32
+            $sections = Course::where('user_id', Auth::user()->id)->where('code', $grouped_course->code)->whereIn('semester_id', Session::get('semesters_ids'))->where('number', $grouped_course->number)->where('semester_id', $grouped_course->semester_id)->get();
33
+
34
+            // For each of the professor's course sections, add the attempted and achieved criteria per outcome
35
+            foreach ($sections as $section)
36
+            {
37
+                if($section->outcomes_achieved!=NULL)
38
+                {
39
+                    $section_outcomes_achieved =json_decode($section->outcomes_achieved, true);
40
+                    $section_outcomes_attempted =json_decode($section->outcomes_attempted, true);
41
+                    for($i=1; $i<=count($outcomes_attempted); $i++)
42
+                    {
43
+                        $outcomes_achieved[$i]+=$section_outcomes_achieved[$i];
44
+                        $outcomes_attempted[$i]+=$section_outcomes_attempted[$i];
45
+                    }
46
+                }
47
+            }
48
+
49
+            $grouped_outcomes_achieved_results[]=$outcomes_achieved;
50
+            $grouped_outcomes_attempted_results[]=$outcomes_attempted;
51
+            $grouped_sections[] = $sections;
52
+
53
+        }
54
+
55
+		return View::make('local.professors.overview', compact('title', 'grouped_courses', 'outcomes', 'grouped_outcomes_attempted_results', 'grouped_outcomes_achieved_results', 'grouped_sections'));
56
+	}
57
+
58
+    public function program()
59
+    {
60
+        $program =  Auth::user()->programs[0];
61
+        $title='Your Program: '.$program->name;
62
+        $program_courses = Course::where('program_id','=', $program->id)->whereIn('semester_id', Session::get('semesters_ids'))->get();
63
+        $outcomes = Outcome::orderBy('name', 'asc')->get();
64
+        $outcomeCount = Outcome::all()->count();
65
+
66
+        $outcomes_achieved = array_fill(1, $outcomeCount, 0);
67
+        $outcomes_attempted = array_fill(1, $outcomeCount, 0);
68
+
69
+        foreach ($program_courses as $course)
70
+        {
71
+            if($course->outcomes_achieved!=NULL)
72
+            {
73
+                $course_outcomes_achieved =json_decode($course->outcomes_achieved, true);
74
+                $course_outcomes_attempted =json_decode($course->outcomes_attempted, true);
75
+                for($i=1; $i<=count($outcomes_attempted); $i++)
76
+                {
77
+                    $outcomes_achieved[$i]+=$course_outcomes_achieved[$i];
78
+                    $outcomes_attempted[$i]+=$course_outcomes_attempted[$i];
79
+                }
80
+            }
81
+        }
82
+
83
+        // Program contact information
84
+        $scoords = User::where('school_id', $program->school_id)
85
+            ->where('role', 2)
86
+            ->get();
87
+        $pcoords = User::
88
+            select('users.*')
89
+            ->join('program_user', 'users.id', '=', 'program_user.user_id')
90
+            ->where('role', 3)
91
+            ->where('program_id', $program->id)
92
+            ->get();
93
+
94
+        return View::make('local.professors.program', compact('title', 'outcomes', 'outcomes_attempted', 'outcomes_achieved', 'scoords', 'pcoords'));
95
+    }
96
+
97
+
98
+    public function generalStudiesOverview(){
99
+
100
+        $title='General Component Assessment Overview';
101
+
102
+        try{
103
+            $programs = Program::generalComponentPrograms();
104
+        }
105
+        catch(Exception $e){
106
+            dd('Unable to find general component programs');
107
+        }
108
+
109
+        $outcomes = Outcome::orderBy('name', 'asc')->get();
110
+        $schools = School::all();
111
+        $program_packs = array();
112
+        if(!$programs->isEmpty()){
113
+            foreach ($programs as $program) {
114
+                $program_packs[]= $program->assessmentOverview();
115
+            }
116
+        }
117
+
118
+        return View::make('local.managers.shared.general_studies_overview', compact('title', 'outcomes', 'schools', 'program_packs'));
119
+
120
+
121
+    }
122
+}

+ 109
- 0
app/controllers/ProgramCoordinatorsController.php ファイルの表示

@@ -0,0 +1,109 @@
1
+<?php
2
+
3
+class ProgramCoordinatorsController extends \BaseController {
4
+
5
+    public function overview()
6
+    {
7
+        //TODO Find a better way to prevent non-scoords from reaching the page
8
+        switch(Auth::user()->role)
9
+        {
10
+            case 1:
11
+                return Redirect::to('administrator');
12
+                break;
13
+            case 2:
14
+                return Redirect::to('school-coordinator');
15
+                break;
16
+        }
17
+
18
+        $title = 'Program Coordinator Overview';
19
+
20
+        $programs = Auth::user()->programs;
21
+
22
+        $outcomes = Outcome::orderBy('name', 'asc')->get();
23
+        $outcomeCount = Outcome::all()->count();
24
+
25
+        $programs_array = array();
26
+        $programs_contact = array();
27
+
28
+        foreach ($programs as $program)
29
+        {
30
+          $program_array = array();
31
+
32
+          $program_array['program'] = $program;
33
+
34
+          $program_array['outcomes_achieved'] = array_fill(1, $outcomeCount, 0);
35
+          $program_array['outcomes_attempted'] = array_fill(1, $outcomeCount, 0);
36
+
37
+          $program_array['program_courses'] = $program->courses;
38
+          $program_array['grouped_objectives'] = $program->objectives();
39
+
40
+          $program_array['assessed_courses_count']=0;
41
+          foreach ($program_array['program_courses'] as $course)
42
+          {
43
+            if($course->outcomes_achieved!=NULL)
44
+            {
45
+              $program_array['course_outcomes_achieved'] =json_decode($course->outcomes_achieved, true);
46
+              $program_array['course_outcomes_attempted'] =json_decode($course->outcomes_attempted, true);
47
+              for($i=1; $i<=count($program_array['outcomes_attempted']); $i++)
48
+              {
49
+                $program_array['outcomes_achieved'][$i]+=$program_array['course_outcomes_achieved'][$i];
50
+                $program_array['outcomes_attempted'][$i]+=$program_array['course_outcomes_attempted'][$i];
51
+              }
52
+              $program_array['assessed_courses_count']+=1;
53
+            }
54
+          }
55
+
56
+          /**
57
+           * List of grouped courses (grouped sections)
58
+           */
59
+
60
+          $program_array['grouped_courses'] = Course::
61
+            select(DB::raw('name, code, number, max(outcomes_attempted) as outcomes_attempted, semester_id, program_id'))
62
+            ->with('semester')
63
+            ->with('program')
64
+            ->where('program_id', $program->id)
65
+            ->whereIn('semester_id', Session::get('semesters_ids'))
66
+            ->groupBy(array('code', 'number', 'semester_id'))
67
+            ->orderBy('code')
68
+            ->orderBy('number')
69
+            ->orderBy('semester_id')
70
+            ->get();
71
+
72
+
73
+          $programs_array[] = $program_array;
74
+
75
+
76
+          // Program contact information
77
+          $users = User::
78
+              select('users.*')
79
+              ->leftJoin('program_user', 'users.id', '=', 'program_user.user_id')
80
+              ->where(function($query) use($program)
81
+              {
82
+                $query
83
+                    ->where('school_id', $program->school_id)
84
+                    ->where('role', 2);
85
+              })
86
+              ->orWhere(function($query) use($program)
87
+              {
88
+                $query
89
+                    ->where('role', 3)
90
+                    ->where('program_id', $program->id);
91
+              })
92
+              ->orWhere(function($query) use($program)
93
+              {
94
+                $query
95
+                    ->where('role', 4)
96
+                    ->where('program_id', $program->id);
97
+              })
98
+              ->get();
99
+
100
+
101
+            $programs_contact[] = $users;
102
+
103
+        }
104
+
105
+
106
+        return View::make('local.managers.pCoords.overview', compact('title', 'programs', 'outcomes', 'programs_array', 'programs_contact'));
107
+    }
108
+
109
+}

+ 156
- 0
app/controllers/ProgramsController.php ファイルの表示

@@ -0,0 +1,156 @@
1
+<?php
2
+
3
+class ProgramsController extends \BaseController
4
+{
5
+
6
+  /**
7
+   * Shows a particular program
8
+   */
9
+  public function show($id)
10
+  {
11
+
12
+    $program = Program::find($id);
13
+    $title= $program->school->name.': '.$program->name;
14
+    $program_courses = $program->courses;
15
+    $outcomes = Outcome::orderBy('name', 'asc')->get();
16
+    $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
+
39
+    /**
40
+     * List of grouped courses (grouped sections)
41
+     */
42
+
43
+    $grouped_courses = Course::
44
+      select(DB::raw('name, code, number, max(outcomes_attempted) as outcomes_attempted, semester_id, program_id'))
45
+      ->with('semester')
46
+      ->with('program')
47
+      ->where('program_id', $program->id)
48
+      ->whereIn('semester_id', Session::get('semesters_ids'))
49
+      ->groupBy(array('code', 'number', 'semester_id'))
50
+      ->orderBy('code')
51
+      ->orderBy('number')
52
+      ->orderBy('semester_id')
53
+      ->get();
54
+
55
+    // Program contact information
56
+    $users = User::
57
+        select('users.*')
58
+        ->leftJoin('program_user', 'users.id', '=', 'program_user.user_id')
59
+        ->where(function($query) use($program)
60
+        {
61
+            $query
62
+                ->where('school_id', $program->school_id)
63
+                ->where('role', 2);
64
+        })
65
+        ->orWhere(function($query) use($program)
66
+        {
67
+            $query
68
+                ->where('role', 3)
69
+                ->where('program_id', $program->id);
70
+        })
71
+        ->orWhere(function($query) use($program)
72
+        {
73
+            $query
74
+                ->where('role', 4)
75
+                ->where('program_id', $program->id);
76
+        })
77
+        ->get();
78
+
79
+    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
+
81
+}
82
+
83
+  /**
84
+   * Info to print a program
85
+   */
86
+  public function print_program($id)
87
+  {
88
+
89
+    $program = Program::find($id);
90
+    $title= $program->name.' Assessment Report - '.date('m/d/Y');
91
+    $program_courses = $program->courses;
92
+    $outcomes = Outcome::orderBy('name', 'asc')->get();
93
+    $schools = School::all();
94
+    $outcomeCount = Outcome::all()->count();
95
+
96
+
97
+    $outcomes_achieved = array_fill(1, $outcomeCount, 0);
98
+    $outcomes_attempted = array_fill(1, $outcomeCount, 0);
99
+
100
+    $assessed_courses_count=0;
101
+    foreach ($program_courses as $course)
102
+    {
103
+      if($course->outcomes_achieved!=NULL)
104
+      {
105
+        $course_outcomes_achieved =json_decode($course->outcomes_achieved, true);
106
+        $course_outcomes_attempted =json_decode($course->outcomes_attempted, true);
107
+        for($i=1; $i<=count($outcomes_attempted); $i++)
108
+        {
109
+          $outcomes_achieved[$i]+=$course_outcomes_achieved[$i];
110
+          $outcomes_attempted[$i]+=$course_outcomes_attempted[$i];
111
+        }
112
+        $assessed_courses_count+=1;
113
+      }
114
+    }
115
+
116
+    /**
117
+     * List of grouped courses (grouped sections)
118
+     */
119
+
120
+    $grouped_courses = Course::
121
+      select(DB::raw('name, code, number, max(outcomes_attempted) as outcomes_attempted, semester_id, program_id'))
122
+      ->with('semester')
123
+      ->with('program')
124
+      ->where('program_id', $program->id)
125
+      ->whereIn('semester_id', Session::get('semesters_ids'))
126
+      ->groupBy(array('code', 'number', 'semester_id'))
127
+      ->orderBy('code')
128
+      ->orderBy('number')
129
+      ->orderBy('semester_id')
130
+      ->get();
131
+
132
+    return View::make('local.managers.shared.print_program', compact('title', 'program', 'outcomes', 'outcomes_attempted', 'outcomes_achieved', 'schools', 'program_courses', 'assessed_courses_count', 'grouped_courses'));
133
+  }
134
+
135
+
136
+  /**
137
+   * A list of all programs
138
+   */
139
+  public function index()
140
+  {
141
+    $title = "Programs by School";
142
+    $programs = Program::orderBy('name')->get();
143
+    $schools = School::all();
144
+
145
+    return View::make('local.managers.shared.programs', compact('programs', 'schools', 'title'));
146
+  }
147
+
148
+  /**
149
+  * Fetch a program
150
+  */
151
+  public function fetch()
152
+  {
153
+    Log::info('id:'.Input::get('id'));
154
+    return School::find(Input::get('id'))->programs;
155
+  }
156
+}

+ 316
- 0
app/controllers/RubricsController.php ファイルの表示

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

+ 287
- 0
app/controllers/SchoolCoordinatorsController.php ファイルの表示

@@ -0,0 +1,287 @@
1
+<?php
2
+
3
+class SchoolCoordinatorsController extends \BaseController {
4
+    
5
+    private function participatingPrograms($school)
6
+    {
7
+        return DB::table('VIEW_participating_programs')
8
+            ->where('school_id', $school->id)
9
+            ->whereIn('semester_id', Session::get('semesters_ids'))
10
+            ->lists('id');
11
+    }
12
+
13
+    public function overview()
14
+    {
15
+        DB::disableQueryLog();
16
+        Log::debug('user'.Auth::user()->id);
17
+
18
+        //TODO Find a better way to prevent non-scoords from reaching the page
19
+        switch(Auth::user()->role)
20
+        {
21
+        case 1:
22
+            return Redirect::to('administrator');
23
+            break;
24
+        case 3:
25
+            return Redirect::to('program-coordinator');
26
+            break;
27
+        }
28
+
29
+        $schools = School::orderBy('name', 'asc')->get();
30
+        $school = Auth::user()->school;
31
+        $title = $school->name.' '.'Overview';
32
+        $id = $school->id;
33
+
34
+        $outcomes = Outcome::orderBy('name', 'asc')->get();
35
+        $outcomeCount = Outcome::all()->count();
36
+
37
+            /**
38
+             * List of grouped courses (grouped sections)
39
+             */
40
+
41
+            $program_ids= $school->programs->lists('id');
42
+
43
+            $undergrad_programs = DB::table('programs')
44
+            ->select('id', 'name', 'school_id', 'is_graduate')
45
+            ->where('is_graduate', '=', 0)
46
+            ->where('school_id', '=', $id)
47
+            ->orderBy('name', 'ASC')
48
+            ->get();
49
+
50
+            $grad_programs = DB::table('programs')
51
+            ->select('id', 'name', 'school_id', 'is_graduate')
52
+            ->where('is_graduate', '=', 1)
53
+            ->where('school_id', '=', $id)
54
+            ->orderBy('name', 'ASC')
55
+            ->get();
56
+    
57
+
58
+            $grad_grouped_courses = Course::
59
+                select(DB::raw('courses.name, courses.code, courses.number, max(courses.outcomes_attempted) as outcomes_attempted, courses.semester_id, courses.program_id'))
60
+                ->with('semester')
61
+                ->with('program')
62
+                ->whereIn('courses.program_id', $program_ids)
63
+                ->whereIn('courses.semester_id', Session::get('semesters_ids'))
64
+                ->leftJoin('programs', 'courses.program_id', '=', 'programs.id')
65
+                ->where('programs.is_graduate', '=', 1)
66
+                ->groupBy(array('courses.code', 'courses.number', 'courses.semester_id'))
67
+                ->orderBy('courses.code')
68
+                ->orderBy('courses.number')
69
+                ->orderBy('courses.semester_id')
70
+                ->get();
71
+
72
+            $undergrad_grouped_courses = Course::
73
+                select(DB::raw('courses.name, courses.code, courses.number, max(courses.outcomes_attempted) as outcomes_attempted, courses.semester_id, courses.program_id'))
74
+                ->with('semester')
75
+                ->with('program')
76
+                ->whereIn('courses.program_id', $program_ids)
77
+                ->whereIn('courses.semester_id', Session::get('semesters_ids'))
78
+                ->leftJoin('programs', 'courses.program_id', '=', 'programs.id')
79
+                ->where('programs.is_graduate', '=', 0)
80
+                ->groupBy(array('courses.code', 'courses.number', 'courses.semester_id'))
81
+                ->orderBy('courses.code')
82
+                ->orderBy('courses.number')
83
+                ->orderBy('courses.semester_id')
84
+                ->get();
85
+
86
+            // Fetch programs with participation
87
+            $participating_programs = $this->participatingPrograms($school);
88
+
89
+
90
+            /**
91
+             * Calculate how many sections are doing assessment
92
+             */
93
+
94
+            $undergrad_outcomes_achieved = array_fill(1, $outcomeCount, 0);
95
+            $undergrad_outcomes_attempted = array_fill(1, $outcomeCount, 0);
96
+            $undergrad_assessed_sections_count = 0;
97
+            $undergrad_school_sections_count = 0;
98
+
99
+            $grad_outcomes_achieved = array_fill(1, $outcomeCount, 0);
100
+            $grad_outcomes_attempted = array_fill(1, $outcomeCount, 0);
101
+            $grad_assessed_sections_count = 0;
102
+            $grad_school_sections_count = 0;
103
+
104
+            foreach($school->programs as $program)
105
+            {
106
+                foreach ($program->courses as $course)
107
+                {
108
+                    if(!$course->program->is_graduate)
109
+                    {
110
+                        if($course->outcomes_achieved != NULL)
111
+                        {
112
+                            $course_outcomes_achieved =json_decode($course->outcomes_achieved, true);
113
+                            $course_outcomes_attempted =json_decode($course->outcomes_attempted, true);
114
+                            for($i=1; $i<=count($undergrad_outcomes_attempted); $i++)
115
+                            {
116
+                                $undergrad_outcomes_achieved[$i]+=$course_outcomes_achieved[$i];
117
+                                $undergrad_outcomes_attempted[$i]+=$course_outcomes_attempted[$i];
118
+                            }
119
+                            $undergrad_assessed_sections_count+=1;
120
+                        }
121
+                        $undergrad_school_sections_count+=1;
122
+                    }
123
+                    else
124
+                    {
125
+                        if($course->outcomes_achieved != NULL)
126
+                        {
127
+                            $course_outcomes_achieved =json_decode($course->outcomes_achieved, true);
128
+                            $course_outcomes_attempted =json_decode($course->outcomes_attempted, true);
129
+                            for($i=1; $i<=count($grad_outcomes_attempted); $i++)
130
+                            {
131
+                                $grad_outcomes_achieved[$i]+=$course_outcomes_achieved[$i];
132
+                                $grad_outcomes_attempted[$i]+=$course_outcomes_attempted[$i];
133
+                            }
134
+                            $grad_assessed_sections_count+=1;
135
+                        }
136
+                        $grad_school_sections_count+=1;
137
+                    }
138
+                }    
139
+            }
140
+
141
+            /**
142
+             * Calculate how many programs achieved and attempted each outcome in this school
143
+             */
144
+
145
+            // Number of programs that achieved a particular learning outcome
146
+            $achievedUndergradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
147
+
148
+            // Number of programs that attempted a particular learning outcome
149
+            $attemptedUndergradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
150
+
151
+            // Fetch programs with participation for the school
152
+            $participating_undergrad_programs = DB::table('VIEW_participating_programs')
153
+                ->whereIn('semester_id', Session::get('semesters_ids'))
154
+                ->where('is_graduate', 0)
155
+                ->where('school_id', $school->id)
156
+                ->groupBy('id')
157
+                ->get();
158
+
159
+            $output = array();
160
+
161
+
162
+            // For each outcome 
163
+            foreach ($outcomes as $outcome)
164
+            {
165
+                // For each program with courses that do assessment
166
+                $programs_with_courses = Program::with(array('courses' => function($query){
167
+                    $query->whereNotNull('outcomes_attempted');
168
+                    $query->whereIn('semester_id', Session::get('semesters_ids'));
169
+                }))->where('is_graduate', 0)->where('school_id', $school->id)->orderBy('name', 'asc')->get();
170
+
171
+                foreach ($programs_with_courses as $program)
172
+                {
173
+                    // To acummulate all criteria for one program
174
+                    $achieved_outcomes_per_undergrad_program = array_fill(1, $outcomeCount, 0);
175
+                    $attempted_outcomes_per_undergrad_program = array_fill(1, $outcomeCount, 0);
176
+
177
+                    //Flag for counting programs
178
+                    $flag =false;
179
+
180
+                    // For each course in the program
181
+                    foreach ($program->courses as $course)
182
+                    {
183
+                        // If the outcome in question is being evaluated
184
+                        $course_outcomes_attempted2 = json_decode($course->outcomes_attempted, true);
185
+                        $course_outcomes_achieved2 = json_decode($course->outcomes_achieved, true);
186
+                        if(array_key_exists($outcome->id, $course_outcomes_attempted2 )
187
+                            && $course_outcomes_attempted2[$outcome->id]>0)
188
+                        {
189
+                            $achieved_outcomes_per_undergrad_program[$outcome->id]+=$course_outcomes_achieved2[$outcome->id];
190
+                            $attempted_outcomes_per_undergrad_program[$outcome->id]+=$course_outcomes_attempted2[$outcome->id];
191
+
192
+                            // Add one to the programs assessing, if it wasn't added before
193
+                            if(!$flag)
194
+                            {
195
+                                $attemptedUndergradProgramsPerOutcome[$outcome->id]+=1;
196
+                                $flag= true;
197
+                            }
198
+                        }
199
+
200
+                        // $output[] = 'ACHIEVED: '.$program->name.'-'.json_encode($achieved_outcomes_per_undergrad_program);
201
+                        // $output[] = 'ATTEMPTED: '.$program->name.'-'.json_encode($attempted_outcomes_per_program);
202
+
203
+                    }
204
+                    //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
205
+                    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)
206
+                    {
207
+                        $achievedUndergradProgramsPerOutcome[$outcome->id]+=1;
208
+                        // $output[]= 'END OF PROGRAM: '.$program->name.'-'.json_encode($achievedProgramsPerOutcome);
209
+                    }
210
+                }
211
+            }
212
+
213
+            /**
214
+             * Calculate how many programs achieved and attempted each outcome in this school
215
+             */
216
+
217
+            // Number of programs that achieved a particular learning outcome
218
+            $achievedGradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
219
+
220
+            // Number of programs that attempted a particular learning outcome
221
+            $attemptedGradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
222
+
223
+            // Fetch programs with participation for the school
224
+            $participating_grad_programs = DB::table('VIEW_participating_programs')
225
+                ->whereIn('semester_id', Session::get('semesters_ids'))
226
+                ->where('is_graduate', 1)
227
+                ->where('school_id', $school->id)
228
+                ->groupBy('id')
229
+                ->get();
230
+
231
+            $output = array();
232
+
233
+
234
+            // For each outcome 
235
+            foreach ($outcomes as $outcome)
236
+            {
237
+                // For each program with courses that do assessment
238
+                $programs_with_courses = Program::with(array('courses' => function($query){
239
+                    $query->whereNotNull('outcomes_attempted');
240
+                    $query->whereIn('semester_id', Session::get('semesters_ids'));
241
+                }))->where('is_graduate', 1)->where('school_id', $school->id)->orderBy('name', 'asc')->get();
242
+
243
+                foreach ($programs_with_courses as $program)
244
+                {
245
+                    // To acummulate all criteria for one program
246
+                    $achieved_outcomes_per_grad_program = array_fill(1, $outcomeCount, 0);
247
+                    $attempted_outcomes_per_grad_program = array_fill(1, $outcomeCount, 0);
248
+
249
+                    //Flag for counting programs
250
+                    $flag =false;
251
+
252
+                    // For each course in the program
253
+                    foreach ($program->courses as $course)
254
+                    {
255
+                        // If the outcome in question is being evaluated
256
+                        $course_outcomes_attempted2 = json_decode($course->outcomes_attempted, true);
257
+                        $course_outcomes_achieved2 = json_decode($course->outcomes_achieved, true);
258
+                        if(array_key_exists($outcome->id, $course_outcomes_attempted2 )
259
+                            && $course_outcomes_attempted2[$outcome->id]>0)
260
+                        {
261
+                            $achieved_outcomes_per_grad_program[$outcome->id]+=$course_outcomes_achieved2[$outcome->id];
262
+                            $attempted_outcomes_per_grad_program[$outcome->id]+=$course_outcomes_attempted2[$outcome->id];
263
+
264
+                            // Add one to the programs assessing, if it wasn't added before
265
+                            if(!$flag)
266
+                            {
267
+                                $attemptedGradProgramsPerOutcome[$outcome->id]+=1;
268
+                                $flag= true;
269
+                            }
270
+                        }
271
+
272
+                        // $output[] = 'ACHIEVED: '.$program->name.'-'.json_encode($achieved_outcomes_per_grad_program);
273
+                        // $output[] = 'ATTEMPTED: '.$program->name.'-'.json_encode($attempted_outcomes_per_program);
274
+
275
+                    }
276
+                    //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
277
+                    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)
278
+                    {
279
+                        $achievedGradProgramsPerOutcome[$outcome->id]+=1;
280
+                        // $output[]= 'END OF PROGRAM: '.$program->name.'-'.json_encode($achievedProgramsPerOutcome);
281
+                    }
282
+                }
283
+            }
284
+            return View::make('local.managers.shared.school', compact('title', 'outcomes','undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs', 'participating_undergrad_programs', 'participating_grad_programs'));
285
+        }
286
+
287
+}

+ 409
- 0
app/controllers/SchoolsController.php ファイルの表示

@@ -0,0 +1,409 @@
1
+<?php
2
+
3
+class SchoolsController extends \BaseController
4
+{
5
+
6
+    private function participatingPrograms($school)
7
+    {
8
+        return DB::table('VIEW_participating_programs')
9
+            ->where('school_id', $school->id)
10
+            ->whereIn('semester_id', Session::get('semesters_ids'))
11
+            ->lists('id');
12
+    }
13
+
14
+	public function show($id)
15
+	{
16
+        ini_set('memory_limit', '256M');
17
+        DB::connection()->disableQueryLog();
18
+        $school = School::find($id);
19
+        $title= $school->name;
20
+        $schools = School::all();
21
+
22
+        $outcomes = Outcome::orderBy('name', 'asc')->get();
23
+        $outcomeCount = Outcome::all()->count();
24
+
25
+
26
+        /**
27
+         * List of grouped courses (grouped sections)
28
+         */
29
+
30
+        $program_ids= $school->programs->lists('id');
31
+
32
+        $undergrad_programs = DB::table('programs')
33
+        ->select('id', 'name', 'school_id', 'is_graduate')
34
+        ->where('is_graduate', '=', 0)
35
+        ->where('school_id', '=', $id)
36
+        ->orderBy('name', 'ASC')
37
+        ->get();
38
+
39
+        $grad_programs = DB::table('programs')
40
+        ->select('id', 'name', 'school_id', 'is_graduate')
41
+        ->where('is_graduate', '=', 1)
42
+        ->where('school_id', '=', $id)
43
+        ->orderBy('name', 'ASC')
44
+        ->get();
45
+   
46
+
47
+        $grad_grouped_courses = Course::
48
+            select(DB::raw('courses.name, courses.code, courses.number, max(courses.outcomes_attempted) as outcomes_attempted, courses.semester_id, courses.program_id'))
49
+            ->with('semester')
50
+            ->with('program')
51
+            ->whereIn('courses.program_id', $program_ids)
52
+            ->whereIn('courses.semester_id', Session::get('semesters_ids'))
53
+            ->leftJoin('programs', 'courses.program_id', '=', 'programs.id')
54
+            ->where('programs.is_graduate', '=', 1)
55
+            ->groupBy(array('courses.code', 'courses.number', 'courses.semester_id'))
56
+            ->orderBy('courses.code')
57
+            ->orderBy('courses.number')
58
+            ->orderBy('courses.semester_id')
59
+            ->get();
60
+
61
+        $undergrad_grouped_courses = Course::
62
+            select(DB::raw('courses.name, courses.code, courses.number, max(courses.outcomes_attempted) as outcomes_attempted, courses.semester_id, courses.program_id'))
63
+            ->with('semester')
64
+            ->with('program')
65
+            ->whereIn('courses.program_id', $program_ids)
66
+            ->whereIn('courses.semester_id', Session::get('semesters_ids'))
67
+            ->leftJoin('programs', 'courses.program_id', '=', 'programs.id')
68
+            ->where('programs.is_graduate', '=', 0)
69
+            ->groupBy(array('courses.code', 'courses.number', 'courses.semester_id'))
70
+            ->orderBy('courses.code')
71
+            ->orderBy('courses.number')
72
+            ->orderBy('courses.semester_id')
73
+            ->get();
74
+
75
+        // Fetch programs with participation
76
+        $participating_programs = $this->participatingPrograms($school);
77
+
78
+
79
+        /**
80
+         * Calculate how many sections are doing assessment
81
+         */
82
+
83
+        $undergrad_outcomes_achieved = array_fill(1, $outcomeCount, 0);
84
+        $undergrad_outcomes_attempted = array_fill(1, $outcomeCount, 0);
85
+        $undergrad_assessed_sections_count = 0;
86
+        $undergrad_school_sections_count = 0;
87
+
88
+        $grad_outcomes_achieved = array_fill(1, $outcomeCount, 0);
89
+        $grad_outcomes_attempted = array_fill(1, $outcomeCount, 0);
90
+        $grad_assessed_sections_count = 0;
91
+        $grad_school_sections_count = 0;
92
+
93
+        foreach($school->programs as $program)
94
+        {
95
+        	foreach ($program->courses as $course)
96
+        	{
97
+                if(!$course->program->is_graduate)
98
+                {
99
+                    if($course->outcomes_achieved != NULL)
100
+                    {
101
+                        $course_outcomes_achieved =json_decode($course->outcomes_achieved, true);
102
+                        $course_outcomes_attempted =json_decode($course->outcomes_attempted, true);
103
+                        for($i=1; $i<=count($undergrad_outcomes_attempted); $i++)
104
+                        {
105
+                            $undergrad_outcomes_achieved[$i]+=$course_outcomes_achieved[$i];
106
+                            $undergrad_outcomes_attempted[$i]+=$course_outcomes_attempted[$i];
107
+                        }
108
+                        $undergrad_assessed_sections_count+=1;
109
+                    }
110
+                    $undergrad_school_sections_count+=1;
111
+                }
112
+                else
113
+                {
114
+                    if($course->outcomes_achieved != NULL)
115
+                    {
116
+                        $course_outcomes_achieved =json_decode($course->outcomes_achieved, true);
117
+                        $course_outcomes_attempted =json_decode($course->outcomes_attempted, true);
118
+                        for($i=1; $i<=count($grad_outcomes_attempted); $i++)
119
+                        {
120
+                            $grad_outcomes_achieved[$i]+=$course_outcomes_achieved[$i];
121
+                            $grad_outcomes_attempted[$i]+=$course_outcomes_attempted[$i];
122
+                        }
123
+                        $grad_assessed_sections_count+=1;
124
+                    }
125
+                    $grad_school_sections_count+=1;
126
+                }
127
+            }    
128
+        }
129
+
130
+        /**
131
+         * Calculate how many programs achieved and attempted each outcome in this school
132
+         */
133
+
134
+        // Number of programs that achieved a particular learning outcome
135
+        $achievedUndergradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
136
+
137
+        // Number of programs that attempted a particular learning outcome
138
+        $attemptedUndergradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
139
+
140
+        // Fetch programs with participation for the school
141
+        $participating_undergrad_programs = DB::table('VIEW_participating_programs')
142
+            ->whereIn('semester_id', Session::get('semesters_ids'))
143
+            ->where('is_graduate', 0)
144
+            ->where('school_id', $school->id)
145
+            ->groupBy('id')
146
+            ->get();
147
+
148
+        $output = array();
149
+
150
+
151
+        // For each outcome 
152
+        foreach ($outcomes as $outcome)
153
+        {
154
+            // For each program with courses that do assessment
155
+            $programs_with_courses = Program::with(array('courses' => function($query){
156
+                $query->whereNotNull('outcomes_attempted');
157
+                $query->whereIn('semester_id', Session::get('semesters_ids'));
158
+            }))->where('is_graduate', 0)->where('school_id', $school->id)->orderBy('name', 'asc')->get();
159
+
160
+            foreach ($programs_with_courses as $program)
161
+            {
162
+                // To acummulate all criteria for one program
163
+                $achieved_outcomes_per_undergrad_program = array_fill(1, $outcomeCount, 0);
164
+                $attempted_outcomes_per_undergrad_program = array_fill(1, $outcomeCount, 0);
165
+
166
+                //Flag for counting programs
167
+                $flag =false;
168
+
169
+                // For each course in the program
170
+                foreach ($program->courses as $course)
171
+                {
172
+                    // If the outcome in question is being evaluated
173
+                    $course_outcomes_attempted2 = json_decode($course->outcomes_attempted, true);
174
+                    $course_outcomes_achieved2 = json_decode($course->outcomes_achieved, true);
175
+                    if(array_key_exists($outcome->id, $course_outcomes_attempted2 )
176
+                        && $course_outcomes_attempted2[$outcome->id]>0)
177
+                    {
178
+                        $achieved_outcomes_per_undergrad_program[$outcome->id]+=$course_outcomes_achieved2[$outcome->id];
179
+                        $attempted_outcomes_per_undergrad_program[$outcome->id]+=$course_outcomes_attempted2[$outcome->id];
180
+
181
+                        // Add one to the programs assessing, if it wasn't added before
182
+                        if(!$flag)
183
+                        {
184
+                            $attemptedUndergradProgramsPerOutcome[$outcome->id]+=1;
185
+                            $flag= true;
186
+                        }
187
+                    }
188
+
189
+                    // $output[] = 'ACHIEVED: '.$program->name.'-'.json_encode($achieved_outcomes_per_undergrad_program);
190
+                    // $output[] = 'ATTEMPTED: '.$program->name.'-'.json_encode($attempted_outcomes_per_program);
191
+
192
+                }
193
+                //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
194
+                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)
195
+                {
196
+                    $achievedUndergradProgramsPerOutcome[$outcome->id]+=1;
197
+                    // $output[]= 'END OF PROGRAM: '.$program->name.'-'.json_encode($achievedProgramsPerOutcome);
198
+                }
199
+            }
200
+        }
201
+
202
+        /**
203
+         * Calculate how many programs achieved and attempted each outcome in this school
204
+         */
205
+
206
+        // Number of programs that achieved a particular learning outcome
207
+        $achievedGradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
208
+
209
+        // Number of programs that attempted a particular learning outcome
210
+        $attemptedGradProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
211
+
212
+        // Fetch programs with participation for the school
213
+        $participating_grad_programs = DB::table('VIEW_participating_programs')
214
+            ->whereIn('semester_id', Session::get('semesters_ids'))
215
+            ->where('is_graduate', 1)
216
+            ->where('school_id', $school->id)
217
+            ->groupBy('id')
218
+            ->get();
219
+
220
+        $output = array();
221
+
222
+
223
+        // For each outcome 
224
+        foreach ($outcomes as $outcome)
225
+        {
226
+            // For each program with courses that do assessment
227
+            $programs_with_courses = Program::with(array('courses' => function($query){
228
+                $query->whereNotNull('outcomes_attempted');
229
+                $query->whereIn('semester_id', Session::get('semesters_ids'));
230
+            }))->where('is_graduate', 1)->where('school_id', $school->id)->orderBy('name', 'asc')->get();
231
+
232
+            foreach ($programs_with_courses as $program)
233
+            {
234
+                // To acummulate all criteria for one program
235
+                $achieved_outcomes_per_grad_program = array_fill(1, $outcomeCount, 0);
236
+                $attempted_outcomes_per_grad_program = array_fill(1, $outcomeCount, 0);
237
+
238
+                //Flag for counting programs
239
+                $flag =false;
240
+
241
+                // For each course in the program
242
+                foreach ($program->courses as $course)
243
+                {
244
+                    // If the outcome in question is being evaluated
245
+                    $course_outcomes_attempted2 = json_decode($course->outcomes_attempted, true);
246
+                    $course_outcomes_achieved2 = json_decode($course->outcomes_achieved, true);
247
+                    if(array_key_exists($outcome->id, $course_outcomes_attempted2 )
248
+                        && $course_outcomes_attempted2[$outcome->id]>0)
249
+                    {
250
+                        $achieved_outcomes_per_grad_program[$outcome->id]+=$course_outcomes_achieved2[$outcome->id];
251
+                        $attempted_outcomes_per_grad_program[$outcome->id]+=$course_outcomes_attempted2[$outcome->id];
252
+
253
+                        // Add one to the programs assessing, if it wasn't added before
254
+                        if(!$flag)
255
+                        {
256
+                            $attemptedGradProgramsPerOutcome[$outcome->id]+=1;
257
+                            $flag= true;
258
+                        }
259
+                    }
260
+
261
+                    // $output[] = 'ACHIEVED: '.$program->name.'-'.json_encode($achieved_outcomes_per_grad_program);
262
+                    // $output[] = 'ATTEMPTED: '.$program->name.'-'.json_encode($attempted_outcomes_per_program);
263
+
264
+                }
265
+                //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
266
+                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)
267
+                {
268
+                    $achievedGradProgramsPerOutcome[$outcome->id]+=1;
269
+                    // $output[]= 'END OF PROGRAM: '.$program->name.'-'.json_encode($achievedProgramsPerOutcome);
270
+                }
271
+            }
272
+        }
273
+        if($school->id == 13){
274
+            return View::make('local.managers.shared.school-uhs', compact('title', 'outcomes','undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs', 'participating_undergrad_programs', 'participating_grad_programs'));
275
+        }else{
276
+            return View::make('local.managers.shared.school', compact('title', 'outcomes','undergrad_programs', 'grad_programs', 'undergrad_outcomes_attempted', 'grad_outcomes_attempted', 'undergrad_outcomes_achieved', 'grad_outcomes_achieved', 'schools', 'school', 'undergrad_assessed_sections_count', 'grad_assessed_sections_count', 'undergrad_school_sections_count', 'grad_school_sections_count', 'achievedUndergradProgramsPerOutcome', 'achievedGradProgramsPerOutcome', 'attemptedUndergradProgramsPerOutcome', 'attemptedGradProgramsPerOutcome', 'grad_grouped_courses', 'undergrad_grouped_courses', 'participating_programs', 'participating_undergrad_programs', 'participating_grad_programs'));
277
+        }
278
+    }
279
+
280
+    public function print_school($id)
281
+    {
282
+        ini_set('memory_limit', '256M');
283
+        DB::connection()->disableQueryLog();
284
+
285
+        $school = School::find($id);
286
+        $title= $school->name.' Assessment Report - '.date('m/d/Y');
287
+
288
+        $outcomes = Outcome::orderBy('name', 'asc')->get();
289
+        $outcomeCount = Outcome::all()->count();
290
+
291
+
292
+
293
+
294
+        /**
295
+         * List of courses (grouped sections)
296
+         */
297
+
298
+        $program_ids= $school->programs->lists('id');
299
+
300
+        $grouped_courses = Course::
301
+            select(DB::raw('name, code, number, max(outcomes_attempted) as outcomes_attempted, semester_id, program_id'))
302
+            ->with('semester')
303
+            ->with('program')
304
+            ->whereIn('program_id', $program_ids)
305
+            ->whereIn('semester_id', Session::get('semesters_ids'))
306
+            ->groupBy(array('code', 'number', 'semester_id'))
307
+            ->orderBy('code')
308
+            ->orderBy('number')
309
+            ->orderBy('semester_id')
310
+            ->get();
311
+
312
+        // Fetch programs with participation
313
+        $participating_programs = $this->participatingPrograms($school);
314
+
315
+        /**
316
+         * Calculate how many sections are doing assessment
317
+         */
318
+
319
+        $outcomes_achieved = array_fill(1, $outcomeCount, 0);
320
+        $outcomes_attempted = array_fill(1, $outcomeCount, 0);
321
+        $assessed_sections_count = 0;
322
+        $school_sections_count = 0;
323
+
324
+        foreach($school->programs as $program)
325
+        {
326
+            foreach ($program->courses as $course)
327
+            {
328
+              if($course->outcomes_achieved!=NULL)
329
+              {
330
+                $course_outcomes_achieved =json_decode($course->outcomes_achieved, true);
331
+                $course_outcomes_attempted =json_decode($course->outcomes_attempted, true);
332
+                for($i=1; $i<=count($outcomes_attempted); $i++)
333
+                {
334
+                  $outcomes_achieved[$i]+=$course_outcomes_achieved[$i];
335
+                  $outcomes_attempted[$i]+=$course_outcomes_attempted[$i];
336
+                }
337
+
338
+                $assessed_sections_count+=1;
339
+              }
340
+              $school_sections_count+=1;
341
+            }
342
+        }
343
+
344
+        /**
345
+         * Calculate how many programs achieved and attempted each outcome in this school
346
+         */
347
+
348
+        // Number of programs that achieved a particular learning outcome
349
+        $achievedProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
350
+
351
+        // Number of programs that attempted a particular learning outcome
352
+        $attemptedProgramsPerOutcome = array_fill(1, $outcomeCount, 0);
353
+
354
+        $output = array();
355
+
356
+
357
+        // For each outcome
358
+        foreach ($outcomes as $outcome)
359
+        {
360
+            // For each program with courses that do assessment
361
+            foreach (Program::with(array('courses' => function($query){
362
+                $query->whereNotNull('outcomes_attempted');
363
+                $query->whereIn('semester_id', Session::get('semesters_ids'));
364
+            }))->where('school_id', $school->id)->orderBy('name', 'asc')->get() as $program)
365
+            {
366
+                // To acummulate all criteria for one program
367
+                $achieved_outcomes_per_program = array_fill(1, $outcomeCount, 0);
368
+                $attempted_outcomes_per_program = array_fill(1, $outcomeCount, 0);
369
+
370
+                //Flag for counting programs
371
+                $flag =false;
372
+
373
+                // For each course in the program
374
+                foreach ($program->courses as $course)
375
+                {
376
+                    // If the outcome in question is being evaluated
377
+                    $course_outcomes_attempted2 = json_decode($course->outcomes_attempted, true);
378
+                    $course_outcomes_achieved2 = json_decode($course->outcomes_achieved, true);
379
+                    if(array_key_exists($outcome->id, $course_outcomes_attempted2 )
380
+                        && $course_outcomes_attempted2[$outcome->id]>0)
381
+                    {
382
+                        $achieved_outcomes_per_program[$outcome->id]+=$course_outcomes_achieved2[$outcome->id];
383
+                        $attempted_outcomes_per_program[$outcome->id]+=$course_outcomes_attempted2[$outcome->id];
384
+
385
+                        // Add one to the programs assessing, if it wasn't added before
386
+                        if(!$flag)
387
+                        {
388
+                            $attemptedProgramsPerOutcome[$outcome->id]+=1;
389
+                            $flag= true;
390
+                        }
391
+                    }
392
+
393
+                    // $output[] = 'ACHIEVED: '.$program->name.'-'.json_encode($achieved_outcomes_per_program);
394
+                    // $output[] = 'ATTEMPTED: '.$program->name.'-'.json_encode($attempted_outcomes_per_program);
395
+
396
+                }
397
+                //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
398
+                if($attempted_outcomes_per_program[$outcome->id]!=0 && (float)$achieved_outcomes_per_program[$outcome->id]/$attempted_outcomes_per_program[$outcome->id]*100 >= $outcome->expected_outcome)
399
+                {
400
+                    $achievedProgramsPerOutcome[$outcome->id]+=1;
401
+                    // $output[]= 'END OF PROGRAM: '.$program->name.'-'.json_encode($achievedProgramsPerOutcome);
402
+                }
403
+            }
404
+        }
405
+
406
+       return View::make('local.managers.shared.print_school', compact('title', 'outcomes', 'outcomes_attempted', 'outcomes_achieved', 'school', 'assessed_sections_count', 'school_sections_count', 'achievedProgramsPerOutcome', 'attemptedProgramsPerOutcome', 'grouped_courses', 'participating_programs'));
407
+    }
408
+
409
+}

+ 82
- 0
app/controllers/SectionsController.php ファイルの表示

@@ -0,0 +1,82 @@
1
+<?php namespace App\Http\Controllers;
2
+
3
+use App\Http\Requests;
4
+use App\Http\Controllers\Controller;
5
+
6
+class SectionsController extends Controller {
7
+
8
+	/**
9
+	 * Display a listing of the resource.
10
+	 *
11
+	 * @return Response
12
+	 */
13
+	public function index()
14
+	{
15
+		//
16
+	}
17
+
18
+	/**
19
+	 * Show the form for creating a new resource.
20
+	 *
21
+	 * @return Response
22
+	 */
23
+	public function create()
24
+	{
25
+		//
26
+	}
27
+
28
+	/**
29
+	 * Store a newly created resource in storage.
30
+	 *
31
+	 * @return Response
32
+	 */
33
+	public function store()
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
+	 * Show the form for editing the specified resource.
51
+	 *
52
+	 * @param  int  $id
53
+	 * @return Response
54
+	 */
55
+	public function edit($id)
56
+	{
57
+		//
58
+	}
59
+
60
+	/**
61
+	 * Update the specified resource in storage.
62
+	 *
63
+	 * @param  int  $id
64
+	 * @return Response
65
+	 */
66
+	public function update($id)
67
+	{
68
+		//
69
+	}
70
+
71
+	/**
72
+	 * Remove the specified resource from storage.
73
+	 *
74
+	 * @param  int  $id
75
+	 * @return Response
76
+	 */
77
+	public function destroy($id)
78
+	{
79
+		//
80
+	}
81
+
82
+}

+ 101
- 0
app/controllers/SemestersController.php ファイルの表示

@@ -0,0 +1,101 @@
1
+<?php 
2
+
3
+class SemestersController extends \BaseController {
4
+
5
+	public function filterSemesters()
6
+	{
7
+		$semesters_ids = array();
8
+		$semesters_info = array();
9
+
10
+		if(count(Input::get('semesters_ids')))
11
+		{
12
+			// For each selected semester, fetch its info to add to the Session arrays
13
+			foreach (Input::get('semesters_ids') as $semester_id) {
14
+				$semesters_ids[] = $semester_id;
15
+				$semester = Semester::find($semester_id);
16
+				$semesters_info[] = $semester->name.' ('.$semester->code.')';
17
+
18
+			}
19
+
20
+			// Put semesters information arrays into Session
21
+			Session::forget('semesters_ids');
22
+			Session::put('semesters_ids', $semesters_ids);
23
+			Session::forget('semesters_info');
24
+			Session::put('semesters_info', $semesters_info);
25
+		}
26
+
27
+		return Redirect::back();
28
+	}
29
+
30
+	public function edit()
31
+	{
32
+		$title = "Semester Management";
33
+		$semesters = Semester::all();
34
+
35
+		return View::make('local.managers.admins.semesters', compact('title', 'semesters'));
36
+	}
37
+
38
+	public function update()
39
+	{
40
+		/** Validate data */
41
+		$validator = Validator::make(
42
+			Input::all(),
43
+			array(
44
+				'id'=>'required|integer',
45
+    			'start'=>'required|date_format:m/d/y H:i:s',
46
+    			'end'=>'required|date_format:m/d/y H:i:s',
47
+    			'visible'=>'required|integer',
48
+			),
49
+			array(
50
+				'start.date_format' => 'The start date must be in this format: mm/dd/yyyy hh:mm:ss',
51
+				'end.date_format' => 'The end date must be in this format: mm/dd/yyyy hh:mm:ss',
52
+			)
53
+		);
54
+
55
+		if(!$validator->fails())
56
+		{
57
+
58
+			$semester = Semester::find(Input::get('id'));
59
+			$semester->start = date('Y-m-d H:i:s', strtotime(Input::get('start')));
60
+			$semester->end = date('Y-m-d H:i:s', strtotime(Input::get('end')));
61
+			// $semester->start = strtotime(Input::get('start'));
62
+			// $semester->end = strtotime(Input::get('end'));
63
+			$semester->is_visible = Input::get('visible');
64
+
65
+			try 
66
+			{
67
+				if($semester->save())
68
+				{
69
+					Session::flash('status', 'success');
70
+				 	Session::flash('message', $semester->name.' updated ('.date('m/d/y h:i:s a').').');
71
+				}
72
+				else
73
+				{
74
+					Session::flash('status', 'danger');
75
+					Session::flash('message', 'Error updating '.$semester->name.'. Try again later. If the problem persists, contact a super-administrator ('.date('m/d/y h:i:s a').').');	
76
+				}
77
+			} catch (Exception $e) {
78
+					Session::flash('status', 'danger');
79
+					Session::flash('message', 'Error updating '.$semester->name.'. Contact a super-administrator ('.date('m/d/y h:i:s a').').');	
80
+						
81
+			}
82
+		}
83
+		else
84
+		{
85
+            /** Prepare error message */
86
+            $message = '<ul>';
87
+
88
+            foreach ($validator->messages()->all('<li>:message</li>') as $validationError)
89
+            {
90
+                $message.=$validationError;
91
+            }
92
+
93
+            $message.='</ul>';
94
+
95
+			Session::flash('status', 'danger');
96
+			Session::flash('message', $message);
97
+		}
98
+	}
99
+
100
+
101
+}

+ 138
- 0
app/controllers/StudentsController.php ファイルの表示

@@ -0,0 +1,138 @@
1
+<?php
2
+
3
+class StudentsController extends \BaseController {
4
+
5
+  public function show($semester_id, $course_identifier, $number)
6
+  {
7
+
8
+  	$student = Student::where('number', '=', $number)->first();
9
+  	$code = substr($course_identifier, 0, 4);
10
+  	$number = substr($course_identifier, 4, 4);
11
+  	$section = substr($course_identifier, 9, 4);
12
+  	$course = Course::where('code', $code)->where('number', $number)->where('section', $section)->where('semester_id', $semester_id)->first();
13
+  	$title = $student->name;
14
+
15
+  	$activities = $course->assessedActivities;
16
+  	$activitiesArray = array();
17
+  	foreach ($activities as $activity)
18
+  	{
19
+  		$activitiesArray[]=$activity->id;
20
+  	}
21
+
22
+    // If the student has be assessed
23
+    if(!$activities->isEmpty())
24
+    {
25
+      // Get the assessments
26
+      $assessments = DB::table('assessments')->whereIn('activity_id', $activitiesArray)->where('student_id', '=', $student->id)->orderBy('created_at')->get();
27
+
28
+      // foreach ($assessments as $assessed_activity)
29
+      // {
30
+      //   $outcomes_achieved = array_fill(1, Outcome::all()->count(), 0);
31
+      //   $outcomes_attempted = array_fill(1, Outcome::all()->count(), 0);
32
+
33
+      //   $single_activity_scores = json_decode($assessed_activity->scores);
34
+      //   foreach($single_activity_scores as $criterion_id => $criterion_score)
35
+      //   {
36
+      //       // Find corresponding learning outcome;
37
+      //       $criterion = Criterion::withTrashed()->find($criterion_id);
38
+      //       $outcome = Outcome::find($criterion->outcome_id);
39
+
40
+      //       // If criterion is achieved (1), add 1 to all arrays
41
+      //       if($criterion_score >= Rubric::find($activity->rubric_id)->expected_points)
42
+      //       {
43
+      //           $outcomes_attempted[$outcome->id]+=1;
44
+      //           $outcomes_achieved[$outcome->id]+=1;;
45
+      //       }
46
+      //       // Else, only add to the attempted outcomes array
47
+      //       else
48
+      //       {
49
+      //           $outcomes_attempted[$outcome->id]+=1;
50
+      //       }
51
+      //   }
52
+
53
+      //   $outcomes_per_activity = array_fill(1, Outcome::all()->count(), 0);
54
+      //   foreach ($outcomes_attempted as $index=>$outcome_attempted)
55
+      //   {
56
+      //     if($outcomes_attempted[$index]!=0)
57
+      //     {
58
+      //       // For each outcome in the activity, calculate and save the percentage
59
+      //       $outcomes_per_activity[$index] = (float)$outcomes_achieved[$index]/$outcomes_attempted[$index]*100;
60
+      //     }
61
+      //   }
62
+
63
+      //   //Save to activity array
64
+      //   $activitiesArray[]=$outcomes_per_activity;
65
+      // }
66
+    }
67
+    else
68
+      $assessments = NULL;
69
+
70
+    return View::make('local.professors.student', compact('student', 'course', 'title', 'assessments'));
71
+  }
72
+
73
+  public function printStudentReport($semester_id, $course_identifier, $number)
74
+  {
75
+
76
+    $student = Student::where('number', '=', $number)->first();
77
+    $code = substr($course_identifier, 0, 4);
78
+    $number = substr($course_identifier, 4, 4);
79
+    $section = substr($course_identifier, 9, 4);
80
+    $course = Course::where('code', $code)->where('number', $number)->where('section', $section)->where('semester_id', $semester_id)->first();
81
+    $title = $student->name;
82
+
83
+    $activities = $course->assessedActivities;
84
+    $activitiesArray = array();
85
+    foreach ($activities as $activity)
86
+    {
87
+      $activitiesArray[]=$activity->id;
88
+    }
89
+
90
+    if(!$activities->isEmpty())
91
+    {
92
+      $assessments = DB::table('assessments')->whereIn('activity_id', $activitiesArray)->where('student_id', '=', $student->id)->get();
93
+
94
+      foreach ($assessments as $assessed_activity)
95
+      {
96
+        $outcomes_achieved = array_fill(1, Outcome::all()->count(), 0);
97
+        $outcomes_attempted = array_fill(1, Outcome::all()->count(), 0);
98
+
99
+        $single_activity_scores = json_decode($assessed_activity->scores);
100
+        foreach($single_activity_scores as $criterion_id=>$criterion_score)
101
+        {
102
+            // Find corresponding learning outcome;
103
+            $criterion = Criterion::withTrashed()->find($criterion_id);
104
+            $outcome = Outcome::find($criterion->outcome_id);
105
+
106
+            // If criterion is achieved (1), add 1 to all arrays
107
+            if($criterion_score >= Rubric::find($activity->rubric_id)->expected_points)
108
+            {
109
+                $outcomes_attempted[$outcome->id]+=1;
110
+                $outcomes_achieved[$outcome->id]+=1;;
111
+            }
112
+            // Else, only add to the attempted outcomes array
113
+            else
114
+            {
115
+                $outcomes_attempted[$outcome->id]+=1;
116
+            }
117
+        }
118
+
119
+        $outcomes_per_activity = array_fill(1, Outcome::all()->count(), 0);
120
+        foreach ($outcomes_attempted as $index=>$outcome_attempted)
121
+        {
122
+          if($outcomes_attempted[$index]!=0)
123
+          {
124
+            // For each outcome in the activity, calculate and save the percentage
125
+            $outcomes_per_activity[$index] = (float)$outcomes_achieved[$index]/$outcomes_attempted[$index]*100;
126
+          }
127
+        }
128
+
129
+        //Save to activity array
130
+        $activitiesArray[]=$outcomes_per_activity;
131
+      }
132
+    }
133
+    else
134
+      $assessments = NULL;
135
+
136
+    return View::make('local.professors.print_student_report', compact('student', 'course', 'title', 'assessments', 'activitiesArray'));
137
+  }
138
+}

+ 248
- 0
app/controllers/TemplatesController.php ファイルの表示

@@ -0,0 +1,248 @@
1
+<?php
2
+
3
+class TemplatesController extends \BaseController {
4
+
5
+	/**
6
+	 * List all templates, grouped by program
7
+	 */
8
+	public function index()
9
+	{
10
+		$title = 'Rubric List';
11
+
12
+		$global_templates = Template::whereNull('school_id')->whereNull('program_id')->get();
13
+
14
+		$schools = School::with('programs.templates')
15
+		->orderBy('name')
16
+		->get();
17
+
18
+		$templates = Template::orderBy('name')->get();
19
+
20
+		return View::make('local.managers.admins.rubric_list', compact('title', 'global_templates','schools', 'templates'));
21
+	}
22
+
23
+	public function schoolCoordinatorIndex()
24
+	{
25
+		$title = 'Rubric List';
26
+
27
+		$global_templates = Template::whereNull('school_id')->whereNull('program_id')->get();
28
+
29
+		$schools = School::with('programs.templates')
30
+		->orderBy('name')
31
+		->get();
32
+
33
+		$templates = Template::orderBy('name')->get();
34
+
35
+		return View::make('local.managers.admins.rubric_list', compact('title', 'global_templates','schools', 'templates'));
36
+	}
37
+
38
+	public function show(Template $template)
39
+	{
40
+	    $title = $template->name;
41
+	    return View::make('local.managers.admins.view_template', compact('template', 'title'));
42
+	}
43
+
44
+	/**
45
+	 * Show the form for creating a new rubric
46
+	 *
47
+	 * @return Response
48
+	 */
49
+	public function newTemplate()
50
+	{
51
+		$title= "Rubric Builder";
52
+
53
+		$templates = Template::orderBy('name', 'ASC')->get();
54
+		$outcomes = Outcome::orderBy('name', 'ASC')->get();
55
+		$criteria = Criterion::orderBy('name', 'ASC')->get();
56
+		$schools = School::orderBy('name', 'ASC')->get();
57
+		$role = Auth::user()->role;
58
+
59
+		$templates = NULL;
60
+		$programs = NULL;
61
+		// Returns templates depending on the type of user
62
+		if( $role == 1)
63
+		{
64
+			$templates = Template::orderBy('name', 'ASC')->get();
65
+			$programs = Program::orderBy('name', 'ASC')->get();
66
+
67
+		} elseif ($role == 2)
68
+		{
69
+			$templates = Template::where('school_id', '=', Auth::user()->school->id )->orWhere('school_id', '=', NULL)->orderBy('name', 'ASC')->get();
70
+			$programs = Auth::user()->school->programs;
71
+		}
72
+		elseif ($role == 3)
73
+		{
74
+			$templates = Template::where('school_id', '=', Auth::user()->programs[0]->school->id)->orWhere('school_id', '=', NULL)->orderBy('name', 'ASC')->get();
75
+			$programs = Auth::user()->programs()->get();
76
+		}
77
+
78
+		return View::make('local.managers.shared.rubrics', compact('title', 'templates', 'outcomes', 'criteria', 'schools', 'programs'));
79
+	}
80
+
81
+	/**
82
+	 * Save a new rubric
83
+	 *
84
+	 * @return Response
85
+	 */
86
+	public function create()
87
+	{
88
+
89
+		$template = new Template;
90
+
91
+		$template->name = Input::get('name');
92
+		$template->contents = Input::get('contents');
93
+		$template->is_visible = Input::get('is_visible');
94
+		$template->expected_percentage = Input::get('expected_percentage');
95
+		$template->expected_points = Input::get('expected_points');
96
+
97
+		// If user can set the school (that is, if school_id is not undefined)
98
+		// set the school id or set to null
99
+		if(is_numeric(Input::get('school_id')))
100
+		{
101
+			if(Input::get('school_id')!=0)
102
+				$template->school_id = Input::get('school_id');
103
+			elseif(Input::get('school_id')==0)
104
+				$template->school_id = NULL;
105
+		}
106
+
107
+		// If user can set the program (that is, if program_id is not undefined)
108
+		// set the program id or set to null
109
+		if(is_numeric(Input::get('program_id')))
110
+		{
111
+			if(Input::get('program_id')!=0)
112
+				$template->program_id = Input::get('program_id');
113
+			elseif(Input::get('program_id')==0)
114
+				$template->program_id = NULL;
115
+		}
116
+
117
+		// If the user is any coordinator, set the school id
118
+		// If the user is a program coordinator, also set program id
119
+		switch (Auth::user()->role) {
120
+			case 2:
121
+				$template->school_id = Auth::user()->school->id;
122
+				break;
123
+
124
+			case 3:
125
+				$template->school_id = Auth::user()->programs[0]->school->id;
126
+				$template->program_id = Auth::user()->programs[0]->id;
127
+				break;
128
+		}
129
+
130
+		if($template->save())
131
+		{
132
+			Session::flash('status', 'success');
133
+			Session::flash('message', 'Rubric created. You can now select it from the list.');
134
+		}
135
+		else
136
+		{
137
+			Session::flash('status', 'danger');
138
+			Session::flash('message', 'Rubric could not be created.');
139
+		}
140
+	}
141
+
142
+	/**
143
+	 * Return a specific template
144
+	 *
145
+	 * @return Template
146
+	 */
147
+	public function fetch()
148
+	{
149
+		return Template::find(Input::get('id'));
150
+	}
151
+
152
+	/**
153
+	 * Update the specified resource in storage.
154
+	 *
155
+	 * @return Response
156
+	 */
157
+	public function update()
158
+	{
159
+		$template = Template::find(Input::get('id'));
160
+		$template->name = Input::get('name');
161
+		$template->contents = Input::get('contents');
162
+		$template->is_visible = Input::get('is_visible');
163
+		$template->expected_percentage = Input::get('expected_percentage');
164
+		$template->expected_points = Input::get('expected_points');
165
+
166
+
167
+		// If user can set the school (that is, if school_id is not undefined)
168
+		// set the school id or set to null
169
+		if(is_numeric(Input::get('school_id')))
170
+		{
171
+			if(Input::get('school_id')!=0)
172
+				$template->school_id = Input::get('school_id');
173
+			elseif(Input::get('school_id')==0)
174
+				$template->school_id = NULL;
175
+		}
176
+
177
+		// If user can set the program (that is, if program_id is not undefined)
178
+		// set the program id or set to null
179
+		if(is_numeric(Input::get('program_id')))
180
+		{
181
+			if(Input::get('program_id')!=0)
182
+				$template->program_id = Input::get('program_id');
183
+			elseif(Input::get('program_id')==0)
184
+				$template->program_id = NULL;
185
+		}
186
+
187
+		if($template->save())
188
+		{
189
+			Session::flash('status', 'success');
190
+			Session::flash('message', 'Rubric updated ('.date('m/d/y, h:i:s a').').');
191
+		}
192
+		else
193
+		{
194
+			Session::flash('status', 'danger');
195
+			Session::flash('message', 'Rubric could not be updated ('.date('m/d/y, h:i:s a').').');
196
+		}
197
+	}
198
+
199
+	/**
200
+	 * Remove the specified resource from storage.
201
+	 *
202
+	 * @return Response
203
+	 */
204
+	public function destroy()
205
+	{
206
+		$template = Template::find(Input::get('id'));
207
+
208
+		if($template->delete())
209
+		{
210
+			Session::flash('status', 'success');
211
+			Session::flash('message', 'Rubric deleted.');
212
+		}
213
+		else
214
+		{
215
+			Session::flash('status', 'danger');
216
+			Session::flash('message', 'Rubric could not be deleted.');
217
+		}
218
+
219
+		return;
220
+	}
221
+
222
+	public function printview($id)
223
+	{
224
+		try {
225
+			$template = Template::find($id);
226
+
227
+			$title = $template->name;
228
+
229
+			if($template->school_id!=NULL)
230
+				$school= $template->school->name;
231
+			else
232
+				$school = 'All Schools';
233
+
234
+			if($template->program_id!=NULL)
235
+				$program= $template->program->name;
236
+			else
237
+				$program = 'All Programs';
238
+
239
+			return View::make('local.managers.shared.print_rubric', compact('title', 'template', 'school', 'program'));
240
+		}
241
+		catch (Exception $e) {
242
+			Session::flash('status', 'danger');
243
+			Session::flash('message', $e->getMessage());
244
+			return Redirect::back();
245
+		}
246
+	}
247
+
248
+}

+ 416
- 0
app/controllers/UsersController.php ファイルの表示

@@ -0,0 +1,416 @@
1
+<?php
2
+
3
+class UsersController extends \BaseController {
4
+
5
+	/**
6
+	 * Display a listing of the users.
7
+	 *
8
+	 * @return Response
9
+	 */
10
+	public function index()
11
+	{
12
+		$title="Users";
13
+
14
+		$users = User::
15
+			with('programs', 'school')
16
+			->orderBy('surnames')
17
+			->orderBy('first_name')
18
+			->get();
19
+
20
+		$schools = School::orderBy('name', 'asc')->get();
21
+		$access_level  = count(User::select('role')->where('has_access', 1)->groupBy('role')->get());
22
+
23
+		return View::make('local.managers.admins.users', compact('title', 'users', 'schools', 'access_level'));
24
+	}
25
+
26
+	/**
27
+	 * Show the form for editing the user.
28
+	 *
29
+	 * @param  int  $id
30
+	 * @return Response
31
+	 */
32
+	public function edit()
33
+	{
34
+		$user = Auth::user();
35
+		$title = "Profile";
36
+		$schools = School::orderBy('name', 'asc')->get();
37
+		$programs = $user->programs;
38
+		return View::make('global.profile', compact('user', 'title', 'schools', 'programs'));
39
+	}
40
+
41
+	/**
42
+	 * Create the user in storage.
43
+	 *
44
+	 * @param  int  $id
45
+	 * @return Response
46
+	 */
47
+	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
+    }
182
+
183
+	/**
184
+	 * Update the user in storage.
185
+	 *
186
+	 * @param  int  $id
187
+	 * @return Response
188
+	 */
189
+	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
+				{
236
+					$user->office_phone = NULL;
237
+                    $user->office_extension = NULL;
238
+				}
239
+
240
+                if(Input::get('cell_phone'))
241
+                {
242
+                    $user->cell_phone = Input::get('cell_phone');
243
+                }
244
+				else
245
+				{
246
+                    $user->cell_phone = NULL;
247
+				}
248
+
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
+    }
415
+
416
+}

+ 1
- 0
app/database/.gitignore ファイルの表示

@@ -0,0 +1 @@
1
+*.sqlite

+ 0
- 0
app/database/migrations/.gitkeep ファイルの表示


+ 34
- 0
app/database/migrations/2014_10_05_052350_create_schools_table.php ファイルの表示

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

+ 41
- 0
app/database/migrations/2014_10_05_055013_create_programs_table.php ファイルの表示

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

+ 43
- 0
app/database/migrations/2014_10_06_050335_create_users_table.php ファイルの表示

@@ -0,0 +1,43 @@
1
+<?php
2
+
3
+use Illuminate\Database\Migrations\Migration;
4
+use Illuminate\Database\Schema\Blueprint;
5
+
6
+class CreateUsersTable extends Migration {
7
+
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function up()
14
+	{
15
+		Schema::create('users', function(Blueprint $table)
16
+		{
17
+			$table->engine = 'InnoDB';
18
+			$table->increments('id');
19
+			$table->string('first_name', 20);
20
+			$table->string('surnames', 40);
21
+			$table->string('email', 50)->unique();
22
+			$table->string('alternate_email', 50)->unique()->nullable();
23
+			$table->string('password', 255);
24
+			$table->integer('role');
25
+			$table->integer('school_id')->nullable();
26
+			$table->integer('program_id')->nullable();
27
+			$table->rememberToken();
28
+			$table->timestamps();
29
+		});
30
+	}
31
+
32
+
33
+	/**
34
+	 * Reverse the migrations.
35
+	 *
36
+	 * @return void
37
+	 */
38
+	public function down()
39
+	{
40
+		Schema::drop('users');
41
+	}
42
+
43
+}

+ 33
- 0
app/database/migrations/2014_10_12_100000_create_password_resets_table.php ファイルの表示

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

+ 43
- 0
app/database/migrations/2014_11_10_035949_create_rubrics_table.php ファイルの表示

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

+ 34
- 0
app/database/migrations/2014_11_29_210957_create_templates_table.php ファイルの表示

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

+ 43
- 0
app/database/migrations/2014_11_29_211309_create_courses_table.php ファイルの表示

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

+ 42
- 0
app/database/migrations/2014_11_29_211310_create_activities_table.php ファイルの表示

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

+ 36
- 0
app/database/migrations/2014_11_29_212240_create_outcomes_table.php ファイルの表示

@@ -0,0 +1,36 @@
1
+<?php
2
+
3
+use Illuminate\Database\Migrations\Migration;
4
+use Illuminate\Database\Schema\Blueprint;
5
+
6
+class CreateOutcomesTable extends Migration {
7
+
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function up()
14
+	{
15
+		Schema::create('outcomes', function(Blueprint $table)
16
+		{
17
+			$table->increments('id');
18
+			$table->string('name');
19
+			$table->text('definition');
20
+			$table->integer('expected_outcome')->default(67);
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('outcomes');
34
+	}
35
+
36
+}

+ 45
- 0
app/database/migrations/2014_11_29_212341_create_criteria_table.php ファイルの表示

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

+ 33
- 0
app/database/migrations/2014_11_29_214028_create_semesters_table.php ファイルの表示

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

+ 43
- 0
app/database/migrations/2014_11_30_134022_create_students_table.php ファイルの表示

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

+ 41
- 0
app/database/migrations/2014_12_07_214036_create_course_student_table.php ファイルの表示

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

+ 41
- 0
app/database/migrations/2015_01_09_171350_create_assessments_table.php ファイルの表示

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

+ 37
- 0
app/database/migrations/2015_01_12_204310_add_columns_to_activities_table.php ファイルの表示

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

+ 37
- 0
app/database/migrations/2015_01_12_222859_add_columns_to_assessments_table.php ファイルの表示

@@ -0,0 +1,37 @@
1
+<?php
2
+
3
+use Illuminate\Database\Migrations\Migration;
4
+use Illuminate\Database\Schema\Blueprint;
5
+
6
+class AddColumnsToAssessmentsTable 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->text('scores')->nullable();
18
+			$table->integer('total')->nullable();
19
+			$table->decimal('average', 5, 2)->nullable();
20
+		});
21
+	}
22
+
23
+
24
+	/**
25
+	 * Reverse the migrations.
26
+	 *
27
+	 * @return void
28
+	 */
29
+	public function down()
30
+	{
31
+		Schema::table('assessments', function(Blueprint $table)
32
+		{
33
+			$table->dropColumn(array('scores', 'total', 'average'));
34
+		});
35
+	}
36
+
37
+}

+ 35
- 0
app/database/migrations/2015_01_13_010052_add_index_to_assessments_table.php ファイルの表示

@@ -0,0 +1,35 @@
1
+<?php
2
+
3
+use Illuminate\Database\Migrations\Migration;
4
+use Illuminate\Database\Schema\Blueprint;
5
+
6
+class AddIndexToAssessmentsTable 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->unique(array('activity_id', 'student_id'));
18
+		});
19
+	}
20
+
21
+
22
+	/**
23
+	 * Reverse the migrations.
24
+	 *
25
+	 * @return void
26
+	 */
27
+	public function down()
28
+	{
29
+		Schema::table('assessments', function(Blueprint $table)
30
+		{
31
+			$table->dropUnique('assessments_activity_id_student_id_unique');
32
+		});
33
+	}
34
+
35
+}

+ 37
- 0
app/database/migrations/2015_01_13_142849_add_column_to_criteria_table.php ファイルの表示

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

+ 37
- 0
app/database/migrations/2015_01_14_140724_add_columns_to_courses_table.php ファイルの表示

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

+ 35
- 0
app/database/migrations/2015_01_21_124809_add_column_to_courses_table.php ファイルの表示

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

+ 45
- 0
app/database/migrations/2015_01_22_195515_add_column_to_templates_table.php ファイルの表示

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

+ 35
- 0
app/database/migrations/2015_01_23_175455_remove_total_from_assessments_table.php ファイルの表示

@@ -0,0 +1,35 @@
1
+<?php
2
+
3
+use Illuminate\Database\Migrations\Migration;
4
+use Illuminate\Database\Schema\Blueprint;
5
+
6
+class RemoveTotalFromAssessmentsTable 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->dropColumn('total');
18
+		});
19
+	}
20
+
21
+
22
+	/**
23
+	 * Reverse the migrations.
24
+	 *
25
+	 * @return void
26
+	 */
27
+	public function down()
28
+	{
29
+		Schema::table('assessments', function(Blueprint $table)
30
+		{
31
+			$table->integer('total');
32
+		});
33
+	}
34
+
35
+}

+ 40
- 0
app/database/migrations/2015_01_23_175923_rename_average_in_assessments_table.php ファイルの表示

@@ -0,0 +1,40 @@
1
+<?php
2
+
3
+use Illuminate\Database\Migrations\Migration;
4
+use Illuminate\Database\Schema\Blueprint;
5
+
6
+class RenameAverageInAssessmentsTable 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->dropColumn('average');
18
+			$table->decimal('percentage', 5, 2);
19
+
20
+			
21
+		});
22
+	}
23
+
24
+
25
+	/**
26
+	 * Reverse the migrations.
27
+	 *
28
+	 * @return void
29
+	 */
30
+	public function down()
31
+	{
32
+		Schema::table('assessments', function(Blueprint $table)
33
+		{
34
+			$table->dropColumn('percentage');
35
+			$table->decimal('average', 5, 2);
36
+			
37
+		});
38
+	}
39
+
40
+}

+ 35
- 0
app/database/migrations/2015_01_28_121848_add_index_to_course_student_table.php ファイルの表示

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

+ 35
- 0
app/database/migrations/2015_01_28_133036_add_criteria_achieved_count_to_activities_table.php ファイルの表示

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

+ 35
- 0
app/database/migrations/2015_02_05_133245_add_transforming_actions_to_activities_table.php ファイルの表示

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

+ 35
- 0
app/database/migrations/2015_02_05_143641_add_assessment_comments_to_activities_table.php ファイルの表示

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

+ 33
- 0
app/database/migrations/2015_02_06_145359_create_password_reminders_table.php ファイルの表示

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

+ 35
- 0
app/database/migrations/2015_02_19_143311_add_is_graduate_to_programs_table.php ファイルの表示

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

+ 35
- 0
app/database/migrations/2015_02_25_170516_add_deleted_at_to_outcomes_table.php ファイルの表示

@@ -0,0 +1,35 @@
1
+<?php
2
+
3
+use Illuminate\Database\Migrations\Migration;
4
+use Illuminate\Database\Schema\Blueprint;
5
+
6
+class AddDeletedAtToOutcomesTable 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->softDeletes();
18
+		});
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->dropColumn('deleted_at');
32
+		});
33
+	}
34
+
35
+}

+ 35
- 0
app/database/migrations/2015_02_25_170529_add_deleted_at_to_criteria_table.php ファイルの表示

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

+ 37
- 0
app/database/migrations/2015_02_27_201953_add_criteria_achieved_percentage_to_activities_table.php ファイルの表示

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

+ 37
- 0
app/database/migrations/2015_03_04_132321_add_copyright_and_notes_to_criteria_table.php ファイルの表示

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

+ 41
- 0
app/database/migrations/2015_04_13_183730_add_program_id_to_templates_table.php ファイルの表示

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

+ 34
- 0
app/database/migrations/2015_04_28_141931_add_is_visible_to_templates_table.php ファイルの表示

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

+ 35
- 0
app/database/migrations/2015_05_04_162918_remove_expected_outcome_from_outcomes_table.php ファイルの表示

@@ -0,0 +1,35 @@
1
+<?php
2
+
3
+use Illuminate\Database\Migrations\Migration;
4
+use Illuminate\Database\Schema\Blueprint;
5
+
6
+class RemoveExpectedOutcomeFromOutcomesTable 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->dropColumn('expected_outcome');
18
+		});
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->integer('expected_outcome')->after('definition')->default('67');
32
+		});
33
+	}
34
+
35
+}

+ 35
- 0
app/database/migrations/2015_05_05_083800_add_decimal_expected_outcome_to_outcomes_table.php ファイルの表示

@@ -0,0 +1,35 @@
1
+<?php
2
+
3
+use Illuminate\Database\Migrations\Migration;
4
+use Illuminate\Database\Schema\Blueprint;
5
+
6
+class AddDecimalExpectedOutcomeToOutcomesTable 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->decimal('expected_outcome',5,2)->after('definition')->default('66.66');
18
+		});
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->dropColumn('expected_outcome');
32
+		});
33
+	}
34
+
35
+}

+ 35
- 0
app/database/migrations/2015_05_18_095002_add_first_login_to_users_table.php ファイルの表示

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

+ 40
- 0
app/database/migrations/2015_05_18_131259_add_columns_to_semesters_table.php ファイルの表示

@@ -0,0 +1,40 @@
1
+<?php
2
+
3
+use Illuminate\Database\Migrations\Migration;
4
+use Illuminate\Database\Schema\Blueprint;
5
+
6
+class AddColumnsToSemestersTable extends Migration {
7
+
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function up()
14
+	{
15
+		Schema::table('semesters', function(Blueprint $table)
16
+		{
17
+			$table->char('code', 3);
18
+			$table->timestamp('start')->nullable();
19
+			$table->timestamp('end')->nullable();
20
+
21
+			$table->dropTimestamps();
22
+		});
23
+	}
24
+
25
+
26
+	/**
27
+	 * Reverse the migrations.
28
+	 *
29
+	 * @return void
30
+	 */
31
+	public function down()
32
+	{
33
+		Schema::table('semesters', function(Blueprint $table)
34
+		{
35
+			$table->dropColumn(['code', 'start', 'end']);
36
+			$table->timestamps();
37
+		});
38
+	}
39
+
40
+}

+ 41
- 0
app/database/migrations/2015_05_18_134926_add_semester_id_to_courses.php ファイルの表示

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

+ 35
- 0
app/database/migrations/2015_06_10_092319_add_name_to_semesters_table.php ファイルの表示

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

+ 35
- 0
app/database/migrations/2015_06_12_085247_add_visibility_to_semesters_table.php ファイルの表示

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

+ 35
- 0
app/database/migrations/2015_06_16_092223_add_has_access_to_users.php ファイルの表示

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

+ 36
- 0
app/database/migrations/2015_06_18_103255_add_expected_percentage_and_points_to_templates_table.php ファイルの表示

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

+ 34
- 0
app/database/migrations/2015_07_10_150430_add_email_to_students_table.php ファイルの表示

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

+ 35
- 0
app/database/migrations/2015_07_13_111726_add_code_to_programs_table.php ファイルの表示

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

+ 36
- 0
app/database/migrations/2015_07_13_132620_add_ssn_and_employee_number_to_users_table.php ファイルの表示

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

+ 41
- 0
app/database/migrations/2015_08_19_130733_add_semester_id_to_course_student_table.php ファイルの表示

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

+ 34
- 0
app/database/migrations/2015_12_10_145451_add_criteria_weights_to_activities_table.php ファイルの表示

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

+ 37
- 0
app/database/migrations/2016_01_12_132034_add_program_id_to_criteria_table.php ファイルの表示

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

+ 35
- 0
app/database/migrations/2016_01_27_093808_add_date_to_activities_table.php ファイルの表示

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

+ 35
- 0
app/database/migrations/2016_01_27_134306_add_draft_to_activities_table.php ファイルの表示

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

+ 37
- 0
app/database/migrations/2016_03_11_085258_add_school_and_concentration_codes_to_students_table.php ファイルの表示

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

+ 0
- 0
app/database/migrations/2016_05_09_145427_create_program_user_table.php ファイルの表示


多くのファイルが変更されたため、一部のファイルはこの差分に表示されません