diff --git a/api/pom.xml b/api/pom.xml index 78f66db197..2e6d7eab65 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -4,7 +4,7 @@ org.sakaiproject.certification certification-base - 23-SNAPSHOT + 25-SNAPSHOT ../pom.xml diff --git a/api/src/java/org/sakaiproject/certification/api/InvalidCertificateDefinitionException.java b/api/src/java/org/sakaiproject/certification/api/InvalidCertificateDefinitionException.java index 5e23714e8b..5ea216a908 100644 --- a/api/src/java/org/sakaiproject/certification/api/InvalidCertificateDefinitionException.java +++ b/api/src/java/org/sakaiproject/certification/api/InvalidCertificateDefinitionException.java @@ -17,11 +17,13 @@ package org.sakaiproject.certification.api; import lombok.Data; +import lombok.EqualsAndHashCode; /** * Thrown when creating a certificate definition, but some constraint isn't met */ @Data +@EqualsAndHashCode(callSuper = true) public class InvalidCertificateDefinitionException extends CertificationException { public static final int REASON_TOO_LONG = 1; diff --git a/api/src/java/org/sakaiproject/certification/api/criteria/gradebook/CertAssignment.java b/api/src/java/org/sakaiproject/certification/api/criteria/gradebook/CertAssignment.java index f9a71878d9..7b337cec3c 100644 --- a/api/src/java/org/sakaiproject/certification/api/criteria/gradebook/CertAssignment.java +++ b/api/src/java/org/sakaiproject/certification/api/criteria/gradebook/CertAssignment.java @@ -17,8 +17,10 @@ package org.sakaiproject.certification.api.criteria.gradebook; import lombok.Data; +import lombok.EqualsAndHashCode; @Data +@EqualsAndHashCode(callSuper = true) public class CertAssignment extends CertGradebookObject { private double pointsPossible; diff --git a/api/src/java/org/sakaiproject/certification/api/criteria/gradebook/CertAssignmentScore.java b/api/src/java/org/sakaiproject/certification/api/criteria/gradebook/CertAssignmentScore.java index 9b8c658dd5..172183ad10 100644 --- a/api/src/java/org/sakaiproject/certification/api/criteria/gradebook/CertAssignmentScore.java +++ b/api/src/java/org/sakaiproject/certification/api/criteria/gradebook/CertAssignmentScore.java @@ -19,9 +19,11 @@ import java.util.Date; import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; @Data +@EqualsAndHashCode(callSuper = true) @NoArgsConstructor public class CertAssignmentScore extends CertGradeRecordObject { diff --git a/impl/pom.xml b/impl/pom.xml index c8e676e889..c67a2054ed 100644 --- a/impl/pom.xml +++ b/impl/pom.xml @@ -4,7 +4,7 @@ org.sakaiproject.certification certification-base - 23-SNAPSHOT + 25-SNAPSHOT ../pom.xml diff --git a/impl/src/java/org/sakaiproject/certification/criteria/impl/gradebook/FinalGradeScoreCriteriaTemplate.java b/impl/src/java/org/sakaiproject/certification/criteria/impl/gradebook/FinalGradeScoreCriteriaTemplate.java index 6d1456e117..8e1764c9e7 100644 --- a/impl/src/java/org/sakaiproject/certification/criteria/impl/gradebook/FinalGradeScoreCriteriaTemplate.java +++ b/impl/src/java/org/sakaiproject/certification/criteria/impl/gradebook/FinalGradeScoreCriteriaTemplate.java @@ -29,6 +29,7 @@ import org.sakaiproject.certification.api.criteria.CriteriaTemplateVariable; import org.sakaiproject.certification.api.criteria.Criterion; import org.sakaiproject.certification.api.criteria.gradebook.FinalGradeScoreCriterion; +import org.sakaiproject.grading.api.GradingConstants; import org.sakaiproject.grading.api.GradingService; import org.sakaiproject.util.ResourceLoader; @@ -45,6 +46,11 @@ public class FinalGradeScoreCriteriaTemplate implements CriteriaTemplate { private final String EXPRESSION_KEY = "final.grade.score.criteria.expression"; private final String VARIABLE_SCORE = "score"; + // TODO: Once these are correct in GradingConstants, delete these + public static final int CATEGORY_TYPE_NO_CATEGORY = 1; + public static final int CATEGORY_TYPE_ONLY_CATEGORY = 2; + public static final int CATEGORY_TYPE_WEIGHTED_CATEGORY = 3; + public FinalGradeScoreCriteriaTemplate(final GradebookCriteriaFactory factory) { this.factory = factory; gradingService = factory.getGradingService(); @@ -104,7 +110,7 @@ public String getExpression (Criterion criterion) { try { categoryType = (Integer) factory.doSecureGradebookAction(typeCallback); - if(categoryType == GradingService.CATEGORY_TYPE_ONLY_CATEGORY) { + if(categoryType == CATEGORY_TYPE_ONLY_CATEGORY) { assnPoints = (Map)factory.doSecureGradebookAction(catOnlyAssnPointsCallback); } else { assnPoints = (Map)factory.doSecureGradebookAction(assnPointsCallback); @@ -116,9 +122,9 @@ public String getExpression (Criterion criterion) { double total = 0; switch(categoryType) { - case GradingService.CATEGORY_TYPE_NO_CATEGORY: - case GradingService.CATEGORY_TYPE_WEIGHTED_CATEGORY: - case GradingService.CATEGORY_TYPE_ONLY_CATEGORY: { + case CATEGORY_TYPE_NO_CATEGORY: + case CATEGORY_TYPE_WEIGHTED_CATEGORY: + case CATEGORY_TYPE_ONLY_CATEGORY: { for (Double points : assnPoints.values()) { total += points; } diff --git a/impl/src/java/org/sakaiproject/certification/criteria/impl/gradebook/GradebookCriteriaFactory.java b/impl/src/java/org/sakaiproject/certification/criteria/impl/gradebook/GradebookCriteriaFactory.java index 1596dc0f95..cfc045e78d 100644 --- a/impl/src/java/org/sakaiproject/certification/criteria/impl/gradebook/GradebookCriteriaFactory.java +++ b/impl/src/java/org/sakaiproject/certification/criteria/impl/gradebook/GradebookCriteriaFactory.java @@ -21,11 +21,12 @@ import java.util.Date; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; +import lombok.Getter; +import lombok.Setter; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -60,11 +61,23 @@ @Slf4j public class GradebookCriteriaFactory implements CriteriaFactory { - private CertificateService certService = null; + @Getter + @Setter + private CertificateService certificateService = null; + @Getter + @Setter private GradingService gradingService = null; + @Getter + @Setter private ToolManager toolManager = null; + @Getter + @Setter private UserDirectoryService userDirectoryService = null; + @Getter + @Setter private SecurityService securityService = null; + @Getter + @Setter private SessionManager sessionManager = null; private final HashMap criteriaTemplates = new HashMap<>(); @@ -82,6 +95,8 @@ public class GradebookCriteriaFactory implements CriteriaFactory { private final Map> itemToUserToGradeMap = new HashMap<>(); private final Map> itemToUserToDateRecordedMap = new HashMap<>(); + @Setter + @Getter private ResourceLoader resourceLoader = null; private static final String PERM_VIEW_OWN_GRADES = "gradebook.viewOwnGrades"; @@ -101,6 +116,11 @@ public class GradebookCriteriaFactory implements CriteriaFactory { private static final String SCORE_REQUIREMENTS = "gradebookItem.requirements"; private static final String COURSE_GRADE_REQUIREMENTS = "courseGrade.requirements"; + // TODO: Once these are correct in GradingConstants, delete these + public static final int CATEGORY_TYPE_NO_CATEGORY = 1;; + public static final int CATEGORY_TYPE_ONLY_CATEGORY = 2; + public static final int CATEGORY_TYPE_WEIGHTED_CATEGORY = 3; + public void init() { gbItemScoreTemplate = new GreaterThanScoreCriteriaTemplate(this); gbItemScoreTemplate.setResourceLoader(resourceLoader); @@ -124,67 +144,11 @@ public void init() { criterionClasses.add(FinalGradeScoreCriterion.class); criterionClasses.add(WillExpireCriterion.class); - if (certService != null) { - certService.registerCriteriaFactory(this); + if (certificateService != null) { + certificateService.registerCriteriaFactory(this); } } - public CertificateService getCertificateService() { - return certService; - } - - public void setCertificateService(CertificateService certService) { - this.certService = certService; - } - - public void setGradingService(GradingService gradingService) { - this.gradingService = gradingService; - } - - public GradingService getGradingService() { - return gradingService; - } - - public void setToolManager(ToolManager tm) { - toolManager = tm; - } - - public ToolManager getToolManager() { - return toolManager; - } - - public void setUserDirectoryService(UserDirectoryService uds) { - userDirectoryService = uds; - } - - public UserDirectoryService getUserDirectoryService() { - return userDirectoryService; - } - - public ResourceLoader getResourceLoader() { - return resourceLoader; - } - - public void setResourceLoader(ResourceLoader resourceLoader) { - this.resourceLoader = resourceLoader; - } - - public SecurityService getSecurityService() { - return securityService; - } - - public void setSecurityService(SecurityService securityService) { - this.securityService = securityService; - } - - public SessionManager getSessionManager() { - return sessionManager; - } - - public void setSessionManager(SessionManager sessionManager) { - this.sessionManager = sessionManager; - } - protected final String contextId() { return getToolManager().getCurrentPlacement().getContext(); } @@ -194,9 +158,7 @@ protected final String userId() { } public Set getCriteriaTemplates() { - HashSet values = new HashSet<>(); - values.addAll(criteriaTemplates.values()); - return values; + return new HashSet<>(criteriaTemplates.values()); } public CriteriaTemplate getCriteriaTemplate(Criterion criterion) throws UnknownCriterionTypeException { @@ -253,7 +215,7 @@ public SecurityAdvice isAllowed(String userId, String function, String reference securityService.pushAdvisor(yesMan); return callback.doSecureAction(); } finally { - securityService.popAdvisor(); + securityService.popAdvisor(yesMan); } } @@ -350,14 +312,14 @@ public Object doSecureAction() { //ignore category weights // TODO: drop all of this custom processing and use the GradingService! - Map catWeights = certService.getCategoryWeights(contextId); - Map assgnScores = certService.getAssignmentScores(contextId, userId); + Map catWeights = certificateService.getCategoryWeights(contextId); + Map assgnScores = certificateService.getAssignmentScores(contextId, userId); double studentTotalScore = 0; - int categoryType = certService.getCategoryType(contextId); + int categoryType = certificateService.getCategoryType(contextId); switch(categoryType) { - case GradingService.CATEGORY_TYPE_NO_CATEGORY: { + case CATEGORY_TYPE_NO_CATEGORY: { for(Map.Entry assgnScore : assgnScores.entrySet()) { Double score = assgnScore.getValue(); studentTotalScore += score == null ? 0:score; @@ -365,8 +327,8 @@ public Object doSecureAction() { break; } - case GradingService.CATEGORY_TYPE_WEIGHTED_CATEGORY: - case GradingService.CATEGORY_TYPE_ONLY_CATEGORY: { + case CATEGORY_TYPE_WEIGHTED_CATEGORY: + case CATEGORY_TYPE_ONLY_CATEGORY: { for(Map.Entry assgnScore : assgnScores.entrySet()) { if(catWeights.containsKey(assgnScore.getKey())) { Double score = assgnScore.getValue(); @@ -578,23 +540,23 @@ public Criterion createCriterion(CriteriaTemplate template, Map criterion.setCriteriaFactory(this); String scoreStr = FormatHelper.inputStringToFormatString(bindings.get(KEY_SCORE)); - Map catWeights = certService.getCategoryWeights(contextId); - Map assgnPoints = certService.getAssignmentPoints(contextId); + Map catWeights = certificateService.getCategoryWeights(contextId); + Map assgnPoints = certificateService.getAssignmentPoints(contextId); double totalAvailable = 0; - int categoryType = certService.getCategoryType(contextId); + int categoryType = certificateService.getCategoryType(contextId); switch(categoryType) { - case GradingService.CATEGORY_TYPE_NO_CATEGORY: { + case CATEGORY_TYPE_NO_CATEGORY: { for(Map.Entry assgnPoint : assgnPoints.entrySet()) { Double point = assgnPoint.getValue(); totalAvailable += point == null ? 0:point; } break; } - case GradingService.CATEGORY_TYPE_WEIGHTED_CATEGORY: - case GradingService.CATEGORY_TYPE_ONLY_CATEGORY: { + case CATEGORY_TYPE_WEIGHTED_CATEGORY: + case CATEGORY_TYPE_ONLY_CATEGORY: { for(Map.Entry assgnPoint : assgnPoints.entrySet()) { if(catWeights.containsKey(assgnPoint.getKey())) { Double point = assgnPoint.getValue(); @@ -788,13 +750,13 @@ public Date getFinalGradeDateRecorded(final String userId,final String contextId return (Date) doSecureGradebookAction(new SecureGradebookActionCallback() { public Object doSecureAction() { //Just following the getFinalScore code, but ignoring grades and looking at dates - Map catWeights = certService.getCategoryWeights(contextId); - Map assgnDates = certService.getAssignmentDatesRecorded(contextId, userId); + Map catWeights = certificateService.getCategoryWeights(contextId); + Map assgnDates = certificateService.getAssignmentDatesRecorded(contextId, userId); Date lastDate = null; - int categoryType = certService.getCategoryType(contextId); + int categoryType = certificateService.getCategoryType(contextId); switch(categoryType) { - case GradingService.CATEGORY_TYPE_NO_CATEGORY: { + case CATEGORY_TYPE_NO_CATEGORY: { for(Map.Entry assgnDate : assgnDates.entrySet()) { if (lastDate==null) { lastDate = assgnDate.getValue(); @@ -807,8 +769,8 @@ public Object doSecureAction() { break; } - case GradingService.CATEGORY_TYPE_ONLY_CATEGORY: - case GradingService.CATEGORY_TYPE_WEIGHTED_CATEGORY: { + case CATEGORY_TYPE_ONLY_CATEGORY: + case CATEGORY_TYPE_WEIGHTED_CATEGORY: { for(Map.Entry assgnDate : assgnDates.entrySet()) { if(catWeights.containsKey(assgnDate.getKey())) { if (lastDate==null) { @@ -840,9 +802,7 @@ public Date getDateIssued(final String userId, final String contextId, Certifica //The last date in chronological order will be selected Date lastDate = null; - Iterator itCriteria = criteria.iterator(); - while (itCriteria.hasNext()) { - Criterion crit = itCriteria.next(); + for (Criterion crit : criteria) { try { if (!isCriterionMet(crit, userId, contextId, useCaching)) { return null; @@ -981,7 +941,7 @@ private Map> getFinalGradeScoreProgressForU UserProgress progress = new UserProgress(userId, criterion, strScore, score >= reqScore, dateRecorded); // add progress to the user's map of criteria to UserProgress (creates an empty map for the user if it doesn't exist) - Map critProgressMap = getCritProgressMapForUser(userCritProgress, userId); + Map critProgressMap = getCritProgressMapForUser(userCritProgress, userId); critProgressMap.put(criterion, progress); } } diff --git a/impl/src/java/org/sakaiproject/certification/impl/hibernate/CertificateServiceHibernateImpl.java b/impl/src/java/org/sakaiproject/certification/impl/hibernate/CertificateServiceHibernateImpl.java index 4099d6353c..ae8c965fa6 100644 --- a/impl/src/java/org/sakaiproject/certification/impl/hibernate/CertificateServiceHibernateImpl.java +++ b/impl/src/java/org/sakaiproject/certification/impl/hibernate/CertificateServiceHibernateImpl.java @@ -30,6 +30,8 @@ import java.util.Map; import java.util.Set; +import lombok.Getter; +import lombok.Setter; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -98,16 +100,33 @@ public class CertificateServiceHibernateImpl extends HibernateDaoSupport implements CertificateService { //managers and services + @Getter + @Setter private DocumentTemplateService documentTemplateService = null; + @Getter + @Setter private UserDirectoryService userDirectoryService = null; + @Setter + @Getter private ToolManager toolManager = null; + @Getter + @Setter private SessionManager sessionManager = null; + @Setter + @Getter private SecurityService securityService = null; + @Setter private SiteService siteService = null; + @Setter private AuthzGroupService authzGroupService= null; + @Setter + @Getter private ContentHostingService contentHostingService = null; + @Setter private CandidateDetailProvider candidateDetailProvider = null; + @Getter + @Setter private String templateDirectory = null; private final HashMap criteriaTemplateMap = new HashMap<>(); private final HashMap criteriaFactoryMap = new HashMap<>(); @@ -138,30 +157,6 @@ public class CertificateServiceHibernateImpl extends HibernateDaoSupport impleme private static final String PERMISSION_VIEW_STUDENT_NUMS = "certificate.extraprops.view"; - public void setAuthzGroupService(AuthzGroupService authzGroupService) { - this.authzGroupService = authzGroupService; - } - - public void setSiteService(SiteService siteService) { - this.siteService = siteService; - } - - public String getTemplateDirectory() { - return templateDirectory; - } - - public void setTemplateDirectory(String templateDirectory) { - this.templateDirectory = templateDirectory; - } - - public ContentHostingService getContentHostingService() { - return contentHostingService; - } - - public void setContentHostingService(ContentHostingService contentHostingService) { - this.contentHostingService = contentHostingService; - } - public String getString(String key) { return messages.getString(key); } @@ -174,50 +169,6 @@ public Locale getLocale(){ return messages.getLocale(); } - public void setDocumentTemplateService(DocumentTemplateService dts) { - documentTemplateService = dts; - } - - public DocumentTemplateService getDocumentTemplateService() { - return documentTemplateService; - } - - public ToolManager getToolManager() { - return toolManager; - } - - public void setToolManager(ToolManager toolManager) { - this.toolManager = toolManager; - } - - public UserDirectoryService getUserDirectoryService() { - return userDirectoryService; - } - - public void setUserDirectoryService(UserDirectoryService userDirectoryService) { - this.userDirectoryService = userDirectoryService; - } - - public SessionManager getSessionManager() { - return sessionManager; - } - - public void setSessionManager(SessionManager sessionManager) { - this.sessionManager = sessionManager; - } - - public SecurityService getSecurityService() { - return securityService; - } - - public void setSecurityService(SecurityService securityService) { - this.securityService = securityService; - } - - public void setCandidateDetailProvider(CandidateDetailProvider candidateDetailProvider) { - this.candidateDetailProvider = candidateDetailProvider; - } - public void init() { log.debug("init"); diff --git a/impl/src/test/java/org/sakaiproject/certification/mock/MockGradingService.java b/impl/src/test/java/org/sakaiproject/certification/mock/MockGradingService.java index 8b5be1979f..dfd3adc097 100644 --- a/impl/src/test/java/org/sakaiproject/certification/mock/MockGradingService.java +++ b/impl/src/test/java/org/sakaiproject/certification/mock/MockGradingService.java @@ -19,9 +19,7 @@ import org.sakaiproject.grading.api.CourseGradeTransferBean; import org.sakaiproject.grading.api.ExternalAssignmentProvider; import org.sakaiproject.grading.api.GradeDefinition; -import org.sakaiproject.grading.api.GradeType; import org.sakaiproject.grading.api.GradebookInformation; -import org.sakaiproject.grading.api.GradingCategoryType; import org.sakaiproject.grading.api.GradingScaleDefinition; import org.sakaiproject.grading.api.GradingService; import org.sakaiproject.grading.api.InvalidCategoryException; @@ -59,6 +57,11 @@ public boolean isGradebookDefined(String gradebookUid) return true; } + @Override + public boolean isUserAbleToViewAssignments(String gradebookUid) { + return false; + } + public boolean isUserAbleToGradeItemForStudent(String gradebookUid, Long itemId, String studentUid) { return false; @@ -203,6 +206,16 @@ public List getCategories(Long gradebookId) return null; } + @Override + public Optional getCategoryDefinition(Long categoryId) { + return Optional.empty(); + } + + @Override + public void updateCategory(CategoryDefinition category) { + + } + public List getCategoryDefinitions(String gradebookUid) { return null; @@ -420,14 +433,14 @@ public void saveGradesAndComments(String gradebookUid, Long gradableObjectId, Li @Override public void saveGradeAndExcuseForStudent(String s, Long aLong, String s1, String s2, boolean b) throws InvalidGradeException, AssessmentNotFoundException { - } @Override - public GradeType getGradeEntryType(String gradebookUid) { - return null; + public Integer getGradeEntryType(String gradebookUid) { + return 0; } + public Map getFixedGrade(String gradebookUid) { return null; @@ -558,7 +571,7 @@ public List getGradingEvents(String studentId, long assignmentId) } @Override - public Optional calculateCategoryScore(Long gradebookId, String studentUuid, Long categoryId, boolean includeNonReleasedItems, GradingCategoryType categoryType, Boolean equalWeightAssignments) { + public Optional calculateCategoryScore(Long gradebookId, String studentUuid, Long categoryId, boolean includeNonReleasedItems, Integer categoryType, Boolean equalWeightAssignments) { return Optional.empty(); } diff --git a/impl/src/test/java/org/sakaiproject/certification/mock/MockUserDirectoryService.java b/impl/src/test/java/org/sakaiproject/certification/mock/MockUserDirectoryService.java index 39d0d95051..c4bae10188 100644 --- a/impl/src/test/java/org/sakaiproject/certification/mock/MockUserDirectoryService.java +++ b/impl/src/test/java/org/sakaiproject/certification/mock/MockUserDirectoryService.java @@ -314,6 +314,11 @@ public String idFromReference(String reference) return null; } + @Override + public boolean isRoleViewType(String id) { + return false; + } + public String getLabel() { return null; diff --git a/model/pom.xml b/model/pom.xml index 4c159e8a1c..00030ea9ec 100644 --- a/model/pom.xml +++ b/model/pom.xml @@ -4,7 +4,7 @@ org.sakaiproject.certification certification-base - 23-SNAPSHOT + 25-SNAPSHOT ../pom.xml diff --git a/pom.xml b/pom.xml index 027dd172d9..ff14ed1506 100644 --- a/pom.xml +++ b/pom.xml @@ -4,13 +4,13 @@ org.sakaiproject master - 23-SNAPSHOT + 25-SNAPSHOT Certification Base Project org.sakaiproject.certification certification-base - 23-SNAPSHOT + 25-SNAPSHOT pom Apereo Foundation - Sakai project diff --git a/tool/pom.xml b/tool/pom.xml index 775f97f5ed..d5f2121571 100644 --- a/tool/pom.xml +++ b/tool/pom.xml @@ -4,7 +4,7 @@ org.sakaiproject.certification certification-base - 23-SNAPSHOT + 25-SNAPSHOT ../pom.xml