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