Skip to content

Commit

Permalink
Added the language and type to the questions
Browse files Browse the repository at this point in the history
  • Loading branch information
UO289845 committed Apr 1, 2024
1 parent d73218e commit 52f85dc
Show file tree
Hide file tree
Showing 7 changed files with 623 additions and 7 deletions.
610 changes: 609 additions & 1 deletion package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ public abstract class AbstractGenerator {
public static Map<String, ItemDocumentImpl> alreadyProcessedEntities = new HashMap<>();

private String propertyId = "";
private QuestionType type;

private static final String MESSAGES_PATH = "messages";
public AbstractGenerator(String propertyId) {
this.propertyId = propertyId;
this.type = type;
}

/**
Expand Down Expand Up @@ -71,7 +73,7 @@ public Question generate(String id) {
answers.add(0, rightAnswer);
//create and return the question

return new Question(question, answers);
return new Question(question, answers, language, type);
}

protected String getName(Map<String, MonolingualTextValue> names) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class CapitalGenerator extends RightAnswerIsEntity {
private final static String PROPERTY = "P36";

public CapitalGenerator(){
super(PROPERTY);
super(PROPERTY, QuestionType.CAPITAL);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class LanguageGenerator extends RightAnswerIsEntity {
private final static String PROPERTY = "P37";

public LanguageGenerator(){
super(PROPERTY);
super(PROPERTY, QuestionType.LANGUAGE);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class PopulationGenerator extends AbstractGenerator {
private final static String PROPERTY = "P1082";

public PopulationGenerator(){
super(PROPERTY);
super(PROPERTY, QuestionType.POPULATION);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class SizeGenerator extends AbstractGenerator {
private final static String PROPERTY = "P2046";

public SizeGenerator(){
super(PROPERTY);
super(PROPERTY, QuestionType.SIZE);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ public class Question {
private String question;
private List<String> answers;
private int number = -1;
private String language;
private QuestionType type;

public Question(String question, List<String> answers){
public Question(String question, List<String> answers, String language, QuestionType type){
this.question = question;
this.answers = new ArrayList<>(answers);
this.language = language;
this.type = type;
}

public Question() {
Expand Down Expand Up @@ -50,6 +54,8 @@ public JSONObject getJSON() {
for(String s : answers)
json.accumulate("answers", s);
if(number != -1) json.accumulate("number", number); //Para que los tests pasen
json.accumulate("language", language);
json.accumulate("type", type);
return json;
}

Expand Down

0 comments on commit 52f85dc

Please sign in to comment.