mirror of
https://gitlab.com/kauron/jstudy
synced 2024-12-23 00:43:32 +01:00
Show feedback setting
This commit is contained in:
parent
c02b61a2fd
commit
e8111c0714
5 changed files with 30 additions and 16 deletions
|
@ -10,16 +10,14 @@ import java.util.ResourceBundle;
|
||||||
|
|
||||||
public class SettingsController implements Initializable {
|
public class SettingsController implements Initializable {
|
||||||
@FXML
|
@FXML
|
||||||
private JFXCheckBox repeatMistakes;
|
private JFXCheckBox repeatMistakes, showFeedback;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(URL location, ResourceBundle resources) {
|
public void initialize(URL location, ResourceBundle resources) {
|
||||||
System.err.println(AppConfig.printValues());
|
|
||||||
repeatMistakes.setSelected(AppConfig.repeatWrong);
|
repeatMistakes.setSelected(AppConfig.repeatWrong);
|
||||||
repeatMistakes.selectedProperty().addListener((change, o, n) -> {
|
repeatMistakes.selectedProperty().addListener((observable, old, value) -> AppConfig.repeatWrong = value);
|
||||||
AppConfig.repeatWrong = n;
|
showFeedback.setSelected(AppConfig.showFeedback);
|
||||||
System.err.println(AppConfig.printValues());
|
showFeedback.selectedProperty().addListener((observable, old, value) -> AppConfig.showFeedback = value);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import javafx.fxml.FXML;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.control.ProgressBar;
|
import javafx.scene.control.ProgressBar;
|
||||||
|
import javafx.scene.layout.HBox;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -20,13 +21,15 @@ public class TestController implements Initializable {
|
||||||
private JFXTextField answer;
|
private JFXTextField answer;
|
||||||
@FXML
|
@FXML
|
||||||
private ProgressBar progress;
|
private ProgressBar progress;
|
||||||
|
@FXML
|
||||||
|
private HBox feedback;
|
||||||
|
|
||||||
private List<TestItem> list;
|
private List<TestItem> list;
|
||||||
private int total, current;
|
private int total, current;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(URL url, ResourceBundle resourceBundle) {
|
public void initialize(URL url, ResourceBundle resourceBundle) {
|
||||||
|
feedback.setVisible(AppConfig.showFeedback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setList(List<TestItem> list) {
|
void setList(List<TestItem> list) {
|
||||||
|
@ -64,6 +67,7 @@ public class TestController implements Initializable {
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void onSkipAction(ActionEvent event) {
|
private void onSkipAction(ActionEvent event) {
|
||||||
|
feedback.setVisible(AppConfig.showFeedback);
|
||||||
answer.setText("");
|
answer.setText("");
|
||||||
current = (int) (Math.random() * list.size());
|
current = (int) (Math.random() * list.size());
|
||||||
question.setText(list.get(current).getQuestion());
|
question.setText(list.get(current).getQuestion());
|
||||||
|
|
|
@ -7,12 +7,13 @@ import java.util.Scanner;
|
||||||
|
|
||||||
public class AppConfig {
|
public class AppConfig {
|
||||||
private static final String FILE = "./config.ini";
|
private static final String FILE = "./config.ini";
|
||||||
public static boolean repeatWrong;
|
public static boolean repeatWrong, showFeedback;
|
||||||
|
|
||||||
public static void save() {
|
public static void save() {
|
||||||
try {
|
try {
|
||||||
PrintWriter pw = new PrintWriter(new File(FILE));
|
PrintWriter pw = new PrintWriter(new File(FILE));
|
||||||
pw.print("repeatWrong=" + repeatWrong);
|
pw.println("repeatWrong=" + repeatWrong);
|
||||||
|
pw.println("showFeedback=" + showFeedback);
|
||||||
pw.flush();
|
pw.flush();
|
||||||
pw.close();
|
pw.close();
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
|
@ -25,9 +26,11 @@ public class AppConfig {
|
||||||
Scanner in = new Scanner(new File(FILE));
|
Scanner in = new Scanner(new File(FILE));
|
||||||
while (in.hasNextLine()) {
|
while (in.hasNextLine()) {
|
||||||
String line = in.nextLine();
|
String line = in.nextLine();
|
||||||
if (line.matches("repeatWrong=.*")) {
|
String value = line.substring(line.indexOf('=') + 1);
|
||||||
repeatWrong = Boolean.parseBoolean(line.substring(line.indexOf('=') + 1));
|
if (line.matches("repeatWrong=.*"))
|
||||||
}
|
repeatWrong = Boolean.parseBoolean(value);
|
||||||
|
else if (line.matches("showFeedback=.*"))
|
||||||
|
showFeedback = Boolean.parseBoolean(value);
|
||||||
}
|
}
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -35,6 +38,6 @@ public class AppConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String printValues() {
|
public static String printValues() {
|
||||||
return "repeatWrong=" + repeatWrong;
|
return String.format("repeatWrong=%b\nshowFeedback=%b", repeatWrong, showFeedback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,20 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import com.jfoenix.controls.JFXCheckBox?>
|
<?import com.jfoenix.controls.JFXCheckBox?>
|
||||||
|
<?import javafx.geometry.Insets?>
|
||||||
<?import javafx.scene.layout.VBox?>
|
<?import javafx.scene.layout.VBox?>
|
||||||
|
|
||||||
|
|
||||||
<VBox alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.76-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="es.kauron.jstudy.controller.SettingsController">
|
<VBox xmlns="http://javafx.com/javafx/8.0.76-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="es.kauron.jstudy.controller.SettingsController">
|
||||||
<children>
|
<children>
|
||||||
<JFXCheckBox fx:id="repeatMistakes" text="Repeat mistakes" />
|
<VBox alignment="CENTER_LEFT" spacing="15.0" VBox.vgrow="NEVER">
|
||||||
|
<children>
|
||||||
|
<JFXCheckBox fx:id="repeatMistakes" text="_Repeat mistakes" />
|
||||||
|
<JFXCheckBox fx:id="showFeedback" layoutX="237.0" layoutY="201.0" text="Show _feedback while testing" />
|
||||||
|
</children>
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
|
||||||
|
</padding>
|
||||||
|
</VBox>
|
||||||
</children>
|
</children>
|
||||||
</VBox>
|
</VBox>
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
<Button defaultButton="true" layoutX="10.0" layoutY="10.0" mnemonicParsing="false" onAction="#onNextAction" prefWidth="70.0" text="Next" />
|
<Button defaultButton="true" layoutX="10.0" layoutY="10.0" mnemonicParsing="false" onAction="#onNextAction" prefWidth="70.0" text="Next" />
|
||||||
</children>
|
</children>
|
||||||
</HBox>
|
</HBox>
|
||||||
<HBox alignment="BOTTOM_CENTER" VBox.vgrow="ALWAYS">
|
<HBox fx:id="feedback" alignment="BOTTOM_CENTER" VBox.vgrow="ALWAYS">
|
||||||
<children>
|
<children>
|
||||||
<GridPane hgap="10.0" HBox.hgrow="NEVER">
|
<GridPane hgap="10.0" HBox.hgrow="NEVER">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
|
|
Loading…
Reference in a new issue