Compare commits

...

2 commits

Author SHA1 Message Date
Nicolas Mailloux
7be7b15e8d FlashExam: add option to save forgotten cards or not 2024-12-02 14:19:32 -05:00
Nicolas Mailloux
c87bdd8e02 FlashExam: write cards not known to file 2024-12-02 13:47:45 -05:00
3 changed files with 76 additions and 41 deletions

View file

@ -31,6 +31,7 @@ flashExam::flashExam(QWidget *parent)
ui->didNotKnowBtn->setIcon(QIcon(":/resources/close.png"));
ui->nextBtn->setIcon(QIcon(":/resources/check.png"));
ui->nonRedundantRandomizationCheckBox->setDisabled(true);
ui->saveCardsNotKnownToFileCheckBox->setDisabled(true);
ui->randomizeCheckBox->click();
ui->randomizeCheckBox->setDisabled(true);
@ -85,6 +86,7 @@ void flashExam::initCardsList(QString cardsList, QString answersList) {
answersStringList = readFile(answersList).split(QRegExp("(\\r\\n)|(\\n\\r)|\\r|\\n"), QString::SkipEmptyParts);
randomize = ui->randomizeCheckBox->isChecked();
nonRedundantRandomization = ui->nonRedundantRandomizationCheckBox->isChecked();
saveCardsNotKnownToFile = ui->saveCardsNotKnownToFileCheckBox->isChecked();
cardsAlreadyShown.clear();
cardsNotKnown.clear();
ui->nonRedundantRandomizationCheckBox->setChecked(false);
@ -95,6 +97,14 @@ void flashExam::initCardsList(QString cardsList, QString answersList) {
void flashExam::on_backBtn_clicked()
{
if(nonRedundantRandomization && cardsNotKnown.count() > 0 && saveCardsNotKnownToFile) {
QString cardsNotKnownQstring;
for(int i = 0; i < cardsNotKnown.count(); i++) {
cardsNotKnownQstring.append(cardsStringList.at(cardsNotKnown.at(i)) + "\n");
}
log("Writing cardsNotKnownQstring to file", className);
writeFile("/mnt/onboard/onboard/flashexam-cards-not-known_" + QDateTime::currentDateTime().toString("dd.MM.yyyy-hh.mm.ss"), cardsNotKnownQstring);
}
this->setDisabled(false);
setupCardsList();
ui->stackedWidget->setCurrentIndex(0);
@ -221,3 +231,14 @@ void flashExam::on_didNotKnowBtn_clicked()
on_nextBtn_clicked();
}
void flashExam::on_nonRedundantRandomizationCheckBox_toggled(bool checked)
{
if(checked) {
ui->saveCardsNotKnownToFileCheckBox->setDisabled(false);
}
else {
ui->saveCardsNotKnownToFileCheckBox->setDisabled(true);
ui->saveCardsNotKnownToFileCheckBox->setChecked(false);
}
}

View file

@ -24,6 +24,7 @@ private:
QString listName;
bool randomize;
bool nonRedundantRandomization;
bool saveCardsNotKnownToFile;
QList<int> cardsAlreadyShown;
QList<int> cardsNotKnown;
bool answerShown = false;
@ -45,6 +46,7 @@ private slots:
void on_nextBtn_clicked();
void on_randomizeCheckBox_toggled(bool checked);
void on_didNotKnowBtn_clicked();
void on_nonRedundantRandomizationCheckBox_toggled(bool checked);
};
#endif // FLASHEXAM_H

View file

@ -35,46 +35,6 @@
</property>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<widget class="Line" name="line">
<property name="frameShadow">
<enum>QFrame::Shadow::Plain</enum>
</property>
<property name="lineWidth">
<number>2</number>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="randomizeCheckBox">
<property name="font">
<font>
<family>U001</family>
</font>
</property>
<property name="text">
<string>Randomized mode</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QListWidget" name="listWidget"/>
</item>
<item row="7" column="0">
<widget class="QPushButton" name="startBtn">
<property name="font">
<font>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Start</string>
</property>
</widget>
</item>
<item row="1" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<property name="bottomMargin">
@ -142,7 +102,7 @@
</item>
</layout>
</item>
<item row="6" column="0">
<item row="7" column="0">
<widget class="Line" name="line_2">
<property name="frameShadow">
<enum>QFrame::Shadow::Plain</enum>
@ -152,6 +112,19 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="Line" name="line">
<property name="frameShadow">
<enum>QFrame::Shadow::Plain</enum>
</property>
<property name="lineWidth">
<number>2</number>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="nonRedundantRandomizationCheckBox">
<property name="font">
@ -164,6 +137,45 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="randomizeCheckBox">
<property name="font">
<font>
<family>U001</family>
</font>
</property>
<property name="text">
<string>Randomized mode</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QPushButton" name="startBtn">
<property name="font">
<font>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Start</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QListWidget" name="listWidget"/>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="saveCardsNotKnownToFileCheckBox">
<property name="font">
<font>
<family>U001</family>
</font>
</property>
<property name="text">
<string>Save forgotten cards list to file</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>