Skip to content

Commit

Permalink
Merge pull request #5 from levante-framework/fix-survey-marked-complete
Browse files Browse the repository at this point in the history
Fix - Subsequent children seeing survey marked as complete.
  • Loading branch information
Zio-4 authored Jun 18, 2024
2 parents 9cd55c8 + 3222d61 commit 4d7f3cb
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 23 deletions.
20 changes: 10 additions & 10 deletions src/components/ConsentPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
<div class="card flex justify-content-center">
<div class="flex flex-wrap gap-3">
<div class="flex align-items-center">
<PvRadioButton v-model="decision" inputId="helpChoose" name="help" value="help" @change="whatDecision" />
<PvRadioButton v-model="decision" input-id="helpChoose" name="help" value="help" @change="whatDecision" />
<label for="helpChoose" class="ml-2">Help me choose</label>
</div>
<div class="flex align-items-center">
<PvRadioButton v-model="decision" inputId="iKnow" name="know" value="know" @change="whatDecision" />
<PvRadioButton v-model="decision" input-id="iKnow" name="know" value="know" @change="whatDecision" />
<label for="iKnow" class="ml-2">I know what to select</label>
</div>
</div>
</div>
<div class="flex flex-row">
<div class="align-content-center" style="width: 50%" v-if="userDrivenFlow">
<div v-if="userDrivenFlow" class="align-content-center" style="width: 50%">
<h3>Default Data Collection</h3>
<div class="border-solid border-round border-1 border-black-alpha-30" style="width: 70%">
<div style="width: 70%; cursor: pointer">
Expand Down Expand Up @@ -42,11 +42,11 @@
</div>
<h3 class="mt-5">Additional Data Collection</h3>
<div
v-tooltip.top="!disableIfNotDefault ? tooltip : ''"
:class="[
'border-solid border-round border-1 border-black-alpha-30 mt-2',
{ 'opacity-80 surface-200 mt-2': !disableIfNotDefault },
]"
v-tooltip.top="!disableIfNotDefault ? tooltip : ''"
style="width: 70%; cursor: pointer"
>
<div class="mt-1 mb-1 ml-2 text-center flex cursor-pointer">
Expand All @@ -69,11 +69,11 @@
</div>
</div>
<div
v-tooltip.top="!disableIfNotDefault ? tooltip : ''"
:class="[
'border-solid border-round border-1 border-black-alpha-30 mt-2',
{ 'opacity-80 surface-200 mt-2': !disableIfNotDefault },
]"
v-tooltip.top="!disableIfNotDefault ? tooltip : ''"
style="width: 70%; cursor: pointer"
>
<div class="mt-1 mb-1 ml-2 text-center flex cursor-pointer">
Expand All @@ -96,11 +96,11 @@
</div>
</div>
<div
v-tooltip.top="!disableIfNotDefault ? tooltip : ''"
:class="[
'border-solid border-round border-1 border-black-alpha-30 mt-2',
{ 'opacity-80 surface-200 mt-2': !disableIfNotDefault },
]"
v-tooltip.top="!disableIfNotDefault ? tooltip : ''"
style="width: 70%; cursor: pointer"
>
<div class="mt-1 mb-1 ml-2 text-center flex cursor-pointer">
Expand Down Expand Up @@ -145,15 +145,15 @@
<PvDropdown
v-model="selectedConsent"
:options="listOfDocs.consent"
optionLabel="fileName"
option-label="fileName"
style="width: 70%"
@change="updateConsent"
/>
<h3 class="pt-3">Select an Assent Form</h3>
<PvDropdown
v-model="selectedAssent"
:options="listOfDocs.assent"
optionLabel="fileName"
option-label="fileName"
style="width: 70%"
@change="updateAssent"
/>
Expand All @@ -178,7 +178,7 @@
<div v-if="knowWhatIWant || userDrivenFlow" class="flex-column" style="width: 50%">
<h3 class="font-bold text-center text-xl">Suggested Forms</h3>
<div class="w-full">
<PvFieldset legend="Consent" v-if="consents && consents.length > 0">
<PvFieldset v-if="consents && consents.length > 0" legend="Consent">
<div class="flex flex-row w-full">
<div style="width: 80%">
<p class="m-0">
Expand All @@ -205,7 +205,7 @@
</div>
</div>
<div class="w-full mt-2">
<PvFieldset legend="Assent" v-if="consents && consents.length > 0">
<PvFieldset v-if="consents && consents.length > 0" legend="Assent">
<div class="flex flex-row w-full">
<div style="width: 80%">
<p class="m-0">
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/query/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export const matchMode2Op = {
notEquals: 'NOT_EQUAL',
};

