Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
3beb45941c
3 changed files with 80 additions and 31 deletions
|
@ -41,7 +41,7 @@ public class MatchTheMeaningController extends SharedCodeController {
|
|||
|
||||
public static ArrayList<DictionaryEntry> answer =new ArrayList<>();
|
||||
private ArrayList<Integer> orderList = new ArrayList<>(Arrays.asList(0,1,2,3));
|
||||
private boolean isEnglish;
|
||||
private boolean isEnglish = AssessmentGenerator.isEnglish;
|
||||
|
||||
|
||||
@FXML
|
||||
|
@ -96,9 +96,8 @@ public class MatchTheMeaningController extends SharedCodeController {
|
|||
*/
|
||||
|
||||
|
||||
private void setWords(ArrayList<DictionaryEntry> questions, ArrayList<Integer> orderList){
|
||||
public void setWords(ArrayList<DictionaryEntry> questions, ArrayList<Integer> orderList){
|
||||
|
||||
isEnglish = AssessmentGenerator.isEnglish;
|
||||
|
||||
if(isEnglish){
|
||||
LeftWord1.setText(questions.get(0).getEnglish());
|
||||
|
|
|
@ -7,19 +7,26 @@ import javafx.scene.image.ImageView;
|
|||
import javafx.scene.shape.Rectangle;
|
||||
import javafx.scene.text.Text;
|
||||
import uk.ac.aber.cs22120.group20.selfassessment.AssessmentGenerator;
|
||||
|
||||
import uk.ac.aber.cs22120.group20.json.DictionaryEntry;
|
||||
/**
|
||||
* Abstract class that contains all the shared FXML elements between the
|
||||
* different controller classes including the sliding menu and the test score counter, to reduce code
|
||||
* duplication. This will be extended by all the controller classes.
|
||||
* @Author
|
||||
* @Version
|
||||
* @See
|
||||
* @Author top19
|
||||
* @Version 0.1 Initial development.
|
||||
* @see Application
|
||||
* @see DictionaryEntry
|
||||
* @see ScreenSwitch
|
||||
* @see AssessmentGenerator
|
||||
*/
|
||||
abstract public class SharedCodeController {
|
||||
|
||||
static int sideBarWidth = 50;
|
||||
|
||||
// /////////////////// //
|
||||
// Instance Variables. //
|
||||
// /////////////////// //
|
||||
|
||||
@FXML
|
||||
Rectangle sideBar;
|
||||
|
||||
|
@ -47,12 +54,17 @@ abstract public class SharedCodeController {
|
|||
@FXML
|
||||
ImageView studyIcon;
|
||||
@FXML
|
||||
ImageView searchIcon;
|
||||
@FXML
|
||||
ImageView addDefinitionIcon;
|
||||
@FXML
|
||||
ImageView currentPageIcon;
|
||||
|
||||
// //////// //
|
||||
// Methods. //
|
||||
// //////// //
|
||||
|
||||
/***
|
||||
* Method that sets up the program's menu in each of the controllers, intialising the icons and text.
|
||||
*/
|
||||
public void setup() {
|
||||
initializeIcons();
|
||||
sideBar.setWidth(sideBarWidth);
|
||||
|
@ -61,6 +73,9 @@ abstract public class SharedCodeController {
|
|||
initializeMenuText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method that sets up all of the menus icons by setting them to the images stored within the resources file.
|
||||
*/
|
||||
private void initializeIcons() {
|
||||
expandMenuIcon.setImage(new Image("file:src/main/resources/assets/icons/white_icons/50px/menu-50.png"));
|
||||
dictionaryIcon.setImage(new Image("file:src/main/resources/assets/icons/white_icons/50px/read-50.png"));
|
||||
|
@ -70,6 +85,9 @@ abstract public class SharedCodeController {
|
|||
addDefinitionIcon.setImage(new Image("file:src/main/resources/assets/icons/white_icons/50px/add-50.png"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method that sets up all of the menus text by setting them to their desired text when the menu is expanded.
|
||||
*/
|
||||
private void initializeMenuText() {
|
||||
dictionaryText.setText("Dictionary");
|
||||
practiceListTest.setText("Practice List");
|
||||
|
@ -78,6 +96,9 @@ abstract public class SharedCodeController {
|
|||
addDefinitionText.setText("Add");
|
||||
}
|
||||
|
||||
/**
|
||||
* Method that disables the menus text when the menu is collapsed.
|
||||
*/
|
||||
private void disableMenuText() {
|
||||
dictionaryText.setText("");
|
||||
practiceListTest.setText("");
|
||||
|
@ -86,47 +107,76 @@ abstract public class SharedCodeController {
|
|||
addDefinitionText.setText("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Event that expands the menu whenever the menu's 'expandMenuIcon' icon is clicked.
|
||||
*/
|
||||
@FXML
|
||||
private void expandMenuClick() {
|
||||
if(sideBar.getWidth() == 50) {
|
||||
if(sideBar.getWidth() == 50) { // If sideBar is currently collapsed, expand it and display menu text.
|
||||
|
||||
sideBar.setWidth(sideBarWidth = 230);
|
||||
initializeMenuText();
|
||||
initializeMenuText(); // Display menu
|
||||
} else {
|
||||
sideBar.setWidth(sideBarWidth = 50);
|
||||
sideBar.setWidth(sideBarWidth = 50); // Else collapse the menu and disable its text.
|
||||
disableMenuText();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event to switch scenes to 'dictionary.fxml' when the menu's 'dictionaryIcon' icon is clicked.
|
||||
* @see ScreenSwitch
|
||||
*/
|
||||
@FXML
|
||||
private void dictionaryIconClick() {
|
||||
ScreenSwitch.swap(ScreenSwitch.SceneEnum.dictionaryScene);
|
||||
}
|
||||
|
||||
/**
|
||||
* Event to switch scenes to 'practicelist.fxml' when the menu's 'practiceListIcon' icon is clicked.
|
||||
* @see ScreenSwitch
|
||||
*/
|
||||
@FXML
|
||||
private void practiceListIconClick() {
|
||||
ScreenSwitch.swap(ScreenSwitch.SceneEnum.practiceListScene);
|
||||
}
|
||||
|
||||
/**
|
||||
* Event to switch scenes to 'flashcard.fxml' when the menu's 'practiceListIcon' icon is clicked. This method checks to see if practiceList is empty before switching in order
|
||||
* to avoid NullPointerException's in the flashcard scene.
|
||||
* @see ScreenSwitch
|
||||
* @see Application
|
||||
* @see DictionaryEntry
|
||||
* @see NullPointerException
|
||||
*/
|
||||
@FXML
|
||||
private void flashcardIconClick() {
|
||||
|
||||
if(Application.practiseList.size() == 0) {
|
||||
if(Application.practiseList.size() == 0) { // Check to see if there are any practice words before switching scene, throwing an alert notifying them that they can't switch scenes.
|
||||
Alert alert = new Alert(Alert.AlertType.ERROR);
|
||||
alert.setTitle("Error");
|
||||
alert.setHeaderText("Unable to use Flashcard");
|
||||
alert.setContentText("The practice list is currently empty, please add some practice words to use the Flashcard feature.");
|
||||
alert.showAndWait();
|
||||
} else{
|
||||
ScreenSwitch.swap(ScreenSwitch.SceneEnum.flashcardScene);
|
||||
ScreenSwitch.swap(ScreenSwitch.SceneEnum.flashcardScene); // Switch to flashcard scene if the program has practice words.
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event to generate an assessment using AssessmentGenerator when the menu's 'studyIcon' icon is clicked.
|
||||
* @see AssessmentGenerator
|
||||
* @see Application
|
||||
* @see DictionaryEntry
|
||||
*/
|
||||
@FXML
|
||||
private void studyIconClick() {
|
||||
AssessmentGenerator.generateAssessment(Application.practiseList);
|
||||
}
|
||||
|
||||
/**
|
||||
* Event to switch scenes to 'addword.fxml' when the menu's 'addwordIcon' icon is clicked.
|
||||
* @see ScreenSwitch
|
||||
*/
|
||||
@FXML
|
||||
private void addWordIconClick(){
|
||||
|
||||
|
|
|
@ -105,11 +105,11 @@ public class SixMeaningsController extends SharedCodeController {
|
|||
|
||||
|
||||
|
||||
private void setWords(boolean isEnglish){
|
||||
public void setWords(ArrayList<DictionaryEntry> questions, ArrayList<Integer> orderList){
|
||||
|
||||
if(isEnglish){
|
||||
|
||||
wordSet.add(allQuestions.get(0));
|
||||
wordSet.add(questions.get(0));
|
||||
|
||||
//WelshWord1 Is the question word and as a result is always right.
|
||||
wordToTranslate.setText(wordSet.get(0).getEnglish());
|
||||
|
@ -117,27 +117,27 @@ public class SixMeaningsController extends SharedCodeController {
|
|||
|
||||
Collections.shuffle(orderList);
|
||||
|
||||
possibleAnswer1.setText(allQuestions.get(orderList.get(0)).getWelsh());
|
||||
possibleAnswer2.setText(allQuestions.get(orderList.get(1)).getWelsh());
|
||||
possibleAnswer3.setText(allQuestions.get(orderList.get(2)).getWelsh());
|
||||
possibleAnswer4.setText(allQuestions.get(orderList.get(3)).getWelsh());
|
||||
possibleAnswer5.setText(allQuestions.get(orderList.get(4)).getWelsh());
|
||||
possibleAnswer6.setText(allQuestions.get(orderList.get(5)).getWelsh());
|
||||
possibleAnswer1.setText(questions.get(orderList.get(0)).getWelsh());
|
||||
possibleAnswer2.setText(questions.get(orderList.get(1)).getWelsh());
|
||||
possibleAnswer3.setText(questions.get(orderList.get(2)).getWelsh());
|
||||
possibleAnswer4.setText(questions.get(orderList.get(3)).getWelsh());
|
||||
possibleAnswer5.setText(questions.get(orderList.get(4)).getWelsh());
|
||||
possibleAnswer6.setText(questions.get(orderList.get(5)).getWelsh());
|
||||
}else {
|
||||
|
||||
wordSet.add(allQuestions.get(0));
|
||||
wordSet.add(questions.get(0));
|
||||
//WelshWord1 Is the question word and as a result is always right.
|
||||
wordToTranslate.setText(wordSet.get(0).getWelsh());
|
||||
//This stores the correct answer for the english word.
|
||||
|
||||
Collections.shuffle(orderList);
|
||||
|
||||
possibleAnswer1.setText(allQuestions.get(orderList.get(0)).getEnglish());
|
||||
possibleAnswer2.setText(allQuestions.get(orderList.get(1)).getEnglish());
|
||||
possibleAnswer3.setText(allQuestions.get(orderList.get(2)).getEnglish());
|
||||
possibleAnswer4.setText(allQuestions.get(orderList.get(3)).getEnglish());
|
||||
possibleAnswer5.setText(allQuestions.get(orderList.get(4)).getEnglish());
|
||||
possibleAnswer6.setText(allQuestions.get(orderList.get(5)).getEnglish());
|
||||
possibleAnswer1.setText(questions.get(orderList.get(0)).getEnglish());
|
||||
possibleAnswer2.setText(questions.get(orderList.get(1)).getEnglish());
|
||||
possibleAnswer3.setText(questions.get(orderList.get(2)).getEnglish());
|
||||
possibleAnswer4.setText(questions.get(orderList.get(3)).getEnglish());
|
||||
possibleAnswer5.setText(questions.get(orderList.get(4)).getEnglish());
|
||||
possibleAnswer6.setText(questions.get(orderList.get(5)).getEnglish());
|
||||
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,7 @@ public class SixMeaningsController extends SharedCodeController {
|
|||
|
||||
|
||||
|
||||
private void checkAnswers() {
|
||||
public void checkAnswers() {
|
||||
|
||||
ArrayList<String> answer = new ArrayList<>();
|
||||
|
||||
|
@ -171,7 +171,7 @@ public class SixMeaningsController extends SharedCodeController {
|
|||
studyIcon.setImage(new Image("file:src/main/resources/assets/icons/black_icons/50px/pass-fail-50.png"));
|
||||
studyText.setFill(Color.BLACK);
|
||||
|
||||
setWords(isEnglish);
|
||||
setWords(allQuestions,orderList);
|
||||
|
||||
correctAnswer.setText(Integer.toString(Question.correctAnswers));
|
||||
|
||||
|
|
Reference in a new issue