From 1b2e6e084e815bbb6d10f16cdd256fd479001d0b Mon Sep 17 00:00:00 2001 From: Aman Dalmia Date: Sun, 6 Jun 2021 14:25:35 +0530 Subject: [PATCH] NEW: support for subjective questions --- schema/SessionAnswer.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/schema/SessionAnswer.js b/schema/SessionAnswer.js index 8d61fda..2d8a042 100644 --- a/schema/SessionAnswer.js +++ b/schema/SessionAnswer.js @@ -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 @@ -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`, }, },