-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/exam-timeline
# Conflicts: # src/main/webapp/app/exam/manage/exam-management.route.ts
- Loading branch information
Showing
44 changed files
with
2,281 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/java/de/tum/in/www1/artemis/domain/quiz/QuizGroup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package de.tum.in.www1.artemis.domain.quiz; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.Table; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
|
||
import de.tum.in.www1.artemis.domain.DomainObject; | ||
|
||
@Entity | ||
@Table(name = "quiz_group") | ||
@JsonInclude(JsonInclude.Include.NON_EMPTY) | ||
public class QuizGroup extends DomainObject { | ||
|
||
@Column(name = "name") | ||
private String name; | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
@JsonIgnore | ||
public boolean isValid() { | ||
return getName() != null && !getName().isEmpty(); | ||
} | ||
} |
119 changes: 119 additions & 0 deletions
119
src/main/java/de/tum/in/www1/artemis/domain/quiz/QuizPool.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
package de.tum.in.www1.artemis.domain.quiz; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import javax.persistence.CascadeType; | ||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.OneToMany; | ||
import javax.persistence.OneToOne; | ||
import javax.persistence.Table; | ||
import javax.persistence.Transient; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.annotation.JsonView; | ||
|
||
import de.tum.in.www1.artemis.domain.DomainObject; | ||
import de.tum.in.www1.artemis.domain.exam.Exam; | ||
import de.tum.in.www1.artemis.domain.view.QuizView; | ||
|
||
@Entity | ||
@Table(name = "quiz_pool") | ||
@JsonInclude | ||
public class QuizPool extends DomainObject implements QuizConfiguration { | ||
|
||
@OneToOne | ||
@JoinColumn(name = "exam_id", referencedColumnName = "id") | ||
private Exam exam; | ||
|
||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) | ||
@JoinColumn(name = "quiz_pool_id", referencedColumnName = "id") | ||
private List<QuizQuestion> quizQuestions; | ||
|
||
@Column(name = "max_points") | ||
private int maxPoints; | ||
|
||
@Column(name = "randomize_question_order") | ||
@JsonView(QuizView.Before.class) | ||
private Boolean randomizeQuestionOrder = false; | ||
|
||
@Transient | ||
private List<QuizGroup> quizGroups; | ||
|
||
public QuizPool() { | ||
this.quizGroups = new ArrayList<>(); | ||
this.quizQuestions = new ArrayList<>(); | ||
} | ||
|
||
public void setExam(Exam exam) { | ||
this.exam = exam; | ||
} | ||
|
||
public Exam getExam() { | ||
return exam; | ||
} | ||
|
||
public int getMaxPoints() { | ||
return maxPoints; | ||
} | ||
|
||
public void setMaxPoints(int maxPoints) { | ||
this.maxPoints = maxPoints; | ||
} | ||
|
||
public Boolean getRandomizeQuestionOrder() { | ||
return randomizeQuestionOrder; | ||
} | ||
|
||
public void setRandomizeQuestionOrder(Boolean randomizeQuestionOrder) { | ||
this.randomizeQuestionOrder = randomizeQuestionOrder; | ||
} | ||
|
||
@Override | ||
public void setQuestionParent(QuizQuestion quizQuestion) { | ||
// Do nothing since the relationship between QuizPool and QuizQuestion is defined in QuizPool. | ||
} | ||
|
||
@Override | ||
public List<QuizQuestion> getQuizQuestions() { | ||
return this.quizQuestions; | ||
} | ||
|
||
public void setQuizQuestions(List<QuizQuestion> quizQuestions) { | ||
this.quizQuestions = quizQuestions; | ||
} | ||
|
||
@JsonProperty(value = "quizGroups", access = JsonProperty.Access.READ_ONLY) | ||
public List<QuizGroup> getQuizGroups() { | ||
return quizGroups; | ||
} | ||
|
||
@JsonProperty(value = "quizGroups", access = JsonProperty.Access.WRITE_ONLY) | ||
public void setQuizGroups(List<QuizGroup> quizGroups) { | ||
this.quizGroups = quizGroups; | ||
} | ||
|
||
/** | ||
* Check if all quiz groups and questions are valid | ||
* | ||
* @return true if all quiz groups and questions are valid | ||
*/ | ||
@JsonIgnore | ||
public boolean isValid() { | ||
for (QuizGroup quizGroup : getQuizGroups()) { | ||
if (!quizGroup.isValid()) { | ||
return false; | ||
} | ||
} | ||
for (QuizQuestion quizQuestion : getQuizQuestions()) { | ||
if (!quizQuestion.isValid()) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/main/java/de/tum/in/www1/artemis/repository/QuizGroupRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package de.tum.in.www1.artemis.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import de.tum.in.www1.artemis.domain.quiz.QuizGroup; | ||
|
||
/** | ||
* Spring Data JPA repository for the QuizGroup entity. | ||
*/ | ||
@SuppressWarnings("unused") | ||
@Repository | ||
public interface QuizGroupRepository extends JpaRepository<QuizGroup, Long> { | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/de/tum/in/www1/artemis/repository/QuizPoolRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package de.tum.in.www1.artemis.repository; | ||
|
||
import java.util.Optional; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import de.tum.in.www1.artemis.domain.quiz.QuizPool; | ||
|
||
/** | ||
* Spring Data JPA repository for the QuizPool entity. | ||
*/ | ||
@SuppressWarnings("unused") | ||
@Repository | ||
public interface QuizPoolRepository extends JpaRepository<QuizPool, Long> { | ||
|
||
@Query(""" | ||
SELECT qe | ||
FROM QuizPool qe | ||
JOIN qe.exam e | ||
LEFT JOIN FETCH qe.quizQuestions qeq | ||
LEFT JOIN FETCH qeq.quizQuestionStatistic | ||
WHERE e.id = :examId | ||
""") | ||
Optional<QuizPool> findWithEagerQuizQuestionsByExamId(Long examId); | ||
} |
Oops, something went wrong.