Skip to content

Commit 00087b0

Browse files
authored
Merge branch 'berkeley-cdss:main' into main
2 parents 9dd0be3 + c564fc6 commit 00087b0

14 files changed

Lines changed: 491 additions & 172 deletions

File tree

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
source 'https://rubygems.org'
22

3-
ruby '~> 3.3.7'
3+
ruby '~> 3.3'
44

55
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
6-
gem 'rails', '~> 7.2.3'
6+
gem 'rails', '~> 7.2.3.1'
77

88
# Use postgres for all env dbs
99
gem 'pg'

Gemfile.lock

Lines changed: 83 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
actioncable (7.2.3)
5-
actionpack (= 7.2.3)
6-
activesupport (= 7.2.3)
4+
actioncable (7.2.3.1)
5+
actionpack (= 7.2.3.1)
6+
activesupport (= 7.2.3.1)
77
nio4r (~> 2.0)
88
websocket-driver (>= 0.6.1)
99
zeitwerk (~> 2.6)
10-
actionmailbox (7.2.3)
11-
actionpack (= 7.2.3)
12-
activejob (= 7.2.3)
13-
activerecord (= 7.2.3)
14-
activestorage (= 7.2.3)
15-
activesupport (= 7.2.3)
10+
actionmailbox (7.2.3.1)
11+
actionpack (= 7.2.3.1)
12+
activejob (= 7.2.3.1)
13+
activerecord (= 7.2.3.1)
14+
activestorage (= 7.2.3.1)
15+
activesupport (= 7.2.3.1)
1616
mail (>= 2.8.0)
17-
actionmailer (7.2.3)
18-
actionpack (= 7.2.3)
19-
actionview (= 7.2.3)
20-
activejob (= 7.2.3)
21-
activesupport (= 7.2.3)
17+
actionmailer (7.2.3.1)
18+
actionpack (= 7.2.3.1)
19+
actionview (= 7.2.3.1)
20+
activejob (= 7.2.3.1)
21+
activesupport (= 7.2.3.1)
2222
mail (>= 2.8.0)
2323
rails-dom-testing (~> 2.2)
24-
actionpack (7.2.3)
25-
actionview (= 7.2.3)
26-
activesupport (= 7.2.3)
24+
actionpack (7.2.3.1)
25+
actionview (= 7.2.3.1)
26+
activesupport (= 7.2.3.1)
2727
cgi
2828
nokogiri (>= 1.8.5)
2929
racc
@@ -33,36 +33,36 @@ GEM
3333
rails-dom-testing (~> 2.2)
3434
rails-html-sanitizer (~> 1.6)
3535
useragent (~> 0.16)
36-
actiontext (7.2.3)
37-
actionpack (= 7.2.3)
38-
activerecord (= 7.2.3)
39-
activestorage (= 7.2.3)
40-
activesupport (= 7.2.3)
36+
actiontext (7.2.3.1)
37+
actionpack (= 7.2.3.1)
38+
activerecord (= 7.2.3.1)
39+
activestorage (= 7.2.3.1)
40+
activesupport (= 7.2.3.1)
4141
globalid (>= 0.6.0)
4242
nokogiri (>= 1.8.5)
43-
actionview (7.2.3)
44-
activesupport (= 7.2.3)
43+
actionview (7.2.3.1)
44+
activesupport (= 7.2.3.1)
4545
builder (~> 3.1)
4646
cgi
4747
erubi (~> 1.11)
4848
rails-dom-testing (~> 2.2)
4949
rails-html-sanitizer (~> 1.6)
50-
activejob (7.2.3)
51-
activesupport (= 7.2.3)
50+
activejob (7.2.3.1)
51+
activesupport (= 7.2.3.1)
5252
globalid (>= 0.3.6)
53-
activemodel (7.2.3)
54-
activesupport (= 7.2.3)
55-
activerecord (7.2.3)
56-
activemodel (= 7.2.3)
57-
activesupport (= 7.2.3)
53+
activemodel (7.2.3.1)
54+
activesupport (= 7.2.3.1)
55+
activerecord (7.2.3.1)
56+
activemodel (= 7.2.3.1)
57+
activesupport (= 7.2.3.1)
5858
timeout (>= 0.4.0)
59-
activestorage (7.2.3)
60-
actionpack (= 7.2.3)
61-
activejob (= 7.2.3)
62-
activerecord (= 7.2.3)
63-
activesupport (= 7.2.3)
59+
activestorage (7.2.3.1)
60+
actionpack (= 7.2.3.1)
61+
activejob (= 7.2.3.1)
62+
activerecord (= 7.2.3.1)
63+
activesupport (= 7.2.3.1)
6464
marcel (~> 1.0)
65-
activesupport (7.2.3)
65+
activesupport (7.2.3.1)
6666
base64
6767
benchmark (>= 0.3)
6868
bigdecimal
@@ -71,10 +71,10 @@ GEM
7171
drb
7272
i18n (>= 1.6, < 2)
7373
logger (>= 1.4.2)
74-
minitest (>= 5.1)
74+
minitest (>= 5.1, < 6)
7575
securerandom (>= 0.3)
7676
tzinfo (~> 2.0, >= 2.0.5)
77-
addressable (2.8.9)
77+
addressable (2.9.0)
7878
public_suffix (>= 2.0.2, < 8.0)
7979
annotaterb (4.22.0)
8080
activerecord (>= 6.0.0)
@@ -100,7 +100,7 @@ GEM
100100
thread_safe (~> 0.3, >= 0.3.1)
101101
base64 (0.3.0)
102102
benchmark (0.5.0)
103-
bigdecimal (4.0.1)
103+
bigdecimal (4.1.1)
104104
bindex (0.8.1)
105105
blazer (3.3.0)
106106
activerecord (>= 7.1)
@@ -203,14 +203,14 @@ GEM
203203
http-cookie (>= 1.0.0)
204204
faraday-net_http (3.4.2)
205205
net-http (~> 0.5)
206-
ffi (1.17.3)
207-
ffi (1.17.3-aarch64-linux-gnu)
208-
ffi (1.17.3-arm-linux-gnu)
209-
ffi (1.17.3-arm64-darwin)
210-
ffi (1.17.3-x86-linux-gnu)
211-
ffi (1.17.3-x86-mingw32)
212-
ffi (1.17.3-x86_64-darwin)
213-
ffi (1.17.3-x86_64-linux-gnu)
206+
ffi (1.17.4)
207+
ffi (1.17.4-aarch64-linux-gnu)
208+
ffi (1.17.4-arm-linux-gnu)
209+
ffi (1.17.4-arm64-darwin)
210+
ffi (1.17.4-x86-linux-gnu)
211+
ffi (1.17.4-x86-mingw32)
212+
ffi (1.17.4-x86_64-darwin)
213+
ffi (1.17.4-x86_64-linux-gnu)
214214
font-awesome-sass (6.7.2)
215215
sassc (~> 2.0)
216216
formatador (1.2.3)
@@ -259,10 +259,7 @@ GEM
259259
jbuilder (2.14.1)
260260
actionview (>= 7.0.0)
261261
activesupport (>= 7.0.0)
262-
json (2.19.1)
263-
json-schema (6.2.0)
264-
addressable (~> 2.8)
265-
bigdecimal (>= 3.1, < 5)
262+
json (2.19.3)
266263
jwt (3.1.2)
267264
base64
268265
language_server-protocol (3.17.0.5)
@@ -303,15 +300,11 @@ GEM
303300
net-smtp
304301
marcel (1.1.0)
305302
matrix (0.4.3)
306-
mcp (0.8.0)
307-
json-schema (>= 4.1)
308303
memoist3 (1.0.0)
309304
method_source (1.1.0)
310305
mini_mime (1.1.5)
311306
mini_portile2 (2.8.9)
312-
minitest (6.0.2)
313-
drb (~> 2.0)
314-
prism (~> 1.5)
307+
minitest (5.27.0)
315308
msgpack (1.8.0)
316309
multi_test (1.1.0)
317310
multi_xml (0.8.1)
@@ -329,18 +322,18 @@ GEM
329322
net-smtp (0.5.1)
330323
net-protocol
331324
nio4r (2.7.5)
332-
nokogiri (1.19.1)
325+
nokogiri (1.19.2)
333326
mini_portile2 (~> 2.8.2)
334327
racc (~> 1.4)
335-
nokogiri (1.19.1-aarch64-linux-gnu)
328+
nokogiri (1.19.2-aarch64-linux-gnu)
336329
racc (~> 1.4)
337-
nokogiri (1.19.1-arm-linux-gnu)
330+
nokogiri (1.19.2-arm-linux-gnu)
338331
racc (~> 1.4)
339-
nokogiri (1.19.1-arm64-darwin)
332+
nokogiri (1.19.2-arm64-darwin)
340333
racc (~> 1.4)
341-
nokogiri (1.19.1-x86_64-darwin)
334+
nokogiri (1.19.2-x86_64-darwin)
342335
racc (~> 1.4)
343-
nokogiri (1.19.1-x86_64-linux-gnu)
336+
nokogiri (1.19.2-x86_64-linux-gnu)
344337
racc (~> 1.4)
345338
notiffany (0.1.3)
346339
nenv (~> 0.1)
@@ -365,8 +358,8 @@ GEM
365358
oauth2 (>= 2.0.2, < 3)
366359
omniauth (~> 2.0)
367360
ostruct (0.6.3)
368-
parallel (1.27.0)
369-
parser (3.3.10.2)
361+
parallel (2.0.0)
362+
parser (3.3.11.1)
370363
ast (~> 2.4.1)
371364
racc
372365
pg (1.6.3)
@@ -390,12 +383,12 @@ GEM
390383
puma (7.2.0)
391384
nio4r (~> 2.0)
392385
racc (1.8.1)
393-
rack (3.2.5)
386+
rack (3.2.6)
394387
rack-protection (4.2.1)
395388
base64 (>= 0.1.0)
396389
logger (>= 1.6.0)
397390
rack (>= 3.0.0, < 4)
398-
rack-session (2.1.1)
391+
rack-session (2.1.2)
399392
base64 (>= 0.1.0)
400393
rack (>= 3.0.0)
401394
rack-test (2.2.0)
@@ -405,20 +398,20 @@ GEM
405398
rack (>= 1.0.0)
406399
rackup (2.3.1)
407400
rack (>= 3)
408-
rails (7.2.3)
409-
actioncable (= 7.2.3)
410-
actionmailbox (= 7.2.3)
411-
actionmailer (= 7.2.3)
412-
actionpack (= 7.2.3)
413-
actiontext (= 7.2.3)
414-
actionview (= 7.2.3)
415-
activejob (= 7.2.3)
416-
activemodel (= 7.2.3)
417-
activerecord (= 7.2.3)
418-
activestorage (= 7.2.3)
419-
activesupport (= 7.2.3)
401+
rails (7.2.3.1)
402+
actioncable (= 7.2.3.1)
403+
actionmailbox (= 7.2.3.1)
404+
actionmailer (= 7.2.3.1)
405+
actionpack (= 7.2.3.1)
406+
actiontext (= 7.2.3.1)
407+
actionview (= 7.2.3.1)
408+
activejob (= 7.2.3.1)
409+
activemodel (= 7.2.3.1)
410+
activerecord (= 7.2.3.1)
411+
activestorage (= 7.2.3.1)
412+
activesupport (= 7.2.3.1)
420413
bundler (>= 1.15.0)
421-
railties (= 7.2.3)
414+
railties (= 7.2.3.1)
422415
rails-controller-testing (1.0.5)
423416
actionpack (>= 5.0.1.rc1)
424417
actionview (>= 5.0.1.rc1)
@@ -430,9 +423,9 @@ GEM
430423
rails-html-sanitizer (1.7.0)
431424
loofah (~> 2.25)
432425
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
433-
railties (7.2.3)
434-
actionpack (= 7.2.3)
435-
activesupport (= 7.2.3)
426+
railties (7.2.3.1)
427+
actionpack (= 7.2.3.1)
428+
activesupport (= 7.2.3.1)
436429
cgi
437430
irb (~> 1.13)
438431
rackup (>= 1.0.0)
@@ -449,7 +442,7 @@ GEM
449442
erb
450443
psych (>= 4.0.0)
451444
tsort
452-
regexp_parser (2.11.3)
445+
regexp_parser (2.12.0)
453446
reline (0.6.3)
454447
io-console (~> 0.5)
455448
request_store (1.7.0)
@@ -478,12 +471,11 @@ GEM
478471
rspec-retry (0.6.2)
479472
rspec-core (> 3.3)
480473
rspec-support (3.13.7)
481-
rubocop (1.85.1)
474+
rubocop (1.86.1)
482475
json (~> 2.3)
483476
language_server-protocol (~> 3.17.0.2)
484477
lint_roller (~> 1.1.0)
485-
mcp (~> 0.6)
486-
parallel (~> 1.10)
478+
parallel (>= 1.10)
487479
parser (>= 3.3.0.2)
488480
rainbow (>= 2.2.2, < 4.0)
489481
regexp_parser (>= 2.9.3, < 3.0)
@@ -558,8 +550,8 @@ GEM
558550
stimulus-rails (1.3.4)
559551
railties (>= 6.0.0)
560552
stringio (3.2.0)
561-
strong_migrations (2.5.2)
562-
activerecord (>= 7.1)
553+
strong_migrations (2.6.0)
554+
activerecord (>= 7.2)
563555
sys-uname (1.5.1)
564556
ffi (~> 1.1)
565557
memoist3 (~> 1.0.0)
@@ -595,7 +587,7 @@ GEM
595587
activemodel (>= 6.0.0)
596588
bindex (>= 0.4.0)
597589
railties (>= 6.0.0)
598-
webmock (3.26.1)
590+
webmock (3.26.2)
599591
addressable (>= 2.8.0)
600592
crack (>= 0.3.2)
601593
hashdiff (>= 0.4.0, < 2.0.0)
@@ -652,7 +644,7 @@ DEPENDENCIES
652644
pg
653645
puma (>= 6.0)
654646
rack_session_access
655-
rails (~> 7.2.3)
647+
rails (~> 7.2.3.1)
656648
rails-controller-testing (~> 1.0)
657649
rspec-rails
658650
rspec-retry

