Skip to content

Commit

Permalink
Merge branch 'develop' into feature/exam-timeline
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/webapp/app/exam/manage/exam-management.route.ts
  • Loading branch information
dependabot-test committed Oct 18, 2023
2 parents 419ff5a + f259364 commit 0d50267
Show file tree
Hide file tree
Showing 44 changed files with 2,281 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ plugins {
}

group = "de.tum.in.www1.artemis"
version = "6.6.1"
version = "6.6.2"
description = "Interactive Learning with Individual Feedback"

sourceCompatibility=17
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "artemis",
"version": "6.6.1",
"version": "6.6.2",
"description": "Interactive Learning with Individual Feedback",
"private": true,
"license": "MIT",
Expand Down
32 changes: 32 additions & 0 deletions src/main/java/de/tum/in/www1/artemis/domain/quiz/QuizGroup.java
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 src/main/java/de/tum/in/www1/artemis/domain/quiz/QuizPool.java
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;
}
}
25 changes: 25 additions & 0 deletions src/main/java/de/tum/in/www1/artemis/domain/quiz/QuizQuestion.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ public abstract class QuizQuestion extends DomainObject {
@JsonView(QuizView.Before.class)
private Boolean invalid = false;

@Column(name = "quiz_group_id")
@JsonView(QuizView.Before.class)
private Long quizGroupId;

@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY, orphanRemoval = true)
@JoinColumn(unique = true)
private QuizQuestionStatistic quizQuestionStatistic;
Expand All @@ -73,6 +77,9 @@ public abstract class QuizQuestion extends DomainObject {
@JsonIgnore
private QuizExercise exercise;

@Transient
private QuizGroup quizGroup;

public String getTitle() {
return title;
}
Expand Down Expand Up @@ -168,6 +175,24 @@ public void setExercise(QuizExercise quizExercise) {
this.exercise = quizExercise;
}

public Long getQuizGroupId() {
return quizGroupId;
}

public void setQuizGroupId(Long quizGroupId) {
this.quizGroupId = quizGroupId;
}

@JsonProperty(value = "quizGroup", access = JsonProperty.Access.READ_ONLY)
public QuizGroup getQuizGroup() {
return quizGroup;
}

@JsonProperty(value = "quizGroup", access = JsonProperty.Access.WRITE_ONLY)
public void setQuizGroup(QuizGroup quizGroup) {
this.quizGroup = quizGroup;
}

/**
* Calculate the score for the given answer
*
Expand Down
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> {
}
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);
}
Loading

0 comments on commit 0d50267

Please sign in to comment.