-
Notifications
You must be signed in to change notification settings - Fork 78
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 course statistics #5440
Add course statistics #5440
Conversation
52c919d
to
1d63b11
Compare
def assessment_info_array | ||
@assessment_info_array ||= Course::Assessment.published.with_default_reference_time. | ||
where.not(course_reference_times: { end_at: nil }). | ||
where(course_id: current_course.id). | ||
pluck(:id, :title, :start_at, :end_at) | ||
end | ||
|
||
def user_submission_array # rubocop:disable Metrics/AbcSize | ||
submission_data_arr = Course::Assessment::Submission.joins(creator: :course_users). | ||
where(assessment_id: assessment_info_array.map { |i| i[0] }, | ||
course_users: { course_id: current_course.id, role: :student }). | ||
group(:creator_id, 'course_users.name', 'course_users.phantom'). | ||
pluck(:creator_id, 'course_users.name', 'course_users.phantom', | ||
'json_agg(assessment_id)', 'array_agg(submitted_at)') | ||
|
||
submission_data_arr.map do |sub_data| | ||
assessment_to_submitted_at = sub_data[3].zip(sub_data[4]).map do |assessment_id, submitted_at| | ||
if submitted_at.nil? | ||
nil | ||
else | ||
[assessment_id, submitted_at] | ||
end | ||
end.compact | ||
|
||
[sub_data[0], sub_data[1], sub_data[2], assessment_to_submitted_at] # id, name, phantom, [ass_id, sub_at] | ||
end | ||
end | ||
|
||
def correctness_hash | ||
query = CourseUser.find_by_sql(<<-SQL.squish | ||
SELECT | ||
id, | ||
AVG(correctness) AS correctness | ||
FROM ( | ||
SELECT | ||
cu.id AS id, | ||
SUM(caa.grade) / SUM(caq.maximum_grade) AS correctness | ||
FROM | ||
course_assessment_categories cat | ||
INNER JOIN course_assessment_tabs tab | ||
ON tab.category_id = cat.id | ||
INNER JOIN course_assessments ca | ||
ON ca.tab_id = tab.id | ||
INNER JOIN course_assessment_submissions cas | ||
ON cas.assessment_id = ca.id | ||
INNER JOIN course_assessment_answers caa | ||
ON caa.submission_id = cas.id | ||
INNER JOIN course_assessment_questions caq | ||
ON caa.question_id = caq.id | ||
INNER JOIN course_users cu | ||
ON cu.user_id = cas.creator_id | ||
WHERE | ||
cat.course_id = #{current_course.id} | ||
AND caa.current_answer IS true | ||
AND cas.workflow_state IN ('graded', 'published') | ||
AND cu.course_id = #{current_course.id} | ||
AND cu.role = 0 | ||
GROUP BY | ||
cu.id, | ||
cas.assessment_id | ||
HAVING | ||
SUM(caq.maximum_grade) > 0 | ||
) course_user_assessment_correctness | ||
GROUP BY | ||
id | ||
SQL | ||
) | ||
query.map { |u| [u.id, u.correctness] }.to_h | ||
end |
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.
Would appreciate any help with rewriting this code to use the ORM more.
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.
Let's add this to TODO
cf9d23a
to
338dad8
Compare
Changed the base to |
I have already rebased the |
338dad8
to
4a5c8c1
Compare
Btw @ekowidianto I think this PR is more or less ready to review. |
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.
Many thanks for the PR! @zhuhanming
See some comments below.
client/app/bundles/course/statistics/utils/parseCourseResponse.js
Outdated
Show resolved
Hide resolved
client/app/bundles/course/statistics/pages/StatisticsIndex/course/StudentProgressionChart.jsx
Outdated
Show resolved
Hide resolved
client/app/bundles/course/statistics/pages/StatisticsIndex/course/StudentPerformanceTable.jsx
Show resolved
Hide resolved
client/app/bundles/course/statistics/pages/StatisticsIndex/course/StudentPerformanceTable.jsx
Show resolved
Hide resolved
@@ -70,11 +69,7 @@ const TabPanel = (props) => { | |||
role="tabpanel" | |||
{...other} | |||
> | |||
{value === index && ( | |||
<Box sx={{ pt: 3, pb: 3 }}> | |||
<Typography>{children}</Typography> |
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.
Actually is there any specific reason why Typography was used? Seems like the children is of JSX.Element type and if there’s div or other elements that cant be nested within p (default typography’s component), it will throw console error
570e6c8
to
b1c6da4
Compare
082bfb0
to
48d429d
Compare
5bfb659
to
13f225e
Compare
8004f49
to
fd5e0e2
Compare
@zhuhanming PR reviewed~ thanks |
- fix proptypes shape error - change injectIntl to useIntl - remove obsolete underLinesOnHover props for <Link />
…level to student performance table
fd5e0e2
to
4d69866
Compare
Majority of #4496 rebased onto
phillmont/migrate-assessment-show
.This PR introduces:
There's some overlap between Course Performance Statistics and the existing Student Statistics. The changes made to Student Statistics are also not rebased yet. All that will be changed in the next PR.
Part of #619 and #1112 (after a few more minor changes).
TODO (which I'll likely be unable to work on)
Course Performance Table
Screen.Recording.2022-12-05.at.9.27.30.PM.mov