forked from sakaiproject/sakai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
S2U-35 Lessons: View items based on grade - MASTER (sakaiproject#12243)
- Loading branch information
Showing
58 changed files
with
2,777 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?xml version="1.0"?> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.sakaiproject.conditions</groupId> | ||
<artifactId>sakai-conditions</artifactId> | ||
<version>24-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<name>sakai-conditions-api</name> | ||
<groupId>org.sakaiproject.conditions</groupId> | ||
<artifactId>sakai-conditions-api</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<properties> | ||
<deploy.target>shared</deploy.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-annotations</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.hibernate</groupId> | ||
<artifactId>hibernate-core</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.sakaiproject.kernel</groupId> | ||
<artifactId>sakai-kernel-api</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<resources> | ||
<resource> | ||
<directory>${basedir}/src/resources</directory> | ||
<includes> | ||
<include>**/*.properties</include> | ||
<include>**/*.metaprops</include> | ||
<include>**/*.xml</include> | ||
</includes> | ||
</resource> | ||
<resource> | ||
<directory>${basedir}/src/java</directory> | ||
<includes> | ||
<include>**/*.properties</include> | ||
</includes> | ||
</resource> | ||
</resources> | ||
</build> | ||
</project> |
24 changes: 24 additions & 0 deletions
24
conditions/api/src/java/org/sakaiproject/condition/api/ConditionEvaluator.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,24 @@ | ||
/** | ||
* Copyright (c) 2023 The Apereo Foundation | ||
* | ||
* Licensed under the Educational Community License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://opensource.org/licenses/ecl2 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.sakaiproject.condition.api; | ||
|
||
import org.sakaiproject.condition.api.model.Condition; | ||
|
||
public interface ConditionEvaluator { | ||
|
||
|
||
public boolean evaluateCondition(Condition condition, String userId); | ||
} |
51 changes: 51 additions & 0 deletions
51
conditions/api/src/java/org/sakaiproject/condition/api/ConditionService.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,51 @@ | ||
/** | ||
* Copyright (c) 2023 The Apereo Foundation | ||
* | ||
* Licensed under the Educational Community License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://opensource.org/licenses/ecl2 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.sakaiproject.condition.api; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import org.sakaiproject.condition.api.model.Condition; | ||
|
||
public interface ConditionService { | ||
|
||
|
||
public static final String CONDITIONS_TOOL_ID = "sakai.conditions"; | ||
|
||
// Permission to create, update and delete a condition | ||
public static final String PERMISSION_UPDATE_CONDITION = "conditions.update.condition"; | ||
|
||
|
||
public void init(); | ||
|
||
public Condition getCondition(String conditionId); | ||
|
||
public List<Condition> getConditionsForSite(String siteId); | ||
|
||
public List<Condition> getConditionsForItem(String siteId, String toolId, String itemId); | ||
|
||
public Optional<Condition> getRootConditionForItem(String siteId, String toolId, String itemId); | ||
|
||
public Condition saveCondition(Condition condition); | ||
|
||
public boolean deleteCondition(String conditionId); | ||
|
||
public boolean evaluateCondition(Condition condition, String userId); | ||
|
||
public boolean isConditionUsed(Condition condition); | ||
|
||
public boolean isToolIdSupported(String toolId); | ||
} |
24 changes: 24 additions & 0 deletions
24
...ons/api/src/java/org/sakaiproject/condition/api/exception/UnsupportedToolIdException.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,24 @@ | ||
/** | ||
* Copyright (c) 2023 The Apereo Foundation | ||
* | ||
* Licensed under the Educational Community License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://opensource.org/licenses/ecl2 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.sakaiproject.condition.api.exception; | ||
|
||
public class UnsupportedToolIdException extends RuntimeException { | ||
|
||
|
||
public UnsupportedToolIdException(String toolId) { | ||
super(String.format("No condition evaluator available for tool with id [%s]", toolId)); | ||
} | ||
} |
119 changes: 119 additions & 0 deletions
119
conditions/api/src/java/org/sakaiproject/condition/api/model/Condition.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 @@ | ||
/** | ||
* Copyright (c) 2023 The Apereo Foundation | ||
* | ||
* Licensed under the Educational Community License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://opensource.org/licenses/ecl2 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.sakaiproject.condition.api.model; | ||
|
||
import java.util.Arrays; | ||
import java.util.Set; | ||
|
||
import javax.persistence.CascadeType; | ||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.EnumType; | ||
import javax.persistence.Enumerated; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.Id; | ||
import javax.persistence.Index; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.JoinTable; | ||
import javax.persistence.ManyToMany; | ||
import javax.persistence.Table; | ||
|
||
import org.hibernate.annotations.GenericGenerator; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
import lombok.NonNull; | ||
import lombok.ToString; | ||
|
||
@Entity | ||
@Table(name = "COND_CONDITION", | ||
indexes = { @Index(name = "IDX_CONDITION_SITE_ID", columnList = "SITE_ID") }) | ||
@Data | ||
@Builder(toBuilder = true) | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@EqualsAndHashCode(exclude = { "subConditions", "parentConditions" }) | ||
public class Condition { | ||
|
||
|
||
@Id | ||
@Column(name = "ID", nullable = false, length = 36) | ||
@GeneratedValue(generator = "uuid") | ||
@GenericGenerator(name = "uuid", strategy = "uuid2") | ||
private String id; | ||
|
||
@NonNull | ||
@Column(name = "TYPE", nullable = false) | ||
@Enumerated(EnumType.STRING) | ||
private ConditionType type; | ||
|
||
@Column(name = "OPERATOR", nullable = true) | ||
@Enumerated(EnumType.STRING) | ||
private ConditionOperator operator; | ||
|
||
@Column(name = "ARGUMENT", nullable = true) | ||
private String argument; | ||
|
||
@Column(name = "SITE_ID", nullable = false) | ||
private String siteId; | ||
|
||
@Column(name = "TOOL_ID", nullable = false) | ||
private String toolId; | ||
|
||
@Column(name = "ITEM_ID", nullable = true) | ||
private String itemId; | ||
|
||
@JsonIgnore | ||
@ManyToMany(mappedBy = "subConditions", cascade = CascadeType.ALL) | ||
private Set<Condition> parentConditions; | ||
|
||
@ManyToMany(cascade = CascadeType.ALL) | ||
@JoinTable(name = "COND_PARENT_CHILD", | ||
joinColumns = { @JoinColumn(name = "PARENT_ID", referencedColumnName = "ID") }, | ||
inverseJoinColumns = { @JoinColumn(name="CHILD_ID", referencedColumnName = "ID") }) | ||
private Set<Condition> subConditions; | ||
|
||
public Boolean getHasParent() { | ||
return this.parentConditions != null | ||
? this.parentConditions.size() > 0 | ||
: null; | ||
} | ||
|
||
// Only show ids of parent-conditions in string representation of condition | ||
@ToString.Include | ||
private String parentConditions() { | ||
return parentConditions != null | ||
? Arrays.deepToString(parentConditions.stream() | ||
.map(Condition::getId) | ||
.toArray(String[]::new)) | ||
: "null"; | ||
} | ||
|
||
// Only show ids of sub-conditions in string representation of condition | ||
@ToString.Include | ||
private String subConditions() { | ||
return subConditions != null | ||
? Arrays.deepToString(subConditions.stream() | ||
.map(Condition::getId) | ||
.toArray(String[]::new)) | ||
: "null"; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
conditions/api/src/java/org/sakaiproject/condition/api/model/ConditionOperator.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 @@ | ||
/** | ||
* Copyright (c) 2023 The Apereo Foundation | ||
* | ||
* Licensed under the Educational Community License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://opensource.org/licenses/ecl2 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.sakaiproject.condition.api.model; | ||
|
||
public enum ConditionOperator { | ||
SMALLER_THAN, | ||
SMALLER_THAN_OR_EQUAL_TO, | ||
EQUAL_TO, | ||
GREATER_THAN_OR_EQUAL_TO, | ||
GREATER_THAN, | ||
|
||
AND, | ||
OR, | ||
} |
24 changes: 24 additions & 0 deletions
24
conditions/api/src/java/org/sakaiproject/condition/api/model/ConditionType.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,24 @@ | ||
/** | ||
* Copyright (c) 2023 The Apereo Foundation | ||
* | ||
* Licensed under the Educational Community License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://opensource.org/licenses/ecl2 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.sakaiproject.condition.api.model; | ||
|
||
public enum ConditionType { | ||
COMPLETED, | ||
SCORE, | ||
|
||
PARENT, | ||
ROOT, | ||
} |
34 changes: 34 additions & 0 deletions
34
conditions/api/src/java/org/sakaiproject/condition/api/persistence/ConditionRepository.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,34 @@ | ||
/** | ||
* Copyright (c) 2023 The Apereo Foundation | ||
* | ||
* Licensed under the Educational Community License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://opensource.org/licenses/ecl2 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.sakaiproject.condition.api.persistence; | ||
|
||
import java.util.List; | ||
|
||
import org.sakaiproject.condition.api.model.Condition; | ||
import org.sakaiproject.serialization.SerializableRepository; | ||
|
||
|
||
public interface ConditionRepository extends SerializableRepository<Condition, String> { | ||
|
||
|
||
public Condition findConditionForId(String conditionId); | ||
|
||
public Condition findRootConditionForItem(String siteId, String toolId, String itemId); | ||
|
||
public List<Condition> findConditionsForSite(String siteId); | ||
|
||
public List<Condition> findConditionsForItem(String siteId, String toolId, String itemId); | ||
} |
Oops, something went wrong.