Skip to content

Commit 080810e

Browse files
committed
expand displayed data, show metadata
1 parent 97c72c2 commit 080810e

File tree

1 file changed

+33
-30
lines changed

1 file changed

+33
-30
lines changed

packages/common-ui/src/components/CardHistoryViewer.vue

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,29 @@
33
<h3 v-if="userId">Card History for User: {{ userId }}</h3>
44
<div v-if="loading">Loading...</div>
55
<div v-else-if="error" class="error-message">{{ error }}</div>
6-
<div v-else>
7-
<v-data-table :headers="headers" :items="history" class="elevation-1">
8-
<template v-slot:item.hasNegativeInterval="{ item }">
9-
<v-chip :color="item.hasNegativeInterval ? 'error' : 'success'" :text-color="'white'" small>
10-
{{ item.hasNegativeInterval ? 'INVALID' : 'Valid' }}
11-
</v-chip>
12-
</template>
13-
14-
<template v-slot:item.intervalFromPrevious="{ item }">
15-
<span :class="{ 'negative-interval': item.hasNegativeInterval }">
16-
{{ item.intervalFromPrevious !== undefined ? item.intervalFromPrevious : '-' }}
17-
</span>
18-
</template>
19-
20-
<template v-slot:item.formattedTimeStamp="{ item }">
21-
<span :class="{ 'invalid-timestamp': item.hasNegativeInterval }">
22-
{{ item.formattedTimeStamp }}
23-
</span>
24-
</template>
25-
</v-data-table>
6+
<div v-else-if="cardHistory">
7+
<v-card class="mb-4">
8+
<v-card-title>Summary</v-card-title>
9+
<v-list-item>
10+
<v-list-item-content>
11+
<v-list-item-title>Best Interval: {{ cardHistory.bestInterval }}</v-list-item-title>
12+
<v-list-item-subtitle>The to-date largest interval between successful card reviews.</v-list-item-subtitle>
13+
</v-list-item-content>
14+
</v-list-item>
15+
<v-list-item>
16+
<v-list-item-content>
17+
<v-list-item-title>Lapses: {{ cardHistory.lapses }}</v-list-item-title>
18+
<v-list-item-subtitle>The number of times that a card has been failed in review.</v-list-item-subtitle>
19+
</v-list-item-content>
20+
</v-list-item>
21+
<v-list-item>
22+
<v-list-item-content>
23+
<v-list-item-title>Streak: {{ cardHistory.streak }}</v-list-item-title>
24+
<v-list-item-subtitle>The number of consecutive successful impressions on this card.</v-list-item-subtitle>
25+
</v-list-item-content>
26+
</v-list-item>
27+
</v-card>
28+
<v-data-table :headers="headers" :items="history" class="elevation-1"></v-data-table>
2629
</div>
2730
</div>
2831
</template>
@@ -62,13 +65,16 @@ export default defineComponent({
6265
data() {
6366
return {
6467
history: [] as FormattedRecord[],
68+
cardHistory: null as CardHistory<CardRecord> | null,
6569
loading: false,
6670
error: null as string | null,
6771
headers: [
6872
{ title: 'Timestamp', key: 'formattedTimeStamp' },
69-
{ title: 'Interval (min)', key: 'intervalFromPrevious' },
7073
{ title: 'Time Spent (s)', key: 'timeSpentSeconds' },
71-
{ title: 'Valid', key: 'hasNegativeInterval' },
74+
{ title: 'Correct?', key: 'isCorrect' },
75+
{ title: 'Performance', key: 'performance' },
76+
{ title: 'Prior Attempts', key: 'priorAttemps' },
77+
{ title: 'User Answer', key: 'userAnswer' },
7278
],
7379
};
7480
},
@@ -96,6 +102,7 @@ export default defineComponent({
96102
try {
97103
const cardHistoryID = getCardHistoryID(this.courseId, this.cardId);
98104
const historyDoc: CardHistory<CardRecord> = await this.userDB.get(cardHistoryID);
105+
this.cardHistory = historyDoc;
99106
100107
// Sort records by timestamp and format them
101108
const sortedRecords = [...historyDoc.records].sort(
@@ -108,16 +115,12 @@ export default defineComponent({
108115
...record,
109116
formattedTimeStamp: currentTime.format('YYYY-MM-DD HH:mm:ss'),
110117
timeSpentSeconds: Math.round(record.timeSpent / 1000),
118+
isCorrect: (record as any).isCorrect,
119+
performance: (record as any).performance,
120+
priorAttemps: (record as any).priorAttemps,
121+
userAnswer: (record as any).userAnswer,
111122
};
112123
113-
// Calculate interval from previous record
114-
if (index > 0) {
115-
const previousTime = moment(sortedRecords[index - 1].timeStamp);
116-
const intervalMinutes = currentTime.diff(previousTime, 'minutes', true);
117-
formatted.intervalFromPrevious = Math.round(intervalMinutes * 100) / 100;
118-
formatted.hasNegativeInterval = intervalMinutes < 0;
119-
}
120-
121124
return formatted;
122125
});
123126
} catch (e) {

0 commit comments

Comments
 (0)