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

Development: Add build config entity for programming exercises #8897

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
b5f1fd4
DB migration and changed domain entities
BBesrour Jun 28, 2024
378c563
MUST REVERT - fix errors
BBesrour Jun 28, 2024
73f1357
add ref to prog exercise
BBesrour Jun 28, 2024
34f605b
Merge branch 'refs/heads/develop' into feature/integrated-code-lifecy…
BBesrour Jul 7, 2024
2cadb58
order master.xml
BBesrour Jul 7, 2024
c9e2708
Merge branch 'develop' into feature/integrated-code-lifecycle/build-c…
BBesrour Jul 9, 2024
a5d0b97
adjust code
BBesrour Jul 11, 2024
5cb286d
adjust code
BBesrour Jul 11, 2024
f07c62a
save config
BBesrour Jul 14, 2024
d4fa2c9
save config
BBesrour Jul 14, 2024
6c6b795
adjust tests
BBesrour Jul 14, 2024
ba79002
TODO: remove personal comments
BBesrour Jul 15, 2024
c530462
TODO: remove personal comments
BBesrour Jul 16, 2024
e08743d
TODO: remove personal comments
BBesrour Jul 16, 2024
f33c52e
TODO: remove personal comments
BBesrour Jul 16, 2024
3287fed
TODO: remove personal comments
BBesrour Jul 16, 2024
53dd42b
TODO: remove personal comments
BBesrour Jul 17, 2024
354abd4
TODO: remove personal comments
BBesrour Jul 17, 2024
538aa9e
TODO: remove personal comments
BBesrour Jul 17, 2024
9a80dcd
TODO: remove personal comments
BBesrour Jul 17, 2024
f474828
TODO: remove personal comments
BBesrour Jul 17, 2024
93ea90f
TODO: remove personal comments
BBesrour Jul 18, 2024
cfe74b8
merge
BBesrour Jul 18, 2024
ac10113
merge
BBesrour Jul 18, 2024
e213422
merge
BBesrour Jul 18, 2024
0edbb48
merge
BBesrour Jul 18, 2024
0064a29
merge
BBesrour Jul 18, 2024
1c25d50
fix server tests
BBesrour Jul 20, 2024
81d8a92
adjust client code
BBesrour Jul 21, 2024
7184819
adjust code
BBesrour Jul 21, 2024
ab5f085
adjust client tests
BBesrour Jul 24, 2024
2f1c8b6
adjust client tests
BBesrour Jul 24, 2024
8da2ab5
adjust e2e tests
BBesrour Jul 25, 2024
474d58f
adjust client tests
BBesrour Jul 25, 2024
bef5693
fix e2e tests
BBesrour Jul 27, 2024
590ad7f
Merge branch 'refs/heads/develop' into feature/integrated-code-lifecy…
BBesrour Jul 27, 2024
0d5033a
fix build
BBesrour Jul 27, 2024
cf23175
update server code
BBesrour Jul 27, 2024
be38baa
update client code
BBesrour Jul 27, 2024
bfb7eb8
fix build
BBesrour Jul 27, 2024
d38ba92
fix tests
BBesrour Jul 27, 2024
7527103
Merge branch 'develop' into feature/integrated-code-lifecycle/build-c…
BBesrour Jul 27, 2024
8e8c18b
fix tests
BBesrour Jul 27, 2024
9e2f03f
fix liquibase migration
BBesrour Jul 28, 2024
ca83491
Merge branch 'refs/heads/develop' into feature/integrated-code-lifecy…
BBesrour Jul 28, 2024
8f3ecf2
feedback
BBesrour Jul 28, 2024
afc82a3
fix tests
BBesrour Jul 28, 2024
382966e
fetch buildconfig with participation
BBesrour Jul 29, 2024
5e8d8af
Add theia config to migration
iyannsch Jul 29, 2024
56b7592
Merge branch 'feature/integrated-code-lifecycle/build-config-instruct…
iyannsch Jul 29, 2024
99dad4e
Merge remote-tracking branch 'origin/feature/integrated-code-lifecycl…
BBesrour Jul 29, 2024
1faacfe
fetch buildconfig with participation
BBesrour Jul 29, 2024
fe9b7ff
remove unused field
BBesrour Jul 29, 2024
7615e33
fix checks
BBesrour Jul 29, 2024
7002318
fix checks
BBesrour Jul 29, 2024
f281f25
Merge branch 'develop' into feature/integrated-code-lifecycle/build-c…
BBesrour Jul 29, 2024
11c67f5
add default value
BBesrour Jul 29, 2024
4b59615
fix e2e. Verify if correct
BBesrour Jul 29, 2024
c1954f6
fix e2e. Verify if correct
BBesrour Jul 30, 2024
2239a09
fix e2e. Verify if correct
BBesrour Jul 30, 2024
1fc3ae9
fix e2e. Verify if correct
BBesrour Jul 30, 2024
bbcc6c0
fix e2e. Verify if correct
BBesrour Jul 30, 2024
20898ab
fix e2e. Verify if correct
BBesrour Jul 30, 2024
099362e
change nullable
BBesrour Jul 30, 2024
6446057
change nullable false in java
BBesrour Jul 30, 2024
52759ea
fix nullable error
BBesrour Jul 30, 2024
5744145
fix import exercise
BBesrour Jul 30, 2024
52bb37e
handle edge cases
BBesrour Jul 30, 2024
9bfa7d3
fix error when importing exercises
BBesrour Jul 30, 2024
1be59f6
fix error when importing exam
BBesrour Jul 30, 2024
950bfa4
feedback
BBesrour Jul 31, 2024
992d2b0
Merge branch 'develop' into feature/integrated-code-lifecycle/build-c…
BBesrour Jul 31, 2024
6f49676
fix issue when importing exercise from file.
BBesrour Aug 2, 2024
5e9962d
TO BE REVERTED
BBesrour Aug 3, 2024
65fa73c
Revert "TO BE REVERTED"
BBesrour Aug 3, 2024
8813f82
fix postgres migration not updating id sequence
BBesrour Aug 3, 2024
9d21586
Merge branch 'refs/heads/develop' into feature/integrated-code-lifecy…
BBesrour Aug 4, 2024
0bf1110
Merge branch 'develop' into feature/integrated-code-lifecycle/build-c…
BBesrour Aug 5, 2024
921443f
Merge branch 'develop' into feature/integrated-code-lifecycle/build-c…
BBesrour Aug 6, 2024
d87ef2e
Merge branch 'develop' into feature/integrated-code-lifecycle/build-c…
BBesrour Aug 7, 2024
f6634fa
new migration
BBesrour Aug 8, 2024
cbdc746
move buildplanaccesssecret
BBesrour Aug 8, 2024
0c9529d
move buildplanaccesssecret
BBesrour Aug 8, 2024
9d21baa
fix code
BBesrour Aug 8, 2024
e0c398b
fix tests
BBesrour Aug 8, 2024
3549f9b
fix style
BBesrour Aug 8, 2024
3eb2268
feedback
BBesrour Aug 10, 2024
37283cf
fix build
BBesrour Aug 10, 2024
886824b
fix build
BBesrour Aug 10, 2024
96c5a36
fix build
BBesrour Aug 10, 2024
b7b3fd3
fix build
BBesrour Aug 10, 2024
364d10a
Merge branch 'refs/heads/develop' into feature/integrated-code-lifecy…
BBesrour Aug 11, 2024
1543e67
fix tests
BBesrour Aug 11, 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
186 changes: 35 additions & 151 deletions src/main/java/de/tum/in/www1/artemis/domain/ProgrammingExercise.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import java.util.stream.Stream;

