-
Notifications
You must be signed in to change notification settings - Fork 56
Add grading controller #101
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
9153a14
Add factories and seeds
indocomsoft 04756f2
Update api spec according to changes from Vignesh
indocomsoft d0314ac
Implement index
indocomsoft 84d7740
Hotfix tests
indocomsoft 005634e
Implement show sans test
indocomsoft 9d96bd1
Add tests
indocomsoft b0c21c4
Update context and model in preparation of implementing update
indocomsoft 2bdc96e
Fix duplicate factory
indocomsoft 30a78d3
Implement update sans test
indocomsoft 9c12d80
Add typespec and is_ecto_id macro guard clause
indocomsoft 912a716
Add and refactor tests
indocomsoft daa72f2
Fix according to code review
indocomsoft 4358317
Change to list comprehension for readability
indocomsoft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| defmodule Cadet.Assessments.Query do | ||
| @moduledoc """ | ||
| Generate queries related to the Assessments context | ||
| """ | ||
| import Ecto.Query | ||
|
|
||
| alias Cadet.Assessments.{Answer, Assessment, Question, Submission} | ||
|
|
||
| @spec all_submissions_with_xp :: Submission.t() | ||
| def all_submissions_with_xp do | ||
| Submission | ||
| |> join(:inner, [s], q in subquery(submissions_xp()), s.id == q.submission_id) | ||
| |> select([s, q], %Submission{s | xp: q.xp}) | ||
| end | ||
|
|
||
| @spec all_assessments_with_max_xp :: Assessment.t() | ||
| def all_assessments_with_max_xp do | ||
| Assessment | ||
| |> join(:inner, [a], q in subquery(assessments_max_xp()), a.id == q.assessment_id) | ||
| |> select([a, q], %Assessment{a | max_xp: q.max_xp}) | ||
| end | ||
|
|
||
| @spec submissions_xp :: %{submission_id: integer(), xp: integer()} | ||
| def submissions_xp do | ||
| Answer | ||
| |> group_by(:submission_id) | ||
| |> select([a], %{ | ||
| submission_id: a.submission_id, | ||
| xp: fragment("? + ?", sum(a.xp), sum(a.adjustment)) | ||
| }) | ||
| end | ||
|
|
||
| @spec assessments_max_xp :: %{assessment_id: integer(), max_xp: integer()} | ||
| def assessments_max_xp do | ||
| Question | ||
| |> group_by(:assessment_id) | ||
| |> select([q], %{assessment_id: q.assessment_id, max_xp: sum(q.max_xp)}) | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,4 +17,10 @@ defmodule Cadet.ContextHelper do | |
| Repo.update(changeset) | ||
| end | ||
| end | ||
|
|
||
| defmacro is_ecto_id(id) do | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Created #113 |
||
| quote do | ||
| is_integer(unquote(id)) or is_binary(unquote(id)) | ||
| end | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙃