Skip to content

Commit

Permalink
Merge pull request #24 from avantifellows/redefine_accuracy_for_subje…
Browse files Browse the repository at this point in the history
…ctive

FIX: all answered subjective questions will be marked correct
  • Loading branch information
dalmia authored Sep 29, 2021
2 parents a06768a + 3337b21 commit a3f78cf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
11 changes: 8 additions & 3 deletions schema/bigquery/SessionAnswer.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,13 @@ cube(`AggregateSessionMetrics`, {
plio_id,
user_id,
COUNT(case when question_type = 'mcq' AND answer 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 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(
case
when question_type = 'mcq' AND answer = question_correct_answer then 1
when question_type = 'subjective' AND answer IS NOT NULL then 1
else NULL
end
) AS num_correct,
COUNT(*) AS num_questions
FROM ${GroupedSessionAnswer.sql()} AS sessionAnswer
WHERE sessionAnswer.item_type = 'question'
Expand Down Expand Up @@ -136,7 +141,7 @@ cube(`AggregateSessionMetrics`, {
type: `avg`,
},
accuracy: {
sql: `100.0 * ${CUBE}.num_correct / NULLIF(${CUBE}.num_answered_evaluation, 0)`,
sql: `100.0 * ${CUBE}.num_correct / NULLIF(${CUBE}.num_answered, 0)`,
type: `avg`,
},
},
Expand Down
11 changes: 8 additions & 3 deletions schema/postgres/SessionAnswer.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,13 @@ cube(`AggregateSessionMetrics`, {
plio_id,
user_id,
COUNT(case when question_type = 'mcq' AND answer 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 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(
case
when question_type = 'mcq' AND answer = question_correct_answer then 1
when question_type = 'subjective' AND answer IS NOT NULL then 1
else NULL
end
) AS num_correct,
COUNT(*) AS num_questions
FROM ${GroupedSessionAnswer.sql()} AS sessionAnswer
WHERE sessionAnswer.item_type = 'question'
Expand Down Expand Up @@ -136,7 +141,7 @@ cube(`AggregateSessionMetrics`, {
type: `avg`,
},
accuracy: {
sql: `100.0 * ${CUBE}.num_correct / NULLIF(${CUBE}.num_answered_evaluation, 0)`,
sql: `100.0 * ${CUBE}.num_correct / NULLIF(${CUBE}.num_answered, 0)`,
type: `avg`,
},
},
Expand Down

0 comments on commit a3f78cf

Please sign in to comment.