Skip to content

Commit 5a1c34d

Browse files
committed
resolved merge conflicts
2 parents 143b9c5 + c564fc6 commit 5a1c34d

15 files changed

Lines changed: 491 additions & 174 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)
@@ -209,14 +209,14 @@ GEM
209209
http-cookie (>= 1.0.0)
210210
faraday-net_http (3.4.2)
211211
net-http (~> 0.5)
212-
ffi (1.17.3)
213-
ffi (1.17.3-aarch64-linux-gnu)
214-
ffi (1.17.3-arm-linux-gnu)
215-
ffi (1.17.3-arm64-darwin)
216-
ffi (1.17.3-x86-linux-gnu)
217-
ffi (1.17.3-x86-mingw32)
218-
ffi (1.17.3-x86_64-darwin)
219-
ffi (1.17.3-x86_64-linux-gnu)
212+
ffi (1.17.4)
213+
ffi (1.17.4-aarch64-linux-gnu)
214+
ffi (1.17.4-arm-linux-gnu)
215+
ffi (1.17.4-arm64-darwin)
216+
ffi (1.17.4-x86-linux-gnu)
217+
ffi (1.17.4-x86-mingw32)
218+
ffi (1.17.4-x86_64-darwin)
219+
ffi (1.17.4-x86_64-linux-gnu)
220220
font-awesome-sass (6.7.2)
221221
sassc (~> 2.0)
222222
formatador (1.2.3)
@@ -275,10 +275,7 @@ GEM
275275
jbuilder (2.14.1)
276276
actionview (>= 7.0.0)
277277
activesupport (>= 7.0.0)
278-
json (2.19.1)
279-
json-schema (6.2.0)
280-
addressable (~> 2.8)
281-
bigdecimal (>= 3.1, < 5)
278+
json (2.19.3)
282279
jwt (3.1.2)
283280
base64
284281
language_server-protocol (3.17.0.5)
@@ -319,15 +316,11 @@ GEM
319316
net-smtp
320317
marcel (1.1.0)
321318
matrix (0.4.3)
322-
mcp (0.8.0)
323-
json-schema (>= 4.1)
324319
memoist3 (1.0.0)
325320
method_source (1.1.0)
326321
mini_mime (1.1.5)
327322
mini_portile2 (2.8.9)
328-
minitest (6.0.2)
329-
drb (~> 2.0)
330-
prism (~> 1.5)
323+
minitest (5.27.0)
331324
msgpack (1.8.0)
332325
multi_test (1.1.0)
333326
multi_xml (0.8.1)
@@ -345,18 +338,18 @@ GEM
345338
net-smtp (0.5.1)
346339
net-protocol
347340
nio4r (2.7.5)
348-
nokogiri (1.19.1)
341+
nokogiri (1.19.2)
349342
mini_portile2 (~> 2.8.2)
350343
racc (~> 1.4)
351-
nokogiri (1.19.1-aarch64-linux-gnu)
344+
nokogiri (1.19.2-aarch64-linux-gnu)
352345
racc (~> 1.4)
353-
nokogiri (1.19.1-arm-linux-gnu)
346+
nokogiri (1.19.2-arm-linux-gnu)
354347
racc (~> 1.4)
355-
nokogiri (1.19.1-arm64-darwin)
348+
nokogiri (1.19.2-arm64-darwin)
356349
racc (~> 1.4)
357-
nokogiri (1.19.1-x86_64-darwin)
350+
nokogiri (1.19.2-x86_64-darwin)
358351
racc (~> 1.4)
359-
nokogiri (1.19.1-x86_64-linux-gnu)
352+
nokogiri (1.19.2-x86_64-linux-gnu)
360353
racc (~> 1.4)
361354
notiffany (0.1.3)
362355
nenv (~> 0.1)
@@ -381,8 +374,8 @@ GEM
381374
oauth2 (>= 2.0.2, < 3)
382375
omniauth (~> 2.0)
383376
ostruct (0.6.3)
384-
parallel (1.27.0)
385-
parser (3.3.10.2)
377+
parallel (2.0.0)
378+
parser (3.3.11.1)
386379
ast (~> 2.4.1)
387380
racc
388381
pg (1.6.3)
@@ -407,12 +400,12 @@ GEM
407400
nio4r (~> 2.0)
408401
raabro (1.4.0)
409402
racc (1.8.1)
410-
rack (3.2.5)
403+
rack (3.2.6)
411404
rack-protection (4.2.1)
412405
base64 (>= 0.1.0)
413406
logger (>= 1.6.0)
414407
rack (>= 3.0.0, < 4)
415-
rack-session (2.1.1)
408+
rack-session (2.1.2)
416409
base64 (>= 0.1.0)
417410
rack (>= 3.0.0)
418411
rack-test (2.2.0)
@@ -422,20 +415,20 @@ GEM
422415
rack (>= 1.0.0)
423416
rackup (2.3.1)
424417
rack (>= 3)
425-
rails (7.2.3)
426-
actioncable (= 7.2.3)
427-
actionmailbox (= 7.2.3)
428-
actionmailer (= 7.2.3)
429-
actionpack (= 7.2.3)
430-
actiontext (= 7.2.3)
431-
actionview (= 7.2.3)
432-
activejob (= 7.2.3)
433-
activemodel (= 7.2.3)
434-
activerecord (= 7.2.3)
435-
activestorage (= 7.2.3)
436-
activesupport (= 7.2.3)
418+
rails (7.2.3.1)
419+
actioncable (= 7.2.3.1)
420+
actionmailbox (= 7.2.3.1)
421+
actionmailer (= 7.2.3.1)
422+
actionpack (= 7.2.3.1)
423+
actiontext (= 7.2.3.1)
424+
actionview (= 7.2.3.1)
425+
activejob (= 7.2.3.1)
426+
activemodel (= 7.2.3.1)
427+
activerecord (= 7.2.3.1)
428+
activestorage (= 7.2.3.1)
429+
activesupport (= 7.2.3.1)
437430
bundler (>= 1.15.0)
438-
railties (= 7.2.3)
431+
railties (= 7.2.3.1)
439432
rails-controller-testing (1.0.5)
440433
actionpack (>= 5.0.1.rc1)
441434
actionview (>= 5.0.1.rc1)
@@ -447,9 +440,9 @@ GEM
447440
rails-html-sanitizer (1.7.0)
448441
loofah (~> 2.25)
449442
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)
450-
railties (7.2.3)
451-
actionpack (= 7.2.3)
452-
activesupport (= 7.2.3)
443+
railties (7.2.3.1)
444+
actionpack (= 7.2.3.1)
445+
activesupport (= 7.2.3.1)
453446
cgi
454447
irb (~> 1.13)
455448
rackup (>= 1.0.0)
@@ -466,7 +459,7 @@ GEM
466459
erb
467460
psych (>= 4.0.0)
468461
tsort
469-
regexp_parser (2.11.3)
462+
regexp_parser (2.12.0)
470463
reline (0.6.3)
471464
io-console (~> 0.5)
472465
request_store (1.7.0)
@@ -495,12 +488,11 @@ GEM
495488
rspec-retry (0.6.2)
496489
rspec-core (> 3.3)
497490
rspec-support (3.13.7)
498-
rubocop (1.85.1)
491+
rubocop (1.86.1)
499492
json (~> 2.3)
500493
language_server-protocol (~> 3.17.0.2)
501494
lint_roller (~> 1.1.0)
502-
mcp (~> 0.6)
503-
parallel (~> 1.10)
495+
parallel (>= 1.10)
504496
parser (>= 3.3.0.2)
505497
rainbow (>= 2.2.2, < 4.0)
506498
regexp_parser (>= 2.9.3, < 3.0)
@@ -575,8 +567,8 @@ GEM
575567
stimulus-rails (1.3.4)
576568
railties (>= 6.0.0)
577569
stringio (3.2.0)
578-
strong_migrations (2.5.2)
579-
activerecord (>= 7.1)
570+
strong_migrations (2.6.0)
571+
activerecord (>= 7.2)
580572
sys-uname (1.5.1)
581573
ffi (~> 1.1)
582574
memoist3 (~> 1.0.0)
@@ -612,7 +604,7 @@ GEM
612604
activemodel (>= 6.0.0)
613605
bindex (>= 0.4.0)
614606
railties (>= 6.0.0)
615-
webmock (3.26.1)
607+
webmock (3.26.2)
616608
addressable (>= 2.8.0)
617609
crack (>= 0.3.2)
618610
hashdiff (>= 0.4.0, < 2.0.0)
@@ -671,7 +663,7 @@ DEPENDENCIES
671663
pg
672664
puma (>= 6.0)
673665
rack_session_access
674-
rails (~> 7.2.3)
666+
rails (~> 7.2.3.1)
675667
rails-controller-testing (~> 1.0)
676668
rspec-rails
677669
rspec-retry

app/controllers/courses_controller.rb

Lines changed: 17 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
@@ -88,7 +98,7 @@ def enrollments
8898
return redirect_to courses_path, alert: 'You do not have access to this page.' unless @role == 'instructor'
8999

90100
@enrollments = @course.user_to_courses.includes(:user)
91-
@is_course_admin = @course.user_to_courses.find_by(user: @user)&.course_admin?
101+
@is_course_admin = @course.course_admin?(@user)
92102
end
93103

94104
def delete
@@ -116,6 +126,12 @@ def set_course
116126

117127
def determine_user_role
118128
@role = @course&.user_role(@user)
129+
@is_course_admin = @course&.course_admin?(@user) || false
130+
end
131+
132+
# Filters Canvas API course hashes by their term name
133+
def filter_by_semester(courses, semester)
134+
courses.select { |c| c.dig('term', 'name') == semester }
119135
end
120136

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

0 commit comments

Comments
 (0)