From bb675fba39bdb90ef680822bd9bd36888c43b69e Mon Sep 17 00:00:00 2001 From: Bram Windey Date: Sat, 6 Jan 2024 12:21:23 +0100 Subject: [PATCH 1/5] Mimic html behaviour to provide a valid link in json to exercises not viewable outside its course context --- app/views/submissions/_submission_basic.json.jbuilder | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/views/submissions/_submission_basic.json.jbuilder b/app/views/submissions/_submission_basic.json.jbuilder index 7fba1c4a73..6509f149ab 100644 --- a/app/views/submissions/_submission_basic.json.jbuilder +++ b/app/views/submissions/_submission_basic.json.jbuilder @@ -6,5 +6,11 @@ else json.user user_url(submission.user.id, format: :json) end json.has_annotations submission.annotated? -json.exercise activity_url(submission.exercise, format: :json) + +if submission.course.nil? + json.exercise activity_url(submission.exercise, format: :json) +else + json.exercise course_activity_path(submission.course, submission.exercise, format: :json) +end + json.course course_url(submission.course, format: :json) if submission.course From be30bdb841951c4f27ce39f75c863cc0101a849d Mon Sep 17 00:00:00 2001 From: Bram Windey Date: Sat, 6 Jan 2024 13:52:59 +0100 Subject: [PATCH 2/5] Fix path -> url for consistency --- app/views/submissions/_submission_basic.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/submissions/_submission_basic.json.jbuilder b/app/views/submissions/_submission_basic.json.jbuilder index 6509f149ab..524a697d91 100644 --- a/app/views/submissions/_submission_basic.json.jbuilder +++ b/app/views/submissions/_submission_basic.json.jbuilder @@ -10,7 +10,7 @@ json.has_annotations submission.annotated? if submission.course.nil? json.exercise activity_url(submission.exercise, format: :json) else - json.exercise course_activity_path(submission.course, submission.exercise, format: :json) + json.exercise course_activity_url(submission.course, submission.exercise, format: :json) end json.course course_url(submission.course, format: :json) if submission.course From 0afa80df1c002ca9a2cd6ce72e8af3ee96ca03e8 Mon Sep 17 00:00:00 2001 From: Bram Windey Date: Sat, 6 Jan 2024 21:47:36 +0100 Subject: [PATCH 3/5] Add exercise-name to each submission in /submissions.json --- app/views/submissions/_submission_basic.json.jbuilder | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/views/submissions/_submission_basic.json.jbuilder b/app/views/submissions/_submission_basic.json.jbuilder index 524a697d91..60c98d1ba5 100644 --- a/app/views/submissions/_submission_basic.json.jbuilder +++ b/app/views/submissions/_submission_basic.json.jbuilder @@ -13,4 +13,7 @@ else json.exercise course_activity_url(submission.course, submission.exercise, format: :json) end +json.exercise_name submission.exercise.name + + json.course course_url(submission.course, format: :json) if submission.course From 165b54ec32d86b5a7856df1995491c39ab78b121 Mon Sep 17 00:00:00 2001 From: Bram Windey Date: Mon, 15 Jan 2024 14:43:58 +0100 Subject: [PATCH 4/5] Implement feedback --- app/views/submissions/_submission_basic.json.jbuilder | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/app/views/submissions/_submission_basic.json.jbuilder b/app/views/submissions/_submission_basic.json.jbuilder index 60c98d1ba5..a98cba867b 100644 --- a/app/views/submissions/_submission_basic.json.jbuilder +++ b/app/views/submissions/_submission_basic.json.jbuilder @@ -6,14 +6,6 @@ else json.user user_url(submission.user.id, format: :json) end json.has_annotations submission.annotated? - -if submission.course.nil? - json.exercise activity_url(submission.exercise, format: :json) -else - json.exercise course_activity_url(submission.course, submission.exercise, format: :json) -end - +json.exercise activity_scoped_url(activity: submission.exercise, course: submission.course, options: { format: :json }) json.exercise_name submission.exercise.name - - json.course course_url(submission.course, format: :json) if submission.course From b4d63865ed6aea26ce2e40f5f3397eaeff12a8cf Mon Sep 17 00:00:00 2001 From: Bram Windey Date: Tue, 16 Jan 2024 14:17:32 +0100 Subject: [PATCH 5/5] Implement feedback --- app/views/submissions/_submission_basic.json.jbuilder | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/submissions/_submission_basic.json.jbuilder b/app/views/submissions/_submission_basic.json.jbuilder index a98cba867b..a652c7b752 100644 --- a/app/views/submissions/_submission_basic.json.jbuilder +++ b/app/views/submissions/_submission_basic.json.jbuilder @@ -7,5 +7,4 @@ else end json.has_annotations submission.annotated? json.exercise activity_scoped_url(activity: submission.exercise, course: submission.course, options: { format: :json }) -json.exercise_name submission.exercise.name json.course course_url(submission.course, format: :json) if submission.course