export const fetchSubcollection = async (collectionPath, subcollectionName, select = [], db = 'admin') => {
export const fetchSubcollection = async (collectionPath, subcollectionName, select = [], db = 'admin') => {
try {
const axiosInstance = getAxiosInstance(db);
const subcollectionPath = `/${collectionPath}/${subcollectionName}`;
Expand Down
8 changes: 4 additions & 4 deletions src/pages/HomeParticipant.vue
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ const {
});
async function checkConsent() {
if (isLevante) return
if (isLevante) return;
const legal = selectedAdmin.value?.legal;
if (!legal) return;
const dob = new Date(userData.value?.studentData.dob);
const grade = userData.value?.studentData.grade;
const currentDate = new Date();
Expand Down Expand Up @@ -264,10 +264,10 @@ const {
staleTime: 5 * 60 * 1000,
});
const { data: surveyResponsesData, } = useQuery({
const { data: surveyResponsesData } = useQuery({
queryKey: ['surveyResponses', uid],
queryFn: () => fetchSubcollection(`users/${uid.value}`, 'surveyResponses'),
enabled: initialized && import.meta.env.MODE === 'LEVANTE',
enabled: initialized.value && import.meta.env.MODE === 'LEVANTE',
staleTime: 5 * 60 * 1000, // 5 minutes
cacheTime: 10 * 60 * 1000,
// refetchOnMount: false,
Expand Down
10 changes: 5 additions & 5 deletions src/pages/LEVANTE/UserSurvey.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { Converter } from 'showdown';
import { useI18n } from 'vue-i18n';
import { BufferLoader, AudioContext } from '@/helpers/audio';
import { useToast } from 'primevue/usetoast';
import { useQueryClient } from '@tanstack/vue-query'
import _merge from 'lodash/merge';
import { useQueryClient } from '@tanstack/vue-query';
import _merge from 'lodash/merge';
const fetchAudioLinks = async (surveyType) => {
const response = await axios.get('https://storage.googleapis.com/storage/v1/b/road-dashboard/o/');
Expand Down Expand Up @@ -157,9 +157,9 @@ async function playAudio(name) {
async function saveResults(sender) {
const allQuestions = sender.getAllQuestions();
const unansweredQuestions = {}
const unansweredQuestions = {};
allQuestions.forEach((question) => unansweredQuestions[question.name] = null);
allQuestions.forEach((question) => (unansweredQuestions[question.name] = null));
// Values from the second object overwrite values from the first
const responsesWithAllQuestions = _merge(unansweredQuestions, sender.data);
Expand All @@ -174,7 +174,7 @@ async function saveResults(sender) {
// update game store to let game tabs know
gameStore.setSurveyCompleted();
queryClient.invalidateQueries({ queryKey: ['surveyResponses', uid] })
queryClient.invalidateQueries({ queryKey: ['surveyResponses', uid] });
// route back to game tabs (HomeParticipant)
gameStore.requireHomeRefresh();
Expand Down
11 changes: 8 additions & 3 deletions src/router/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createRouter, createWebHistory } from 'vue-router';
import { useAuthStore } from '@/store/auth';
import { useGameStore } from '@/store/game';
import _get from 'lodash/get';
import { pageTitlesEN, pageTitlesUS, pageTitlesES, pageTitlesCO } from '@/translations/exports';

Expand Down Expand Up @@ -242,13 +243,17 @@ const routes = [
path: '/signout',
name: 'SignOut',
async beforeEnter() {
const store = useAuthStore();
if (store.isAuthenticated) {
await store.signOut();
const authStore = useAuthStore();
if (authStore.isAuthenticated) {
await authStore.signOut();
}
// Clear auth and game store so kids playing on the same device don't run into issues
sessionStorage.removeItem('gameStore');
sessionStorage.removeItem('authStore');

const gameStore = useGameStore();
gameStore.$reset();

return { name: 'SignIn' };
},
meta: {
Expand Down

0 comments on commit 4d7f3cb

Please sign in to comment.