Skip to content

Commit

Permalink
Apply/517 qt analytics - save History and session time (#774)
Browse files Browse the repository at this point in the history
* 517 Collect more detailed history of qualifying test responses
- Save history
	- on Exit Modal
	- on information page
	- on review
	- on Situational Judgement
- Save session
	- on skip
	- on SAve

* Disable circleci config

* Include CODEOWNERS

* digital-platform#305 Include pull request template

* Include lint and test in PR workflow

* Fix the broken preview URLs and workflow (#752)

* Small change to test broken

* Preview workflow should use node 10, for now

* Update package-lock

* Small change to test fixed

* test to fix

Co-authored-by: Tom Russell <TR115251@hotmail.co.uk>

* #729 Fixed errors on Qualifications page (#734)

* #729 Fixed errors on Qualifications page

* #729 Changes as per PR comments

Co-authored-by: Maria Brookes <maria_brookes@yahoo.co.uk>
Co-authored-by: warrensearle <warren.searle@judicialappointments.digital>

* #708 account creation issues (#751)

* Add await into account creation - improve password validation

* sort sign-in chronology

* add and fix password tests

* Add await into account creation - improve password validation

* sort sign-in chronology

* add and fix password tests

* fix signUp test

Co-authored-by: warrensearle <warren.searle@judicialappointments.digital>

* #720 Added a message if vacancy was unpublished (#732)

* #720 Added a message if vacancy was unpublished

* #720 Display message if vacancy unpublished

* Made changes to make applications appear

* Made changes to make applications appear

* Made changes to make applications appear

* WIP

* #720 Made changes to accommodate unpublished vacancy

Co-authored-by: Maria Brookes <maria_brookes@yahoo.co.uk>
Co-authored-by: warrensearle <warren.searle@judicialappointments.digital>

* Update github workflow files

* Bump version number to 1.39.0

* Remove circleCI config

* Update README.md

* Bump version number to 1.40.0

* Update workflows to target staging and production

* Bump version number to 1.39.0

* Remove name-blind sift and phone assessment from timeline (#753)

* remove name-blind sift and phone assessment from timeline

* fix timeline tests

* delete commented code

Co-authored-by: HalcyonJAC <79906532+HalcyonJAC@users.noreply.github.com>

* Security/769 weak passwords allowed in reset form (#778)

* Reset PW component with proper validation

* check for valid action code

* #771 Authentication Generic Errors (#775)

* Display a generic erorr for wrong password or user not found

* Update SignIn.vue

replicating changes from local copy due to a 403 error

* adding lodash as explicit dependency

Co-authored-by: warrensearle <warren.searle@judicialappointments.digital>

* #1289 Remove gaps in employment from non-legal exercises (#761)

* inital changes

* Update readme

* remove commented code

Co-authored-by: Warren Searle <warren@precise-minds.co.uk>

* #1313 Location preferences (#777)

* wip

* wip

* ranked choice changes

* remove unrelated changes

* remove padding

* remove phantom checkbox

* add to review page

* remove from review page [wrong branch]

Co-authored-by: warrensearle <warren.searle@judicialappointments.digital>

* Workflow: on merge. Change develop to main branch

* Bump version number to 1.40.0

* 517 Collect more detailed history of qualifying test responses
- Save history
	- on Exit Modal
	- on information page
	- on review
	- on Situational Judgement
- Save session
	- on skip
	- on SAve

* [517] fix anlytics

* [517] resolve conflict package-lock

Co-authored-by: Lisias (Lee) Loback <lisias@loback.co.uk>
Co-authored-by: Warren Searle <warren@precise-minds.co.uk>
Co-authored-by: warrensearle <warren.searle@judicialappointments.digital>
Co-authored-by: Tom Russell <TR115251@hotmail.co.uk>
Co-authored-by: Maria Brookes <40855898+mbrookeswebdev@users.noreply.github.com>
Co-authored-by: Maria Brookes <maria_brookes@yahoo.co.uk>
Co-authored-by: tomlovesgithub <44227249+tomlovesgithub@users.noreply.github.com>
Co-authored-by: HalcyonJAC <79906532+HalcyonJAC@users.noreply.github.com>
  • Loading branch information
9 people authored Aug 10, 2021
1 parent 0c105ff commit d206768
Show file tree
Hide file tree
Showing 7 changed files with 191 additions and 15 deletions.
28 changes: 28 additions & 0 deletions src/views/QualifyingTests/QualifyingTest.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
</div>
</template>
<script>
import firebase from '@/firebase';
import LoadingMessage from '@/components/LoadingMessage';
import Modal from '@/components/Page/Modal';
import Countdown from '@/components/QualifyingTest/Countdown';
Expand Down Expand Up @@ -212,12 +213,26 @@ export default {
this.$refs.timeElapsedModalRef.openModal();
},
openExitModal(){
const historyToSave = this.prepareSaveHistory({
action: 'exit',
txt: 'Exit Test',
location: 'timer bar',
question: this.$route.params.questionNumber - 1,
});
this.$store.dispatch('qualifyingTestResponse/save', historyToSave);
this.$refs.exitModalRef.openModal();
},
btnModalConfirmed() {
this.$router.push({ name: 'qualifying-test-submitted' });
},
btnExitModalConfirmed() {
const historyToSave = this.prepareSaveHistory({
action: 'exit',
txt: `Exit Test question ${this.$route.params.questionNumber}`,
location: 'modal',
question: this.$route.params.questionNumber - 1,
});
this.$store.dispatch('qualifyingTestResponse/save', historyToSave);
this.timerEnded = true;
this.$nextTick(() => { // ensures change is picked up before we leave this route
this.$router.push({ name: 'qualifying-tests' });
Expand All @@ -228,6 +243,19 @@ export default {
const hyphenated = `${params.qualifyingTestId}--scenario-${params.scenarioNumber}--from-${params.questionNumber}-to-${params.questionNumber - 1}`;
return hyphenated;
},
prepareSaveHistory(data) {
const timeNow = firebase.firestore.FieldValue.serverTimestamp();
const date = new Date();
const objToSave = {
history: firebase.firestore.FieldValue.arrayUnion({
...data,
timestamp: firebase.firestore.Timestamp.fromDate(date),
utcOffset: date.getTimezoneOffset(),
}),
lastUpdated: timeNow,
};
return objToSave;
},
},
};
</script>
Expand Down
17 changes: 17 additions & 0 deletions src/views/QualifyingTests/QualifyingTest/Information.vue
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
</div>
</template>
<script>
import firebase from '@/firebase';
import Form from '@/components/Form/Form';
import ErrorSummary from '@/components/Form/ErrorSummary';
import Checkbox from '@/components/Form/Checkbox';
Expand Down Expand Up @@ -214,14 +215,30 @@ export default {
throw new Error('You must agree to keep this test confidential.');
}
await this.$store.dispatch('qualifyingTestResponse/startTest');
}
this.$router.push(this.nextPage);
} catch (error) {
this.errors.push({ message: error.message });
this.scrollToTop();
}
const saveHistory = this.prepareSaveHistory({ action: 'start', location: 'information' });
await this.$store.dispatch('qualifyingTestResponse/save', saveHistory);
}
},
prepareSaveHistory(data) {
const timeNow = firebase.firestore.FieldValue.serverTimestamp();
const date = new Date();
const objToSave = {
history: firebase.firestore.FieldValue.arrayUnion({
...data,
timestamp: firebase.firestore.Timestamp.fromDate(date),
utcOffset: date.getTimezoneOffset(),
}),
lastUpdated: timeNow,
};
return objToSave;
},
},
};
</script>
66 changes: 59 additions & 7 deletions src/views/QualifyingTests/QualifyingTest/Question.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<form
ref="formRef"
@submit.prevent="save(true)"
@submit.prevent="save(true, {})"
>
<component
:is="questionType"
Expand Down Expand Up @@ -168,25 +168,38 @@ export default {
await this.$store.dispatch('qualifyingTestResponse/save', data);
}
this.questionStartedOnPreviousTest();
this.questionSessionStart = firebase.firestore.Timestamp.now();
},
methods: {
async skip() {
this.saveHistoryAndSession({ action: 'skip', txt: 'Skip' }, true);
this.$router.push(this.nextPage);
},
async save(isCompleted) {
async save(isCompleted, history) {
let data = {};
if (isCompleted) {
const historyToSave = this.prepareSaveHistory({ action: 'save', txt: 'Save and continue' });
const sessionToSave = this.prepareSaveQuestionSession();
this.response.completed = firebase.firestore.Timestamp.fromDate(new Date());
data = {
...historyToSave,
...sessionToSave,
responses: this.responses,
};
} else {
const historyToSave = this.prepareSaveHistory(history);
data = {
...historyToSave,
responses: this.responses,
};
}
const data = {
responses: this.responses,
};
await this.$store.dispatch('qualifyingTestResponse/save', data);
if (isCompleted) {
this.$router.push(this.nextPage);
}
},
questionAnswered() {
this.save(false);
questionAnswered(val) {
this.save(false, { action: 'changed', answer: { value: val.value, type: val.type } });
},
questionStartedOnPreviousTest() {
if (this.response.started && this.response.completed) {
Expand All @@ -195,6 +208,45 @@ export default {
}
}
},
async saveHistoryAndSession(data) {
const historyToSave = this.prepareSaveHistory(data);
const sessionToSave = this.prepareSaveQuestionSession();
const objToSave = {
...historyToSave,
...sessionToSave,
};
await this.$store.dispatch('qualifyingTestResponse/save', objToSave);
},
prepareSaveHistory(data) {
const timeNow = firebase.firestore.FieldValue.serverTimestamp();
const date = new Date();
const objToSave = {
history: firebase.firestore.FieldValue.arrayUnion({
...data,
timestamp: firebase.firestore.Timestamp.fromDate(date),
location: `question ${this.questionNumber}`,
question: this.questionNumber - 1,
utcOffset: date.getTimezoneOffset(),
}),
lastUpdated: timeNow,
};
return objToSave;
},
prepareSaveQuestionSession() {
const timeNow = firebase.firestore.FieldValue.serverTimestamp();
const date = new Date();
const objToSave = {
questionSession: firebase.firestore.FieldValue.arrayUnion({
start: this.questionSessionStart,
end: firebase.firestore.Timestamp.fromDate(date),
question: this.questionNumber - 1,
timestamp: firebase.firestore.Timestamp.fromDate(date),
utcOffset: date.getTimezoneOffset(),
}),
lastUpdated: timeNow,
};
return objToSave;
},
},
};
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ export default {
},
set(val) {
this.$emit('input', val);
this.$emit('answered');
// this.$emit('answered');
if (val !== this.value && this.value !== null && this.value !== undefined) {
this.$emit('answered', { value: val });
}
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ export default {
if (value === this.localValue.mostAppropriate) {
this.localValue.mostAppropriate = null;
}
this.$emit('answered');
this.$emit('answered', { value, type: 'leastAppropriate' });
},
'localValue.mostAppropriate': function (value) {
if (value === this.localValue.leastAppropriate) {
this.localValue.leastAppropriate = null;
}
this.$emit('answered');
this.$emit('answered', { value, type: 'mostAppropriate' });
},
},
};
Expand Down
26 changes: 25 additions & 1 deletion src/views/QualifyingTests/QualifyingTest/Review.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
v-for="(question, questionIndex) in questions"
:key="questionIndex"
class="moj-task-list__item display-flex"
@click="saveHistory({ action: 'review', question: questionIndex, txt: question.details });"
>
<RouterLink
:to="{ name: `qualifying-test-question`, params: { questionNumber: questionIndex + 1 } }"
Expand Down Expand Up @@ -68,6 +69,7 @@
v-for="(question, questionIndex) in scenario.options"
:key="questionIndex"
class="moj-task-list__item display-flex"
@click="saveHistory({ action: 'review', question: questionIndex, scenario: index, txt: question.question });"
>
<RouterLink
:to="{ name: `qualifying-test-scenario`, params: { scenarioNumber: index + 1, questionNumber: questionIndex + 1 } }"
Expand Down Expand Up @@ -147,6 +149,7 @@ export default {
},
methods: {
openModal(){
this.saveHistory({ action: 'submit', txt: 'Submit answers' });
this.$refs.modalRef.openModal();
},
async modalConfirmed(){
Expand All @@ -156,10 +159,31 @@ export default {
};
await this.$store.dispatch('qualifyingTestResponse/save', data);
await this.$store.dispatch('connectionMonitor/stop');
this.saveHistory({ action: 'modal', txt: 'Submit answers' });
this.$router.push({ name: 'qualifying-test-submitted' });
},
modalClosed(){
//pass
this.saveHistory({ action: 'modal', txt: 'Cancel' });
},
async saveHistory(data) {
const objToSave = this.prepareSaveHistory({
...data,
location: 'review answers',
});
await this.$store.dispatch('qualifyingTestResponse/save', objToSave);
},
prepareSaveHistory(data) {
const timeNow = firebase.firestore.FieldValue.serverTimestamp();
const date = new Date();
const objToSave = {
history: firebase.firestore.FieldValue.arrayUnion({
...data,
timestamp: firebase.firestore.Timestamp.fromDate(date),
utcOffset: date.getTimezoneOffset(),
}),
lastUpdated: timeNow,
};
return objToSave;
},
},
};
Expand Down
60 changes: 56 additions & 4 deletions src/views/QualifyingTests/QualifyingTest/Scenario.vue
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,14 @@ export default {
};
await this.$store.dispatch('qualifyingTestResponse/save', data);
}
this.questionSessionStart = firebase.firestore.Timestamp.now();
},
methods: {
toggleAccordion() {
this.showDetails = !this.showDetails;
},
async skip() {
this.saveHistoryAndSession({ action: 'skip', txt: 'Skip' });
this.$router.push(this.nextPage);
},
async save() {
Expand All @@ -257,13 +259,21 @@ export default {
},
async saveResponse(markAsCompleted) {
// TODO only save if there are un-saved changes
let data = {};
if (markAsCompleted) {
this.response.completed = firebase.firestore.Timestamp.fromDate(new Date());
const historyToSave = this.prepareSaveHistory({ action: 'saved' });
const sessionToSave = this.prepareSaveQuestionSession();
data = {
...historyToSave,
...sessionToSave,
responses: this.responses,
};
} else {
data = {
responses: this.responses,
};
}
// testQuestions: this.qualifyingTestResponse.testQuestions,
const data = {
responses: this.responses,
};
await this.$store.dispatch('qualifyingTestResponse/save', data);
},
clickAdditional(index) {
Expand Down Expand Up @@ -303,6 +313,48 @@ export default {
this.enableScenario = false;
this.$router.push({ name: 'qualifying-tests' });
},
async saveQuestionSession() {
const objToSave = this.prepareSaveQuestionSession({});
await this.$store.dispatch('qualifyingTestResponse/save', objToSave);
},
async saveHistoryAndSession(data) {
const historyToSave = this.prepareSaveHistory(data);
const sessionToSave = this.prepareSaveQuestionSession();
const objToSave = {
...historyToSave,
...sessionToSave,
};
await this.$store.dispatch('qualifyingTestResponse/save', objToSave);
},
prepareSaveHistory(data) {
const timeNow = firebase.firestore.FieldValue.serverTimestamp();
const date = new Date();
const objToSave = {
history: firebase.firestore.FieldValue.arrayUnion({
...data,
question: this.questionNumber - 1,
timestamp: firebase.firestore.Timestamp.fromDate(date),
utcOffset: date.getTimezoneOffset(),
}),
lastUpdated: timeNow,
};
return objToSave;
},
prepareSaveQuestionSession() {
const timeNow = firebase.firestore.FieldValue.serverTimestamp();
const date = new Date();
const objToSave = {
questionSession: firebase.firestore.FieldValue.arrayUnion({
start: this.questionSessionStart,
end: firebase.firestore.Timestamp.fromDate(date),
question: this.questionNumber - 1,
timestamp: firebase.firestore.Timestamp.fromDate(date),
utcOffset: date.getTimezoneOffset(),
}),
lastUpdated: timeNow,
};
return objToSave;
},
},
};
</script>
Expand Down

0 comments on commit d206768

Please sign in to comment.