From 53e629c4731d466279f75623f31686441be206d8 Mon Sep 17 00:00:00 2001 From: severus2293 Date: Wed, 28 Jun 2023 19:01:03 +0300 Subject: [PATCH 01/29] training_greeting_ui: fixed --- app/static/css/training_greeting.css | 23 ++++++++++++++ app/static/js/training_greeting.js | 46 ++++++++++++++++++++++++++-- app/templates/training_greeting.html | 11 +++++-- 3 files changed, 75 insertions(+), 5 deletions(-) create mode 100644 app/static/css/training_greeting.css diff --git a/app/static/css/training_greeting.css b/app/static/css/training_greeting.css new file mode 100644 index 00000000..76042489 --- /dev/null +++ b/app/static/css/training_greeting.css @@ -0,0 +1,23 @@ +body { + margin-left: 10px; +} +td { + text-align: center; + vertical-align: middle; +} +th { + text-align: center; + vertical-align: middle; +} +h3 { + text-align: center; +} + +table{ + margin-right: 10px; +} +#start-training-button{ + margin-top: 10px; + width: 150px; + height: 30px; +} \ No newline at end of file diff --git a/app/static/js/training_greeting.js b/app/static/js/training_greeting.js index 7f6587f6..b4f26492 100644 --- a/app/static/js/training_greeting.js +++ b/app/static/js/training_greeting.js @@ -1,3 +1,45 @@ function setCriteriaPackDescription(s) { - document.getElementById('criteria-pack-description').innerText = `${s}`; -} \ No newline at end of file + parseTableData(s); +} + +function parseTableData(s){ + let criteria = s.split("Критерий:").filter(function( obj ) { + return obj !== ''; + }); + let description = []; + let grade = []; + let criterionWeight = []; + for(let i = 0;i< criteria.length;i++){ + description.push(criteria[i].slice(criteria[i].indexOf('описание:')+"описание: ".length,criteria[i].indexOf('оценка:') - ",\n".length)); + grade.push(criteria[i].slice(criteria[i].indexOf('оценка:')+"оценка: ".length,criteria[i].indexOf('вес критерия =') - ",\n".length)); + criterionWeight.push(criteria[i].slice(criteria[i].indexOf('вес критерия =') + "вес критерия = ".length,criteria[i].length - ".\n".length)); + criteria[i] = criteria[i].slice(0,criteria[i].indexOf(',')); + + + } //получили разделённые данные + const criteriaTable = document.getElementById('criteria-table'); + let criteriaRow = document.createElement("tr"); + let HeadData = ["Критерий","Описание","Оценка","Вес критерия"]; + HeadData.forEach(element => { + let tableHead = document.createElement("th"); + tableHead.innerText = element; + criteriaRow.appendChild(tableHead); + }); + criteriaTable.appendChild(criteriaRow); // заполнили заголовки + for(let i = 0;i< criteria.length;i++){ // заполняем таблицу данными + criteriaRow = document.createElement("tr"); + let criteriaData = document.createElement("td"); + criteriaData.innerText = criteria[i]; + let descriptionData = document.createElement("td"); + descriptionData.innerText = description[i]; + let gradeData = document.createElement("td"); + gradeData.innerText = grade[i]; + let criterionWeightData = document.createElement("td"); + criterionWeightData.innerText = criterionWeight[i]; + criteriaRow.appendChild(criteriaData); + criteriaRow.appendChild(descriptionData); + criteriaRow.appendChild(gradeData); + criteriaRow.appendChild(criterionWeightData); + criteriaTable.appendChild(criteriaRow); + } +} \ No newline at end of file diff --git a/app/templates/training_greeting.html b/app/templates/training_greeting.html index bdbf8ad0..de29ca0c 100644 --- a/app/templates/training_greeting.html +++ b/app/templates/training_greeting.html @@ -1,4 +1,8 @@ -{% extends 'base.html' %} {% block content %} +{% extends 'base.html' %} +{% block header %} + +{% endblock %} +{% block content %}

{{ t("Задание для тренировки") }}: {{ task_id }}

{{ t("Описание задания") }}: {{ task_description }}

@@ -6,8 +10,9 @@

{{ t("Проходной балл") }}: {{ required_points }} / {{ maximal_p

{{ t("Номер попытки") }}: {{ attempt_number }}

{{ t("Номер тренировки") }}: {{ training_number }} / {{ attempt_count }}

{{ t("Сумма баллов за предыдущие тренировки") }}: {{ current_points_sum }}

-

{{ t("Набор критериев") }}: {{ criteria_pack_id }}

-
{{ criteria_pack_description }}
+ {{ t("Набор критериев") }}: {{ criteria_pack_id }} + +