Merge branch 'master' of https://gitlab.dcs.aber.ac.uk/ncw/gp20
This commit is contained in:
commit
ce18020eae
10 changed files with 91 additions and 81 deletions
|
@ -1,6 +1,10 @@
|
|||
![Logo](https://cdn.discordapp.com/icons/671688550311526413/67359a4a386c62bb66eaf4641ab8de5c.png?size=128)
|
||||
<div align="center">
|
||||
|
||||
![Logo](https://cdn.discordapp.com/icons/671688550311526413/67359a4a386c62bb66eaf4641ab8de5c.png?size=128)
|
||||
# Welsh Vocabulary Tutor
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
> This is the group repository for Group 20 doing the CS22120 Group Project 2020.
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -12,31 +12,56 @@ import java.util.Random;
|
|||
* @Version
|
||||
* @See
|
||||
*/
|
||||
public class AssessmentGenerator extends Question {
|
||||
public class AssessmentGenerator {
|
||||
static boolean isEnglish;
|
||||
|
||||
|
||||
/**
|
||||
* Method that will generate a randomized list of questions consisting of random distribution of questions
|
||||
* types, using the dictionary’s practice words as the parameter.
|
||||
* @param wordList
|
||||
* @return
|
||||
*/
|
||||
public LinkedList<Question> generateAssessment(LinkedList<DictionaryEntry> wordList){
|
||||
LinkedList<Question> returnValue = new LinkedList<>();
|
||||
public static LinkedList<Question> generateAssessment(LinkedList<DictionaryEntry> wordList){
|
||||
LinkedList<Question> listOfAssessment = new LinkedList<>();
|
||||
LinkedList<DictionaryEntry> practiseList = Application.practiseList;
|
||||
Random rand = new Random();
|
||||
|
||||
int quizType = rand.nextInt(3);
|
||||
switch(quizType){
|
||||
case(0): //0 Means translation test.
|
||||
int wordToTranslatePlace = rand.nextInt(Application.practiseList.size());
|
||||
DictionaryEntry wordToTranslate = Application.practiseList.get(wordToTranslatePlace);
|
||||
|
||||
case(1): //1 Means six meanings test.
|
||||
|
||||
|
||||
case(2): //2 Means match meanings test.
|
||||
int wordToTranslatePlace;
|
||||
|
||||
for (int numberToGenerate = 0; numberToGenerate < 10; numberToGenerate++) {
|
||||
Question generatedAssessment = null;
|
||||
int quizType = rand.nextInt(3);
|
||||
switch (quizType) {
|
||||
case (0): //0 Means translation test.
|
||||
//wordToTranslatePlace = rand.nextInt(Application.practiseList.size());
|
||||
//wordToTranslate = Application.practiseList.get(wordToTranslatePlace);
|
||||
|
||||
generatedAssessment = generateTranslationTest(practiseList);
|
||||
break;
|
||||
case (1): //1 Means six meanings test.
|
||||
//wordToTranslatePlace = rand.nextInt(Application.practiseList.size());
|
||||
//wordToTranslate = Application.practiseList.get(wordToTranslatePlace);
|
||||
|
||||
generatedAssessment = generateSixMeanings(practiseList);
|
||||
break;
|
||||
case (2): //2 Means match meanings test.
|
||||
// LinkedList<DictionaryEntry> wordsToTranslate = new LinkedList<>();
|
||||
// for (int i = 0; i < 3; i++) {
|
||||
// wordToTranslatePlace = rand.nextInt(Application.practiseList.size());
|
||||
// wordsToTranslate.add(Application.practiseList.get(wordToTranslatePlace));
|
||||
// wordsToTranslate.toArray();
|
||||
// }
|
||||
|
||||
generatedAssessment = generateMatchMeaning(practiseList);
|
||||
break;
|
||||
}
|
||||
listOfAssessment.add(generatedAssessment);
|
||||
}
|
||||
|
||||
return listOfAssessment;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,8 +70,12 @@ public class AssessmentGenerator extends Question {
|
|||
* practice words as the parameter.
|
||||
* @return
|
||||
*/
|
||||
public LinkedList<Question> generateWordMatch(LinkedList<DictionaryEntry> a){
|
||||
return null;
|
||||
public static Question generateMatchMeaning(LinkedList<DictionaryEntry> practiceList){
|
||||
Random rand = new Random();
|
||||
DictionaryEntry selectedCorrectAnswer;
|
||||
selectedCorrectAnswer = practiceList.get(rand.nextInt(practiceList.size()-1));
|
||||
TranslationQuestion generatedQuestion = new TranslationQuestion(selectedCorrectAnswer);
|
||||
return generatedQuestion;
|
||||
|
||||
}
|
||||
|
||||
|
@ -56,7 +85,7 @@ public class AssessmentGenerator extends Question {
|
|||
* words as the parameter.
|
||||
* @return
|
||||
*/
|
||||
public static void generateSixMeanings(LinkedList<DictionaryEntry> practiseList){
|
||||
public static Question generateSixMeanings(LinkedList<DictionaryEntry> practiseList){
|
||||
|
||||
//CHANGE DICTIONARY TO PRACTISE LIST
|
||||
|
||||
|
@ -104,7 +133,7 @@ public class AssessmentGenerator extends Question {
|
|||
* the parameter.
|
||||
* @return
|
||||
*/
|
||||
public LinkedList<Question> generateWordEnter(LinkedList<DictionaryEntry> a){
|
||||
public static Question generateTranslationTest(LinkedList<DictionaryEntry> a){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,13 @@
|
|||
package uk.ac.aber.cs22120.group20.selfassessment;
|
||||
|
||||
public class MatchTheMeaningQuestion {
|
||||
import uk.ac.aber.cs22120.group20.json.DictionaryEntry;
|
||||
|
||||
public class MatchTheMeaningQuestion extends Question {
|
||||
DictionaryEntry[] correctAnswer;
|
||||
|
||||
public MatchTheMeaningQuestion(DictionaryEntry[] correctAnswer){
|
||||
this.correctAnswer = correctAnswer;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
package uk.ac.aber.cs22120.group20.selfassessment;
|
||||
|
||||
public class SixMeaningsQuestion {
|
||||
private static SixMeaningsQuestion ourInstance = new SixMeaningsQuestion();
|
||||
import uk.ac.aber.cs22120.group20.json.DictionaryEntry;
|
||||
|
||||
public static SixMeaningsQuestion getInstance() {
|
||||
return ourInstance;
|
||||
}
|
||||
import java.util.LinkedList;
|
||||
|
||||
private SixMeaningsQuestion() {
|
||||
public class SixMeaningsQuestion extends Question{
|
||||
private DictionaryEntry correctAnswer;
|
||||
private LinkedList<DictionaryEntry> dictionary;
|
||||
|
||||
private SixMeaningsQuestion(DictionaryEntry correctAnswer, LinkedList<DictionaryEntry> dictionary) {
|
||||
this.correctAnswer = correctAnswer;
|
||||
this.dictionary = dictionary;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,15 +22,8 @@ import uk.ac.aber.cs22120.group20.javafx.Application;
|
|||
*
|
||||
*/
|
||||
public class TranslationController extends Question {
|
||||
ArrayList<DictionaryEntry> practiceList = new ArrayList<>();
|
||||
|
||||
|
||||
/**
|
||||
* Represents the words that have already been used, and are no longer to be generated.
|
||||
*/
|
||||
ArrayList<Integer> numbersUsed = new ArrayList<Integer>();
|
||||
int correctGuessesInt = 0;
|
||||
int incorrectGuessesInt = 0;
|
||||
private ArrayList<DictionaryEntry> practiceList = new ArrayList<>();
|
||||
public static DictionaryEntry practiceWord = new DictionaryEntry();
|
||||
|
||||
/**
|
||||
* Represents the word that will be randomly chosen from the practiceList.
|
||||
|
@ -57,8 +50,6 @@ public class TranslationController extends Question {
|
|||
Random rand = new Random();
|
||||
|
||||
|
||||
boolean englishOrWelsh = false; // False means English to Welsh, true means Welsh to English
|
||||
|
||||
|
||||
/**
|
||||
* Loads the test for the first time, filling the practice list with words from the dictionary,
|
||||
|
@ -70,35 +61,23 @@ public class TranslationController extends Question {
|
|||
|
||||
submitButton.setImage(new Image ("file:src/main/resources/assets/icons/black_icons/50px/right-50.png"));
|
||||
|
||||
for(DictionaryEntry entry : Application.dictionary){
|
||||
if(entry.isPracticeWord()){
|
||||
practiceList.add(entry);
|
||||
}
|
||||
}
|
||||
correctGuesses.setText("Correct Guesses: " + correctAnswers);
|
||||
incorrectGuesses.setText("Incorrect Guesses: " + wrongAnswers);
|
||||
|
||||
|
||||
chosenWord = (rand.nextInt(practiceList.size()));
|
||||
numbersUsed.add(chosenWord);
|
||||
|
||||
englishOrWelsh = rand.nextBoolean();
|
||||
|
||||
correctGuesses.setText("Correct Guesses: 0");
|
||||
incorrectGuesses.setText("Incorrect Guesses: 0");
|
||||
|
||||
if(englishOrWelsh){
|
||||
wordToTranslate.setText(practiceList.get(chosenWord).getWelsh());
|
||||
if(AssessmentGenerator.isEnglish){
|
||||
wordToTranslate.setText(practiceWord.getWelsh());
|
||||
}
|
||||
else{
|
||||
wordToTranslate.setText(practiceList.get(chosenWord).getEnglish());
|
||||
wordToTranslate.setText(practiceWord.getEnglish());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Takes the word that the user has entered as their attempt at translate, compares
|
||||
* it to the correct translation, and depending on if it is correct or not, increment how many
|
||||
* right or wrong answers they have so far. After checking if the user got it right,
|
||||
* it will generate a new word for the user to translate, provided they have words left to translate.
|
||||
* Takes the word the user inputs and compares it to the correct answer using
|
||||
* the checkAnswer function in the QuestionClass.
|
||||
*/
|
||||
@FXML
|
||||
void translateWord() {
|
||||
|
@ -109,35 +88,8 @@ public class TranslationController extends Question {
|
|||
ArrayList<DictionaryEntry> correctTranslation = new ArrayList<>();
|
||||
correctTranslation.add(practiceList.get(chosenWord));
|
||||
|
||||
checkAnswer(correctTranslation, usersInput, englishOrWelsh);
|
||||
checkAnswer(correctTranslation, usersInput, AssessmentGenerator.isEnglish);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
correctGuesses.setText("Correct Guesses: " + correctAnswer);
|
||||
incorrectGuesses.setText("Incorrect Guesses: " + wrongAnswer);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
do{
|
||||
chosenWord = (rand.nextInt(practiceList.size()));
|
||||
}while((numbersUsed.contains(chosenWord)) && numbersUsed.size() < practiceList.size());
|
||||
|
||||
numbersUsed.add(chosenWord);
|
||||
|
||||
if(numbersUsed.size() > practiceList.size()){
|
||||
wordToTranslate.setText("Test Complete");
|
||||
submitButton.setVisible(false);
|
||||
}
|
||||
|
||||
if(englishOrWelsh){
|
||||
wordToTranslate.setText(practiceList.get(chosenWord).getWelsh());
|
||||
}
|
||||
else{
|
||||
wordToTranslate.setText(practiceList.get(chosenWord).getEnglish());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package uk.ac.aber.cs22120.group20.selfassessment;
|
||||
|
||||
import uk.ac.aber.cs22120.group20.json.DictionaryEntry;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class TranslationQuestion extends Question {
|
||||
DictionaryEntry correctAnswer;
|
||||
|
||||
public TranslationQuestion(DictionaryEntry correctAnswer){
|
||||
this.correctAnswer = correctAnswer;
|
||||
}
|
||||
}
|
Reference in a new issue