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

#945 Improve analysis of qualifying test questions #1317

Merged
merged 6 commits into from
Aug 10, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 0 additions & 1 deletion src/views/Exercises/Show/Reports/Agency.vue
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,6 @@
</tr>
</tbody>
</table>

</template>
</div>
</TabsList>
Expand Down
3 changes: 2 additions & 1 deletion src/views/Exercises/Show/Reports/ReasonableAdjustments.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@

<div
v-if="report != null"
class="govuk-grid-row">
class="govuk-grid-row"
>
<div class="govuk-grid-column-one-half">
<div class="panel govuk-!-margin-bottom-9">
<span class="govuk-caption-m">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@
</div>
<div v-if="activeTab === 'logs'">
<h2 class="govuk-heading-m">
Logs
Connection Logs
</h2>
<div
v-for="(log, i) in logs"
Expand All @@ -320,6 +320,65 @@
</table>
</div>
</div>
<!-- // END CONNECTION TAB -->
<div v-if="activeTab === 'history'">
<h2 class="govuk-heading-m">
History Logs
</h2>
<div>
<table class="history-logs">
<div
v-for="(testQuestion, index) in questions"
:key="index"
>
<tr
class="log_row"
>
<td rowspan="6">
Question {{ index + 1 }}
</td>
</tr>
<tr>
<td>Amount of time on question: </td><td>{{ amountOfTimeOnQuestion(index) }}</td>
</tr>
<tr>
<td>How many times visited question: </td><td>{{ amountOfTimeVisitedQuestion(index) }} </td>
</tr>
<tr>
<td>how many times saved: </td><td>{{ historyCount('save', index) }}</td>
</tr>
<tr>
<td>How many times skipped: </td><td>{{ historyCount('skip', index) }}</td>
</tr>
<tr>
<td>How many times changed answer: </td><td>{{ historyCount('changed', index) }}</td>
</tr>
</div>
</table>
</div>
<div
v-for="(log, i, index) in sortHistory()"
:key="i"
>
<table>
<tr class="log_row">
<td class="log_row_time">
{{ differenceInTime(index, log.timestamp) }}
</td>
<td class="log_row_date">
<span v-if="log.action">{{ log.action }} </span>
<span v-if="log.question >= 0">question {{ log.question + 1 }} </span>
<span v-if="log.txt">("{{ log.txt }}" on {{ log.location }})</span>
<!-- <span v-if="log.location">{{ log.location }}</span> -->

<!-- <br>
{{ i }}<br> {{ log }} -->
</td>
</tr>
</table>
</div>
</div>
<!-- // END HISTORY TAB -->
</div><!-- hasStarted -->
</div>
</div>
Expand Down Expand Up @@ -349,6 +408,7 @@ export default {
isEditingTestDate: false,
activeTab: 'questions',
authorisedToPerformAction: false,
history: null,
};
},
computed: {
Expand All @@ -360,7 +420,11 @@ export default {
},
{
ref: 'logs',
title: 'Logs',
title: 'Connection',
},
{
ref: 'history',
title: 'History',
},
];
},
Expand Down Expand Up @@ -485,10 +549,11 @@ export default {
if (newActiveTab === 'logs') {
const candidateId = this.candidate.id;
const qualifyingTestId = this.$route.params.qualifyingTestId;
// eslint-disable-next-line no-console
// console.log('mounted', candidateId, qualifyingTestId, this);
await this.$store.dispatch('connectionMonitor/bind', { qualifyingTestId, candidateId });
}
if (newActiveTab === 'history') {
this.dateCalculate = null;
}
},
},
async created() {
Expand Down Expand Up @@ -600,6 +665,15 @@ export default {
return new Date(minDate).toISOString().substr(11, 8);
}
},
differenceInTime(index, date) {
const date2 = this.dateCalculate === null ? date : this.dateCalculate ;
const minDate = date - date2;
this.dateCalculate = date;
return index === 0 ? '00:00:00' : new Date(minDate).toISOString().substr(11, 8);
},
differenceInMills(entry1, entry2) {
return (entry1 - entry2);
},
timeOffline(index) {
const thisTimeOffline = this.logs[index] && this.logs[index].offline;
const nextIndex = index + 1 >= this.logs.length ? this.logs.length : index + 1;
Expand All @@ -611,6 +685,56 @@ export default {
return new Date(timeOffline).toISOString().substr(11, 8);
}
},
sortHistory() {
let ordered = {};
if (this.response.history) {
ordered = Object.keys(this.response.history).sort()
.reduce(
(obj, key) => {
obj[key] = this.response.history[key];
return obj;
},
{}
);
}
return ordered;
},
historyCount(value, index) {
let timeSaved = {};
if (this.response.history) {
timeSaved = Object.keys(this.response.history)
.filter(key => {
return (this.response.history[key].action === value && this.response.history[key].question === index);
});
}
const amountTimeSaved = Object.keys(timeSaved).length;
return amountTimeSaved;
},
amountOfTimeOnQuestion(index) {
let millisecs = 0;
if (this.response.history) {
Object.keys(this.response.questionSession).map(key => {
const item = this.response.questionSession[key];
if (item.question === index) {
const diff = this.differenceInMills(item.end, item.start);
millisecs = millisecs + diff;
}
});
}
return new Date(millisecs).toISOString().substr(11, 8);
},
amountOfTimeVisitedQuestion(index) {
let counter = 0;
if (this.response.history) {
Object.keys(this.response.history).map(key => {
const item = this.response.history[key];
if (item.question === index && (item.action === 'save' || item.action === 'skip' || item.action === 'exit')) {
counter++;
}
});
}
return counter;
},
},
};
</script>
Expand Down Expand Up @@ -638,5 +762,9 @@ export default {
line-height: 1;
padding: 5px;
}
.history-logs [rowspan] {
font-weight: bold;
font-size: larger;
}
</style>