diff --git a/src/apps/flashexam.cpp b/src/apps/flashexam.cpp index b946c4f..fc7d776 100644 --- a/src/apps/flashexam.cpp +++ b/src/apps/flashexam.cpp @@ -18,16 +18,21 @@ flashExam::flashExam(QWidget *parent) ui->revealBtn->setProperty("type", "borderless"); ui->nextBtn->setProperty("type", "borderless"); ui->backBtn->setProperty("type", "borderless"); + ui->didNotKnowBtn->setProperty("type", "borderless"); ui->startBtn->setStyleSheet("padding: 20px; QPushButton[type='borderless']:pressed { background: black; color: white; border: none }"); ui->closeBtn->setStyleSheet("QPushButton[type='borderless']:pressed { background: black; color: white; border: none}"); ui->revealBtn->setStyleSheet("padding: 20px; QPushButton[type='borderless']:pressed { background: black; color: white; border: none}"); ui->nextBtn->setStyleSheet("padding: 20px; QPushButton[type='borderless']:pressed { background: black; color: white; border: none}"); + ui->didNotKnowBtn->setStyleSheet("padding: 20px; QPushButton[type='borderless']:pressed { background: black; color: white; border: none}"); ui->backBtn->setStyleSheet("QPushButton[type='borderless']:pressed { background: black; color: white; border: none}"); ui->textBrowser->setStyleSheet("font-size: 12pt"); ui->closeBtn->setIcon(QIcon(":/resources/close.png")); ui->backBtn->setIcon(QIcon(":/resources/arrow-left.png")); + ui->didNotKnowBtn->setIcon(QIcon(":/resources/close.png")); + ui->nextBtn->setIcon(QIcon(":/resources/check.png")); ui->nonRedundantRandomizationCheckBox->setDisabled(true); ui->randomizeCheckBox->click(); + ui->randomizeCheckBox->setDisabled(true); graphicsScene = new QGraphicsScene(this); setupCardsList(); @@ -46,6 +51,7 @@ void flashExam::on_closeBtn_clicked() void flashExam::setupCardsList() { QDir dir("/mnt/onboard/onboard/.flashexam"); ui->listWidget->clear(); + ui->cardNumberLabel->show(); for (const QString &filename : dir.entryList(QDir::Files)) { if(!filename.contains(".answers")) { ui->listWidget->addItem(filename); @@ -80,6 +86,7 @@ void flashExam::initCardsList(QString cardsList, QString answersList) { randomize = ui->randomizeCheckBox->isChecked(); nonRedundantRandomization = ui->nonRedundantRandomizationCheckBox->isChecked(); cardsAlreadyShown.clear(); + cardsNotKnown.clear(); ui->nonRedundantRandomizationCheckBox->setChecked(false); cardsTotal = cardsStringList.count() + 1; displayCard(false); @@ -101,7 +108,8 @@ void flashExam::on_revealBtn_clicked() } else { QString answerText = displayImage(answersStringList.at(currentCardNumber)); - ui->textBrowser->setText(answerText); + ui->textBrowser->clear(); + ui->textBrowser->setText("" + answerText + ""); answerShown = true; ui->revealBtn->setText("Hide answer"); } @@ -114,6 +122,21 @@ void flashExam::on_nextBtn_clicked() } void flashExam::displayCard(bool existingCardNumber) { + if(nonRedundantRandomization) { + float cardsTotalFloat = cardsTotal * 1.0; + float cardsAlreadyShownNumber = cardsAlreadyShown.count() * 1.0; + float cardsNotKnownNumber = cardsNotKnown.count() * 1.0; + if(answerShown) { + ui->cardNumberLabel->setText(QString::number((cardsAlreadyShownNumber - 1) / cardsTotalFloat * 100, 'f', 1) + "% done, " + QString::number(cardsNotKnownNumber / cardsTotalFloat * 100, 'f', 1) + "% forgotten"); + } + else { + ui->cardNumberLabel->setText(QString::number(cardsAlreadyShownNumber / cardsTotalFloat * 100, 'f', 1) + "% done, " + QString::number(cardsNotKnownNumber / cardsTotalFloat * 100, 'f', 1) + "% forgotten"); + } + } + else { + ui->cardNumberLabel->hide(); + } + if(!existingCardNumber) { if(randomize) { while(true) { @@ -142,7 +165,8 @@ void flashExam::displayCard(bool existingCardNumber) { } } QString cardText = displayImage(cardsStringList.at(currentCardNumber)); - ui->cardNumberLabel->setText("Card " + QString::number(currentCardNumber + 1)); + + ui->textBrowser->clear(); ui->textBrowser->setText(cardText); ui->revealBtn->setText("Show answer"); @@ -193,3 +217,10 @@ void flashExam::on_randomizeCheckBox_toggled(bool checked) } } + +void flashExam::on_didNotKnowBtn_clicked() +{ + cardsNotKnown.append(currentCardNumber); + on_nextBtn_clicked(); +} + diff --git a/src/apps/flashexam.h b/src/apps/flashexam.h index 4d9e2fe..c0f444c 100644 --- a/src/apps/flashexam.h +++ b/src/apps/flashexam.h @@ -25,6 +25,7 @@ private: bool randomize; bool nonRedundantRandomization; QList cardsAlreadyShown; + QList cardsNotKnown; bool answerShown = false; QStringList cardsStringList; QStringList answersStringList; @@ -43,6 +44,7 @@ private slots: void on_revealBtn_clicked(); void on_nextBtn_clicked(); void on_randomizeCheckBox_toggled(bool checked); + void on_didNotKnowBtn_clicked(); }; #endif // FLASHEXAM_H diff --git a/src/apps/flashexam.ui b/src/apps/flashexam.ui index b4b6b6a..8ad8740 100644 --- a/src/apps/flashexam.ui +++ b/src/apps/flashexam.ui @@ -93,17 +93,18 @@ - - - - - U001 - + + + + Qt::Orientation::Horizontal - - Select a cards list + + + 40 + 20 + - + @@ -120,18 +121,17 @@ - - - - Qt::Orientation::Horizontal + + + + + U001 + - - - 40 - 20 - + + Select a cards list - + @@ -184,28 +184,6 @@ - - - - - 0 - 0 - - - - - - - - - true - - - - Next card - - - @@ -255,8 +233,17 @@ - - + + + + + true + + + + Show answer + + @@ -271,6 +258,49 @@ + + + + + 0 + 0 + + + + + + + + 0 + + + + + + + 0 + + + + + + + + + + + + + true + + + + + + + + + @@ -284,18 +314,6 @@ - - - - - true - - - - Show answer - - -