-
Notifications
You must be signed in to change notification settings - Fork 647
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
Add score in practice quiz #12564
Open
thesujai
wants to merge
9
commits into
learningequality:develop
Choose a base branch
from
thesujai:score-in-partice-quiz
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+123
−11
Open
Add score in practice quiz #12564
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
dd289eb
return num_attempts, num_correct_attempts and total_questions from th…
thesujai 0243551
count distinct Attemptlog.item for num_correct_attempts
thesujai 716c641
most recent masterylog
thesujai 5c27095
call it num_question_answered as the num_attempts is confusing
thesujai 4d19dfb
add questions left label
thesujai 6e806b5
state management for num_question_answered
thesujai 456ab69
update progressbar to display score and remaining questions for a pra…
thesujai 04a473b
rename contentNodeQuizProgressMap to contentNodeProgressMetaDataMap(a…
thesujai ca7df17
remove unused coresting questionLeftLabel
thesujai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,18 +9,39 @@ | |
:aria-valuenow="progress * 100" | ||
> | ||
<p | ||
v-if="completed" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will add an extraneous
|
||
class="completion-label" | ||
:style="{ color: $themePalette.grey.v_800 }" | ||
> | ||
<ProgressIcon | ||
:progress="progress" | ||
class="completion-icon" | ||
/> | ||
{{ coreString('completedLabel') }} | ||
<template v-if="isQuiz"> | ||
<template v-if="progress < 1"> | ||
<ProgressIcon | ||
:progress="progress" | ||
class="completion-icon" | ||
/> | ||
{{ | ||
coreString('questionsLeftLabel', { | ||
remaining: remainingQuestions, | ||
}) | ||
}} | ||
</template> | ||
<template v-else> | ||
<ProgressIcon | ||
:progress="progress" | ||
class="completion-icon" | ||
/> | ||
{{ coreString('scoreLabel') }} {{ $formatNumber(score, { style: 'percent' }) }} | ||
</template> | ||
</template> | ||
<template v-else> | ||
<ProgressIcon | ||
:progress="progress" | ||
class="completion-icon" | ||
/> | ||
{{ coreString('completedLabel') }} | ||
</template> | ||
</p> | ||
<KLinearLoader | ||
v-if="progress && !completed" | ||
v-if="!isQuiz && progress && !completed" | ||
class="k-linear-loader" | ||
:delay="false" | ||
:progress="progress * 100" | ||
|
@@ -36,6 +57,7 @@ | |
|
||
import ProgressIcon from 'kolibri.coreVue.components.ProgressIcon'; | ||
import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings'; | ||
import lodashGet from 'lodash/get'; | ||
import useContentNodeProgress from '../composables/useContentNodeProgress'; | ||
|
||
/** | ||
|
@@ -51,8 +73,8 @@ | |
}, | ||
mixins: [commonCoreStrings], | ||
setup() { | ||
const { contentNodeProgressMap } = useContentNodeProgress(); | ||
return { contentNodeProgressMap }; | ||
const { contentNodeProgressMap, contentNodeQuizProgressMap } = useContentNodeProgress(); | ||
return { contentNodeProgressMap, contentNodeQuizProgressMap }; | ||
}, | ||
props: { | ||
// eslint-disable-next-line kolibri/vue-no-unused-properties | ||
|
@@ -62,7 +84,34 @@ | |
}, | ||
}, | ||
computed: { | ||
isQuiz() { | ||
return lodashGet(this.contentNode, ['options', 'modality'], false) === 'QUIZ'; | ||
}, | ||
score() { | ||
if (this.isQuiz) { | ||
const quizProgress = | ||
this.contentNodeQuizProgressMap[this.contentNode && this.contentNode.content_id]; | ||
if (quizProgress.total_questions) { | ||
return quizProgress.num_question_answered_correctly / quizProgress.total_questions; | ||
} | ||
} | ||
}, | ||
remainingQuestions() { | ||
if (this.isQuiz) { | ||
const quizProgress = | ||
this.contentNodeQuizProgressMap[this.contentNode && this.contentNode.content_id]; | ||
if (quizProgress.total_questions) { | ||
return quizProgress.total_questions - quizProgress.num_question_answered; | ||
} | ||
} | ||
}, | ||
progress() { | ||
if (this.isQuiz) { | ||
return ( | ||
this.contentNodeQuizProgressMap[this.contentNode && this.contentNode.content_id] | ||
?.progress || 0 | ||
); | ||
} | ||
return this.contentNodeProgressMap[this.contentNode && this.contentNode.content_id] || 0; | ||
}, | ||
completed() { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah - one blocking note here. I missed this was part of the diff in my initial review and thought it was pre-existing when I saw this.
We'll need to use ICU syntax for the word "questions" here which allows translators to translate the various ways of expressing an amount of something. A similar string is defined here in the
QuizCard
component which demonstrates how this works where we can say "when the value ofquestionsLeft
isone
then the word isquestion
otherwise, usequestions
".You could probably just copy that string directly into the
ProgressBar
component - note how you'll add a$tr: {}
object to that component, then add the string inside of that object there.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting! ✅