mirror of
https://github.com/Quill-OS/quill.git
synced 2025-01-11 23:47:19 -08:00
FlashExam: new 'brain brute-force' mode
This commit is contained in:
parent
e98f4561f7
commit
dcfaa5d1eb
3 changed files with 148 additions and 44 deletions
|
@ -34,6 +34,7 @@ flashExam::flashExam(QWidget *parent)
|
|||
ui->saveCardsNotKnownToFileCheckBox->setDisabled(true);
|
||||
ui->randomizeCheckBox->click();
|
||||
ui->randomizeCheckBox->setDisabled(true);
|
||||
ui->brainBruteForceCardsThresholdSpinBox->setDisabled(true);
|
||||
|
||||
graphicsScene = new QGraphicsScene(this);
|
||||
setupCardsList();
|
||||
|
@ -69,6 +70,7 @@ void flashExam::on_startBtn_clicked()
|
|||
listName = ui->listWidget->currentItem()->text();
|
||||
QString cardsList = "/mnt/onboard/onboard/.flashexam/" + listName;
|
||||
QString answersList = "/mnt/onboard/onboard/.flashexam/" + listName + ".answers";
|
||||
brainBruteForceCardsThreshold = ui->brainBruteForceCardsThresholdSpinBox->value();
|
||||
if(QFile::exists(answersList)) {
|
||||
log("Setting up cards list '" + listName + "'", className);
|
||||
initCardsList(cardsList, answersList);
|
||||
|
@ -87,6 +89,7 @@ void flashExam::initCardsList(QString cardsList, QString answersList) {
|
|||
randomize = ui->randomizeCheckBox->isChecked();
|
||||
nonRedundantRandomization = ui->nonRedundantRandomizationCheckBox->isChecked();
|
||||
saveCardsNotKnownToFile = ui->saveCardsNotKnownToFileCheckBox->isChecked();
|
||||
brainBruteForceMode = ui->brainBruteForceCheckBox->isChecked();
|
||||
cardsAlreadyShown.clear();
|
||||
cardsNotKnown.clear();
|
||||
ui->nonRedundantRandomizationCheckBox->setChecked(false);
|
||||
|
@ -140,13 +143,32 @@ void flashExam::displayCard(bool existingCardNumber) {
|
|||
ui->cardNumberLabel->setText(QString::number(cardsAlreadyShownNumber / cardsTotalFloat * 100, 'f', 1) + "% done, " + QString::number(cardsNotKnownNumber / cardsTotalFloat * 100, 'f', 1) + "% forgotten");
|
||||
}
|
||||
else {
|
||||
ui->cardNumberLabel->hide();
|
||||
if(!brainBruteForceLock) {
|
||||
ui->cardNumberLabel->hide();
|
||||
}
|
||||
}
|
||||
|
||||
if(!existingCardNumber) {
|
||||
if(randomize) {
|
||||
if(brainBruteForceLock && cardsNotKnown.isEmpty()) {
|
||||
brainBruteForceLock = false;
|
||||
ui->cardNumberLabel->hide();
|
||||
ui->cardNumberLabel->setText("");
|
||||
}
|
||||
if(brainBruteForceMode && cardsNotKnown.count() >= brainBruteForceCardsThreshold) {
|
||||
brainBruteForceLock = true;
|
||||
ui->cardNumberLabel->setText("Brain brute-force mode");
|
||||
ui->cardNumberLabel->show();
|
||||
}
|
||||
while(true) {
|
||||
currentCardNumber = QRandomGenerator::global()->bounded(cardsTotal - 1);
|
||||
if(brainBruteForceLock) {
|
||||
currentCardNumber = cardsNotKnown.at(cardsNotKnown.count() - 1);
|
||||
cardsNotKnown.removeLast();
|
||||
log("Brain brute-force mode: displaying card " + QString::number(currentCardNumber), className);
|
||||
}
|
||||
else {
|
||||
currentCardNumber = QRandomGenerator::global()->bounded(cardsTotal - 1);
|
||||
}
|
||||
if(nonRedundantRandomization) {
|
||||
if(!cardsAlreadyShown.contains(currentCardNumber)) {
|
||||
cardsAlreadyShown.append(currentCardNumber);
|
||||
|
@ -218,9 +240,11 @@ void flashExam::on_randomizeCheckBox_toggled(bool checked)
|
|||
{
|
||||
if(checked) {
|
||||
ui->nonRedundantRandomizationCheckBox->setDisabled(false);
|
||||
ui->brainBruteForceCheckBox->setDisabled(false);
|
||||
}
|
||||
else {
|
||||
ui->nonRedundantRandomizationCheckBox->setDisabled(true);
|
||||
ui->brainBruteForceCheckBox->setDisabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -234,7 +258,9 @@ void flashExam::on_didNotKnowBtn_clicked()
|
|||
void flashExam::on_nonRedundantRandomizationCheckBox_toggled(bool checked)
|
||||
{
|
||||
if(checked) {
|
||||
ui->saveCardsNotKnownToFileCheckBox->setDisabled(false);
|
||||
if(!ui->brainBruteForceCheckBox->isChecked()) {
|
||||
ui->saveCardsNotKnownToFileCheckBox->setDisabled(false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
ui->saveCardsNotKnownToFileCheckBox->setDisabled(true);
|
||||
|
@ -242,3 +268,21 @@ void flashExam::on_nonRedundantRandomizationCheckBox_toggled(bool checked)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void flashExam::on_brainBruteForceCheckBox_toggled(bool checked)
|
||||
{
|
||||
if(checked) {
|
||||
if(ui->nonRedundantRandomizationCheckBox->isChecked()) {
|
||||
ui->saveCardsNotKnownToFileCheckBox->setDisabled(true);
|
||||
ui->saveCardsNotKnownToFileCheckBox->setChecked(false);
|
||||
}
|
||||
ui->brainBruteForceCardsThresholdSpinBox->setDisabled(false);
|
||||
}
|
||||
else {
|
||||
if(ui->nonRedundantRandomizationCheckBox->isChecked()) {
|
||||
ui->saveCardsNotKnownToFileCheckBox->setDisabled(false);
|
||||
}
|
||||
ui->brainBruteForceCardsThresholdSpinBox->setDisabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,9 @@ private:
|
|||
bool randomize;
|
||||
bool nonRedundantRandomization;
|
||||
bool saveCardsNotKnownToFile;
|
||||
bool brainBruteForceMode;
|
||||
bool brainBruteForceLock = false;
|
||||
int brainBruteForceCardsThreshold;
|
||||
QList<int> cardsAlreadyShown;
|
||||
QList<int> cardsNotKnown;
|
||||
bool answerShown = false;
|
||||
|
@ -47,6 +50,7 @@ private slots:
|
|||
void on_randomizeCheckBox_toggled(bool checked);
|
||||
void on_didNotKnowBtn_clicked();
|
||||
void on_nonRedundantRandomizationCheckBox_toggled(bool checked);
|
||||
void on_brainBruteForceCheckBox_toggled(bool checked);
|
||||
};
|
||||
|
||||
#endif // FLASHEXAM_H
|
||||
|
|
|
@ -35,6 +35,31 @@
|
|||
</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="5" column="0">
|
||||
<widget class="QCheckBox" name="nonRedundantRandomizationCheckBox">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>U001</family>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Non-redundant randomized mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="bottomMargin">
|
||||
|
@ -102,7 +127,10 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<item row="3" column="0">
|
||||
<widget class="QListWidget" name="listWidget"/>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="Line" name="line_2">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Shadow::Plain</enum>
|
||||
|
@ -112,28 +140,27 @@
|
|||
</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">
|
||||
<item row="6" column="0">
|
||||
<widget class="QCheckBox" name="saveCardsNotKnownToFileCheckBox">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>U001</family>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Non-redundant randomized mode</string>
|
||||
<string>Save forgotten cards list to file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" 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>
|
||||
|
@ -150,31 +177,60 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QPushButton" name="startBtn">
|
||||
<property name="font">
|
||||
<font>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
<layout class="QGridLayout" name="gridLayout_8">
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</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 row="0" column="2">
|
||||
<widget class="QSpinBox" name="brainBruteForceCardsThresholdSpinBox">
|
||||
<property name="value">
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="brainBruteForceCheckBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>U001</family>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Brain brute-force mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>U001</family>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Every</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>U001</family>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>forgotten cards</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
|
|
Loading…
Reference in a new issue