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

Question sources #11658

Merged
merged 17 commits into from
Jan 3, 2024
8 changes: 8 additions & 0 deletions .trunk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*out
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what .trunk is but you can add it to the .gitignore file in the Kolibri project root.

Once you do that you'll need to run git rm -r --cached .trunk to remove it from the git index. It will keep the files on your local machine, however. Relevant StackOverflow

*logs
*actions
*notifications
*tools
plugins
user_trunk.yaml
user.yaml
4 changes: 4 additions & 0 deletions .trunk/configs/.hadolint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Following source doesn't work in most setups
ignored:
- SC1090
- SC1091
2 changes: 2 additions & 0 deletions .trunk/configs/.isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[settings]
profile=black
10 changes: 10 additions & 0 deletions .trunk/configs/.markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Autoformatter friendly markdownlint config (all formatting rules disabled)
default: true
blank_lines: false
bullet: false
html: false
indentation: false
line_length: false
spaces: false
url: false
whitespace: false
7 changes: 7 additions & 0 deletions .trunk/configs/.shellcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
enable=all
source-path=SCRIPTDIR
disable=SC2154

# If you're having issues with shellcheck following source, disable the errors via:
# disable=SC1090
# disable=SC1091
10 changes: 10 additions & 0 deletions .trunk/configs/.yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
rules:
quoted-strings:
required: only-when-needed
extra-allowed: ["{|}"]
empty-values:
forbid-in-block-mappings: true
forbid-in-flow-mappings: true
key-duplicates: {}
octal-values:
forbid-implicit-octal: true
5 changes: 5 additions & 0 deletions .trunk/configs/ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Generic, formatter-friendly config.
select = ["B", "D3", "E", "F"]

# Never enforce `E501` (line length violations). This should be handled by formatters.
ignore = ["E501"]
14 changes: 14 additions & 0 deletions .trunk/configs/svgo.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
plugins: [
{
name: "preset-default",
params: {
overrides: {
removeViewBox: false, // https://github.com/svg/svgo/issues/1128
sortAttrs: true,
removeOffCanvasPaths: true,
},
},
},
],
};
51 changes: 51 additions & 0 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# This file controls the behavior of Trunk: https://docs.trunk.io/cli
# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml
version: 0.1
cli:
version: 1.18.0
# Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins)
plugins:
sources:
- id: trunk
ref: v1.4.0
uri: https://github.com/trunk-io/plugins
# Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes)
runtimes:
enabled:
- [email protected]
- [email protected]
- [email protected]
# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration)
lint:
enabled:
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- git-diff-check
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
actions:
disabled:
- git-lfs
- trunk-announce
- trunk-check-pre-push
- trunk-fmt-pre-commit
enabled:
- trunk-upgrade-available
115 changes: 55 additions & 60 deletions kolibri/plugins/learn/assets/src/views/ExamPage/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
:appBarTitle="exam.title || ''"
>
<KCircularLoader v-if="loading" />
<div v-else >
<div v-else>
<KGrid :gridStyle="gridStyle">
<!-- this.$refs.questionListWrapper is referenced inside AnswerHistory for scrolling -->
<KGridItem
Expand Down Expand Up @@ -68,7 +68,7 @@
<ResourceSyncingUiAlert v-else :multiple="false" />
</KPageContainer>



<!-- below prev/next buttons in tab and DOM order, in page -->
<!-- <KPageContainer v-if="!windowIsLarge">
Expand All @@ -94,7 +94,7 @@
</main>
</KGridItem>
</KGrid>
<BottomAppBar >
<BottomAppBar>
<KGrid>
<KGridItem
:layout12="{ span: 4 }"
Expand All @@ -119,69 +119,68 @@
</template>
<span v-if="displayNavigationButtonLabel">{{ $tr('previousQuestion') }}</span>
</KButton>
</KGridItem>

<KGridItem
:layout12="{ span: 4 }"
:layout8="{ span: 2 }"
:layout4="{ span: 1 }"
>
<div class="" style="text-align:center">
<span>{{ $tr("numberOfAnsweredQuestion") }}</span>
</div>
</KGridItem>
</KGridItem>

<KGridItem
:layout12="{ span: 4 }"
:layout8="{ span: 4 }"
:layout4="{ span: 2 }"
:layout8="{ span: 2 }"
:layout4="{ span: 1 }"
>
<div class="" style="float:right">
<KButton
:disabled="questionNumber === exam.question_count - 1"
:primary="true"
:dir="layoutDirReset"
:aria-label="$tr('nextQuestion')"
:appearanceOverrides="navigationButtonStyle"
@click="goToQuestion(questionNumber + 1)"

