Skip to content

Commit

Permalink
Merge pull request #204 from concord-consortium/really-fix-backslash-…
Browse files Browse the repository at this point in the history
…escaping

fix: Really fixed the backslash escaping
  • Loading branch information
dougmartin authored Oct 17, 2023
2 parents 34c889d + fb7198e commit 77e5ab0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion query-creator/create-query/steps/aws.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ const getColumnsForQuestion = (questionId, question, denormalizedResource, authD
case "open_response":
// When there is no answer to an open_response question the report state JSON is saved as the answer in Firebase.
// This detects if the answer looks like the report state JSON and if so returns an empty string to show there was no answer to the question.
const filterNoAnswerJSON = `if(starts_with(${learnersAndAnswersTable}.kv1['${questionId}'], '"{\\"mode\":\\"report\\"'), '', ${learnersAndAnswersTable}.kv1['${questionId}'])`;
const filterNoAnswerJSON = `if(starts_with(${learnersAndAnswersTable}.kv1['${questionId}'], '"{\\"mode\\":\\"report\\"'), '', ${learnersAndAnswersTable}.kv1['${questionId}'])`;

columns.push({name: `${columnPrefix}_text`,
value: filterNoAnswerJSON,
Expand Down
6 changes: 3 additions & 3 deletions query-creator/create-query/tests/unit/test-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,8 @@ describe('Query creation', function () {
array_join(transform(CAST(json_extract(learners_and_answers_1.kv1['multiple_choice_02000'],'$.choice_ids') AS ARRAY(VARCHAR)), x -> CONCAT(activities_1.choices['multiple_choice_02000'][x].content, IF(activities_1.choices['multiple_choice_02000'][x].correct,' (correct)',' (wrong)'))),', ') AS res_1_multiple_choice_02000_choice,
array_join(transform(CAST(json_extract(learners_and_answers_1.kv1['multiple_choice_03000'],'$.choice_ids') AS ARRAY(VARCHAR)), x -> CONCAT(activities_1.choices['multiple_choice_03000'][x].content, IF(activities_1.choices['multiple_choice_03000'][x].correct,' (correct)',' (wrong)'))),', ') AS res_1_multiple_choice_03000_choice,
COALESCE(learners_and_answers_1.submitted['multiple_choice_03000'], false) AS res_1_multiple_choice_03000_submitted,
if(starts_with(learners_and_answers_1.kv1['open_response_11111'], '"{\\"mode\":\\"report\\"'), '', learners_and_answers_1.kv1['open_response_11111']) AS res_1_open_response_11111_text,
if(starts_with(learners_and_answers_1.kv1['open_response_22222'], '"{\\"mode\":\\"report\\"'), '', learners_and_answers_1.kv1['open_response_22222']) AS res_1_open_response_22222_text,
if(starts_with(learners_and_answers_1.kv1['open_response_11111'], '"{\\"mode\\":\\"report\\"'), '', learners_and_answers_1.kv1['open_response_11111']) AS res_1_open_response_11111_text,
if(starts_with(learners_and_answers_1.kv1['open_response_22222'], '"{\\"mode\\":\\"report\\"'), '', learners_and_answers_1.kv1['open_response_22222']) AS res_1_open_response_22222_text,
COALESCE(learners_and_answers_1.submitted['open_response_22222'], false) AS res_1_open_response_22222_submitted,
json_extract_scalar(learners_and_answers_1.kv1['image_question_33333'], '$.image_url') AS res_1_image_question_33333_image_url,
json_extract_scalar(learners_and_answers_1.kv1['image_question_33333'], '$.text') AS res_1_image_question_33333_text,
Expand All @@ -396,7 +396,7 @@ describe('Query creation', function () {
json_extract_scalar(learners_and_answers_1.kv1['image_question_44444'], '$.text') AS res_1_image_question_44444_text,
learners_and_answers_1.kv1['image_question_44444'] AS res_1_image_question_44444_answer,
COALESCE(learners_and_answers_1.submitted['image_question_44444'], false) AS res_1_image_question_44444_submitted,
if(starts_with(learners_and_answers_1.kv1['managed_interactive_55555'], '"{\\"mode\":\\"report\\"'), '', learners_and_answers_1.kv1['managed_interactive_55555']) AS res_1_managed_interactive_55555_text,
if(starts_with(learners_and_answers_1.kv1['managed_interactive_55555'], '"{\\"mode\\":\\"report\\"'), '', learners_and_answers_1.kv1['managed_interactive_55555']) AS res_1_managed_interactive_55555_text,
array_join(transform(CAST(json_extract(learners_and_answers_1.kv1['managed_interactive_66666'],'$.choice_ids') AS ARRAY(VARCHAR)), x -> CONCAT(activities_1.choices['managed_interactive_66666'][x].content, IF(activities_1.choices['managed_interactive_66666'][x].correct,' (correct)',' (wrong)'))),', ') AS res_1_managed_interactive_66666_choice,
json_extract_scalar(learners_and_answers_1.kv1['managed_interactive_77777'], '$.image_url') AS res_1_managed_interactive_77777_image_url,
json_extract_scalar(learners_and_answers_1.kv1['managed_interactive_77777'], '$.text') AS res_1_managed_interactive_77777_text,
Expand Down

0 comments on commit 77e5ab0

Please sign in to comment.