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 course statistics #5440

Merged
merged 18 commits into from
Dec 22, 2022
Merged

Add course statistics #5440

merged 18 commits into from
Dec 22, 2022

Conversation

zhuhanming
Copy link
Member

@zhuhanming zhuhanming commented Dec 4, 2022

Majority of #4496 rebased onto phillmont/migrate-assessment-show.

This PR introduces:

  • Course Progression Statistics
  • Course Performance Statistics

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)

  • Show in UI which submissions are late/overdue
  • Add groups filtering (and perhaps support group average vs class average comparisons)
  • Possible extension would be Student Watchlist #113, since now we can check specific rows in the table and perform operations. Instructors should be able to select these students and add them into the watchlist.
  • Write more tests, especially on the correctness of the statistics provided.

Course Performance Table

Screen.Recording.2022-12-05.at.9.27.30.PM.mov

@zhuhanming zhuhanming changed the base branch from phillmont/migrate-assessment-show to master December 4, 2022 20:26
@zhuhanming zhuhanming changed the base branch from master to phillmont/migrate-assessment-show December 4, 2022 20:27
@zhuhanming zhuhanming force-pushed the hanming/add-course-statistics-2 branch from 52c919d to 1d63b11 Compare December 4, 2022 20:30
Comment on lines 31 to 98
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
Copy link
Member Author

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.

Copy link
Member

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

@zhuhanming zhuhanming mentioned this pull request Dec 4, 2022
@zhuhanming zhuhanming force-pushed the hanming/add-course-statistics-2 branch 2 times, most recently from cf9d23a to 338dad8 Compare December 5, 2022 01:53
@zhuhanming zhuhanming changed the base branch from phillmont/migrate-assessment-show to master December 5, 2022 01:54
@zhuhanming
Copy link
Member Author

Changed the base to master as it contains fixes that allow the app to be run locally.

@ekowidianto
Copy link
Member

Changed the base to master as it contains fixes that allow the app to be run locally.

I have already rebased the phillmont/migrate-assessment-showoff the latest master branch.

@zhuhanming zhuhanming force-pushed the hanming/add-course-statistics-2 branch from 338dad8 to 4a5c8c1 Compare December 6, 2022 05:26
@zhuhanming zhuhanming changed the base branch from master to phillmont/migrate-assessment-show December 6, 2022 05:26
@zhuhanming
Copy link
Member Author

Btw @ekowidianto I think this PR is more or less ready to review.

Copy link
Member

@ekowidianto ekowidianto left a 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.

@@ -70,11 +69,7 @@ const TabPanel = (props) => {
role="tabpanel"
{...other}
>
{value === index && (
<Box sx={{ pt: 3, pb: 3 }}>
<Typography>{children}</Typography>
Copy link
Member

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

@purfectliterature purfectliterature force-pushed the phillmont/migrate-assessment-show branch 2 times, most recently from 570e6c8 to b1c6da4 Compare December 9, 2022 04:48
@ekowidianto ekowidianto force-pushed the hanming/add-course-statistics-2 branch from 082bfb0 to 48d429d Compare December 9, 2022 06:43
@purfectliterature purfectliterature force-pushed the phillmont/migrate-assessment-show branch 7 times, most recently from 5bfb659 to 13f225e Compare December 9, 2022 10:29
Base automatically changed from phillmont/migrate-assessment-show to master December 9, 2022 15:28
@ekowidianto ekowidianto force-pushed the hanming/add-course-statistics-2 branch 3 times, most recently from 8004f49 to fd5e0e2 Compare December 10, 2022 15:18
@ekowidianto
Copy link
Member

Btw @ekowidianto I think this PR is more or less ready to review.

@zhuhanming PR reviewed~ thanks

@ekowidianto ekowidianto force-pushed the hanming/add-course-statistics-2 branch from fd5e0e2 to 4d69866 Compare December 22, 2022 09:11
@ekowidianto ekowidianto merged commit c3238f7 into master Dec 22, 2022
@ekowidianto ekowidianto deleted the hanming/add-course-statistics-2 branch December 22, 2022 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants