|
38 | 38 | <AttemptLogItem
|
39 | 39 | class="attempt-selected"
|
40 | 40 | :isSurvey="isSurvey"
|
41 |
| - :attemptLog="attemptLogs[selectedQuestionNumber]" |
| 41 | + :attemptLog="selectedAttemptLog" |
| 42 | + :questionNumber="selectedQuestionNumber + 1" |
42 | 43 | displayTag="span"
|
43 | 44 | />
|
44 | 45 | </template>
|
45 | 46 | <template #option="{ index }">
|
46 | 47 | <AttemptLogItem
|
| 48 | + v-if="attemptLogsForCurrentSection[index]" |
47 | 49 | class="attempt-option"
|
48 | 50 | :isSurvey="isSurvey"
|
49 |
| - :attemptLog="attemptLogs[sections[currentSectionIndex].startQuestionNumber + index]" |
| 51 | + :attemptLog="attemptLogsForCurrentSection[index]" |
| 52 | + :questionNumber="index + 1" |
50 | 53 | displayTag="span"
|
51 | 54 | />
|
52 | 55 | </template>
|
|
131 | 134 | "
|
132 | 135 | >
|
133 | 136 | <AttemptLogItem
|
| 137 | + v-if="attemptLogsForCurrentSection[qIndex]" |
134 | 138 | :isSurvey="isSurvey"
|
135 |
| - :attemptLog="attemptLogs[section.startQuestionNumber + qIndex]" |
| 139 | + :attemptLog="attemptLogsForCurrentSection[qIndex]" |
| 140 | + :questionNumber="qIndex + 1" |
136 | 141 | displayTag="p"
|
137 | 142 | />
|
138 | 143 | </a>
|
|
193 | 198 | return sections.value[currentSectionIndex.value];
|
194 | 199 | });
|
195 | 200 |
|
| 201 | + // Computed property for attempt logs of the current section |
| 202 | + const attemptLogsForCurrentSection = computed(() => { |
| 203 | + const start = currentSection.value.startQuestionNumber; |
| 204 | + return props.attemptLogs.slice(start, start + currentSection.value.questions.length); |
| 205 | + }); |
| 206 | +
|
196 | 207 | const questionSelectOptions = computed(() => {
|
197 | 208 | return currentSection.value.questions.map((question, index) => ({
|
198 | 209 | value: index,
|
199 | 210 | label: questionNumberLabel$({ questionNumber: index + 1 }),
|
| 211 | + disabled: !attemptLogsForCurrentSection.value[index], |
200 | 212 | }));
|
201 | 213 | });
|
202 | 214 |
|
|
212 | 224 | ];
|
213 | 225 | });
|
214 | 226 |
|
| 227 | + // Computed property for the selected attempt log |
| 228 | + const selectedAttemptLog = computed(() => { |
| 229 | + return props.attemptLogs[selectedQuestionNumber.value]; |
| 230 | + }); |
| 231 | +
|
215 | 232 | function handleQuestionChange(index) {
|
216 | 233 | emit('select', index + currentSection.value.startQuestionNumber);
|
217 | 234 | expandCurrentSectionIfNeeded();
|
|
239 | 256 | sectionSelectOptions,
|
240 | 257 | selectedQuestion,
|
241 | 258 | questionSelectOptions,
|
| 259 | + attemptLogsForCurrentSection, |
| 260 | + selectedAttemptLog, |
242 | 261 | };
|
243 | 262 | },
|
244 | 263 | props: {
|
|
0 commit comments