From 467a54f2c0b5ef79e8b759a2b4417e9fa5efab47 Mon Sep 17 00:00:00 2001 From: Brad Corbett Date: Thu, 30 Apr 2020 13:02:12 +0100 Subject: [PATCH 1/5] 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 2/5] 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 3/5] 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" > - - - - - +