added educational level

This commit is contained in:
Mirjan Hoffmann 2022-11-07 09:12:21 +01:00
parent ca736d99c7
commit 9ba8d1124c
6 changed files with 70 additions and 1 deletions

View file

@ -119,6 +119,15 @@
data-i18n-placeholder="LABEL_KEYWORDS_PLACEHOLDER" value="">
</div>
</div>
<div class="form-group row">
<label for="inputEducationalLevel" class="col-sm-2 col-form-label" data-i18n="LABEL_EDUCATIONALLEVEL">Bildungsstufe</label>
<div class="col-sm-10">
<select data-style="input-dropdown" data-width="100%" class="selectpicker" id="inputEducationalLevel" data-i18n-title="LABEL_EDUCATIONALLEVEL_CHOOSE" required multiple>
</select>
<div class="valid-feedback"></div>
<div class="invalid-feedback" data-i18n="LABEL_MANDATORY_FIELD">Pflichtfeld</div>
</div>
</div>
<div class="form-group row">
<label for="inputResourceType" class="col-sm-2 col-form-label" data-i18n="LABEL_LEARNINGRESOURCETYPE">Materialart</label>
<div class="col-sm-10">
@ -246,11 +255,18 @@
await i18nLoader();
chooseLicense();
addCreator();
$("#inputEducationalLevel option[value='https://w3id.org/kim/educationalLevel/level_A']").attr("selected", "true");
$('.selectpicker').selectpicker('refresh');
}
let vocabInstitutions = []
function loadVocabs() {
$(document).ready(function () {
$.getJSON("vocabs/educationalLevel.json", function (result) {
$.each(result, function (i, item) {
$("#inputEducationalLevel").append('<option value="' + item + '" data-i18n="' + item + '"></option>');
});
});
$.getJSON("vocabs/hcrt.json", function (result) {
$.each(result, function (i, item) {
$("#inputResourceType").append('<option value="' + item + '" data-i18n="' + item + '"></option>');
@ -537,6 +553,7 @@
const selectedLanguages = $('#inputLanguage').val();
const selectedSubjects = $('#inputSubjectOf').val();
const selectedResourceTypes = $('#inputResourceType').val();
const selectedEducationalLevel = $('#inputEducationalLevel').val();
let meta = {
creativeWorkStatus: document.getElementById("inputStatus").value,
id: document.getElementById("inputUrl").value,
@ -562,6 +579,9 @@
if (selectedResourceTypes.length > 0) {
meta.learningResourceType = selectedResourceTypes.map((t) => ({id: t}))
}
if (selectedEducationalLevel.length > 0) {
meta.educationalLevel = selectedEducationalLevel.map((t) => ({id: t}))
}
document.getElementById("comment").value = jsyaml.dump(meta);
}
@ -660,6 +680,9 @@
const jsons = await Promise.all(
langs.map((l) => fetch("i18n/" + l + ".json").then((r) => r.json()))
);
const educationalLevelLabels = await Promise.all(
langs.map((l) => fetch("i18n/educationalLevel-" + l + ".json").then((r) => r.json()))
);
const hcrt = await Promise.all(
langs.map((l) => fetch("i18n/hcrt-" + l + ".json").then((r) => r.json()))
);
@ -670,7 +693,7 @@
langs.map((l) => fetch("i18n/subject-" + l + ".json").then((r) => r.json()))
);
const res = langs.reduce((acc, l, idx) => {
acc[l] = {translation: {...jsons[idx], ...hcrt[idx], ...languageLabels[idx], ...subjectLabels[idx]}};
acc[l] = {translation: {...jsons[idx], ...educationalLevelLabels[idx], ...hcrt[idx], ...languageLabels[idx], ...subjectLabels[idx]}};
return acc;
}, {});
await i18next.init({