-
Notifications
You must be signed in to change notification settings - Fork 53
Leaderboard #1238
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
base: master
Are you sure you want to change the base?
Leaderboard #1238
Changes from all commits
e80c289
2464ad4
e840385
0a11acd
3093544
fe9b9bf
595bdea
e760976
c806f63
f99a898
f42c4cd
05f8e80
82e633f
64e812b
731bf09
0e89b53
31d821d
9410c4f
4e78a24
04f9d20
9500bcb
ab255e0
1166189
1096a05
61a4561
0e1ed61
80fcb05
97345b0
db2888a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,11 @@ defmodule CadetWeb.AssessmentsController do | |
|
||
use PhoenixSwagger | ||
|
||
import Ecto.Query, only: [where: 2] | ||
|
||
alias Cadet.Assessments | ||
alias Cadet.Assessments.{Question, Assessment} | ||
alias Cadet.{Assessments, Repo} | ||
|
||
# These roles can save and finalise answers for closed assessments and | ||
# submitted answers | ||
|
@@ -67,6 +71,44 @@ defmodule CadetWeb.AssessmentsController do | |
end | ||
end | ||
|
||
def combined_total_xp_for_all_users(conn, %{"course_id" => course_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. Is there a reason why we require all users? Could we possible paginate this. It feels like it would be an expensive query. |
||
users_with_xp = Assessments.all_user_total_xp(course_id) | ||
json(conn, %{users: users_with_xp}) | ||
end | ||
|
||
def get_contest_popular_scores(conn, %{ | ||
"assessmentid" => assessment_id, | ||
"course_id" => course_id | ||
}) do | ||
contest_id = | ||
Question | ||
|> where(assessment_id: ^assessment_id) | ||
|> Repo.one() | ||
|
||
contestpop = Assessments.fetch_contest_popular_scores(contest_id.id) | ||
voting_id = Assessments.fetch_contest_voting_assesment_id(assessment_id) | ||
json(conn, %{contest_popular: contestpop, voting_id: voting_id}) | ||
end | ||
|
||
def get_contest_relative_scores(conn, %{ | ||
"assessmentid" => assessment_id, | ||
"course_id" => course_id | ||
}) do | ||
contest_id = | ||
Question | ||
|> where(assessment_id: ^assessment_id) | ||
|> Repo.one() | ||
Comment on lines
+97
to
+100
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. I know contests are supposed to have one question, but can we handle the error raised in case for some reason there was more than one question? i.e. returning a proper error message. |
||
|
||
contestscore = Assessments.fetch_contest_relative_scores(contest_id.id) | ||
voting_id = Assessments.fetch_contest_voting_assesment_id(assessment_id) | ||
json(conn, %{contest_score: contestscore, voting_id: voting_id}) | ||
end | ||
|
||
def get_all_contests(conn, %{"course_id" => course_id}) do | ||
contests = Assessments.fetch_all_contests(course_id) | ||
json(conn, contests) | ||
end | ||
|
||
swagger_path :submit do | ||
post("/courses/{course_id}/assessments/{assessmentId}/submit") | ||
summary("Finalise submission for an assessment") | ||
|
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.
Not sure if you need to alias
Assessments
again