app/controllers/courses_controller.rb

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,21 @@ def new
3838
@courses = Course.fetch_courses(token)
3939
flash[:alert] = 'No courses found.' if @courses.empty?
4040

41+
# Collect unique semester names from Canvas term data for the filter dropdown
42+
@semesters = @courses.filter_map { |c| c.dig('term', 'name') }.uniq.sort
43+
@selected_semester = params[:semester]
44+
4145
teacher_enrollment_types = %w[teacher ta]
4246
# TODO: Add spec for when a course is created, but the user is not enrolled in it.
4347
# TODO: Why do some courses have empty enrollments?
4448
existing_canvas_ids = @user.courses.pluck(:canvas_id)
4549
@courses_teacher = filter_courses(@courses, teacher_enrollment_types, existing_canvas_ids)
4650
@courses_student = filter_courses(@courses, [ 'student' ], existing_canvas_ids)
51+
52+
if @selected_semester.present?
53+
@courses_teacher = filter_by_semester(@courses_teacher, @selected_semester)
54+
@courses_student = filter_by_semester(@courses_student, @selected_semester)
55+
end
4756
end
4857

4958
def edit
@@ -68,6 +77,7 @@ def sync_assignments
6877

6978
def sync_enrollments
7079
return render json: { error: 'Course not found.' }, status: :not_found unless @course
80+
return render json: { error: 'You do not have permission.' }, status: :forbidden unless @is_course_admin
7181

7282
@course.sync_all_enrollments_from_canvas(@user.id)
7383
render json: { message: 'Users synced successfully.' }, status: :ok
@@ -78,7 +88,7 @@ def enrollments
7888
return redirect_to courses_path, alert: 'You do not have access to this page.' unless @role == 'instructor'
7989

8090
@enrollments = @course.user_to_courses.includes(:user)
81-
@is_course_admin = @course.user_to_courses.find_by(user: @user)&.course_admin?
91+
@is_course_admin = @course.course_admin?(@user)
8292
end
8393

8494
def delete
@@ -106,6 +116,17 @@ def set_course
106116

107117
def determine_user_role
108118
@role = @course&.user_role(@user)
119+
@is_course_admin = @course&.course_admin?(@user) || false
120+
end
121+
122+
# Filters Canvas API course hashes by their term name
123+
def filter_by_semester(courses, semester)
124+
courses.select { |c| c.dig('term', 'name') == semester }
125+
end
126+
127+
# Filters Canvas API course hashes by their term name
128+
def filter_by_semester(courses, semester)
129+
courses.select { |c| c.dig('term', 'name') == semester }
109130
end
110131

111132
# TODO: This should be moved to the Canvas Facade

0 commit comments

Comments
 (0)