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

Make display of attempts parallel between mobile and non-mobile display #8890

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
97 changes: 97 additions & 0 deletions kolibri/core/assets/src/views/AttemptLogItem.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<template>

<span>
<KIcon
v-if="attemptLog.noattempt"
class="item svg-item"
icon="notStarted"
/>
<KIcon
v-else-if="attemptLog.correct"
class="item svg-item"
:style="{ fill: $themeTokens.correct }"
icon="correct"
/>
<KIcon
v-else-if="attemptLog.error"
class="svg-item"
:style=" { fill: $themeTokens.annotation }"
icon="helpNeeded"
/>
<KIcon
v-else-if="!attemptLog.correct"
class="item svg-item"
:style="{ fill: $themeTokens.incorrect }"
icon="incorrect"
/>
<KIcon
v-else-if="attemptLog.hinted"
class="item svg-item"
:style=" { fill: $themeTokens.annotation }"
icon="hint"
/>
<component :is="displayTag" class="item">
{{ coreString(
'questionNumberLabel',
{ questionNumber: attemptLog.questionNumber }
)
}}
</component>
<CoachContentLabel
class="coach-content-label"
:value="attemptLog.num_coach_contents || 0"
:isTopic="false"
/>
</span>

</template>


<script>

import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings';
import CoachContentLabel from 'kolibri.coreVue.components.CoachContentLabel';

export default {
name: 'AttemptLogItem',
components: {
CoachContentLabel,
},
mixins: [commonCoreStrings],
props: {
attemptLog: {
type: Object,
required: true,
},
displayTag: {
type: String,
required: true,
},
},
};

</script>


<style lang="scss" scoped>

.coach-content-label {
display: inline-block;
width: auto; // keeps on same line as question
margin-top: -4px;
margin-left: 8px;
vertical-align: middle;
}

.item {
display: inline-block;
height: 100%;
}

.svg-item {
margin-right: 12px;
margin-bottom: -4px;
font-size: 24px;
}

</style>
81 changes: 16 additions & 65 deletions kolibri/core/assets/src/views/AttemptLogList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@
:options="options"
:disabled="$attrs.disabled"
@change="handleDropdownChange($event.value)"
/>
>
<template #display>
<AttemptLogItem :attemptLog="attemptLogs[selectedQuestionNumber]" displayTag="span" />
</template>
<template #option="{ index }">
<AttemptLogItem :attemptLog="attemptLogs[index]" displayTag="span" />
</template>
</KSelect>

<ul
v-else
Expand Down Expand Up @@ -46,48 +53,7 @@
@keydown.enter="setSelectedAttemptLog(index)"
@keydown.space.prevent="setSelectedAttemptLog(index)"
>
<KIcon
v-if="attemptLog.noattempt"
class="item svg-item"
icon="notStarted"
/>
<KIcon
v-else-if="attemptLog.correct"
class="item svg-item"
:style="{ fill: $themeTokens.correct }"
icon="correct"
/>
<KIcon
v-else-if="attemptLog.error"
class="svg-item"
:style=" { fill: $themeTokens.annotation }"
icon="helpNeeded"
/>
<KIcon
v-else-if="!attemptLog.correct"
class="item svg-item"
:style="{ fill: $themeTokens.incorrect }"
icon="incorrect"
/>
<KIcon
v-else-if="attemptLog.hinted"
class="item svg-item"
:style=" { fill: $themeTokens.annotation }"
icon="hint"
/>
<p class="item">
{{ coreString(
'questionNumberLabel',
{ questionNumber: attemptLog.questionNumber }
)
}}
</p>
<CoachContentLabel
v-if="windowIsLarge"
class="coach-content-label"
:value="attemptLog.num_coach_contents || 0"
:isTopic="false"
/>
<AttemptLogItem :attemptLog="attemptLog" displayTag="p" />
</a>
</li>
</template>
Expand All @@ -100,13 +66,13 @@
<script>

import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings';
import CoachContentLabel from 'kolibri.coreVue.components.CoachContentLabel';
import responsiveWindowMixin from 'kolibri.coreVue.mixins.responsiveWindowMixin';
import AttemptLogItem from './AttemptLogItem';

export default {
name: 'AttemptLogList',
components: {
CoachContentLabel,
AttemptLogItem,
},
mixins: [commonCoreStrings, responsiveWindowMixin],
props: {
Expand Down Expand Up @@ -171,7 +137,11 @@
},
scrollToSelectedAttemptLog(questionNumber) {
let selectedElement;
if (this.$refs.attemptListOption && this.$refs.attemptList.children) {
if (
this.$refs.attemptListOption &&
this.$refs.attemptList &&
this.$refs.attemptList.children
) {
selectedElement = this.$refs.attemptList.children[questionNumber];
}
if (selectedElement) {
Expand Down Expand Up @@ -201,14 +171,6 @@

<style lang="scss" scoped>

.coach-content-label {
display: inline-block;
width: auto; // keeps on same line as question
margin-top: -4px;
margin-left: 8px;
vertical-align: middle;
}

.header {
padding-top: 10px;
padding-bottom: 10px;
Expand All @@ -229,17 +191,6 @@
margin: auto;
}

.item {
display: inline-block;
height: 24px;
}

.svg-item {
margin-right: 12px;
margin-bottom: -4px;
font-size: 24px;
}

.attempt-item {
display: block;
min-width: 120px;
Expand Down
6 changes: 4 additions & 2 deletions kolibri/core/assets/src/views/KSelect/KeenUiSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@
class="ui-select-display-value"
:class="{ 'is-placeholder': !hasDisplayText }"
>
{{ hasDisplayText ? displayText : (
hasFloatingLabel && isLabelInline) ? null : placeholder }}
<slot name="display">
{{ hasDisplayText ? displayText : (
hasFloatingLabel && isLabelInline) ? null : placeholder }}
</slot>
</div>

<UiIcon v-if="!clearableState" class="ui-select-dropdown-button">
Expand Down
16 changes: 15 additions & 1 deletion kolibri/core/assets/src/views/KSelect/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,21 @@
:placeholder="placeholder"
@change="handleChange"
@blur="$emit('blur')"
/>
>
<template #display>
<slot name="display"></slot>
</template>
<template #option="{ highlighted, index, option, selected }">
<slot
name="option"
:highlighted="highlighted"
:index="index"
:option="option"
:selected="selected"
>
</slot>
</template>
</UiSelect>

</template>

Expand Down