added late skills test

This commit is contained in:
mandlm 2018-06-26 16:59:51 +02:00
parent 76264eb814
commit 0a1eea0fe2
18 changed files with 303 additions and 3 deletions

View File

@ -45,6 +45,7 @@ target_link_libraries(${PROJECT_NAME}
Genus Genus
AkkusativDativ AkkusativDativ
V2Svk V2Svk
LateSkills
ResultWidget ResultWidget
Qt5::Widgets Qt5::Widgets
) )

View File

@ -12,6 +12,8 @@ DataModel::DataModel(QObject *parent)
, m_akkusativ(this) , m_akkusativ(this)
, m_dativ(this) , m_dativ(this)
, m_v2Svk(this) , m_v2Svk(this)
, m_passiv(this)
, m_genitiv(this)
{ {
connect(&m_plural, &PluralModel::dataChanged, this, connect(&m_plural, &PluralModel::dataChanged, this,
&DataModel::pluralModelChanged); &DataModel::pluralModelChanged);
@ -27,6 +29,10 @@ DataModel::DataModel(QObject *parent)
&DataModel::dativModelChanged); &DataModel::dativModelChanged);
connect(&m_v2Svk, &V2SvkModel::dataChanged, this, connect(&m_v2Svk, &V2SvkModel::dataChanged, this,
&DataModel::v2SvkModelChanged); &DataModel::v2SvkModelChanged);
connect(&m_passiv, &PassivModel::dataChanged, this,
&DataModel::passivModelChanged);
connect(&m_genitiv, &GenitivModel::dataChanged, this,
&DataModel::genitivModelChanged);
} }
void DataModel::write(QJsonObject &target) const void DataModel::write(QJsonObject &target) const
@ -38,6 +44,8 @@ void DataModel::write(QJsonObject &target) const
write(m_akkusativ, target, "Akkusativ"); write(m_akkusativ, target, "Akkusativ");
write(m_dativ, target, "Dativ"); write(m_dativ, target, "Dativ");
write(m_v2Svk, target, "V2Svk"); write(m_v2Svk, target, "V2Svk");
write(m_passiv, target, "Passiv");
write(m_genitiv, target, "Genitiv");
} }
void DataModel::read(const QJsonObject &source) void DataModel::read(const QJsonObject &source)
@ -49,6 +57,8 @@ void DataModel::read(const QJsonObject &source)
read(m_akkusativ, source, "Akkusativ"); read(m_akkusativ, source, "Akkusativ");
read(m_dativ, source, "Dativ"); read(m_dativ, source, "Dativ");
read(m_v2Svk, source, "V2Svk"); read(m_v2Svk, source, "V2Svk");
read(m_passiv, source, "Passiv");
read(m_genitiv, source, "Genitiv");
} }
void DataModel::pluralModelChanged() void DataModel::pluralModelChanged()
@ -86,3 +96,13 @@ void DataModel::v2SvkModelChanged()
m_results.setV2Result(m_v2Svk.getV2Points()); m_results.setV2Result(m_v2Svk.getV2Points());
m_results.setSvkResult(m_v2Svk.getSvkPoints()); m_results.setSvkResult(m_v2Svk.getSvkPoints());
} }
void DataModel::passivModelChanged()
{
m_results.setPassivResult(m_passiv.getPoints());
}
void DataModel::genitivModelChanged()
{
m_results.setGenitivResult(m_genitiv.getPoints());
}

View File

@ -7,6 +7,8 @@
#include "AkkusativModel.h" #include "AkkusativModel.h"
#include "DativModel.h" #include "DativModel.h"
#include "V2SvkModel.h" #include "V2SvkModel.h"
#include "PassivModel.h"
#include "GenitivModel.h"
#include "ResultModel.h" #include "ResultModel.h"
@ -24,6 +26,8 @@ public:
AkkusativModel m_akkusativ; AkkusativModel m_akkusativ;
DativModel m_dativ; DativModel m_dativ;
V2SvkModel m_v2Svk; V2SvkModel m_v2Svk;
PassivModel m_passiv;
GenitivModel m_genitiv;
ResultModel m_results; ResultModel m_results;
@ -62,4 +66,6 @@ private slots:
void akkusativModelChanged(); void akkusativModelChanged();
void dativModelChanged(); void dativModelChanged();
void v2SvkModelChanged(); void v2SvkModelChanged();
void passivModelChanged();
void genitivModelChanged();
}; };

View File

