Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Publish Grading Feature #965

Merged
merged 87 commits into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from 83 commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
8022419
Add migrations to create is_grading_published column for submissions
emptygx Jul 3, 2023
8125ac1
Merge branch 'master' into add-publish-grading
emptygx Jul 3, 2023
e286902
Add and update endpoints for new publish grading feature
emptygx Jul 7, 2023
d174fbd
Fix missing return tuple values in assessments.ex
emptygx Jul 9, 2023
bc36b60
Fix notification and formatting
emptygx Jul 12, 2023
5dcc425
Merge branch 'master' into add-publish-grading
emptygx Jul 16, 2023
2153280
Fix indentation and minor error
emptygx Jul 17, 2023
1891d72
Fix formatting
emptygx Jul 17, 2023
55c5a36
fix formatting
YaleChen299 Jul 23, 2023
af683fd
fix credo long line
YaleChen299 Jul 24, 2023
cf98cff
fix credo nesting alias
YaleChen299 Jul 24, 2023
568cc6f
Fix formatting and code quality
emptygx Jul 25, 2023
4700a49
Fix tests
emptygx Jul 28, 2023
0ec5a50
Merge branch 'master' into add-publish-grading
RichDom2185 Sep 3, 2023
a026ec8
Merge branch 'master' into add-publish-grading
GabrielCWT Feb 26, 2024
750ba95
feat: Implement format helper function
GabrielCWT Mar 1, 2024
f82e43f
feat: Add formatting function for getting all assessments
GabrielCWT Mar 1, 2024
e7090f8
fix: Fix bug of using virtual variable instead
GabrielCWT Mar 1, 2024
5c1b155
refactor: Remove default value for virtual variable is_grading_published
GabrielCWT Mar 1, 2024
788e31e
feat: Implement tests for helper functions
GabrielCWT Mar 2, 2024
70ebac5
feat: Add isGradingPublished to response for fetching all assessments
GabrielCWT Mar 2, 2024
54cbcfc
refactor: Format
GabrielCWT Mar 2, 2024
cf62185
chore: Remove unused match
GabrielCWT Mar 4, 2024
6b5f0e8
feat: Implement tests for unpublish route
GabrielCWT Mar 4, 2024
2a05597
feat: Implement tests for publish route
GabrielCWT Mar 4, 2024
9934af4
refactor: Move repeated code into setup for publish test
GabrielCWT Mar 4, 2024
1097e23
refactor: Move repeated code into setup for unpublish test
GabrielCWT Mar 4, 2024
4ce2d6e
refactor: Format code
GabrielCWT Mar 4, 2024
9de59c6
Merge branch 'master' into add-publish-grading
GabrielCWT Mar 4, 2024
98587e6
Merge branch 'master' into add-publish-grading
RichDom2185 Mar 4, 2024
d046b3b
feat: Add a guard to prevent unsubmit when grade is still published
GabrielCWT Mar 14, 2024
07f2548
feat: Implement filter by notPublished
GabrielCWT Mar 14, 2024
9b33670
refactor: Format
GabrielCWT Mar 14, 2024
e658166
fix: Fix incorrect guard check for is_grading_published
GabrielCWT Mar 15, 2024
054d89a
refactor: Edit tests to accommodate new guard
GabrielCWT Mar 15, 2024
2caecd7
feat: Implement test for new guard (check is_grading_published)
GabrielCWT Mar 15, 2024
dd7742e
Merge branch 'master' into add-publish-grading
GabrielCWT Mar 21, 2024
f65bc56
Merge branch 'master' into add-publish-grading
GabrielCWT Mar 21, 2024
1f41b11
feat: Update seed to include is_grading_published
GabrielCWT Mar 21, 2024
8c1387f
refactor: Update old tests to accommodate for is_grading_published
GabrielCWT Mar 21, 2024
7cc1448
refactor: Improve filter tests to be more flexible
GabrielCWT Mar 21, 2024
44cbab8
feat: Implement test for filter by not published
GabrielCWT Mar 21, 2024
89411ad
chore: Format
GabrielCWT Mar 21, 2024
888a4f7
refactor: Make is_grading_published default to false in factory function
GabrielCWT Mar 21, 2024
4298970
feat: Add is_grading_auto_published column to assessment config
GabrielCWT Mar 22, 2024
147cf4d
feat: Add guard clause to ensure submission is fully graded before pu…
GabrielCWT Mar 22, 2024
a41a894
feat: Implement publish_grading and is_fully_autograded?
GabrielCWT Mar 22, 2024
d2b173b
chore: Clean up code
GabrielCWT Mar 22, 2024
626b61c
feat: Add is_grading_auto_published and is_manually_graded to seed
GabrielCWT Mar 22, 2024
07a63e6
feat: Implement tests for is_fully_autograded?/1
GabrielCWT Mar 22, 2024
38b3303
feat: Implement publish_all_grades route
GabrielCWT Mar 24, 2024
ae9b42f
feat: Add publish_all_grades in controller
GabrielCWT Mar 24, 2024
b606905
feat: Implement publish_all_graded function
GabrielCWT Mar 24, 2024
582a394
feat: Implement tests for publish_all_graded/2
GabrielCWT Mar 24, 2024
ade0e24
refactor: Rename param names and allow filter by true or false
GabrielCWT Mar 24, 2024
f3a0eeb
refactor: Add tests for change in param and refactor code
GabrielCWT Mar 24, 2024
1abf60b
refactor: Change response for publish all grades
GabrielCWT Mar 24, 2024
1ae8d87
refactor: Use update_all instead of recursively updating individual s…
GabrielCWT Mar 24, 2024
5077d70
feat: Implement unpublish all grades route
GabrielCWT Mar 24, 2024
50a85a9
feat: Implement unpublish_all
GabrielCWT Mar 24, 2024
ddd522d
feat: Implement unpublish_all tests
GabrielCWT Mar 24, 2024
5360e3a
chore: Format
GabrielCWT Mar 24, 2024
a33ff69
feat: Implement auto publish for mcq/voting questions
GabrielCWT Mar 24, 2024
858c740
feat: Implement auto publish for auto graded programming questions
GabrielCWT Mar 24, 2024
f376f1e
chore: Fix consistency issue
GabrielCWT Mar 24, 2024
a2a23f7
Merge branch 'master' into add-publish-grading
GabrielCWT Mar 27, 2024
5b91c12
feat: Implement published and unpublished notifications and remove de…
GabrielCWT Mar 27, 2024
64b5305
feat: Include isGradingAutoPublished in response for assessment configs
GabrielCWT Mar 27, 2024
21c65f6
fix: Include sending of notifications when publishing/unpublishing all
GabrielCWT Apr 1, 2024
596d3c3
docs: Add docs for functions implemented
GabrielCWT Apr 2, 2024
340de3a
chore: Update wording for tests
GabrielCWT Apr 2, 2024
b2ab4b0
chore: Remove unused variables
GabrielCWT Apr 2, 2024
a25f9f7
feat: Implement test for unpublish and publish all routes
GabrielCWT Apr 6, 2024
9d9069c
Merge branch 'master' into add-publish-grading
GabrielCWT Apr 6, 2024
fd1508b
feat: Implement guard for publish/unpublish grades
GabrielCWT Apr 7, 2024
4ac87af
refactor: Change notification types in swagger_schema
GabrielCWT Apr 7, 2024
93d6bd2
chore: Add comment in seed
GabrielCWT Apr 7, 2024
bd9abf9
refactor: remove redundant lines
GabrielCWT Apr 8, 2024
c34d265
Merge branch 'master' into add-publish-grading
GabrielCWT Apr 8, 2024
365cfb4
Merge branch 'master' into add-publish-grading
GabrielCWT Apr 11, 2024
ce6ec53
Redate migrations
RichDom2185 Apr 11, 2024
710213c
Revert unnecessary changes
RichDom2185 Apr 11, 2024
593708e
Revert more unnecessary changes
RichDom2185 Apr 11, 2024
d00b686
refactor: Move duplicate code into helper function
GabrielCWT Apr 12, 2024
e355d54
chore: Fix typo
GabrielCWT Apr 12, 2024
541fac9
refactor: Change control flow structure
GabrielCWT Apr 12, 2024
b366bc9
Merge branch 'master' into add-publish-grading
RichDom2185 Apr 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/cadet/accounts/notification_type.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import EctoEnum
defenum(Cadet.Accounts.NotificationType, :notification_type, [
# Notifications for new assessments
:new,
# Notifications for autograded assessments
:autograded,
# Notifications for manually graded assessments
:graded,
# Notifications for unsubmitted submissions
:unsubmitted,
# Notifications for submitted assessments
:submitted
:submitted,
# Notifications for published grades
:published_grading,
# Notifications for unpublished grades
:unpublished_grading
])
33 changes: 28 additions & 5 deletions lib/cadet/accounts/notifications.ex
Original file line number Diff line number Diff line change
Expand Up @@ -145,18 +145,41 @@ defmodule Cadet.Accounts.Notifications do
{:ok, Ecto.Schema.t()} | {:error, Ecto.Changeset.t()}
def handle_unsubmit_notifications(assessment_id, student = %CourseRegistration{})
when is_ecto_id(assessment_id) do
# Fetch and delete all notifications of :autograded and :graded
# Fetch and delete all notifications of :unpublished_grading
# Add new notification :unsubmitted