>
<span v-if="displayNavigationButtonLabel">{{ $tr('nextQuestion') }}</span>
<template #iconAfter>
<KIcon
icon="forward"
:color="$themeTokens.textInverted"
:style="navigationIconStyleNext"
/>
</template>
</KButton>
</div>

<!-- below prev/next buttons in tab and DOM order, in footer -->
<!-- <div
v-if="windowIsLarge"
:dir="layoutDirReset"
class="left-align"
>
<div class="" style="text-align:center">
<div v-if="!missingResources" class="answered">
{{ answeredText }}
<div v-if="missingResources" class="nosubmit">
{{ $tr('unableToSubmit') }}
</div>
</div>
<KButton
v-if="!missingResources"
:text="$tr('submitExam')"
:primary="false"
appearance="flat-button"
@click="toggleModal"
/>
<div v-if="missingResources" class="nosubmit">
{{ $tr('unableToSubmit') }}
</div>
</div> -->
</div>
</KGridItem>


<KGridItem
:layout12="{ span: 4 }"
:layout8="{ span: 4 }"
:layout4="{ span: 2 }"
>
<div class="" style="float:right">
<div class="" style="float:right">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering why the two floats are needed here.

In this case I think that we could leverage some other CSS properties for a cleaner and more consistent alignment & layout.

By using the position: relative; property on the parent element (the outermost <div> here), we can then use position: absolute; on any child of that div so that you can position that child w/ the right/left/top/bottom CSS properties

In this case, I'd suggest trying the following structure -- which may not be exactly right but should hopefully demonstrate the idea:

<KGridItem ...>
    <div style="position: relative;"> 
        <KButton style="position: absolute; right: 0">

This way it can be reasoned about kinda like:

The KButton is absolutely 0px from the right edge, relative to the parent div

<template v-if="questionNumber !== exam.question_count - 1">
<KButton
:disabled="questionNumber === exam.question_count - 1"
:primary="true"
:dir="layoutDirReset"
:aria-label="$tr('nextQuestion')"
:appearanceOverrides="navigationButtonStyle"
@click="goToQuestion(questionNumber + 1)"
>
<span v-if="displayNavigationButtonLabel">{{ $tr('nextQuestion') }}</span>
<template #iconAfter>
<KIcon
icon="forward"
:color="$themeTokens.textInverted"
:style="navigationIconStyleNext"
/>
</template>
</KButton>
</template>

<template v-else>
<KButton
v-if="!missingResources"
:text="$tr('submitExam')"
:primary="true"
appearance="raised-button"
@click="toggleModal"
/>
</template>
</div>
</div>
</kgriditem>
</KGrid>
</BottomAppBar>
</div>



<KModal
Expand Down Expand Up @@ -231,8 +230,8 @@
},
components: {
AnswerHistory,
UiAlert,

Check failure on line 233 in kolibri/plugins/learn/assets/src/views/ExamPage/index.vue

View workflow job for this annotation

GitHub Actions / All file linting

The "UiAlert" component has been registered but not used
UiIconButton,

Check failure on line 234 in kolibri/plugins/learn/assets/src/views/ExamPage/index.vue

View workflow job for this annotation

GitHub Actions / All file linting

The "UiIconButton" component has been registered but not used
BottomAppBar,
TimeDuration,
SuggestedTime,
Expand Down Expand Up @@ -356,7 +355,7 @@
// https://github.com/vuejs/vue/issues/2870#issuecomment-219096773
return debounce(this.setAndSaveCurrentExamAttemptLog, 500);
},
bottomBarLayoutDirection() {

Check failure on line 358 in kolibri/plugins/learn/assets/src/views/ExamPage/index.vue

View workflow job for this annotation

GitHub Actions / All file linting

Unused computed property found: "bottomBarLayoutDirection"
// Allows contents to be displayed visually in reverse-order,
// but semantically in correct order.
return this.isRtl ? 'ltr' : 'rtl';
Expand Down Expand Up @@ -497,7 +496,7 @@
},
$trs: {
submitExam: {
message: 'Submit quiz',
message: 'Submit',
context:
'Action that learner takes to submit their quiz answers so that the coach can review them.',
},
Expand Down Expand Up @@ -536,10 +535,6 @@
context:
'Indicates that a learner cannot submit the quiz because they are not able to see all the questions.',
},
numberOfAnsweredQuestion:{
message:'1 of 6 answered',
context:"Displays the number of the answered quiz questions"
}
},
};

Expand All @@ -550,7 +545,7 @@

.answered {
display: inline-block;
margin-right: 8px;
margin-right: 700px;
margin-left: 8px;
white-space: nowrap;
}
Expand Down
Loading