show all types in app list

This commit is contained in:
jorenchik
2024-09-29 12:30:50 +03:00
parent 586ad72e70
commit d19f082da6
6 changed files with 90 additions and 3 deletions

42
memorybase/all_types.mdem Normal file
View File

@@ -0,0 +1,42 @@
- What is the capital of Latvia? >
- Rīga
- [cap_est] What is the capital of Estonia? >
- Tallin
- What countries reside in Europe? >
+ Latvia
- Peru
+ Poland
- China
- Arrange these events in the order they occurred >
-^ The Fall of the Roman Empire (476 AD)
-^ The Renaissance (14th\-17th century)
-^ The Industrial Revolution (18th\-19th century)
- [scient_method_order] Place the following steps of the scientific method in the correct order >
- Ask a Question
- Form a Hypothesis
-^ Conduct an Experiment
- Analyze Data
- Match Planets to Their Characteristics >
- Earth:
- Contains Life
- Mars:
- Red Planet
- Jupiter:
- Largest Planet
- Has Rings
- Venus:
- Hottest Planet
- Mercury:
- Smallest Planet
- Saturn:
- Has Rings
- Neptune:
- Farthest from the Sun
- Has Rings

1
src/cpp/.gitignore vendored
View File

@@ -1 +1,2 @@
Debug/
Release/

View File

@@ -1,2 +1,4 @@
#pragma once
#include <string>
std::string cleanContent(std::string answer);

View File

@@ -185,7 +185,21 @@ void CreateMdems(std::vector<Question*>& questions) {
auto choices = mw->Choices;
for (size_t k = 0; k < choices.size(); ++k) {
auto answer = choices[k].Answer;
answer = std::format("- {}", answer);
switch (mw->type) {
case MultiElementType::Order:
answer = std::format("{}. {}", k + 1, answer);
break;
case MultiElementType::MultiChoice:
if (choices[k].IsCorrect) {
answer = std::format("+ {}", answer);
} else {
answer = std::format("- {}", answer);
}
break;
case MultiElementType::Regular:
answer = std::format("- {}", answer);
break;
}
if (k < mdems[i]->backLabels.size()) {
mdems[i]->backLabels[k]->setText(QString::fromStdString(answer));
} else {
@@ -195,7 +209,31 @@ void CreateMdems(std::vector<Question*>& questions) {
mdems[i]->wBack->layout()->addWidget(label);
}
}
mdems[i]->labelCount = choices.size();
mdems[i]->labelCount = choices.size();
} else if (GroupQuestion* mw = dynamic_cast<GroupQuestion*>(questions[i])) {
mdems[i]->wFrontText->setText(
QString::fromStdString(mw->QuestionText)
);
auto groups = mw->Groups;
std::vector<std::string> elements;
for (size_t k = 0; k < groups.size(); ++k) {
auto answer = groups[k].name;
elements.push_back(std::format("- {}:", answer));
for (size_t l = 0; l < groups[k].elements.size(); ++l) {
elements.push_back(std::format(" - {}", groups[k].elements[l]));
}
}
for (size_t k = 0; k < elements.size(); ++k) {
if (k < mdems[i]->backLabels.size()) {
mdems[i]->backLabels[k]->setText(QString::fromStdString(elements[k]));
} else {
auto label = new QLabel();
label->setText(QString::fromStdString(elements[k]));
mdems[i]->backLabels.push_back(label);
mdems[i]->wBack->layout()->addWidget(label);
}
}
mdems[i]->labelCount = groups.size();
}
if (!mdems[i]->wMdem->isVisible()) {
mdems[i]->wMdem->show();

View File

@@ -3,6 +3,7 @@
#include <QToolButton>
#include <qboxlayout.h>
#include <qlabel.h>
#include <qlayoutitem.h>
#include <qlistview.h>
#include <qnamespace.h>
#include <qstandarditemmodel.h>
@@ -206,11 +207,15 @@ void initTrainWindow() {
actionButtons = new QWidget();
hButtons = new QHBoxLayout();
btnPrev = new QToolButton();
auto *leftSpacer = new QSpacerItem(50, 50, QSizePolicy::Expanding, QSizePolicy::Minimum);
btnShowAnswer = new QToolButton();
auto *rightSpacer = new QSpacerItem(50, 50, QSizePolicy::Expanding, QSizePolicy::Minimum);
btnNext = new QToolButton();
hButtons->addWidget(btnPrev);
hButtons->addItem(leftSpacer);
hButtons->addWidget(btnShowAnswer);
hButtons->addItem(rightSpacer);
hButtons->addWidget(btnNext);
vButtonBox->addWidget(actionButtons);
actionButtons->setLayout(hButtons);

View File

@@ -176,7 +176,6 @@ Result<std::vector<Question*>> ParseQuestions(const std::vector<Token>& tokens)
std::string section;
size_t i = 0;
debug = true;
if (debug) {
std::cout << "SECTION: Parser output:\n";
}