mirror of
https://github.com/Quill-OS/quill.git
synced 2025-01-12 07:57:19 -08:00
Compare commits
No commits in common. "d5f23ac88a4fc626fcf7552b20caea3e16dddf7f" and "e98f4561f71d41ce688670602f94edc25e690b17" have entirely different histories.
d5f23ac88a
...
e98f4561f7
3 changed files with 55 additions and 161 deletions
|
@ -34,7 +34,6 @@ 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();
|
||||||
|
@ -70,7 +69,6 @@ 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);
|
||||||
|
@ -89,11 +87,9 @@ 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);
|
||||||
|
@ -137,43 +133,23 @@ void flashExam::on_nextBtn_clicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
void flashExam::displayCard(bool existingCardNumber) {
|
void flashExam::displayCard(bool existingCardNumber) {
|
||||||
|
if(nonRedundantRandomization) {
|
||||||
|
float cardsTotalFloat = cardsTotal * 1.0;
|
||||||
|
float cardsAlreadyShownNumber = cardsAlreadyShown.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");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ui->cardNumberLabel->hide();
|
||||||
|
}
|
||||||
|
|
||||||
if(!existingCardNumber) {
|
if(!existingCardNumber) {
|
||||||
if(randomize) {
|
if(randomize) {
|
||||||
if(brainBruteForceLock && cardsNotKnown.isEmpty()) {
|
|
||||||
brainBruteForceLock = false;
|
|
||||||
}
|
|
||||||
if(nonRedundantRandomization) {
|
|
||||||
float cardsTotalFloat = cardsTotal * 1.0;
|
|
||||||
float cardsAlreadyShownNumber = cardsAlreadyShown.count() * 1.0;
|
|
||||||
float cardsNotKnownNumber = cardsNotKnown.count() * 1.0;
|
|
||||||
if(!brainBruteForceLock) {
|
|
||||||
if(brainBruteForceMode) {
|
|
||||||
ui->cardNumberLabel->setText(QString::number(cardsAlreadyShownNumber / cardsTotalFloat * 100, 'f', 1) + "% done");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
while(true) {
|
while(true) {
|
||||||
if(brainBruteForceLock) {
|
currentCardNumber = QRandomGenerator::global()->bounded(cardsTotal - 1);
|
||||||
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(nonRedundantRandomization) {
|
||||||
if(brainBruteForceLock || !cardsAlreadyShown.contains(currentCardNumber)) {
|
if(!cardsAlreadyShown.contains(currentCardNumber)) {
|
||||||
if(!brainBruteForceLock) {
|
cardsAlreadyShown.append(currentCardNumber);
|
||||||
cardsAlreadyShown.append(currentCardNumber);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -242,11 +218,9 @@ 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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,9 +234,7 @@ 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);
|
||||||
|
@ -270,21 +242,3 @@ 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,9 +25,6 @@ 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;
|
||||||
|
@ -50,7 +47,6 @@ 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,31 +35,6 @@
|
||||||
</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">
|
||||||
|
@ -127,10 +102,7 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="7" 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>
|
||||||
|
@ -140,27 +112,28 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QCheckBox" name="saveCardsNotKnownToFileCheckBox">
|
<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">
|
<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>Non-redundant randomized mode</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>
|
||||||
|
@ -177,60 +150,31 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="8" column="0">
|
<item row="8" column="0">
|
||||||
<layout class="QGridLayout" name="gridLayout_8">
|
<widget class="QPushButton" name="startBtn">
|
||||||
<property name="bottomMargin">
|
<property name="font">
|
||||||
<number>0</number>
|
<font>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="2">
|
<property name="text">
|
||||||
<widget class="QSpinBox" name="brainBruteForceCardsThresholdSpinBox">
|
<string>Start</string>
|
||||||
<property name="value">
|
</property>
|
||||||
<number>10</number>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
</widget>
|
<item row="3" column="0">
|
||||||
</item>
|
<widget class="QListWidget" name="listWidget"/>
|
||||||
<item row="0" column="0">
|
</item>
|
||||||
<widget class="QCheckBox" name="brainBruteForceCheckBox">
|
<item row="6" column="0">
|
||||||
<property name="sizePolicy">
|
<widget class="QCheckBox" name="saveCardsNotKnownToFileCheckBox">
|
||||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
<property name="font">
|
||||||
<horstretch>0</horstretch>
|
<font>
|
||||||
<verstretch>0</verstretch>
|
<family>U001</family>
|
||||||
</sizepolicy>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="font">
|
<property name="text">
|
||||||
<font>
|
<string>Save forgotten cards list to file</string>
|
||||||
<family>U001</family>
|
</property>
|
||||||
</font>
|
</widget>
|
||||||
</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>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
|
Loading…
Reference in a new issue