Expand All @@ -28,7 +27,6 @@
import jakarta.persistence.OneToOne;
import jakarta.persistence.OrderColumn;
import jakarta.persistence.SecondaryTable;
import jakarta.validation.constraints.Size;

import org.hibernate.Hibernate;
import org.slf4j.Logger;
Expand All @@ -37,8 +35,6 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;

import de.tum.in.www1.artemis.domain.enumeration.AssessmentType;
import de.tum.in.www1.artemis.domain.enumeration.BuildPlanType;
Expand All @@ -56,8 +52,6 @@
import de.tum.in.www1.artemis.domain.participation.TemplateProgrammingExerciseParticipation;
import de.tum.in.www1.artemis.domain.submissionpolicy.SubmissionPolicy;
import de.tum.in.www1.artemis.service.ExerciseDateService;
import de.tum.in.www1.artemis.service.connectors.aeolus.Windfile;
import de.tum.in.www1.artemis.service.connectors.vcs.AbstractVersionControlService;
import de.tum.in.www1.artemis.service.programming.ProgrammingLanguageFeature;
import de.tum.in.www1.artemis.web.rest.errors.BadRequestAlertException;

Expand Down Expand Up @@ -94,6 +88,9 @@ public String getType() {
@Column(name = "allow_offline_ide", table = "programming_exercise_details")
private Boolean allowOfflineIde;

@Column(name = "allow_online_ide", table = "programming_exercise_details", nullable = false)
private boolean allowOnlineIde = false;

@Column(name = "static_code_analysis_enabled", table = "programming_exercise_details")
private Boolean staticCodeAnalysisEnabled;

Expand All @@ -107,9 +104,6 @@ public String getType() {
@Column(name = "package_name")
private String packageName;

@Column(name = "sequential_test_runs")
private Boolean sequentialTestRuns;

@Column(name = "show_test_names_to_students", table = "programming_exercise_details")
private boolean showTestNamesToStudents;

Expand All @@ -124,11 +118,6 @@ public String getType() {
@Column(name = "project_key", table = "programming_exercise_details", nullable = false)
private String projectKey;

@Size(max = 36)
@Nullable
@Column(name = "build_plan_access_secret", table = "programming_exercise_details", length = 36)
private String buildPlanAccessSecret;

@OneToOne(cascade = CascadeType.REMOVE, orphanRemoval = true, fetch = FetchType.LAZY)
@JoinColumn(unique = true, name = "template_participation_id")
@JsonIgnoreProperties("programmingExercise")
Expand Down Expand Up @@ -164,27 +153,13 @@ public String getType() {
@OneToMany(mappedBy = "exercise", cascade = CascadeType.REMOVE, orphanRemoval = true, fetch = FetchType.LAZY)
private Set<ExerciseHint> exerciseHints = new HashSet<>();

@Column(name = "testwise_coverage_enabled", table = "programming_exercise_details")
private boolean testwiseCoverageEnabled;

@Column(name = "branch", table = "programming_exercise_details")
private String branch;

@Column(name = "release_tests_with_example_solution", table = "programming_exercise_details")
private boolean releaseTestsWithExampleSolution;
@Column(name = "release_tests_with_example_solution", table = "programming_exercise_details", nullable = false)
private boolean releaseTestsWithExampleSolution = false;

@Column(name = "build_plan_configuration", table = "programming_exercise_details", columnDefinition = "longtext")
private String buildPlanConfiguration;

@Column(name = "build_script", table = "programming_exercise_details", columnDefinition = "longtext")
private String buildScript;

/**
* This boolean flag determines whether the solution repository should be checked out during the build (additional to the student's submission).
* This is currently only supported for HASKELL and OCAML, thus the default value is false.
*/
@Column(name = "checkout_solution_repository", table = "programming_exercise_details", columnDefinition = "boolean default false")
private boolean checkoutSolutionRepository;
@OneToOne(cascade = CascadeType.REMOVE, orphanRemoval = true, fetch = FetchType.LAZY)
@JoinColumn(unique = true, name = "programming_exercise_build_config_id", table = "programming_exercise_details")
@JsonIgnoreProperties("programmingExercise")
private ProgrammingExerciseBuildConfig buildConfig;
BBesrour marked this conversation as resolved.
Show resolved Hide resolved

/**
* Convenience getter. The actual URL is stored in the {@link TemplateProgrammingExerciseParticipation}
Expand Down Expand Up @@ -298,6 +273,18 @@ public void setAllowOfflineIde(Boolean allowOfflineIde) {
this.allowOfflineIde = allowOfflineIde;
}

public boolean isAllowOnlineIde() {
return allowOnlineIde;
}

public void setAllowOnlineIde(boolean allowOnlineIde) {
this.allowOnlineIde = allowOnlineIde;
}
BBesrour marked this conversation as resolved.
Show resolved Hide resolved

public String getProjectKey() {
return this.projectKey;
}

public Boolean isStaticCodeAnalysisEnabled() {
return this.staticCodeAnalysisEnabled;
}
Expand All @@ -314,25 +301,6 @@ public void setMaxStaticCodeAnalysisPenalty(Integer maxStaticCodeAnalysisPenalty
this.maxStaticCodeAnalysisPenalty = maxStaticCodeAnalysisPenalty;
}

public String getProjectKey() {
return this.projectKey;
}

public void setBranch(String branch) {
this.branch = branch;
}

/**
* Getter for the stored default branch of the exercise.
* Use {@link AbstractVersionControlService#getOrRetrieveBranchOfExercise(ProgrammingExercise)} if you are not sure that the value was already set in the Artemis database
*
* @return the name of the default branch or null if not yet stored in Artemis
*/
@JsonIgnore
public String getBranch() {
return branch;
}

public void setReleaseTestsWithExampleSolution(boolean releaseTestsWithExampleSolution) {
this.releaseTestsWithExampleSolution = releaseTestsWithExampleSolution;
}
Expand Down Expand Up @@ -482,6 +450,14 @@ public void setSubmissionPolicy(SubmissionPolicy submissionPolicy) {
this.submissionPolicy = submissionPolicy;
}

public ProgrammingExerciseBuildConfig getBuildConfig() {
return buildConfig;
}

public void setBuildConfig(ProgrammingExerciseBuildConfig buildConfig) {
this.buildConfig = buildConfig;
}

// jhipster-needle-entity-add-getters-setters - Jhipster will add getters and setters here, do not remove

/**
Expand Down Expand Up @@ -606,15 +582,6 @@ public void addStaticCodeAnalysisCategory(final StaticCodeAnalysisCategory categ
staticCodeAnalysisCategories.add(category);
}

@JsonProperty("sequentialTestRuns")
public boolean hasSequentialTestRuns() {
return Objects.requireNonNullElse(sequentialTestRuns, false);
}

public void setSequentialTestRuns(Boolean sequentialTestRuns) {
this.sequentialTestRuns = sequentialTestRuns;
}

public Boolean getShowTestNamesToStudents() {
return showTestNamesToStudents;
}
Expand Down Expand Up @@ -657,14 +624,6 @@ public void setProjectType(@Nullable ProjectType projectType) {
this.projectType = projectType;
}

public Boolean isTestwiseCoverageEnabled() {
return testwiseCoverageEnabled;
}

public void setTestwiseCoverageEnabled(Boolean testwiseCoverageEnabled) {
this.testwiseCoverageEnabled = testwiseCoverageEnabled;
}

/**
* set all sensitive information to null, so no info with respect to the solution gets leaked to students through json
*/
Expand All @@ -675,8 +634,9 @@ public void filterSensitiveInformation() {
setTestRepositoryUri(null);
setTemplateBuildPlanId(null);
setSolutionBuildPlanId(null);
setBuildPlanConfiguration(null);
setBuildScript(null);
if (buildConfig != null && Hibernate.isInitialized(buildConfig)) {
buildConfig.filterSensitiveInformation();
}
super.filterSensitiveInformation();
}

Expand Down Expand Up @@ -761,16 +721,8 @@ private boolean checkForAssessedResult(Result result) {
public String toString() {
return "ProgrammingExercise{" + "id=" + getId() + ", templateRepositoryUri='" + getTemplateRepositoryUri() + "'" + ", solutionRepositoryUri='" + getSolutionRepositoryUri()
+ "'" + ", templateBuildPlanId='" + getTemplateBuildPlanId() + "'" + ", solutionBuildPlanId='" + getSolutionBuildPlanId() + "'" + ", allowOnlineEditor='"
+ isAllowOnlineEditor() + "'" + ", programmingLanguage='" + getProgrammingLanguage() + "'" + ", packageName='" + getPackageName() + "'" + ", testCasesChanged='"
+ testCasesChanged + "'" + "}";
}

public boolean getCheckoutSolutionRepository() {
return this.checkoutSolutionRepository;
}

public void setCheckoutSolutionRepository(boolean checkoutSolutionRepository) {
this.checkoutSolutionRepository = checkoutSolutionRepository;
+ isAllowOnlineEditor() + "'" + ", allowOnlineIde='" + isAllowOnlineIde() + "'" + ", programmingLanguage='" + getProgrammingLanguage() + "'" + ", packageName='"
+ getPackageName() + "'" + "'" + ", testCasesChanged='" + testCasesChanged + "'" + "}";
}

/**
Expand Down Expand Up @@ -812,7 +764,7 @@ public void validateStaticCodeAnalysisSettings(ProgrammingLanguageFeature progra
}

// Check that programming exercise doesn't have sequential test runs and static code analysis enabled
if (Boolean.TRUE.equals(isStaticCodeAnalysisEnabled()) && hasSequentialTestRuns()) {
if (Boolean.TRUE.equals(isStaticCodeAnalysisEnabled()) && getBuildConfig().hasSequentialTestRuns()) {
throw new BadRequestAlertException("The static code analysis with sequential test runs is not supported at the moment", "Exercise", "staticCodeAnalysisAndSequential");
}

Expand Down Expand Up @@ -867,19 +819,6 @@ public void setExerciseHints(Set<ExerciseHint> exerciseHints) {
this.exerciseHints = exerciseHints;
}

public boolean hasBuildPlanAccessSecretSet() {
return buildPlanAccessSecret != null && !buildPlanAccessSecret.isEmpty();
}

@Nullable
public String getBuildPlanAccessSecret() {
return buildPlanAccessSecret;
}

public void generateAndSetBuildPlanAccessSecret() {
buildPlanAccessSecret = UUID.randomUUID().toString();
}

/**
* {@inheritDoc}
*/
Expand All @@ -890,61 +829,6 @@ public void disconnectRelatedEntities() {
super.disconnectRelatedEntities();
}

/**
* Returns the JSON encoded custom build plan configuration
*
* @return the JSON encoded custom build plan configuration or null if the default one should be used
*/
public String getBuildPlanConfiguration() {
return buildPlanConfiguration;
}

/**
* Sets the JSON encoded custom build plan configuration
*
* @param buildPlanConfiguration the JSON encoded custom build plan configuration
*/
public void setBuildPlanConfiguration(String buildPlanConfiguration) {
this.buildPlanConfiguration = buildPlanConfiguration;
}

/**
* We store the build plan configuration as a JSON string in the database, as it is easier to handle than a complex object structure.
* This method parses the JSON string and returns a {@link Windfile} object.
*
* @return the {@link Windfile} object or null if the JSON string could not be parsed
*/
public Windfile getWindfile() {
if (buildPlanConfiguration == null) {
return null;
}
try {
return Windfile.deserialize(buildPlanConfiguration);
}
catch (JsonProcessingException e) {
log.error("Could not parse build plan configuration for programming exercise {}", this.getId(), e);
}
return null;
}

/**
* We store the bash script in the database
*
* @return the build script or null if the build script does not exist
*/
public String getBuildScript() {
return buildScript;
}

/**
* Update the build script
*
* @param buildScript the new build script for the programming exercise
*/
public void setBuildScript(String buildScript) {
this.buildScript = buildScript;
}

/**
* In course exercises students shall receive immediate feedback. {@link Visibility#ALWAYS}
* In Exams misconfiguration and leaking test results to students during an exam shall be prevented by the default setting. {@link Visibility#AFTER_DUE_DATE}
Expand Down
Loading
Loading