From 8a9de02e74747c75150c89ea8c39f8c0aeaa81f2 Mon Sep 17 00:00:00 2001 From: law39 Date: Thu, 30 Apr 2020 12:48:38 +0100 Subject: [PATCH 1/2] 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 2/2] 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