Skip to content

Commit

Permalink
Feature/short-answer-quizzes
Browse files Browse the repository at this point in the history
Implemented a new 3rd question type Short Answer Quizzes with a first work in progress prototype.
Their use is still limited:
- Explanations and Hints are missing
- Limitations in the combination of answer spots and answer options in more complex short answer questions
- The visual mode for the creation is missing
- Re-evaluation is not possible at the moment
- Further code improvements and code cleanup is needed
  • Loading branch information
fde312 authored and Stephan Krusche committed Feb 3, 2019
1 parent 007523e commit 5f11a17
Show file tree
Hide file tree
Showing 56 changed files with 3,404 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ public JCacheManagerCustomizer cacheManagerCustomizer() {
cm.createCache(de.tum.in.www1.artemis.domain.ShortAnswerSubmittedAnswer.class.getName() + ".submittedTexts", jcacheConfiguration);
cm.createCache(de.tum.in.www1.artemis.domain.ShortAnswerSubmittedText.class.getName(), jcacheConfiguration);
cm.createCache(de.tum.in.www1.artemis.domain.ShortAnswerMapping.class.getName(), jcacheConfiguration);
cm.createCache(de.tum.in.www1.artemis.domain.ShortAnswerSpot.class.getName() + ".mappings", jcacheConfiguration);
cm.createCache(de.tum.in.www1.artemis.domain.ShortAnswerSolution.class.getName() + ".mappings", jcacheConfiguration);
cm.createCache(de.tum.in.www1.artemis.domain.Complaint.class.getName(), jcacheConfiguration);
cm.createCache(de.tum.in.www1.artemis.domain.ComplaintResponse.class.getName(), jcacheConfiguration);
cm.createCache(de.tum.in.www1.artemis.domain.TutorParticipation.class.getName(), jcacheConfiguration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,7 @@ public DropLocation findDropLocationById (Long dropLocationId) {
*/
public void undoUnallowedChanges (Question originalQuestion) {

if (originalQuestion != null
&& originalQuestion instanceof DragAndDropQuestion) {
if (originalQuestion instanceof DragAndDropQuestion) {
DragAndDropQuestion dndOriginalQuestion = (DragAndDropQuestion) originalQuestion;
//undo unallowed dragItemChanges
undoUnallowedDragItemChanges(dndOriginalQuestion);
Expand Down Expand Up @@ -428,7 +427,7 @@ private void undoUnallowedDropLocationChanges (DragAndDropQuestion originalQuest
* @return a boolean which is true if the dragItem and dropLocation-changes make an update necessary and false if not
*/
public boolean isUpdateOfResultsAndStatisticsNecessary(Question originalQuestion) {
if (originalQuestion != null && originalQuestion instanceof DragAndDropQuestion){
if (originalQuestion instanceof DragAndDropQuestion){
DragAndDropQuestion dndOriginalQuestion = (DragAndDropQuestion) originalQuestion;
return checkDragItemsIfRecalculationIsNecessary(dndOriginalQuestion) ||
checkDropLocationsIfRecalculationIsNecessary(dndOriginalQuestion) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@ public AnswerOption findAnswerOptionById (Long answerOptionId) {
*/
public void undoUnallowedChanges (Question originalQuestion) {

if (originalQuestion != null
&& originalQuestion instanceof MultipleChoiceQuestion) {
if (originalQuestion instanceof MultipleChoiceQuestion) {
MultipleChoiceQuestion mcOriginalQuestion = (MultipleChoiceQuestion) originalQuestion;
undoUnallowedAnswerChanges(mcOriginalQuestion);
}
Expand Down Expand Up @@ -196,7 +195,7 @@ private void undoUnallowedAnswerChanges (MultipleChoiceQuestion originalQuestion
* @return a boolean which is true if the answer-changes make an update necessary and false if not
*/
public boolean isUpdateOfResultsAndStatisticsNecessary(Question originalQuestion) {
if (originalQuestion != null && originalQuestion instanceof MultipleChoiceQuestion){
if (originalQuestion instanceof MultipleChoiceQuestion){
MultipleChoiceQuestion mcOriginalQuestion = (MultipleChoiceQuestion) originalQuestion;
return checkAnswersIfRecalculationIsNecessary(mcOriginalQuestion);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

@JsonSubTypes({
@JsonSubTypes.Type(value=MultipleChoiceQuestionStatistic.class, name="multiple-choice"),
@JsonSubTypes.Type(value=DragAndDropQuestionStatistic.class, name="drag-and-drop")
@JsonSubTypes.Type(value=DragAndDropQuestionStatistic.class, name="drag-and-drop"),
@JsonSubTypes.Type(value=ShortAnswerQuestionStatistic.class, name="short-answer")
})
public abstract class QuestionStatistic extends Statistic implements Serializable {

Expand Down
29 changes: 29 additions & 0 deletions src/main/java/de/tum/in/www1/artemis/domain/QuizExercise.java
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,35 @@ public void reconnectJSONIgnoreAttributes() {
}
}
}
if (question instanceof ShortAnswerQuestion) {
ShortAnswerQuestion shortAnswerQuestion = (ShortAnswerQuestion) question;
ShortAnswerQuestionStatistic shortAnswerStatistic = (ShortAnswerQuestionStatistic) shortAnswerQuestion.getQuestionStatistic();
// reconnect spots
for (ShortAnswerSpot spot : shortAnswerQuestion.getSpots()) {
if (spot.getId() != null) {
spot.setQuestion(shortAnswerQuestion);
}
}
// reconnect solutions
for (ShortAnswerSolution solution : shortAnswerQuestion.getSolutions()) {
if (solution.getId() != null) {
solution.setQuestion(shortAnswerQuestion);
}
}
// reconnect correctMappings
for (ShortAnswerMapping mapping : shortAnswerQuestion.getCorrectMappings()) {
if (mapping.getId() != null) {
mapping.setQuestion(shortAnswerQuestion);
}
}
//reconnect spotCounters
for (ShortAnswerSpotCounter shortAnswerSpotCounter : shortAnswerStatistic.getShortAnswerSpotCounters()) {
if (shortAnswerSpotCounter.getId() != null) {
shortAnswerSpotCounter.setShortAnswerQuestionStatistic(shortAnswerStatistic);
shortAnswerSpotCounter.getSpot().setQuestion(shortAnswerQuestion);
}
}
}
}
}
//reconnect quizPointStatistic
Expand Down
Loading

0 comments on commit 5f11a17

Please sign in to comment.