From 0d54e54d9955830f5f44bfb770328902d10aa102 Mon Sep 17 00:00:00 2001 From: law39 Date: Thu, 30 Apr 2020 12:03:57 +0100 Subject: [PATCH 01/25] Fixed Assessment Generator Assessment would not run due to a logic error causing a null reference exception, this is now fixed. --- .../selfassessment/AssessmentGenerator.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/selfassessment/AssessmentGenerator.java b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/selfassessment/AssessmentGenerator.java index 9b86847..398574f 100644 --- a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/selfassessment/AssessmentGenerator.java +++ b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/selfassessment/AssessmentGenerator.java @@ -52,21 +52,20 @@ public class AssessmentGenerator { case (0): //0 Means translation test. //wordToTranslatePlace = rand.nextInt(Application.practiseList.size()); //wordToTranslate = Application.practiseList.get(wordToTranslatePlace); - if(!(listOfAssessment.getLast() == null) || (listOfAssessment.getLast() instanceof TranslationQuestion)){ + if((listOfAssessment.isEmpty()) || !(listOfAssessment.getLast() instanceof TranslationQuestion)){ + generatedAssessment = generateTranslationTest(practiseList); + }else { numberToGenerate--; - break; } - generatedAssessment = generateTranslationTest(practiseList); break; case (1): //1 Means six meanings test. //wordToTranslatePlace = rand.nextInt(Application.practiseList.size()); //wordToTranslate = Application.practiseList.get(wordToTranslatePlace); - if(!(listOfAssessment.getLast() == null) || (listOfAssessment.getLast() instanceof SixMeaningsQuestion)){ + if(((listOfAssessment.isEmpty())) || !(listOfAssessment.getLast() instanceof SixMeaningsQuestion)){ + generatedAssessment = generateSixMeanings(practiseList); + }else { numberToGenerate--; - break; } - generatedAssessment = generateSixMeanings(practiseList); - break; case (2): //2 Means match meanings test. // LinkedList wordsToTranslate = new LinkedList<>(); @@ -75,15 +74,16 @@ public class AssessmentGenerator { // wordsToTranslate.add(Application.practiseList.get(wordToTranslatePlace)); // wordsToTranslate.toArray(); // } - if(!(listOfAssessment.getLast() == null) || (listOfAssessment.getLast() instanceof MatchTheMeaningQuestion)){ + if((listOfAssessment.isEmpty()) || !(listOfAssessment.getLast() instanceof MatchTheMeaningQuestion)){ + generatedAssessment = generateMatchMeaning(practiseList); + }else { numberToGenerate--; - break; } - - generatedAssessment = generateMatchMeaning(practiseList); break; } - listOfAssessment.add(generatedAssessment); + if(generatedAssessment != null) { + listOfAssessment.add(generatedAssessment); + } } AssessmentGenerator.listOfAssessment = listOfAssessment; goToNextQuestion(); From 1d40ac93a87d57d86148b6e485440430efd82824 Mon Sep 17 00:00:00 2001 From: top19 Date: Thu, 30 Apr 2020 12:04:05 +0100 Subject: [PATCH 02/25] Changed flashcard to flip an image instead of a rectangle. --- .../cs22120/group20/javafx/FlashcardController.java | 10 +++++----- .../uk/ac/aber/cs22120/group20/flashcard.fxml | 9 ++++----- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/FlashcardController.java b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/FlashcardController.java index ae1db1b..2f7ed37 100644 --- a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/FlashcardController.java +++ b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/FlashcardController.java @@ -45,10 +45,10 @@ public class FlashcardController extends SharedCodeController { @FXML private Text wordType; @FXML - private Rectangle flashcard; - @FXML private Text testWord; + @FXML + private ImageView flashcard; @FXML private ImageView leftArrow; @FXML @@ -76,9 +76,9 @@ public class FlashcardController extends SharedCodeController { updateCounter(); card = flashcard; - - leftArrow.setImage(new Image(getClass().getResourceAsStream("/assets/icons/black_icons/50px/left-50.png"))); - rightArrow.setImage(new Image(getClass().getResourceAsStream("/assets/icons/black_icons/50px/right-50.png"))); + flashcard.setImage(new Image("file:src/main/resources/assets/flashcard/Flashcard.png")); + leftArrow.setImage(new Image("file:src/main/resources/assets/icons/black_icons/50px/left-50.png")); + rightArrow.setImage(new Image("file:src/main/resources/assets/icons/black_icons/50px/right-50.png")); } /** diff --git a/src/Welsh Vocabulary Tutor/src/main/resources/uk/ac/aber/cs22120/group20/flashcard.fxml b/src/Welsh Vocabulary Tutor/src/main/resources/uk/ac/aber/cs22120/group20/flashcard.fxml index 013a9e1..6335e5e 100644 --- a/src/Welsh Vocabulary Tutor/src/main/resources/uk/ac/aber/cs22120/group20/flashcard.fxml +++ b/src/Welsh Vocabulary Tutor/src/main/resources/uk/ac/aber/cs22120/group20/flashcard.fxml @@ -1,4 +1,4 @@ - + @@ -124,11 +124,10 @@ - + - - + + From 37d597f356f958fc5089b45c7034162b8beedc52 Mon Sep 17 00:00:00 2001 From: osp1 Date: Thu, 30 Apr 2020 12:11:41 +0100 Subject: [PATCH 03/25] Refactored practiseList to practiceList --- .../cs22120/group20/javafx/Application.java | 112 ++++++------------ .../group20/javafx/DictionaryController.java | 11 +- .../javafx/PracticeListController.java | 11 +- 3 files changed, 40 insertions(+), 94 deletions(-) diff --git a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/Application.java b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/Application.java index 9020ee6..7b150e3 100644 --- a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/Application.java +++ b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/Application.java @@ -1,14 +1,11 @@ /** - * @(#) App.java 0,1 2020/04/07 + * @(#) Application.java 0,2 2020/04/30 *

* Copyright (c) 2020 Aberystwyth University. * All rights reserved. */ package uk.ac.aber.cs22120.group20.javafx; -import javafx.fxml.FXMLLoader; -import javafx.scene.Parent; -import javafx.scene.Scene; import javafx.stage.FileChooser; import javafx.stage.Stage; import uk.ac.aber.cs22120.group20.json.DictionaryEntry; @@ -16,9 +13,7 @@ import uk.ac.aber.cs22120.group20.json.JsonProcessing; import java.io.File; import java.io.IOException; -import java.net.URL; import java.util.LinkedList; -import java.util.Scanner; /** * A class that launches the Welsh Vocabulary tutor Application. @@ -31,89 +26,50 @@ import java.util.Scanner; * @author Oscar Pocock [osp1] * @author Waylen Watts [ncw] * @author Luke Wybar [law39] - * * @version 0.1 Initial development */ public class Application extends javafx.application.Application { - - private JsonProcessing jsonProcessing = new JsonProcessing(); - private Scanner scanner = new Scanner(System.in); - + // Dictionary containing all the words. public static LinkedList dictionary = new LinkedList<>(); - public static LinkedList practiseList = new LinkedList<>(); + + // Practice list containing all the practice words. + public static LinkedList practiceList = new LinkedList<>(); + + // Json processor to import and export the json dictionary file. + private JsonProcessing jsonProcessing = new JsonProcessing(); /** - * - * @param stage - * @throws IOException - */ - @Override - public void start(Stage stage) throws IOException { - Scene scene; - File jsonFileLocation = null; - - while(jsonFileLocation ==null) { - FileChooser fileChooser = new FileChooser(); - fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("Json Files", "*.json")); - fileChooser.setTitle("Open Json File"); - jsonFileLocation = fileChooser.showOpenDialog(stage); - } - - final File jsonFileFinalLocation = jsonFileLocation; - dictionary = jsonProcessing.readInJson(jsonFileFinalLocation); - for (DictionaryEntry entry : dictionary) { - if (entry.isPracticeWord()) { - practiseList.add(entry); - } - } -// dictionary.add(new DictionaryEntry("abbey", "abaty", "nm", false)); -// dictionary.add(new DictionaryEntry("believe", "credu", "verb", true)); -// dictionary.add(new DictionaryEntry("concert", "cyngerdd", "nm", false)); -// dictionary.add(new DictionaryEntry("disease", "clefyd", "nm", true)); -// dictionary.add(new DictionaryEntry("extremely", "dros ben", "other", false)); -// dictionary.add(new DictionaryEntry("flu", "ffliw", "nm", false)); - new ScreenSwitch(stage); -// scene = new Scene(loadFXML("dictionary")); -// stage.setScene(scene); -// stage.setOnCloseRequest(e -> { -// jsonProcessing.writeOutJson(jsonFileLocation, dictionary); -// Platform.exit(); -// System.exit(0); -// }); -// stage.show(); -// ScreenSwitch.setScene(scene); - } - - /** - * @deprecated Please now use ScreenSwitch swap method with SceneEnum - * @param fxml - * @throws IOException - * @see ScreenSwitch - * @see ScreenSwitch.SceneEnum - */ - static void setRoot(String fxml) throws IOException { - ScreenSwitch.swap(ScreenSwitch.SceneEnum.dictionaryScene); - } - -// /** -// * -// * @param fxml -// * @return -// * @throws IOException -// */ -// private static Parent loadFXML(String fxml) throws IOException { -//// FXMLLoader fxmlLoader = new FXMLLoader(Application.class.getResource(fxml + ".fxml")); -// FXMLLoader fxmlLoader = new FXMLLoader(new URL("file:src/main/resources/uk/ac/aber/cs22120/group20/" + fxml + ".fxml")); -// return fxmlLoader.load(); -// } - - /** - * * @param args */ public static void main(String[] args) { launch(); } + /** + * @param stage + * @throws IOException + */ + @Override + public void start(Stage stage) throws IOException { + + // Prompts the user to load their dictionary json file. + File jsonFileLocation = null; + while (jsonFileLocation == null) { + FileChooser fileChooser = new FileChooser(); + fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("Json Files", "*.json")); + fileChooser.setTitle("Open Json File"); + jsonFileLocation = fileChooser.showOpenDialog(stage); + } + final File jsonFileFinalLocation = jsonFileLocation; + dictionary = jsonProcessing.readInJson(jsonFileFinalLocation); + + // Adds all words that are practice words to the practice list. + for (DictionaryEntry entry : dictionary) { + if (entry.isPracticeWord()) { + practiceList.add(entry); + } + } + new ScreenSwitch(stage); + } } \ No newline at end of file diff --git a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/DictionaryController.java b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/DictionaryController.java index 6f14342..34914b6 100644 --- a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/DictionaryController.java +++ b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/DictionaryController.java @@ -12,7 +12,6 @@ import javafx.collections.ObservableList; import javafx.collections.transformation.FilteredList; import javafx.collections.transformation.SortedList; import javafx.fxml.FXML; -import javafx.fxml.Initializable; import javafx.scene.control.TableColumn; import javafx.scene.control.TableRow; import javafx.scene.control.TableView; @@ -21,13 +20,9 @@ import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.paint.Color; import javafx.stage.Stage; -import uk.ac.aber.cs22120.group20.javafx.Application; import uk.ac.aber.cs22120.group20.json.DictionaryEntry; -import java.io.IOException; -import java.net.URL; import java.util.ArrayList; -import java.util.ResourceBundle; /** * A class that handles the keyboard and mouse input and interaction for the 'Dictionary Page' which is @@ -160,16 +155,16 @@ public class DictionaryController extends SharedCodeController { if (row.getItem().isPracticeWord()) { Application.dictionary.get(list.indexOf(row.getItem())).setPracticeWord(false); ArrayList toRemove = new ArrayList(); - for (DictionaryEntry entry : Application.practiseList) { + for (DictionaryEntry entry : Application.practiceList) { if (entry.equals(row.getItem())) { toRemove.add(entry); } } - Application.practiseList.removeAll(toRemove); + Application.practiceList.removeAll(toRemove); // row.getItem().setPracticeWord(false); } else if (!row.getItem().isPracticeWord()) { Application.dictionary.get(list.indexOf(row.getItem())).setPracticeWord(true); - Application.practiseList.add(row.getItem()); + Application.practiceList.add(row.getItem()); // row.getItem().setPracticeWord(true); } table.getSelectionModel().clearSelection(); diff --git a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/PracticeListController.java b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/PracticeListController.java index 3b2a0e5..c6e7399 100644 --- a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/PracticeListController.java +++ b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/PracticeListController.java @@ -12,19 +12,14 @@ import javafx.collections.ObservableList; import javafx.collections.transformation.FilteredList; import javafx.collections.transformation.SortedList; import javafx.fxml.FXML; -import javafx.fxml.Initializable; import javafx.scene.control.*; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.paint.Color; import javafx.stage.Stage; -import uk.ac.aber.cs22120.group20.javafx.Application; import uk.ac.aber.cs22120.group20.json.DictionaryEntry; -import java.io.IOException; -import java.net.URL; import java.util.ArrayList; -import java.util.ResourceBundle; /** * A class that handles the keyboard and mouse input and interaction for the 'Dictionary Page' which is @@ -83,7 +78,7 @@ public class PracticeListController extends SharedCodeController{ langSort.setImage(new Image("file:src/main/resources/assets/icons/black_icons/50px/sort-lang-50.png")); // list.addAll(Application.dictionary); - list.addAll(Application.practiseList); + list.addAll(Application.practiceList); // for (DictionaryEntry entry : Application.dictionary) { // if (entry.isPracticeWord()) // list.add(entry); @@ -150,13 +145,13 @@ public class PracticeListController extends SharedCodeController{ } ArrayList toRemove = new ArrayList(); - for (DictionaryEntry entry : Application.practiseList) { + for (DictionaryEntry entry : Application.practiceList) { if (entry.equals(row.getItem())) { toRemove.add(entry); list.remove(row.getItem()); } } - Application.practiseList.removeAll(toRemove); + Application.practiceList.removeAll(toRemove); table.getSelectionModel().clearSelection(); } }); From 3ace4ac40d1cf2bfde23e8c0c31d6decc70713b8 Mon Sep 17 00:00:00 2001 From: law39 Date: Thu, 30 Apr 2020 12:12:52 +0100 Subject: [PATCH 04/25] Added TestFX to module.info TestFX is now exported to the test package. --- src/Welsh Vocabulary Tutor/src/main/java/module-info.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Welsh Vocabulary Tutor/src/main/java/module-info.java b/src/Welsh Vocabulary Tutor/src/main/java/module-info.java index a013a76..f6cdc5f 100644 --- a/src/Welsh Vocabulary Tutor/src/main/java/module-info.java +++ b/src/Welsh Vocabulary Tutor/src/main/java/module-info.java @@ -17,6 +17,6 @@ module uk.ac.aber.cs22120.group20 { exports uk.ac.aber.cs22120.group20.json to com.fasterxml.jackson.databind; exports uk.ac.aber.cs22120.group20.javafx to javafx.graphics, javafx.fxml; - exports uk.ac.aber.cs22120.group20.test to org.junit.jupiter; -// exports uk.ac.aber.cs22120.group20.test to junit; + exports uk.ac.aber.cs22120.group20.test to org.junit.jupiter, org.testfx; + // exports uk.ac.aber.cs22120.group20.test to junit; } \ No newline at end of file From e7d1d091302a656880871452381c2bbf903c59e9 Mon Sep 17 00:00:00 2001 From: osp1 Date: Thu, 30 Apr 2020 12:13:31 +0100 Subject: [PATCH 05/25] Refactored practiseList->practiceList in Generator --- .../cs22120/group20/selfassessment/AssessmentGenerator.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/selfassessment/AssessmentGenerator.java b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/selfassessment/AssessmentGenerator.java index 398574f..2edd29f 100644 --- a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/selfassessment/AssessmentGenerator.java +++ b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/selfassessment/AssessmentGenerator.java @@ -197,10 +197,8 @@ public class AssessmentGenerator { if (result.isEmpty() || result.get() == noBtn) { ScreenSwitch.swap(ScreenSwitch.SceneEnum.dictionaryScene); } else { - generateAssessment(Application.practiseList); + generateAssessment(Application.practiceList); } } - } - } From 31bbd11187ba0e723c35eef10ec733ab135233c4 Mon Sep 17 00:00:00 2001 From: osp1 Date: Thu, 30 Apr 2020 12:16:39 +0100 Subject: [PATCH 06/25] Refactored practiseList>practiceList in Flashcard --- .../group20/javafx/FlashcardController.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/FlashcardController.java b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/FlashcardController.java index 2f7ed37..8fa6ec6 100644 --- a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/FlashcardController.java +++ b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/FlashcardController.java @@ -71,7 +71,7 @@ public class FlashcardController extends SharedCodeController { flashcardIcon.setImage(new Image("file:src/main/resources/assets/icons/black_icons/50px/flashcard-50.png")); flashcardsText.setFill(Color.BLACK); - testWord.setText(Application.practiseList.getFirst().getWelsh()); + testWord.setText(Application.practiceList.getFirst().getWelsh()); wordType.setText("Welsh"); updateCounter(); @@ -103,7 +103,7 @@ public class FlashcardController extends SharedCodeController { index--; } updateCounter(); - testWord.setText(Application.practiseList.get(index).getWelsh()); + testWord.setText(Application.practiceList.get(index).getWelsh()); wordType.setText("Welsh"); } @@ -115,12 +115,12 @@ public class FlashcardController extends SharedCodeController { @FXML private void handleNextCard() { // If statement to check the end of the practiceList hasn't been reached before moving to the next card. - if (index < Application.practiseList.size()-1) { + if (index < Application.practiceList.size()-1) { index++; } updateCounter(); - testWord.setText(Application.practiseList.get(index).getWelsh()); + testWord.setText(Application.practiceList.get(index).getWelsh()); wordType.setText("Welsh"); } @@ -130,7 +130,7 @@ public class FlashcardController extends SharedCodeController { * @see DictionaryEntry */ private void updateCounter() { - counter.setText((index + 1) + "/" + Application.practiseList.size()); + counter.setText((index + 1) + "/" + Application.practiceList.size()); } /** @@ -157,10 +157,10 @@ public class FlashcardController extends SharedCodeController { rotate.setOnFinished(event -> { // Once the transition is completed, update the text on the flashcard. if (wordType.getText().equals("Welsh")) { // If the word currently on the flashcard is welsh, display the english translation. - testWord.setText(Application.practiseList.get(index).getEnglish()); + testWord.setText(Application.practiceList.get(index).getEnglish()); wordType.setText("English"); } else { // Else display the welsh translation. - testWord.setText(Application.practiseList.get(index).getWelsh()); + testWord.setText(Application.practiceList.get(index).getWelsh()); wordType.setText("Welsh"); } testWord.setVisible(true); From c8ccba45dbf920d8235e38d367e57ae18d395e79 Mon Sep 17 00:00:00 2001 From: Brad Corbett Date: Thu, 30 Apr 2020 12:23:25 +0100 Subject: [PATCH 07/25] Added updated QuestionTest class. --- .../cs22120/group20/test/QuestionTest.java | 121 ++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/test/QuestionTest.java diff --git a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/test/QuestionTest.java b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/test/QuestionTest.java new file mode 100644 index 0000000..b03c0bf --- /dev/null +++ b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/test/QuestionTest.java @@ -0,0 +1,121 @@ +package uk.ac.aber.cs22120.group20.test; + +import org.junit.jupiter.api.Test; +import uk.ac.aber.cs22120.group20.json.DictionaryEntry; +import uk.ac.aber.cs22120.group20.selfassessment.AssessmentGenerator; +import uk.ac.aber.cs22120.group20.selfassessment.Question; +import uk.ac.aber.cs22120.group20.selfassessment.TranslationQuestion; + +import java.util.ArrayList; +import java.util.LinkedList; + +import static org.junit.jupiter.api.Assertions.*; + +class QuestionTest { + + @Test + void testCheckRightAnswerTranslation() { + ArrayList correctAnswerList = new ArrayList<>(); + ArrayList correctEntryList = new ArrayList<>(); + DictionaryEntry wordToTest = new DictionaryEntry("english1", "welsh1","verb"); + boolean isEnglish = true; + + correctAnswerList.add(wordToTest); + correctEntryList.add(wordToTest.getWelsh()); + + Question question; + + Question.checkAnswer(correctAnswerList, correctEntryList, isEnglish); + + assertEquals(1, Question.correctAnswers); + + + } + + @Test + void testCheckWrongAnswerTranslation() { + ArrayList correctAnswerList = new ArrayList<>(); + ArrayList correctEntryList = new ArrayList<>(); + DictionaryEntry wordToTest = new DictionaryEntry("english1", "welsh1","verb"); + boolean isEnglish = true; + + correctAnswerList.add(wordToTest); + correctEntryList.add("incorrectValue"); + + Question question; + + Question.checkAnswer(correctAnswerList, correctEntryList, isEnglish); + + assertEquals(1, Question.wrongAnswers); + + + } + + @Test + void testCheckRightAnswerMatchMeaning(){ + ArrayList correctAnswerList = new ArrayList<>(); + ArrayList correctEntryList = new ArrayList<>(); + DictionaryEntry wordToTest1 = new DictionaryEntry("english1", "welsh1","verb"); + DictionaryEntry wordToTest2 = new DictionaryEntry("english2", "welsh2","verb"); + DictionaryEntry wordToTest3 = new DictionaryEntry("english3", "welsh3","verb"); + DictionaryEntry wordToTest4 = new DictionaryEntry("english4", "welsh4","verb"); + boolean isEnglish = true; + + correctAnswerList.add(wordToTest1); + correctAnswerList.add(wordToTest2); + correctAnswerList.add(wordToTest3); + correctAnswerList.add(wordToTest4); + correctEntryList.add("welsh1"); + correctEntryList.add("welsh2"); + correctEntryList.add("welsh3"); + correctEntryList.add("welsh4"); + + AssessmentGenerator.isEnglish = true; + + Question.checkAnswer(correctAnswerList, correctEntryList, isEnglish); + + assertEquals(4, Question.correctAnswers); + } + + @Test + void testCheckWrongAnswerMatchMeaning(){ + ArrayList correctAnswerList = new ArrayList<>(); + ArrayList correctEntryList = new ArrayList<>(); + DictionaryEntry wordToTest1 = new DictionaryEntry("english1", "welsh1","verb"); + DictionaryEntry wordToTest2 = new DictionaryEntry("english2", "welsh2","verb"); + DictionaryEntry wordToTest3 = new DictionaryEntry("english3", "welsh3","verb"); + DictionaryEntry wordToTest4 = new DictionaryEntry("english4", "welsh4","verb"); + + + correctAnswerList.add(wordToTest1); + correctAnswerList.add(wordToTest2); + correctAnswerList.add(wordToTest3); + correctAnswerList.add(wordToTest4); + correctEntryList.add(""); + correctEntryList.add(""); + correctEntryList.add(""); + correctEntryList.add(""); + + boolean isEnglish = true; + + Question.checkAnswer(correctAnswerList, correctEntryList, isEnglish); + + + + assertEquals(4, Question.wrongAnswers); + } + + @Test + void testCheckRightAnswerSixMeanings(){ + + } + + @Test + void testCheckWrongAnswerSixMeanings(){ + + } + + @Test + void resetScore() { + } +} \ No newline at end of file From 937b6beee877d20195ef486edcc154c8e786d617 Mon Sep 17 00:00:00 2001 From: osp1 Date: Thu, 30 Apr 2020 12:33:18 +0100 Subject: [PATCH 08/25] Made wordType enum and added words are now in PL --- .../group20/javafx/AddWordController.java | 11 ++++---- .../group20/javafx/DictionaryController.java | 8 +++--- .../javafx/PracticeListController.java | 9 +++--- .../cs22120/group20/json/DictionaryEntry.java | 28 ++++++++++++++----- 4 files changed, 36 insertions(+), 20 deletions(-) diff --git a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/AddWordController.java b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/AddWordController.java index a944611..3fe3985 100644 --- a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/AddWordController.java +++ b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/AddWordController.java @@ -51,15 +51,15 @@ public class AddWordController extends SharedCodeController { @FXML protected void addButtonClick(ActionEvent actionEvent) { - String trueWordType; + DictionaryEntry.wordTypeEnum trueWordType; if (wordType.getValue() == "Masculine noun") { - trueWordType = "nm"; + trueWordType = DictionaryEntry.wordTypeEnum.nm; } else if (wordType.getValue() == "Feminine noun") { - trueWordType = "nf"; + trueWordType = DictionaryEntry.wordTypeEnum.nf; } else if (wordType.getValue() == "Verb") { - trueWordType = "verb"; + trueWordType = DictionaryEntry.wordTypeEnum.verb; } else { - trueWordType = "other"; + trueWordType = DictionaryEntry.wordTypeEnum.other; } boolean entryFound = false; // one or more blank fields @@ -100,6 +100,7 @@ public class AddWordController extends SharedCodeController { dictionaryEntry.setPracticeWord(true); Application.dictionary.contains(dictionaryEntry); Application.dictionary.add(dictionaryEntry); + Application.practiceList.add(dictionaryEntry); // output of what was saved for testing // System.out.print(english.getText()); diff --git a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/DictionaryController.java b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/DictionaryController.java index 34914b6..8dd3513 100644 --- a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/DictionaryController.java +++ b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/DictionaryController.java @@ -174,9 +174,9 @@ public class DictionaryController extends SharedCodeController { } ); welsh.setCellValueFactory(dictionaryEntryStringCellDataFeatures -> { - if (dictionaryEntryStringCellDataFeatures.getValue().getWordType().equals("nm")) { + if (dictionaryEntryStringCellDataFeatures.getValue().getWordType().equals(DictionaryEntry.wordTypeEnum.nm)) { return new SimpleStringProperty(dictionaryEntryStringCellDataFeatures.getValue().getWelsh() + " {nm}"); - } else if (dictionaryEntryStringCellDataFeatures.getValue().getWordType().equals("nf")) { + } else if (dictionaryEntryStringCellDataFeatures.getValue().getWordType().equals(DictionaryEntry.wordTypeEnum.nf)) { return new SimpleStringProperty(dictionaryEntryStringCellDataFeatures.getValue().getWelsh() + " {nf}"); } else { return new SimpleStringProperty(dictionaryEntryStringCellDataFeatures.getValue().getWelsh()); @@ -184,7 +184,7 @@ public class DictionaryController extends SharedCodeController { }); english.setCellValueFactory(dictionaryEntryStringCellDataFeatures -> { - if (dictionaryEntryStringCellDataFeatures.getValue().getWordType().equals("verb")) { + if (dictionaryEntryStringCellDataFeatures.getValue().getWordType().equals(DictionaryEntry.wordTypeEnum.verb)) { return new SimpleStringProperty("to " + dictionaryEntryStringCellDataFeatures.getValue().getEnglish()); } else { return new SimpleStringProperty(dictionaryEntryStringCellDataFeatures.getValue().getEnglish()); @@ -210,7 +210,7 @@ public class DictionaryController extends SharedCodeController { result = true; // Filter matches English // } else if (dictionaryEntry.getWordType().toLowerCase().contains(lowerCaseSearchFilter)) { // result = true; // Filter matches Word Type - } else if (dictionaryEntry.getWordType().equals("verb") && ("to " + dictionaryEntry.getEnglish()).toLowerCase().contains(lowerCaseSearchFilter)) { + } else if (dictionaryEntry.getWordType().equals(DictionaryEntry.wordTypeEnum.verb) && ("to " + dictionaryEntry.getEnglish()).toLowerCase().contains(lowerCaseSearchFilter)) { result = true; // Filter matches ['to' + a word] or [a word] if word is a verb } } diff --git a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/PracticeListController.java b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/PracticeListController.java index c6e7399..3211868 100644 --- a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/PracticeListController.java +++ b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/PracticeListController.java @@ -11,6 +11,7 @@ import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.collections.transformation.FilteredList; import javafx.collections.transformation.SortedList; +import javafx.css.converter.DurationConverter; import javafx.fxml.FXML; import javafx.scene.control.*; import javafx.scene.image.Image; @@ -104,7 +105,7 @@ public class PracticeListController extends SharedCodeController{ result = true; // Filter matches English // } else if (dictionaryEntry.getWordType().toLowerCase().contains(lowerCaseSearchFilter)) { // result = true; // Filter matches Word Type - } else if (dictionaryEntry.getWordType().equals("verb") && ("to " + dictionaryEntry.getEnglish()).toLowerCase().contains(lowerCaseSearchFilter)) { + } else if (dictionaryEntry.getWordType().equals(DictionaryEntry.wordTypeEnum.verb) && ("to " + dictionaryEntry.getEnglish()).toLowerCase().contains(lowerCaseSearchFilter)) { result = true; // Filter matches ['to' + a word] or [a word] if word is a verb } } @@ -161,9 +162,9 @@ public class PracticeListController extends SharedCodeController{ welsh.setCellValueFactory(dictionaryEntryStringCellDataFeatures -> { - if (dictionaryEntryStringCellDataFeatures.getValue().getWordType().equals("nm")) { + if (dictionaryEntryStringCellDataFeatures.getValue().getWordType().equals(DictionaryEntry.wordTypeEnum.nm)) { return new SimpleStringProperty(dictionaryEntryStringCellDataFeatures.getValue().getWelsh() + " {nm}"); - } else if (dictionaryEntryStringCellDataFeatures.getValue().getWordType().equals("nf")) { + } else if (dictionaryEntryStringCellDataFeatures.getValue().getWordType().equals(DictionaryEntry.wordTypeEnum.nf)) { return new SimpleStringProperty(dictionaryEntryStringCellDataFeatures.getValue().getWelsh() + " {nf}"); } else { return new SimpleStringProperty(dictionaryEntryStringCellDataFeatures.getValue().getWelsh()); @@ -171,7 +172,7 @@ public class PracticeListController extends SharedCodeController{ }); english.setCellValueFactory(dictionaryEntryStringCellDataFeatures -> { - if (dictionaryEntryStringCellDataFeatures.getValue().getWordType().equals("verb")) { + if (dictionaryEntryStringCellDataFeatures.getValue().getWordType().equals(DictionaryEntry.wordTypeEnum.verb)) { return new SimpleStringProperty("to " + dictionaryEntryStringCellDataFeatures.getValue().getEnglish()); } else { return new SimpleStringProperty(dictionaryEntryStringCellDataFeatures.getValue().getEnglish()); diff --git a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/json/DictionaryEntry.java b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/json/DictionaryEntry.java index 6174b6a..e096c0e 100644 --- a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/json/DictionaryEntry.java +++ b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/json/DictionaryEntry.java @@ -26,7 +26,11 @@ import uk.ac.aber.cs22120.group20.javafx.DictionaryController; public class DictionaryEntry { private String english; private String welsh; - private String wordType; + public enum wordTypeEnum { + nm, nf, verb, other + } + private wordTypeEnum wordType; +// private String wordType; private Boolean practiceWord; @@ -46,9 +50,10 @@ public class DictionaryEntry { * @see Application * @see DictionaryController */ - public DictionaryEntry(String english, String welsh, String wordType) { + public DictionaryEntry(String english, String welsh, wordTypeEnum wordType) { this.english = english; this.welsh = welsh; +// this.wordType = wordType; this.wordType = wordType; } @@ -68,15 +73,22 @@ public class DictionaryEntry { this.welsh = welsh.trim(); } - public String getWordType() { + public wordTypeEnum getWordType() { return wordType; } +// public word getWordType() { +// return wordType; +// } - public void setWordType(String wordType) { - this.wordType = wordType.trim(); + public void setWordType(wordTypeEnum wordType) { + this.wordType = wordType; } - public Boolean isPracticeWord() { +// public void setWordType(String wordType) { +// this.wordType = wordType; +// } + + public Boolean isPracticeWord() { return practiceWord; } @@ -87,6 +99,8 @@ public class DictionaryEntry { @Override public boolean equals(Object entry) { DictionaryEntry otherEntry = (DictionaryEntry) entry; - return otherEntry.getEnglish().equals(this.getEnglish()) && otherEntry.getWelsh().equals(this.getWelsh()) && otherEntry.getWordType().equals(this.getWordType()); + return otherEntry.getEnglish().equals(this.getEnglish()) && + otherEntry.getWelsh().equals(this.getWelsh()) && + otherEntry.getWordType().equals(this.getWordType()); } } From fdf09aba31e875231966da7f93fbdb14cd444024 Mon Sep 17 00:00:00 2001 From: law39 Date: Thu, 30 Apr 2020 12:34:03 +0100 Subject: [PATCH 09/25] Added Feedback to assessment At the end of each assessment, the user is told the correct answer, and if their answer was correct --- .../group20/selfassessment/Question.java | 40 ++++++++++++++++--- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/selfassessment/Question.java b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/selfassessment/Question.java index dd81d8d..34f366c 100644 --- a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/selfassessment/Question.java +++ b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/selfassessment/Question.java @@ -1,5 +1,7 @@ package uk.ac.aber.cs22120.group20.selfassessment; +import javafx.scene.control.Alert; +import javafx.scene.control.Dialog; import uk.ac.aber.cs22120.group20.json.DictionaryEntry; import java.util.ArrayList; @@ -25,24 +27,50 @@ public class Question { * @param isEnglish */ public static void checkAnswer(ArrayList listOfCorrectQuestions, ArrayListlistOfAnswers, boolean isEnglish){ + StringBuilder sb; if(isEnglish){ for(int i=0; i Date: Thu, 30 Apr 2020 12:39:44 +0100 Subject: [PATCH 10/25] Changed checkAnswer method. --- .../javafx/MatchTheMeaningController.java | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/MatchTheMeaningController.java b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/MatchTheMeaningController.java index 48b33cc..23668f6 100644 --- a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/MatchTheMeaningController.java +++ b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/MatchTheMeaningController.java @@ -133,20 +133,30 @@ public class MatchTheMeaningController extends SharedCodeController { */ public void checkAnswers(){ + ArrayList answers = new ArrayList<>(); ArrayList listOfAnswers = new ArrayList<>(); + + answers.add(answer.get(Integer.parseInt(word1.getValue())-1)); + answers.add(answer.get(Integer.parseInt(word2.getValue())-1)); + answers.add(answer.get(Integer.parseInt(word3.getValue())-1)); + answers.add(answer.get(Integer.parseInt(word4.getValue())-1)); + if(isEnglish){ - listOfAnswers.add(RightWord1.getText()); - listOfAnswers.add(RightWord2.getText()); - listOfAnswers.add(RightWord3.getText()); - listOfAnswers.add(RightWord4.getText()); - }else { listOfAnswers.add(LeftWord1.getText()); listOfAnswers.add(LeftWord2.getText()); listOfAnswers.add(LeftWord3.getText()); listOfAnswers.add(LeftWord4.getText()); + + + }else { + listOfAnswers.add(RightWord1.getText()); + listOfAnswers.add(RightWord2.getText()); + listOfAnswers.add(RightWord3.getText()); + listOfAnswers.add(RightWord4.getText()); + } - Question.checkAnswer(answer,listOfAnswers,isEnglish); + Question.checkAnswer(answers,listOfAnswers,isEnglish); answer.clear(); From 70edefd4a6a543835e6f86a415a2d23dc4ab9a06 Mon Sep 17 00:00:00 2001 From: top19 Date: Thu, 30 Apr 2020 12:46:19 +0100 Subject: [PATCH 11/25] Updated flashcard to display based on the language sort. --- .../group20/javafx/FlashcardController.java | 29 +++++++++++++++---- .../group20/javafx/SharedCodeController.java | 6 ++-- .../uk/ac/aber/cs22120/group20/flashcard.fxml | 2 +- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/FlashcardController.java b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/FlashcardController.java index 8fa6ec6..e80bda4 100644 --- a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/FlashcardController.java +++ b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/FlashcardController.java @@ -71,8 +71,13 @@ public class FlashcardController extends SharedCodeController { flashcardIcon.setImage(new Image("file:src/main/resources/assets/icons/black_icons/50px/flashcard-50.png")); flashcardsText.setFill(Color.BLACK); - testWord.setText(Application.practiceList.getFirst().getWelsh()); - wordType.setText("Welsh"); + if(isSortedByEnglish){ + testWord.setText(Application.practiceList.getFirst().getEnglish()); + wordType.setText("English"); + } else{ + testWord.setText(Application.practiceList.getFirst().getWelsh()); + wordType.setText("Welsh"); + } updateCounter(); card = flashcard; @@ -103,8 +108,14 @@ public class FlashcardController extends SharedCodeController { index--; } updateCounter(); - testWord.setText(Application.practiceList.get(index).getWelsh()); - wordType.setText("Welsh"); + + if(isSortedByEnglish){ + testWord.setText(Application.practiceList.get(index).getEnglish()); + wordType.setText("English"); + } else{ + testWord.setText(Application.practiceList.get(index).getWelsh()); + wordType.setText("Welsh"); + } } /** @@ -120,8 +131,14 @@ public class FlashcardController extends SharedCodeController { } updateCounter(); - testWord.setText(Application.practiceList.get(index).getWelsh()); - wordType.setText("Welsh"); + if(isSortedByEnglish){ + testWord.setText(Application.practiceList.get(index).getEnglish()); + wordType.setText("English"); + } else{ + testWord.setText(Application.practiceList.get(index).getWelsh()); + wordType.setText("Welsh"); + } + } /** diff --git a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/SharedCodeController.java b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/SharedCodeController.java index a9d5330..4b567dc 100644 --- a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/SharedCodeController.java +++ b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/SharedCodeController.java @@ -20,7 +20,7 @@ import uk.ac.aber.cs22120.group20.json.DictionaryEntry; * @see AssessmentGenerator */ abstract public class SharedCodeController { - + static boolean isSortedByEnglish = true; static int sideBarWidth = 50; // /////////////////// // @@ -151,7 +151,7 @@ abstract public class SharedCodeController { @FXML private void flashcardIconClick() { - 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. + if(Application.practiceList.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"); @@ -170,7 +170,7 @@ abstract public class SharedCodeController { */ @FXML private void studyIconClick() { - AssessmentGenerator.generateAssessment(Application.practiseList); + AssessmentGenerator.generateAssessment(Application.practiceList); } /** diff --git a/src/Welsh Vocabulary Tutor/src/main/resources/uk/ac/aber/cs22120/group20/flashcard.fxml b/src/Welsh Vocabulary Tutor/src/main/resources/uk/ac/aber/cs22120/group20/flashcard.fxml index 6335e5e..8c2e91e 100644 --- a/src/Welsh Vocabulary Tutor/src/main/resources/uk/ac/aber/cs22120/group20/flashcard.fxml +++ b/src/Welsh Vocabulary Tutor/src/main/resources/uk/ac/aber/cs22120/group20/flashcard.fxml @@ -126,7 +126,7 @@ - + From 8a9de02e74747c75150c89ea8c39f8c0aeaa81f2 Mon Sep 17 00:00:00 2001 From: law39 Date: Thu, 30 Apr 2020 12:48:38 +0100 Subject: [PATCH 12/25] Assessment now gives a final score in percentage Percentage is preferable rather than display the arbitrary number of wrong answers generated by the six meaning assessment. --- .../cs22120/group20/selfassessment/AssessmentGenerator.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/selfassessment/AssessmentGenerator.java b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/selfassessment/AssessmentGenerator.java index 2edd29f..c1438de 100644 --- a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/selfassessment/AssessmentGenerator.java +++ b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/selfassessment/AssessmentGenerator.java @@ -171,9 +171,9 @@ public class AssessmentGenerator { } else { StringBuilder sb = new StringBuilder(); - sb.append("You scored: ") - .append(Question.correctAnswers).append("/") - .append(Question.correctAnswers + Question.wrongAnswers) + sb.append("You got ") + .append(Question.correctAnswers / (Question.correctAnswers + Question.wrongAnswers)) + .append("%") .append("\n Would you like to test yourself again?"); ButtonType yesBtn = new ButtonType("Yes"); From 467a54f2c0b5ef79e8b759a2b4417e9fa5efab47 Mon Sep 17 00:00:00 2001 From: Brad Corbett Date: Thu, 30 Apr 2020 13:02:12 +0100 Subject: [PATCH 13/25] Updated QuestionTest class. --- .../cs22120/group20/test/QuestionTest.java | 79 ++++++++++++++----- 1 file changed, 58 insertions(+), 21 deletions(-) diff --git a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/test/QuestionTest.java b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/test/QuestionTest.java index b03c0bf..dfee4e3 100644 --- a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/test/QuestionTest.java +++ b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/test/QuestionTest.java @@ -10,14 +10,34 @@ import java.util.ArrayList; import java.util.LinkedList; import static org.junit.jupiter.api.Assertions.*; +import static uk.ac.aber.cs22120.group20.json.DictionaryEntry.wordTypeEnum.verb; + +/** + * Class that contains methods which will be used to test the Question class, and its methods. + * @author Brad Corbett [brc9] + * @author Henry Dugmore [hjd3] + * @author Kain Bryan-Jones [kab74] + * @author Luke Wybar [law39] + * @author Marcin Jakob [maj83] + * @author Oscar Pocock [osp1] + * @author Tom Perry [top1] + * @author Waylen Watts [ncw] + * @version 0.1 Initial development + * @See Question + */ class QuestionTest { + /** + * Tests that the correctAnswers variable increments when a user gets a right answer + * when doing either a Translation or SixMeanings test. + */ + @Test - void testCheckRightAnswerTranslation() { + void testCheckRightAnswerTranslationOrSixMeanings() { ArrayList correctAnswerList = new ArrayList<>(); ArrayList correctEntryList = new ArrayList<>(); - DictionaryEntry wordToTest = new DictionaryEntry("english1", "welsh1","verb"); + DictionaryEntry wordToTest = new DictionaryEntry("english1", "welsh1",verb); boolean isEnglish = true; correctAnswerList.add(wordToTest); @@ -32,11 +52,16 @@ class QuestionTest { } + /** + * Tests that the wrongAnswers variable increments when a user gets a wrong answer + * when doing either a Translation or SixMeanings test. + */ + @Test - void testCheckWrongAnswerTranslation() { + void testCheckWrongAnswerTranslationOrSixMeanings() { ArrayList correctAnswerList = new ArrayList<>(); ArrayList correctEntryList = new ArrayList<>(); - DictionaryEntry wordToTest = new DictionaryEntry("english1", "welsh1","verb"); + DictionaryEntry wordToTest = new DictionaryEntry("english1", "welsh1",verb); boolean isEnglish = true; correctAnswerList.add(wordToTest); @@ -44,6 +69,8 @@ class QuestionTest { Question question; + Question.resetScore(); + Question.checkAnswer(correctAnswerList, correctEntryList, isEnglish); assertEquals(1, Question.wrongAnswers); @@ -51,14 +78,20 @@ class QuestionTest { } + + /** + * Tests that the correctAnswers variable increments when a user gets a right answer + * when doing either a MatchTheMeaning test. + */ + @Test void testCheckRightAnswerMatchMeaning(){ ArrayList correctAnswerList = new ArrayList<>(); ArrayList correctEntryList = new ArrayList<>(); - DictionaryEntry wordToTest1 = new DictionaryEntry("english1", "welsh1","verb"); - DictionaryEntry wordToTest2 = new DictionaryEntry("english2", "welsh2","verb"); - DictionaryEntry wordToTest3 = new DictionaryEntry("english3", "welsh3","verb"); - DictionaryEntry wordToTest4 = new DictionaryEntry("english4", "welsh4","verb"); + DictionaryEntry wordToTest1 = new DictionaryEntry("english1", "welsh1",verb); + DictionaryEntry wordToTest2 = new DictionaryEntry("english2", "welsh2",verb); + DictionaryEntry wordToTest3 = new DictionaryEntry("english3", "welsh3",verb); + DictionaryEntry wordToTest4 = new DictionaryEntry("english4", "welsh4",verb); boolean isEnglish = true; correctAnswerList.add(wordToTest1); @@ -72,19 +105,26 @@ class QuestionTest { AssessmentGenerator.isEnglish = true; + Question.resetScore(); + Question.checkAnswer(correctAnswerList, correctEntryList, isEnglish); assertEquals(4, Question.correctAnswers); } + /** + * Tests that the wrongAnswers variable increments when a user gets a wrong answer + * when doing either a MatchTheMeaning test. + */ + @Test void testCheckWrongAnswerMatchMeaning(){ ArrayList correctAnswerList = new ArrayList<>(); ArrayList correctEntryList = new ArrayList<>(); - DictionaryEntry wordToTest1 = new DictionaryEntry("english1", "welsh1","verb"); - DictionaryEntry wordToTest2 = new DictionaryEntry("english2", "welsh2","verb"); - DictionaryEntry wordToTest3 = new DictionaryEntry("english3", "welsh3","verb"); - DictionaryEntry wordToTest4 = new DictionaryEntry("english4", "welsh4","verb"); + DictionaryEntry wordToTest1 = new DictionaryEntry("english1", "welsh1",verb); + DictionaryEntry wordToTest2 = new DictionaryEntry("english2", "welsh2",verb); + DictionaryEntry wordToTest3 = new DictionaryEntry("english3", "welsh3",verb); + DictionaryEntry wordToTest4 = new DictionaryEntry("english4", "welsh4",verb); correctAnswerList.add(wordToTest1); @@ -105,17 +145,14 @@ class QuestionTest { assertEquals(4, Question.wrongAnswers); } - @Test - void testCheckRightAnswerSixMeanings(){ - - } - - @Test - void testCheckWrongAnswerSixMeanings(){ - - } @Test void resetScore() { + Question.wrongAnswers = 5; + Question.correctAnswers = 5; + Question.resetScore(); + + assertEquals(0, Question.correctAnswers); + assertEquals(0, Question.wrongAnswers); } } \ No newline at end of file From 2ff007d378bada0de18ebd9c1c5c4f583b856312 Mon Sep 17 00:00:00 2001 From: top19 Date: Thu, 30 Apr 2020 13:17:28 +0100 Subject: [PATCH 14/25] Make the practice and dictionary sort by language sort by default --- .../group20/javafx/DictionaryController.java | 15 ++++++++++++--- .../group20/javafx/PracticeListController.java | 15 ++++++++++++--- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/DictionaryController.java b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/DictionaryController.java index 8dd3513..75020ea 100644 --- a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/DictionaryController.java +++ b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/DictionaryController.java @@ -64,7 +64,7 @@ public class DictionaryController extends SharedCodeController { */ @FXML private void switchLangSort() { - if (table.getSortOrder().contains(english)) { + if (isSortedByEnglish) { if (welsh.getSortType().equals(TableColumn.SortType.ASCENDING)) { alphaSort.setImage(new Image("file:src/main/resources/assets/icons/black_icons/50px/sort-alpha-up-50.png")); } @@ -73,8 +73,10 @@ public class DictionaryController extends SharedCodeController { } table.getSortOrder().clear(); table.getSortOrder().add(welsh); + + isSortedByEnglish = false; } - else if (table.getSortOrder().contains(welsh)) { + else { if (english.getSortType().equals(TableColumn.SortType.ASCENDING)) { alphaSort.setImage(new Image("file:src/main/resources/assets/icons/black_icons/50px/sort-alpha-up-50.png")); } @@ -83,8 +85,10 @@ public class DictionaryController extends SharedCodeController { } table.getSortOrder().clear(); table.getSortOrder().add(english); + isSortedByEnglish = true; } table.sort(); + } /** @@ -224,7 +228,12 @@ public class DictionaryController extends SharedCodeController { // english.setCellValueFactory(new PropertyValueFactory("english")); table.setItems(sortedList); - table.getSortOrder().add(english); + + if(isSortedByEnglish){ + table.getSortOrder().add(english); + } else{ + table.getSortOrder().add(welsh); + } } } diff --git a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/PracticeListController.java b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/PracticeListController.java index 3211868..535faf5 100644 --- a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/PracticeListController.java +++ b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/javafx/PracticeListController.java @@ -180,12 +180,17 @@ public class PracticeListController extends SharedCodeController{ }); table.setItems(sortedList); - table.getSortOrder().add(english); + if(isSortedByEnglish){ + table.getSortOrder().add(english); + } else{ + table.getSortOrder().add(welsh); + } + } @FXML private void switchLangSort() { - if (table.getSortOrder().contains(english)) { + if (isSortedByEnglish) { if (welsh.getSortType().equals(TableColumn.SortType.ASCENDING)) { alphaSort.setImage(new Image("file:src/main/resources/assets/icons/black_icons/50px/sort-alpha-up-50.png")); } @@ -194,8 +199,10 @@ public class PracticeListController extends SharedCodeController{ } table.getSortOrder().clear(); table.getSortOrder().add(welsh); + + isSortedByEnglish = false; } - else if (table.getSortOrder().contains(welsh)) { + else { if (english.getSortType().equals(TableColumn.SortType.ASCENDING)) { alphaSort.setImage(new Image("file:src/main/resources/assets/icons/black_icons/50px/sort-alpha-up-50.png")); } @@ -204,6 +211,8 @@ public class PracticeListController extends SharedCodeController{ } table.getSortOrder().clear(); table.getSortOrder().add(english); + + isSortedByEnglish = true; } table.sort(); } From 7a35413498c36e6bdb4465a6d8c070a29743f1c2 Mon Sep 17 00:00:00 2001 From: top19 Date: Thu, 30 Apr 2020 13:45:07 +0100 Subject: [PATCH 15/25] Removde tilted pane from translation and sixmeanings fxml. --- .../resources/uk/ac/aber/cs22120/group20/sixmeanings.fxml | 6 +----- .../resources/uk/ac/aber/cs22120/group20/translation.fxml | 6 ++---- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/Welsh Vocabulary Tutor/src/main/resources/uk/ac/aber/cs22120/group20/sixmeanings.fxml b/src/Welsh Vocabulary Tutor/src/main/resources/uk/ac/aber/cs22120/group20/sixmeanings.fxml index c071640..d4e1a9a 100644 --- a/src/Welsh Vocabulary Tutor/src/main/resources/uk/ac/aber/cs22120/group20/sixmeanings.fxml +++ b/src/Welsh Vocabulary Tutor/src/main/resources/uk/ac/aber/cs22120/group20/sixmeanings.fxml @@ -120,11 +120,7 @@ prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" > - - - - - +

- - + + @@ -153,8 +153,6 @@ - - From 366c10984b0035a2be663514e56ddfff6be960c7 Mon Sep 17 00:00:00 2001 From: law39 Date: Thu, 30 Apr 2020 14:32:53 +0100 Subject: [PATCH 16/25] Updated Match the meaning FXML Now reads total answers than Wrong answers --- .../resources/uk/ac/aber/cs22120/group20/matchthemeaning.fxml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Welsh Vocabulary Tutor/src/main/resources/uk/ac/aber/cs22120/group20/matchthemeaning.fxml b/src/Welsh Vocabulary Tutor/src/main/resources/uk/ac/aber/cs22120/group20/matchthemeaning.fxml index fe90509..4362f4b 100644 --- a/src/Welsh Vocabulary Tutor/src/main/resources/uk/ac/aber/cs22120/group20/matchthemeaning.fxml +++ b/src/Welsh Vocabulary Tutor/src/main/resources/uk/ac/aber/cs22120/group20/matchthemeaning.fxml @@ -181,7 +181,7 @@