From cf1636d7ba841abb5b5ea31430c18a8127c8fa8e Mon Sep 17 00:00:00 2001 From: Manuel Garcia Date: Fri, 15 Mar 2024 13:13:03 +0100 Subject: [PATCH 1/2] Add useAnswerStore import and update submitAnswer function --- frontend/stores/response.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/frontend/stores/response.js b/frontend/stores/response.js index c1bf71d5..2d197eb6 100644 --- a/frontend/stores/response.js +++ b/frontend/stores/response.js @@ -3,6 +3,9 @@ import { useUserStore } from './user'; import { useGlobalStore } from './global'; import setRequestConfig from './utils/setRequestConfig'; import { useSurveyStore } from './survey'; +import { useAnswerStore } from './answer'; + +// const answer = useAnswerStore(); export const useStoreResponse = defineStore('response', { @@ -17,11 +20,12 @@ export const useStoreResponse = defineStore('response', { return { responseData: {}, answers: - [ + [ // expects and array of objects with the following structure // { // question_index: integer, // body: text, + // locations: [list of locations], // } ], @@ -126,7 +130,7 @@ export const useStoreResponse = defineStore('response', { // Clear all the answers this.answers = [] }, - async submitAnswer(response_url, question_url, answer_value) { + async submitAnswer(response_url, question_id, answer_value) { // TODO: must include locations in the answer const user = useUserStore(); const global = useGlobalStore(); const csrftoken = user.getCookie('csrftoken'); @@ -141,10 +145,11 @@ export const useStoreResponse = defineStore('response', { // pas the data for the new Response object as the request body // TODO: have the repondent set to the logged in user + body: { response: response_url, - question: question_url, - body: answer_value + question: question_id, + body: answer_value, } }; if (token) { @@ -156,7 +161,10 @@ export const useStoreResponse = defineStore('response', { if (response) { console.log('response submitted //> '); } - + if (error) { + console.log('error in SubmitAnswer //> ', error); + } + } // TODO: CONTINUE HERE From 4011aa8716b5461e1d0f7e68e0e4c6c696276615 Mon Sep 17 00:00:00 2001 From: Manuel Garcia Date: Mon, 18 Mar 2024 10:51:00 +0100 Subject: [PATCH 2/2] Remove point location test case --- citizenvoice/tests/test_api_methods.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/citizenvoice/tests/test_api_methods.py b/citizenvoice/tests/test_api_methods.py index eb3a936b..a55be813 100644 --- a/citizenvoice/tests/test_api_methods.py +++ b/citizenvoice/tests/test_api_methods.py @@ -31,18 +31,6 @@ def setUpTestData(cls): question_type='text', choices='', survey=survey) question.save() - # Create a new point location - point_location = PointLocation(location='SRID=4326;POINT (0.0075149652548134 0.0322341867016535)', name='test location', - question=question) - point_location.save() - - pass - - def test_get_pointlocation_by_question(self): - question = Question.objects.get(id=1) - point_location = PointLocation.objects.get(question=question) - location = point_location.location - self.assertEqual(location, 'SRID=4326;POINT (0.0075149652548134 0.0322341867016535)') def test_get_non_expired_surveys(self): print('=================================')