Skip to content

Commit

Permalink
Merge pull request #20 from avantifellows/subjective-questions
Browse files Browse the repository at this point in the history
Support for subjective questions
  • Loading branch information
dalmia authored Jun 7, 2021
2 parents f870bc1 + 1b2e6e0 commit 73ab037
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions schema/SessionAnswer.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ cube(`AggregateSessionMetrics`, {
ROW_NUMBER() OVER (ORDER BY plio_id, user_id) as id,
plio_id,
user_id,
COUNT(case when answer::int IS NULL then NULL else 1 end) AS num_answered,
COUNT(case when question_type = 'mcq' AND answer::int IS NULL THEN NULL when question_type = 'subjective' AND answer IS NULL then NULL else 1 end) AS num_answered,
COUNT(case when question_type = 'mcq' AND answer::int IS NOT NULL THEN 1 else NULL end) AS num_answered_evaluation,
COUNT(case when question_type = 'mcq' AND answer = question_correct_answer then 1 else NULL end) AS num_correct,
COUNT(*) AS num_questions
FROM ${GroupedSessionAnswer.sql()} AS sessionAnswer
Expand Down Expand Up @@ -135,7 +136,7 @@ cube(`AggregateSessionMetrics`, {
type: `avg`,
},
accuracy: {
sql: `100.0 * ${CUBE}.num_correct / NULLIF(${CUBE}.num_answered, 0)`,
sql: `100.0 * ${CUBE}.num_correct / NULLIF(${CUBE}.num_answered_evaluation, 0)`,
type: `avg`,
},
},
Expand Down

0 comments on commit 73ab037

Please sign in to comment.