Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
e67abcffa2
11 changed files with 97 additions and 112 deletions
Binary file not shown.
Binary file not shown.
|
@ -4,6 +4,7 @@ module uk.ac.aber.cs22120.group20 {
|
|||
requires com.fasterxml.jackson.core;
|
||||
requires com.fasterxml.jackson.databind;
|
||||
requires junit;
|
||||
requires org.junit.jupiter.api;
|
||||
|
||||
|
||||
opens uk.ac.aber.cs22120.group20.javafx to javafx.fxml;
|
||||
|
@ -12,4 +13,5 @@ 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 junit;
|
||||
}
|
|
@ -84,7 +84,9 @@ public class DictionaryEntry {
|
|||
this.practiceWord = practiceWord;
|
||||
}
|
||||
|
||||
public boolean equals(DictionaryEntry entry) {
|
||||
return entry.getEnglish().equals(this.getEnglish()) && entry.getWelsh().equals(this.getWelsh()) && entry.getWordType().equals(this.getWordType());
|
||||
@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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ import java.util.*;
|
|||
public class MatchTheMeaningController extends Question implements Initializable{
|
||||
|
||||
|
||||
private ArrayList<DictionaryEntry> setOfQuestions=new ArrayList<>();
|
||||
private ArrayList<DictionaryEntry> answer =new ArrayList<>();
|
||||
private ArrayList<Integer> orderList = new ArrayList<>(Arrays.asList(0,1,2,3));
|
||||
private boolean isEnglish;
|
||||
|
||||
|
@ -86,7 +86,7 @@ public class MatchTheMeaningController extends Question implements Initializable
|
|||
*/
|
||||
private void getQuestions(){
|
||||
|
||||
setOfQuestions.addAll(AssessmentGenerator.generateWordMatch());
|
||||
answer.addAll(AssessmentGenerator.generateWordMatch());
|
||||
|
||||
}
|
||||
|
||||
|
@ -147,12 +147,12 @@ public class MatchTheMeaningController extends Question implements Initializable
|
|||
listOfAnswers.add(LeftWord4.getText());
|
||||
}
|
||||
|
||||
checkAnswer(setOfQuestions,listOfAnswers,isEnglish);
|
||||
checkAnswer(answer,listOfAnswers,isEnglish);
|
||||
|
||||
CorrectAnswer.setText(Integer.toString(correctAnswers));
|
||||
WrongAnswer.setText(Integer.toString(wrongAnswers));
|
||||
|
||||
setOfQuestions.clear();
|
||||
answer.clear();
|
||||
this.prepare();
|
||||
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ public class MatchTheMeaningController extends Question implements Initializable
|
|||
*/
|
||||
private void prepare(){
|
||||
getQuestions();
|
||||
setWords(setOfQuestions,orderList);
|
||||
setWords(answer,orderList);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -35,11 +35,11 @@ import java.util.*;
|
|||
public class SixMeaningsController extends TranslationController implements Initializable {
|
||||
|
||||
private Random rand = new Random();
|
||||
private LinkedList<DictionaryEntry> wordSet = new LinkedList<>();
|
||||
private ArrayList<DictionaryEntry> wordSet = new ArrayList<>();
|
||||
private ArrayList<DictionaryEntry> tamp = new ArrayList<>();
|
||||
private ArrayList<Integer> orderList = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5));
|
||||
private int correct = 0;
|
||||
private int incorrect = 0;
|
||||
private String wordCounterpart;
|
||||
private boolean isEnglish = AssessmentGenerator.isEnglish;
|
||||
|
||||
|
||||
@FXML
|
||||
|
@ -70,126 +70,98 @@ public class SixMeaningsController extends TranslationController implements Init
|
|||
private Text possibleAnswer6;
|
||||
|
||||
@FXML
|
||||
void temp(MouseEvent event) {
|
||||
|
||||
void answer1(MouseEvent event) {
|
||||
wordCounterpart = possibleAnswer1.getText();
|
||||
checkAnswers();
|
||||
}
|
||||
@FXML
|
||||
void answer2(MouseEvent event) {
|
||||
wordCounterpart = possibleAnswer2.getText();
|
||||
checkAnswers();
|
||||
}
|
||||
@FXML
|
||||
void answer3(MouseEvent event) {
|
||||
wordCounterpart = possibleAnswer3.getText();
|
||||
checkAnswers();
|
||||
}
|
||||
@FXML
|
||||
void answer4(MouseEvent event) {
|
||||
wordCounterpart = possibleAnswer4.getText();
|
||||
checkAnswers();
|
||||
}
|
||||
@FXML
|
||||
void answer5(MouseEvent event) {
|
||||
wordCounterpart = possibleAnswer5.getText();
|
||||
checkAnswers();
|
||||
}
|
||||
@FXML
|
||||
void answer6(MouseEvent event) {
|
||||
wordCounterpart = possibleAnswer6.getText();
|
||||
checkAnswers();
|
||||
}
|
||||
|
||||
|
||||
private void getWords(LinkedList<DictionaryEntry> practiceList) {
|
||||
boolean isDuplicate = false;
|
||||
do {
|
||||
int word = rand.nextInt(practiceList.size() - 1);
|
||||
DictionaryEntry chosenWord = practiceList.get(word);
|
||||
private void getWords() {
|
||||
|
||||
if (wordSet.size() >= 1) {
|
||||
|
||||
for (DictionaryEntry setOfQuestion : wordSet) {
|
||||
|
||||
if (setOfQuestion.equals(chosenWord)) {
|
||||
isDuplicate = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//If duplicate wasn't found add entry to the list
|
||||
if (!isDuplicate) {
|
||||
wordSet.add(chosenWord);
|
||||
}
|
||||
|
||||
//... otherwise, add entry to the
|
||||
} else {
|
||||
wordSet.add(chosenWord);
|
||||
}
|
||||
|
||||
isDuplicate = false;
|
||||
|
||||
} while (wordSet.size() < 6);
|
||||
wordSet = AssessmentGenerator.generateSixMeanings();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void setWordsE(LinkedList<DictionaryEntry> questions, ArrayList<Integer> orderList) {
|
||||
//WelshWord1 Is the question word and as a result is always right.
|
||||
wordToTranslate.setText(questions.get(0).getWelsh());
|
||||
//This stores the correct answer for the english word.
|
||||
wordCounterpart = questions.get(0).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());
|
||||
|
||||
Collections.shuffle(orderList); //I know that this does not belong here it was moved here for debug purposes. It lives five lines up.
|
||||
}
|
||||
private void setWords(boolean isEnglish){
|
||||
if(isEnglish){
|
||||
//WelshWord1 Is the question word and as a result is always right.
|
||||
wordToTranslate.setText(questions.get(0).getEnglish());
|
||||
//This stores the correct answer for the english word.
|
||||
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());
|
||||
|
||||
private void setWordsW(LinkedList<DictionaryEntry> questions, ArrayList<Integer> orderList) {
|
||||
//WelshWord1 Is the question word and as a result is always right.
|
||||
wordToTranslate.setText(questions.get(0).getEnglish());
|
||||
//This stores the correct answer for the english word.
|
||||
wordCounterpart = questions.get(0).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());
|
||||
Collections.shuffle(orderList); //I know that this does not belong here it was moved here for debug purposes. It lives five lines up.
|
||||
}else {
|
||||
//WelshWord1 Is the question word and as a result is always right.
|
||||
wordToTranslate.setText(questions.get(0).getWelsh());
|
||||
//This stores the correct answer for the english word.
|
||||
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());
|
||||
|
||||
Collections.shuffle(orderList); //I know that this does not belong here it was moved here for debug purposes. It lives five lines up.
|
||||
}
|
||||
|
||||
Collections.shuffle(orderList); //I know that this does not belong here it was moved here for debug purposes. It lives five lines up.
|
||||
}
|
||||
|
||||
|
||||
public void checkAnswers() {
|
||||
String option1 = possibleAnswer1.toString();
|
||||
String option2 = possibleAnswer2.toString();
|
||||
String option3 = possibleAnswer3.toString();
|
||||
String option4 = possibleAnswer4.toString();
|
||||
String option5 = possibleAnswer5.toString();
|
||||
String option6 = possibleAnswer6.toString();
|
||||
|
||||
if (option1 == wordCounterpart) {
|
||||
correct++;
|
||||
} else incorrect++;
|
||||
private void checkAnswers() {
|
||||
|
||||
if (option2 == wordCounterpart) {
|
||||
correct++;
|
||||
} else incorrect++;
|
||||
ArrayList<String> answer = new ArrayList<>();
|
||||
|
||||
if (option3 == wordCounterpart) {
|
||||
correct++;
|
||||
} else incorrect++;
|
||||
answer.add(wordCounterpart);
|
||||
|
||||
if (option4 == wordCounterpart) {
|
||||
correct++;
|
||||
} else incorrect++;
|
||||
checkAnswer(wordSet,answer,isEnglish);
|
||||
|
||||
if (option5 == wordCounterpart) {
|
||||
correct++;
|
||||
} else incorrect++;
|
||||
correctAnswer.setText(Integer.toString(Question.correctAnswers));
|
||||
|
||||
if (option6 == wordCounterpart) {
|
||||
correct++;
|
||||
} else incorrect++;
|
||||
|
||||
correctAnswer.setText(Integer.toString(correct));
|
||||
|
||||
wrongAnswer.setText(Integer.toString(incorrect));
|
||||
wrongAnswer.setText(Integer.toString(Question.wrongAnswers));
|
||||
|
||||
wordSet.clear();
|
||||
this.prepare();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void prepare() {
|
||||
getWords(Application.dictionary);
|
||||
getWords();
|
||||
Random rd = new Random();
|
||||
System.out.println(rd.nextBoolean());
|
||||
if (rd.nextBoolean() == true) {
|
||||
setWordsE(wordSet, orderList);
|
||||
} else setWordsW(wordSet, orderList);
|
||||
setWords(AssessmentGenerator.isEnglish);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,11 +2,15 @@ package uk.ac.aber.cs22120.group20.selfassessment;
|
|||
|
||||
import uk.ac.aber.cs22120.group20.json.DictionaryEntry;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class SixMeaningsQuestion extends Question{
|
||||
private DictionaryEntry correctAnswer;
|
||||
private LinkedList<DictionaryEntry> dictionary;
|
||||
|
||||
private SixMeaningsQuestion(DictionaryEntry correctAnswer) {
|
||||
public SixMeaningsQuestion(DictionaryEntry correctAnswer, LinkedList<DictionaryEntry> dictionary) {
|
||||
this.correctAnswer = correctAnswer;
|
||||
this.dictionary = dictionary;
|
||||
}
|
||||
|
||||
public DictionaryEntry getCorrectAnswer() {
|
||||
|
|
|
@ -18,12 +18,12 @@ import uk.ac.aber.cs22120.group20.javafx.Application;
|
|||
* Controller for the translationTest fxml file.
|
||||
*
|
||||
* @author Brad Corbett brc9
|
||||
* @version 0.9
|
||||
* @version 0.1
|
||||
*
|
||||
*/
|
||||
public class TranslationController extends Question {
|
||||
private ArrayList<DictionaryEntry> practiceList = new ArrayList<>();
|
||||
public static DictionaryEntry practiceWord = new DictionaryEntry();
|
||||
public static DictionaryEntry answer = new DictionaryEntry();
|
||||
|
||||
/**
|
||||
* Represents the word that will be randomly chosen from the practiceList.
|
||||
|
@ -67,10 +67,10 @@ public class TranslationController extends Question {
|
|||
|
||||
|
||||
if(AssessmentGenerator.isEnglish){
|
||||
wordToTranslate.setText(practiceWord.getWelsh());
|
||||
wordToTranslate.setText(answer.getWelsh());
|
||||
}
|
||||
else{
|
||||
wordToTranslate.setText(practiceWord.getEnglish());
|
||||
wordToTranslate.setText(answer.getEnglish());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ public class TranslationController extends Question {
|
|||
usersInput.add(translationBox.getText());
|
||||
|
||||
ArrayList<DictionaryEntry> correctTranslation = new ArrayList<>();
|
||||
correctTranslation.add(practiceList.get(chosenWord));
|
||||
correctTranslation.add(answer);
|
||||
|
||||
checkAnswer(correctTranslation, usersInput, AssessmentGenerator.isEnglish);
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class FlashcardControllerTest {
|
||||
|
||||
}
|
|
@ -23,17 +23,17 @@
|
|||
<Font name="System Bold" size="25.0"/>
|
||||
</font>
|
||||
</Label>
|
||||
<Text fx:id="possibleAnswer1" layoutX="61.0" layoutY="176.0" onMouseClicked="#temp" strokeType="OUTSIDE"
|
||||
<Text fx:id="possibleAnswer1" layoutX="61.0" layoutY="176.0" onMouseClicked="#answer1" strokeType="OUTSIDE"
|
||||
strokeWidth="0.0" text="English Word 1"/>
|
||||
<Text fx:id="possibleAnswer2" layoutX="260.0" layoutY="175.0" onMouseClicked="#temp"
|
||||
<Text fx:id="possibleAnswer2" layoutX="260.0" layoutY="175.0" onMouseClicked="#answer2"
|
||||
strokeType="OUTSIDE" strokeWidth="0.0" text="English Word 2"/>
|
||||
<Text fx:id="possibleAnswer3" layoutX="472.0" layoutY="175.0" onMouseClicked="#temp"
|
||||
<Text fx:id="possibleAnswer3" layoutX="472.0" layoutY="175.0" onMouseClicked="#answer3"
|
||||
strokeType="OUTSIDE" strokeWidth="0.0" text="English Word 3"/>
|
||||
<Text fx:id="possibleAnswer4" layoutX="61.0" layoutY="297.0" onMouseClicked="#temp" strokeType="OUTSIDE"
|
||||
<Text fx:id="possibleAnswer4" layoutX="61.0" layoutY="297.0" onMouseClicked="#answer4" strokeType="OUTSIDE"
|
||||
strokeWidth="0.0" text="English Word 4"/>
|
||||
<Text fx:id="possibleAnswer5" layoutX="260.0" layoutY="297.0" onMouseClicked="#temp"
|
||||
<Text fx:id="possibleAnswer5" layoutX="260.0" layoutY="297.0" onMouseClicked="#answer5"
|
||||
strokeType="OUTSIDE" strokeWidth="0.0" text="English Word 5"/>
|
||||
<Text fx:id="possibleAnswer6" layoutX="472.0" layoutY="297.0" onMouseClicked="#temp"
|
||||
<Text fx:id="possibleAnswer6" layoutX="472.0" layoutY="297.0" onMouseClicked="#answer6"
|
||||
strokeType="OUTSIDE" strokeWidth="0.0" text="English Word 6"/>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
|
|
Reference in a new issue