@ -0,0 +1,39 @@
#pragma once
#include "PRMap.h"
class GenitivPR : public PRMap
{
public:
GenitivPR()
{
// clang-format off
m_ages = {
{ 7, 0 },
{ 7, 6 },
{ 8, 0 },
{ 9, 0 }
};
m_PRs = {
{ 0, 0, 0 },
{ 1, 3, 0 },
{ 2, 3, 0 },
{ 2, 5, 1 },
{ 7, 5, 1 },
{ 8, 6, 1 },
{ 14, 8, 2 },
{ 18, 9, 4 },
{ 21, 17, 7 },
{ 29, 18, 8 },
{ 38, 29, 14 },
{ 50, 42, 23 },
{ 66, 54, 33 },
{ 82, 68, 51 },
{ 90, 83, 72 },
{ 96, 92, 87 },
{ 100, 100, 100 }
};
// clang-format on
}
};

View File

@ -0,0 +1,32 @@
#pragma once
#include "PRMap.h"
class PassivPR : public PRMap
{
public:
PassivPR()
{
// clang-format off
m_ages = {
{ 7, 0 },
{ 8, 6 },
{ 9, 0 }
};
m_PRs = {
{ 1, 0 },
{ 2, 0 },
{ 6, 2 },
{ 9, 3 },
{ 23, 12 },
{ 34, 23 },
{ 55, 41 },
{ 71, 59 },
{ 85, 76 },
{ 94, 84 },
{ 100, 100 }
};
// clang-format on
}
};

View File

@ -7,6 +7,8 @@
#include "DativPR.h" #include "DativPR.h"
#include "V2PR.h" #include "V2PR.h"
#include "SvkPR.h" #include "SvkPR.h"
#include "PassivPR.h"
#include "GenitivPR.h"
#include <QDebug> #include <QDebug>
@ -188,3 +190,23 @@ void ResultModel::setSvkResult(unsigned int points)
emit dataChanged(index(0, 1), index(4, 1)); emit dataChanged(index(0, 1), index(4, 1));
} }
} }
void ResultModel::setPassivResult(unsigned int points)
{
if (m_results[3].points() != points)
{
m_results[3].setPoints(points);
m_results[3].setPR(PassivPR().lookup(m_age, points));
emit dataChanged(index(0, 3), index(4, 3));
}
}
void ResultModel::setGenitivResult(unsigned int points)
{
if (m_results[7].points() != points)
{
m_results[7].setPoints(points);
m_results[7].setPR(GenitivPR().lookup(m_age, points));
emit dataChanged(index(0, 7), index(4, 7));
}
}

View File

@ -70,4 +70,6 @@ public:
void setDativResult(unsigned int points); void setDativResult(unsigned int points);
void setV2Result(unsigned int points); void setV2Result(unsigned int points);
void setSvkResult(unsigned int points); void setSvkResult(unsigned int points);
void setPassivResult(unsigned int points);
void setGenitivResult(unsigned int points);
}; };

View File

@ -5,3 +5,4 @@ add_subdirectory(Genus)
add_subdirectory(Plural) add_subdirectory(Plural)
add_subdirectory(AkkusativDativ) add_subdirectory(AkkusativDativ)
add_subdirectory(V2Svk) add_subdirectory(V2Svk)
add_subdirectory(LateSkills)

View File

@ -0,0 +1,37 @@
cmake_minimum_required(VERSION 3.6)
project(LateSkills LANGUAGES CXX)
find_package(Qt5Widgets REQUIRED)
set(CMAKE_AUTOMOC ON)
qt5_wrap_ui(UI_HEADERS
LateSkillsWidget.ui
)
add_library(${PROJECT_NAME}
LateSkillsWidget.cpp
PassivModel.cpp
GenitivModel.cpp
${UI_HEADERS}
)
set_target_properties(${PROJECT_NAME}
PROPERTIES CXX_STANDARD 14
)
target_include_directories(${PROJECT_NAME}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}
)
target_link_libraries(${PROJECT_NAME}
PRIVATE
CheckableItem
CheckableTest
CheckableTestModel
Qt5::Widgets
)

View File

@ -0,0 +1,10 @@
#include "GenitivModel.h"
GenitivModel::GenitivModel(QObject *parent)
: CheckableTestModel(parent)
{
m_tests = {
{ "Genitiv Präpositionen", { "anstelle", "außerhalb", "mithilfe" } },
{ "Attributierung", { "Schuhe", "Zauberstab", "Hut", "Brille", "Gürtel" } },
};
}

