Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Learning paths: Allow instructors to include prerequisites at the start #8947

Merged
merged 20 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7061933
Refactor a lot to schedule prerequisites
JohannesStoehr Jul 2, 2024
595fb64
Fix tests
JohannesStoehr Jul 2, 2024
7e4b138
Fix more tests and fix prerequisite stuff
JohannesStoehr Jul 2, 2024
ac23a6c
Fix more tests
JohannesStoehr Jul 2, 2024
39f81c1
Add client test
JohannesStoehr Jul 2, 2024
1721df9
Fix client test and prerequisite utility
JohannesStoehr Jul 2, 2024
87fc6f3
Add server tests
JohannesStoehr Jul 2, 2024
4ee597c
Merge branch 'develop' into feature/learning-path/schedule-prerequisites
JohannesStoehr Jul 2, 2024
145717e
Merge branch 'refs/heads/develop' into feature/learning-path/schedule…
JohannesStoehr Jul 2, 2024
3cf635a
Fix server style
JohannesStoehr Jul 2, 2024
0bee493
Merge branch 'refs/heads/develop' into feature/learning-path/schedule…
JohannesStoehr Jul 3, 2024
54683ce
Patrik
JohannesStoehr Jul 3, 2024
0e5e0da
Fix reviews
JohannesStoehr Jul 4, 2024
c76b48f
Merge branch 'refs/heads/develop' into feature/learning-path/schedule…
JohannesStoehr Jul 5, 2024
eca6600
Merge branch 'develop' into feature/learning-path/schedule-prerequisites
JohannesStoehr Jul 5, 2024
35c2c6d
Merge branch 'develop' into feature/learning-path/schedule-prerequisites
MaximilianAnzinger Jul 8, 2024
28d3bc0
Merge branch 'refs/heads/develop' into feature/learning-path/schedule…
JohannesStoehr Jul 11, 2024
68fd051
Merge branch 'refs/heads/develop' into feature/learning-path/schedule…
JohannesStoehr Jul 12, 2024
f6117c0
Fix CourseCompetency vs. Competency
JohannesStoehr Jul 12, 2024
88f3314
Merge branch 'refs/heads/develop' into feature/learning-path/schedule…
JohannesStoehr Jul 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/main/java/de/tum/in/www1/artemis/domain/Exercise.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonView;