Notification
|> where(course_reg_id: ^student.id)
|> where(assessment_id: ^assessment_id)
|> where([n], n.type in ^[:autograded, :graded])
|> where([n], n.type in ^[:unpublished_grading])
|> Repo.delete_all()

write(%{
type: :unsubmitted,
role: student.role,
role: :student,
course_reg_id: student.id,
assessment_id: assessment_id
})
end

@doc """
Function that handles notifications when a submission grade is unpublished.
Deletes all :published notifications and adds a new :unpublished_grading notification.
"""
@spec handle_unpublish_grades_notifications(integer(), CourseRegistration.t()) ::
{:ok, Ecto.Schema.t()} | {:error, Ecto.Changeset.t()}
def handle_unpublish_grades_notifications(assessment_id, student = %CourseRegistration{})
when is_ecto_id(assessment_id) do
Notification
|> where(course_reg_id: ^student.id)
|> where(assessment_id: ^assessment_id)
|> where([n], n.type in ^[:published_grading])
|> Repo.delete_all()

write(%{
type: :unpublished_grading,
read: false,
role: :student,
course_reg_id: student.id,
assessment_id: assessment_id
})
Expand All @@ -166,9 +189,9 @@ defmodule Cadet.Accounts.Notifications do
Writes a notification that a student's submission has been
graded successfully. (for the student)
"""
@spec write_notification_when_graded(integer(), any()) ::
@spec write_notification_when_published(integer(), any()) ::
{:ok, Ecto.Schema.t()} | {:error, Ecto.Changeset.t()}
def write_notification_when_graded(submission_id, type) when type in [:graded, :autograded] do
def write_notification_when_published(submission_id, type) when type in [:published_grading] do
case Repo.get(Submission, submission_id) do
nil ->
{:error, %Ecto.Changeset{}}
Expand Down
1 change: 1 addition & 0 deletions lib/cadet/assessments/assessment.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ defmodule Cadet.Assessments.Assessment do
field(:grading_status, :string, virtual: true)
field(:question_count, :integer, virtual: true)
field(:graded_count, :integer, virtual: true)
field(:is_grading_published, :boolean, virtual: true)
field(:title, :string)
field(:is_published, :boolean, default: false)
field(:summary_short, :string)
Expand Down
Loading
Loading