View File

@ -0,0 +1,11 @@
#pragma once
#include "CheckableTestModel.h"
class GenitivModel : public CheckableTestModel
{
Q_OBJECT
public:
GenitivModel(QObject *parent);
};

View File

@ -0,0 +1,29 @@
#include "LateSkillsWidget.h"
#include "ui_LateSkillsWidget.h"
#include "PassivModel.h"
#include "GenitivModel.h"
LateSkillsWidget::LateSkillsWidget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::LateSkillsWidget)
{
ui->setupUi(this);
ui->passivTableView->horizontalHeader()->hide();
ui->genitivTableView->horizontalHeader()->hide();
}
LateSkillsWidget::~LateSkillsWidget()
{
delete ui;
}
void LateSkillsWidget::setPassivModel(PassivModel *model)
{
ui->passivTableView->setModel(model);
}
void LateSkillsWidget::setGenitivModel(GenitivModel *model)
{
ui->genitivTableView->setModel(model);
}

View File

@ -0,0 +1,25 @@
#pragma once
#include <QWidget>
class PassivModel;
class GenitivModel;
namespace Ui {
class LateSkillsWidget;
};
class LateSkillsWidget : public QWidget
{
Q_OBJECT
private:
Ui::LateSkillsWidget *ui;
public:
LateSkillsWidget(QWidget *parent = nullptr);
~LateSkillsWidget();
void setPassivModel(PassivModel *model);
void setGenitivModel(GenitivModel *model);
};

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>LateSkillsWidget</class>
<widget class="QWidget" name="LateSkillsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTableView" name="passivTableView"/>
</item>
<item>
<widget class="QTableView" name="genitivTableView"/>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,9 @@
#include "PassivModel.h"
PassivModel::PassivModel(QObject *parent)
: CheckableTestModel(parent)
{
m_tests = {
{ "Passiv", { "Elefant", "Pferde", "Bälle", "Ball", "Fleisch" } }
};
}

View File

@ -0,0 +1,11 @@
#pragma once
#include "CheckableTestModel.h"
class PassivModel : public CheckableTestModel
{
Q_OBJECT
public:
PassivModel(QObject *parent);
};

View File

@ -38,6 +38,8 @@ void MainWindow::newFile()
ui->akkusativDativWidget->setAkkusativModel(&m_dataModel->m_akkusativ); ui->akkusativDativWidget->setAkkusativModel(&m_dataModel->m_akkusativ);
ui->akkusativDativWidget->setDativModel(&m_dataModel->m_dativ); ui->akkusativDativWidget->setDativModel(&m_dataModel->m_dativ);
ui->v2SvkWidget->setV2SvkModel(&m_dataModel->m_v2Svk); ui->v2SvkWidget->setV2SvkModel(&m_dataModel->m_v2Svk);
ui->lateSkillsWidget->setPassivModel(&m_dataModel->m_passiv);
ui->lateSkillsWidget->setGenitivModel(&m_dataModel->m_genitiv);
ui->resultWidget->setModel(&m_dataModel->m_results); ui->resultWidget->setModel(&m_dataModel->m_results);

View File

@ -18,7 +18,7 @@
<item> <item>
<widget class="QTabWidget" name="testTabWidget"> <widget class="QTabWidget" name="testTabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>6</number>
</property> </property>
<widget class="QWidget" name="MetaDataTab"> <widget class="QWidget" name="MetaDataTab">
<attribute name="title"> <attribute name="title">
@ -70,7 +70,7 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="PluralTab"> <widget class="QWidget" name="pluralTab">
<attribute name="title"> <attribute name="title">
<string>Subtest 5: Plural</string> <string>Subtest 5: Plural</string>
</attribute> </attribute>
@ -80,6 +80,16 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="lateSkillsTab">
<attribute name="title">
<string>Subtest 6: Späte Fähigkeiten (7;0-8;11)</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<widget class="LateSkillsWidget" name="lateSkillsWidget" native="true"/>
</item>
</layout>
</widget>
</widget> </widget>
</item> </item>
<item> <item>
@ -240,7 +250,13 @@
<customwidget> <customwidget>
<class>V2SvkWidget</class> <class>V2SvkWidget</class>
<extends>QWidget</extends> <extends>QWidget</extends>
<header location="global">V2SvkWidget.h</header> <header>V2SvkWidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>LateSkillsWidget</class>
<extends>QWidget</extends>
<header location="global">LateSkillsWidget.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
</customwidgets> </customwidgets>