Skip to content

Commit

Permalink
feat: Add url column for open response questions [PT-181870149]
Browse files Browse the repository at this point in the history
This adds an url column to each open response question that points to the portal dashboard so that researchers can listen to audio responses.
  • Loading branch information
dougmartin committed Mar 13, 2024
1 parent 9e844ce commit a2095f4
Show file tree
Hide file tree
Showing 2 changed files with 143 additions and 133 deletions.
41 changes: 21 additions & 20 deletions query-creator/create-query/steps/aws.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,24 @@ const getColumnsForQuestion = (questionId, question, denormalizedResource, authD

const columnPrefix = `res_${activityIndex}_${questionId}`;

const modelUrl = [`CONCAT(`,
`'${process.env.PORTAL_REPORT_URL}`,
`?auth-domain=${encodeURIComponent(authDomain)}`,
`&firebase-app=${process.env.FIREBASE_APP}`,
`&sourceKey=${sourceKey}`,
`&iframeQuestionId=${questionId}`,
`&class=${encodeURIComponent(`${authDomain}/api/v1/classes/`)}',`,
` CAST(${learnersAndAnswersTable}.class_id AS VARCHAR), `,
`'&offering=${encodeURIComponent(`${authDomain}/api/v1/offerings/`)}',`,
` CAST(${learnersAndAnswersTable}.offering_id AS VARCHAR), `,
`'&studentId=',`,
` CAST(${learnersAndAnswersTable}.user_id AS VARCHAR), `,
`'&answersSourceKey=', `,
` ${learnersAndAnswersTable}.source_key['${questionId}']`,
`)`
].join("")
const conditionalModelUrl = `CASE WHEN ${learnersAndAnswersTable}.kv1['${questionId}'] IS NULL THEN '' ELSE ${modelUrl} END`;

switch (type) {
case "image_question":
columns.push({name: `${columnPrefix}_image_url`,
Expand All @@ -160,6 +178,9 @@ const getColumnsForQuestion = (questionId, question, denormalizedResource, authD
columns.push({name: `${columnPrefix}_text`,
value: filterNoAnswerJSON,
header: promptHeader});
columns.push({name: `${columnPrefix}_url`,
value: conditionalModelUrl,
header: promptHeader});
break;
case "multiple_choice":
let questionHasCorrectAnswer = false;
Expand All @@ -181,26 +202,6 @@ const getColumnsForQuestion = (questionId, question, denormalizedResource, authD
columns.push({name: `${columnPrefix}_json`,
value: `${learnersAndAnswersTable}.kv1['${questionId}']`,
header: promptHeader});

const modelUrl = [`CONCAT(`,
`'${process.env.PORTAL_REPORT_URL}`,
`?auth-domain=${encodeURIComponent(authDomain)}`,
`&firebase-app=${process.env.FIREBASE_APP}`,
`&sourceKey=${sourceKey}`,
`&iframeQuestionId=${questionId}`,
`&class=${encodeURIComponent(`${authDomain}/api/v1/classes/`)}',`,
` CAST(${learnersAndAnswersTable}.class_id AS VARCHAR), `,
`'&offering=${encodeURIComponent(`${authDomain}/api/v1/offerings/`)}',`,
` CAST(${learnersAndAnswersTable}.offering_id AS VARCHAR), `,
`'&studentId=',`,
` CAST(${learnersAndAnswersTable}.user_id AS VARCHAR), `,
`'&answersSourceKey=', `,
` ${learnersAndAnswersTable}.source_key['${questionId}']`,
`)`
].join("")

const conditionalModelUrl = `CASE WHEN ${learnersAndAnswersTable}.kv1['${questionId}'] IS NULL THEN '' ELSE ${modelUrl} END`;

columns.push({name: `${columnPrefix}_url`,
value: conditionalModelUrl,
header: promptHeader});
Expand Down
Loading

0 comments on commit a2095f4

Please sign in to comment.