import de.tum.in.www1.artemis.domain.competency.Competency;
import de.tum.in.www1.artemis.domain.competency.CourseCompetency;
import de.tum.in.www1.artemis.domain.enumeration.ExerciseType;
import de.tum.in.www1.artemis.domain.enumeration.IncludedInOverallScore;
import de.tum.in.www1.artemis.domain.enumeration.InitializationState;
Expand Down Expand Up @@ -111,7 +111,7 @@ public abstract class Exercise extends BaseExercise implements LearningObject {
@JoinTable(name = "competency_exercise", joinColumns = @JoinColumn(name = "exercise_id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "competency_id", referencedColumnName = "id"))
@JsonIgnoreProperties({ "exercises", "course" })
@JsonView(QuizView.Before.class)
private Set<Competency> competencies = new HashSet<>();
private Set<CourseCompetency> competencies = new HashSet<>();

@ElementCollection(fetch = FetchType.LAZY)
@CollectionTable(name = "exercise_categories", joinColumns = @JoinColumn(name = "exercise_id"))
Expand Down Expand Up @@ -452,11 +452,11 @@ public void setPlagiarismDetectionConfig(PlagiarismDetectionConfig plagiarismDet
// jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove

@Override
public Set<Competency> getCompetencies() {
public Set<CourseCompetency> getCompetencies() {
return competencies;
}

public void setCompetencies(Set<Competency> competencies) {
public void setCompetencies(Set<CourseCompetency> competencies) {
this.competencies = competencies;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.Optional;
import java.util.Set;

import de.tum.in.www1.artemis.domain.competency.Competency;
import de.tum.in.www1.artemis.domain.competency.CourseCompetency;

public interface LearningObject {

Expand All @@ -18,5 +18,5 @@ public interface LearningObject {

Long getId();

Set<Competency> getCompetencies();
Set<CourseCompetency> getCompetencies();
}
Original file line number Diff line number Diff line change
@@ -1,143 +1,23 @@
package de.tum.in.www1.artemis.domain.competency;

import java.time.ZonedDateTime;
import java.util.HashSet;
import java.util.Set;

import jakarta.persistence.CascadeType;
import jakarta.persistence.DiscriminatorValue;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToMany;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.PrePersist;
import jakarta.persistence.PreUpdate;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import de.tum.in.www1.artemis.domain.Exercise;
import de.tum.in.www1.artemis.domain.lecture.ExerciseUnit;
import de.tum.in.www1.artemis.domain.lecture.LectureUnit;

@Entity
@DiscriminatorValue("C")
public class Competency extends CourseCompetency {

// TODO: move properties (linkedStandardizedCompetency, exercises, lectureUnits, userProgress, learningPaths) to CourseCompetency when refactoring
@ManyToOne
@JoinColumn(name = "linked_standardized_competency_id")
@JsonIgnoreProperties({ "competencies" })
private StandardizedCompetency linkedStandardizedCompetency;

@ManyToMany(mappedBy = "competencies")
@JsonIgnoreProperties({ "competencies", "course" })
private Set<Exercise> exercises = new HashSet<>();

@ManyToMany(mappedBy = "competencies")
@JsonIgnoreProperties("competencies")
private Set<LectureUnit> lectureUnits = new HashSet<>();

@OneToMany(mappedBy = "competency", fetch = FetchType.LAZY, cascade = CascadeType.REMOVE, orphanRemoval = true)
@JsonIgnoreProperties({ "user", "competency" })
private Set<CompetencyProgress> userProgress = new HashSet<>();

@ManyToMany(mappedBy = "competencies")
@JsonIgnoreProperties({ "competencies", "course" })
private Set<LearningPath> learningPaths = new HashSet<>();

@OneToMany(mappedBy = "competency", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
private Set<CompetencyJol> competencyJols = new HashSet<>();

public Competency() {
}

public Competency(String title, String description, ZonedDateTime softDueDate, Integer masteryThreshold, CompetencyTaxonomy taxonomy, boolean optional) {
super(title, description, softDueDate, masteryThreshold, taxonomy, optional);
}

public StandardizedCompetency getLinkedStandardizedCompetency() {
return linkedStandardizedCompetency;
}

public void setLinkedStandardizedCompetency(StandardizedCompetency linkedStandardizedCompetency) {
this.linkedStandardizedCompetency = linkedStandardizedCompetency;
}

public Set<Exercise> getExercises() {
return exercises;
}

public void setExercises(Set<Exercise> exercises) {
this.exercises = exercises;
}

public void addExercise(Exercise exercise) {
this.exercises.add(exercise);
exercise.getCompetencies().add(this);
}

public Set<LectureUnit> getLectureUnits() {
return lectureUnits;
}

public void setLectureUnits(Set<LectureUnit> lectureUnits) {
this.lectureUnits = lectureUnits;
}

/**
* Adds the lecture unit to the competency (bidirectional)
* Note: ExerciseUnits are not accepted, should be set via the connected exercise (see {@link #addExercise(Exercise)})
*
* @param lectureUnit The lecture unit to add
*/
public void addLectureUnit(LectureUnit lectureUnit) {
if (lectureUnit instanceof ExerciseUnit) {
// The competencies of ExerciseUnits are taken from the corresponding exercise
throw new IllegalArgumentException("ExerciseUnits can not be connected to competencies");
}
this.lectureUnits.add(lectureUnit);
lectureUnit.getCompetencies().add(this);
}

/**
* Removes the lecture unit from the competency (bidirectional)
* Note: ExerciseUnits are not accepted, should be set via the connected exercise
*
* @param lectureUnit The lecture unit to remove
*/
public void removeLectureUnit(LectureUnit lectureUnit) {
if (lectureUnit instanceof ExerciseUnit) {
// The competencies of ExerciseUnits are taken from the corresponding exercise
throw new IllegalArgumentException("ExerciseUnits can not be disconnected from competencies");
}
this.lectureUnits.remove(lectureUnit);
lectureUnit.getCompetencies().remove(this);
}

public Set<CompetencyProgress> getUserProgress() {
return userProgress;
}

public void setUserProgress(Set<CompetencyProgress> userProgress) {
this.userProgress = userProgress;
}

public Set<LearningPath> getLearningPaths() {
return learningPaths;
}

public void setLearningPaths(Set<LearningPath> learningPaths) {
this.learningPaths = learningPaths;
public Competency() {
}

/**
* Ensure that exercise units are connected to competencies through the corresponding exercise
*/
@PrePersist
@PreUpdate
public void prePersistOrUpdate() {
this.lectureUnits.removeIf(lectureUnit -> lectureUnit instanceof ExerciseUnit);
@Override
public String getType() {
return "competency";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class CompetencyJol extends DomainObject {

@ManyToOne
@JoinColumn(name = "competency_id", nullable = false)
private Competency competency;
private CourseCompetency competency;

@ManyToOne
@JoinColumn(name = "user_id", nullable = false)
Expand All @@ -44,11 +44,11 @@ public class CompetencyJol extends DomainObject {
@Column(name = "competency_confidence")
private double competencyConfidence;

public Competency getCompetency() {
public CourseCompetency getCompetency() {
return this.competency;
}

public void setCompetency(Competency competency) {
public void setCompetency(CourseCompetency competency) {
this.competency = competency;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class CompetencyProgress implements Serializable {
@ManyToOne
@MapsId("competencyId")
@JsonIgnore
private Competency competency;
private CourseCompetency competency;

@Column(name = "progress")
private Double progress;
Expand Down Expand Up @@ -81,11 +81,11 @@ public void setUser(User user) {
this.user = user;
}

public Competency getCompetency() {
public CourseCompetency getCompetency() {
return competency;
}

public void setCompetency(Competency competency) {
public void setCompetency(CourseCompetency competency) {
this.competency = competency;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,29 @@ public class CompetencyRelation extends DomainObject {

@ManyToOne
@JoinColumn(name = "tail_competency_id", nullable = false)
private Competency tailCompetency;
private CourseCompetency tailCompetency;

@ManyToOne
@JoinColumn(name = "head_competency_id", nullable = false)
private Competency headCompetency;
private CourseCompetency headCompetency;

@Column(name = "type", nullable = false)
@Enumerated(EnumType.ORDINAL)
private RelationType type;

public Competency getTailCompetency() {
public CourseCompetency getTailCompetency() {
return tailCompetency;
}

public void setTailCompetency(Competency tailCompetency) {
public void setTailCompetency(CourseCompetency tailCompetency) {
this.tailCompetency = tailCompetency;
}

public Competency getHeadCompetency() {
public CourseCompetency getHeadCompetency() {
return headCompetency;
}

public void setHeadCompetency(Competency headCompetency) {
public void setHeadCompetency(CourseCompetency headCompetency) {
this.headCompetency = headCompetency;
}

Expand Down
Loading
Loading