mirror of
https://gitlab.com/kauron/jstudy
synced 2024-12-22 08:23:33 +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 {
|
||||
@FXML
|
||||
private JFXCheckBox repeatMistakes;
|
||||
private JFXCheckBox repeatMistakes, showFeedback;
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
System.err.println(AppConfig.printValues());
|
||||
repeatMistakes.setSelected(AppConfig.repeatWrong);
|
||||
repeatMistakes.selectedProperty().addListener((change, o, n) -> {
|
||||
AppConfig.repeatWrong = n;
|
||||
System.err.println(AppConfig.printValues());
|
||||
});
|
||||
repeatMistakes.selectedProperty().addListener((observable, old, value) -> AppConfig.repeatWrong = value);
|
||||
showFeedback.setSelected(AppConfig.showFeedback);
|
||||
showFeedback.selectedProperty().addListener((observable, old, value) -> AppConfig.showFeedback = value);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import javafx.fxml.FXML;
|
|||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ProgressBar;
|
||||
import javafx.scene.layout.HBox;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
|
@ -20,13 +21,15 @@ public class TestController implements Initializable {
|
|||
private JFXTextField answer;
|
||||
@FXML
|
||||
private ProgressBar progress;
|
||||
@FXML
|
||||
private HBox feedback;
|
||||
|
||||
private List<TestItem> list;
|
||||
private int total, current;
|
||||
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle resourceBundle) {
|
||||
|
||||
feedback.setVisible(AppConfig.showFeedback);
|
||||
}
|
||||
|
||||
void setList(List<TestItem> list) {
|
||||
|
@ -64,6 +67,7 @@ public class TestController implements Initializable {
|
|||
|
||||
@FXML
|
||||
private void onSkipAction(ActionEvent event) {
|
||||
feedback.setVisible(AppConfig.showFeedback);
|
||||
answer.setText("");
|
||||
current = (int) (Math.random() * list.size());
|
||||
question.setText(list.get(current).getQuestion());
|
||||
|
|
|
@ -7,12 +7,13 @@ import java.util.Scanner;
|
|||
|
||||
public class AppConfig {
|
||||
private static final String FILE = "./config.ini";
|
||||
public static boolean repeatWrong;
|
||||
public static boolean repeatWrong, showFeedback;
|
||||
|
||||
public static void save() {
|
||||
try {
|
||||
PrintWriter pw = new PrintWriter(new File(FILE));
|
||||
pw.print("repeatWrong=" + repeatWrong);
|
||||
pw.println("repeatWrong=" + repeatWrong);
|
||||
pw.println("showFeedback=" + showFeedback);
|
||||
pw.flush();
|
||||
pw.close();
|
||||
} catch (FileNotFoundException e) {
|
||||
|
@ -25,9 +26,11 @@ public class AppConfig {
|
|||
Scanner in = new Scanner(new File(FILE));
|
||||
while (in.hasNextLine()) {
|
||||
String line = in.nextLine();
|
||||
if (line.matches("repeatWrong=.*")) {
|
||||
repeatWrong = Boolean.parseBoolean(line.substring(line.indexOf('=') + 1));
|
||||
}
|
||||
String value = 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) {
|
||||
e.printStackTrace();
|
||||
|
@ -35,6 +38,6 @@ public class AppConfig {
|
|||
}
|
||||
|
||||
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"?>
|
||||
|
||||
<?import com.jfoenix.controls.JFXCheckBox?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?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>
|
||||
<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>
|
||||
</VBox>
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
<Button defaultButton="true" layoutX="10.0" layoutY="10.0" mnemonicParsing="false" onAction="#onNextAction" prefWidth="70.0" text="Next" />
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox alignment="BOTTOM_CENTER" VBox.vgrow="ALWAYS">
|
||||
<HBox fx:id="feedback" alignment="BOTTOM_CENTER" VBox.vgrow="ALWAYS">
|
||||
<children>
|
||||
<GridPane hgap="10.0" HBox.hgrow="NEVER">
|
||||
<columnConstraints>
|
||||
|
|
Loading…
Reference in a new issue