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

Add warning banner for "insufficient resources" #13146

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@

<div>
<div class="mb-20">
{{ maxNumberOfQuestionsInfo$({ count: maxQuestions }) }}
{{ maxNumberOfQuestionsInfo$({ count: settings.maxQuestions }) }}
</div>
<UiAlert
v-if="showAlert && addableQuestionCount < settings.maxQuestions"
type="warning"
@dismiss="showAlert = false"
>
{{ insufficientResources$({ count: addableQuestionCount }) }}
</UiAlert>
<div class="number-question">
<div>
<KTextbox
Expand Down Expand Up @@ -62,6 +69,7 @@
} from 'kolibri-common/strings/enhancedQuizManagementStrings';
import { searchAndFilterStrings } from 'kolibri-common/strings/searchAndFilterStrings';
import { coreStrings } from 'kolibri/uiText/commonCoreStrings';
import UiAlert from 'kolibri-design-system/lib/keen/UiAlert';
import { PageNames } from '../../../../../../constants';
import { injectQuizCreation } from '../../../../../../composables/useQuizCreation';

Expand All @@ -71,11 +79,22 @@

export default {
name: 'SelectFromBookmarks',
components: {},
components: {
UiAlert,
},
setup(props) {
const prevRoute = ref(null);
const showAlert = ref(true);
const instance = getCurrentInstance();

const { data: channels } = props.channelsFetch;

const addableQuestionCount = computed(() => {
return channels.value.reduce((total, currentObject) => {
return total + currentObject.num_assessments;
}, 0);
});

const {
questionsSettingsLabel$,
numberOfQuestionsLabel$,
Expand All @@ -85,6 +104,7 @@
clearSelectionNotice$,
} = enhancedQuizManagementStrings;

const { insufficientResources$, saveSettingsAction$ } = searchAndFilterStrings;
const { activeSection, activeSectionIndex } = injectQuizCreation();

props.setTitle(
Expand Down Expand Up @@ -123,7 +143,6 @@
});
};

const { saveSettingsAction$ } = searchAndFilterStrings;
const { continueAction$ } = coreStrings;
const continueText = props.isLanding ? continueAction$() : saveSettingsAction$();

Expand All @@ -149,15 +168,22 @@
return {
// eslint-disable-next-line vue/no-unused-properties
prevRoute,
showAlert,
questionCount: workingQuestionCount,
isChoosingManually: workingIsChoosingManually,
clearSelectionNotice$,
questionCountIsEditable,
maxQuestions: computed(() => props.settings.maxQuestions),
maxQuestions: computed(() =>
addableQuestionCount.value > props.settings.maxQuestions
? props.settings.maxQuestions
: addableQuestionCount.value,
),
maxNumberOfQuestions$,
numberOfQuestionsLabel$,
maxNumberOfQuestionsInfo$,
chooseQuestionsManuallyLabel$,
insufficientResources$,
addableQuestionCount,
};
},
props: {
Expand All @@ -181,6 +207,10 @@
type: Boolean,
default: false,
},
channelsFetch: {
type: Object,
required: true,
},
},
beforeRouteEnter(to, from, next) {
next(vm => {
Expand Down
6 changes: 6 additions & 0 deletions packages/kolibri-common/strings/searchAndFilterStrings.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,10 @@ export const searchAndFilterStrings = createTranslator('SearchAndFilterStrings',
message: 'Save settings',
context: 'Button label to save resource selection settings',
},
insufficientResources: {
message:
'There are currently only {count, number} questions across all practice resources in your library. To create a larger quiz, consider adding more resources to your library.',
context:
'Message to indicate that the resources are not sufficient for the user to create a quiz.',
},
});
Loading