Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Really fixed the backslash escaping #204

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading