From 2e7422662e6c91e8d45f06ae61327652a6a1db52 Mon Sep 17 00:00:00 2001 From: jkjanetschek Date: Tue, 26 Sep 2023 11:20:24 +0200 Subject: [PATCH 01/35] SAK-42608: display user notifications for available tests and quizzes(samigo) --- .../samigo/util/SamigoConstants.java | 8 + .../author/EditAssessmentListener.java | 27 ++ .../author/PublishAssessmentListener.java | 43 +- .../author/RepublishAssessmentListener.java | 55 ++- .../author/SavePublishedSettingsListener.java | 85 +++- ...estsAndQuizzesUserNotificationHandler.java | 373 ++++++++++++++++++ .../main/bundle/sui-notifications.properties | 2 + .../js/sui-notifications/sui-notifications.js | 9 + 8 files changed, 585 insertions(+), 17 deletions(-) create mode 100644 samigo/samigo-services/src/java/org/sakaiproject/tool/assessment/TestsAndQuizzesUserNotificationHandler.java diff --git a/samigo/samigo-api/src/java/org/sakaiproject/samigo/util/SamigoConstants.java b/samigo/samigo-api/src/java/org/sakaiproject/samigo/util/SamigoConstants.java index 0087d2da5034..570b37828b50 100644 --- a/samigo/samigo-api/src/java/org/sakaiproject/samigo/util/SamigoConstants.java +++ b/samigo/samigo-api/src/java/org/sakaiproject/samigo/util/SamigoConstants.java @@ -77,6 +77,10 @@ public final class SamigoConstants { public static final String EVENT_ASSESSMENT_PUBLISH = "sam.assessment.publish"; public static final String EVENT_ASSESSMENT_ATTACHMENT_NEW = "sam.assessment.attachment.new"; public static final String EVENT_ASSESSMENT_ATTACHMENT_DELETE = "sam.assessment.attachment.delete"; + public static final String EVENT_ASSESSMENT_AVAILABLE = "sam.assessment.available"; + public static final String EVENT_ASSESSMENT_UPDATE_AVAILABLE = "sam.assessment.update.available"; + public static final String EVENT_ASSESSMENT_DELETE = "sam.assessment.delete"; + //Published assessment events public static final String EVENT_PUBLISHED_ASSESSMENT_REVISE = "sam.pubassessment.revise"; @@ -86,6 +90,10 @@ public final class SamigoConstants { public static final String EVENT_PUBLISHED_ASSESSMENT_REPUBLISH = "sam.pubassessment.republish"; public static final String EVENT_PUBLISHED_ASSESSMENT_SETTING_EDIT = "sam.pubsetting.edit"; public static final String EVENT_PUBLISHED_ASSESSMENT_UNINDEXITEM = "sam.pubassessment.unindexitem"; + public static final String EVENT_PUBLISHED_ASSESSMENT_RETRACTED = "sam.pubassessment.retracted"; + public static final String EVENT_PUBLISHED_ASSESSMENT_REPUBLISH_AVAILABLE = "sam.pubassessment.republish.available"; + public static final String EVENT_PUBLISHED_ASSESSMENT_SETTING_EDIT_BULLHORN = "sam.pubsetting.edit.bullhorn"; + public static final String EVENT_UPDATE_PUBLISHED_ASSESSMENT_OPENDATE = "sam.pubassessment.update.opendate"; //Question pool events public static final String EVENT_QUESTIONPOOL_QUESTIONMOVED = "sam.questionpool.questionmoved"; diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/EditAssessmentListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/EditAssessmentListener.java index c7cf8edd68c6..f7e6e2012a34 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/EditAssessmentListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/EditAssessmentListener.java @@ -33,6 +33,7 @@ import org.sakaiproject.component.cover.ServerConfigurationService; import org.sakaiproject.samigo.api.SamigoAvailableNotificationService; import org.sakaiproject.tool.assessment.data.ifc.assessment.AssessmentBaseIfc; +import org.sakaiproject.tool.assessment.data.ifc.assessment.AssessmentIfc; import org.sakaiproject.tool.assessment.facade.AgentFacade; import org.sakaiproject.tool.assessment.facade.AssessmentFacade; import org.sakaiproject.tool.assessment.facade.PublishedAssessmentFacade; @@ -48,6 +49,12 @@ import org.sakaiproject.tool.assessment.ui.listener.util.ContextUtil; import org.sakaiproject.tool.cover.ToolManager; +import static org.sakaiproject.samigo.util.SamigoConstants.EVENT_PUBLISHED_ASSESSMENT_RETRACTED; +import static org.sakaiproject.samigo.util.SamigoConstants.EVENT_ASSESSMENT_AVAILABLE; +import org.sakaiproject.event.cover.EventTrackingService; + +import java.util.Objects; + /** *

Title: Samigo

2 *

Description: Sakai Assessment Manager

@@ -78,6 +85,26 @@ public void processAction(ActionEvent ae) throws AbortProcessingException author.setIsEditPoolFlow(false); } + //cancel not fired event and fire event for userNotification alert deletion + AssessmentBean assessmentBean = (AssessmentBean) ContextUtil + .lookupBean("assessmentBean"); + String assessmentId = assessmentBean.getAssessmentId(); + + + //check if draft + if((assessmentId != null && assessmentBean.getAssessment() == null) || (assessmentId != null && assessmentBean.getAssessment() != null && assessmentBean.getAssessment().getAssessmentBaseId() != null + && !Long.toString(assessmentBean.getAssessment().getAssessmentBaseId()).equals(assessmentId))){ + PublishedAssessmentService publishedAssessmentService = new PublishedAssessmentService(); + try{ + PublishedAssessmentFacade assessment = publishedAssessmentService.getPublishedAssessment(assessmentId); + if(!Objects.equals(assessment.getStatus(), AssessmentIfc.RETRACT_FOR_EDIT_STATUS)){ + EventTrackingService.cancelDelays("siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), EVENT_ASSESSMENT_AVAILABLE); + EventTrackingService.post(EventTrackingService.newEvent(EVENT_PUBLISHED_ASSESSMENT_RETRACTED,"siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId() ,true)); + } + }catch (Exception e){ + log.warn("Could not get published Assessment for id {}", assessmentId); + } + } if (editType != null) { if ("pendingAssessment".equals(editType)) { diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/PublishAssessmentListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/PublishAssessmentListener.java index c02862c1fd90..e5010a7e7bc3 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/PublishAssessmentListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/PublishAssessmentListener.java @@ -51,7 +51,7 @@ import org.sakaiproject.component.cover.ComponentManager; import org.sakaiproject.component.cover.ServerConfigurationService; import org.sakaiproject.email.cover.EmailService; -import org.sakaiproject.event.cover.EventTrackingService; +import org.sakaiproject.event.api.EventTrackingService; import org.sakaiproject.exception.IdUnusedException; import org.sakaiproject.grading.api.InvalidCategoryException; import org.sakaiproject.rubrics.api.RubricsConstants; @@ -98,6 +98,13 @@ import org.sakaiproject.util.ResourceLoader; import org.springframework.web.client.HttpClientErrorException; + +import org.sakaiproject.tool.assessment.data.dao.assessment.ExtendedTime; +import org.sakaiproject.time.api.Time; +import java.util.ListIterator; +import java.time.Instant; +import org.sakaiproject.tool.assessment.data.dao.assessment.ExtendedTime; + /** *

Title: Samigo

2 *

Description: Sakai Assessment Manager

@@ -121,11 +128,13 @@ public class PublishAssessmentListener private RubricsService rubricsService; private TaskService taskService; private SamigoAvailableNotificationService samigoAvailableNotificationService; + private EventTrackingService eventTrackingService; public PublishAssessmentListener() { rubricsService = ComponentManager.get(RubricsService.class); taskService = ComponentManager.get(TaskService.class); samigoAvailableNotificationService = ComponentManager.get(SamigoAvailableNotificationService.class); + eventTrackingService = ComponentManager.get(EventTrackingService.class); } public void processAction(ActionEvent ae) throws AbortProcessingException { @@ -271,13 +280,41 @@ private void publish(AssessmentFacade assessment, ExtendedTimeFacade extendedTimeFacade = PersistenceService.getInstance().getExtendedTimeFacade(); extendedTimeFacade.copyEntriesToPub(pub.getData(), assessmentSettings.getExtendedTimes()); - EventTrackingService.post(EventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_PUBLISH, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + pub.getPublishedAssessmentId(), true)); + eventTrackingService.post(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_PUBLISH, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + pub.getPublishedAssessmentId(), true)); + + /* + * UserNotification: check if event should be fired immediately or/and must be delayed --> subsequent events are handled by TestsAndQuizzesUserNotificationHandler + */ + List extendedTimes = assessmentSettings.getExtendedTimes(); + Instant instant = pub.getStartDate().toInstant(); + if (instant.isBefore(Instant.now())) { + eventTrackingService.post(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + pub.getPublishedAssessmentId(), true)); + } else { + Instant earliestDelayInstant = instant; + if(assessmentSettings.getExtendedTimesSize() != 0){ + ListIterator it = extendedTimes.listIterator(); + boolean postEvent = false; + while (it.hasNext()){ + ExtendedTime exTime = (ExtendedTime) it.next(); + Instant startInstant = exTime.getStartDate().toInstant(); + if(startInstant.isBefore(Instant.now()) && !postEvent) { + postEvent = true; + } else if (startInstant.isBefore(instant)) { + earliestDelayInstant = startInstant; + } + } + if(postEvent) { + eventTrackingService.post(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + pub.getPublishedAssessmentId(), true)); + } + } + eventTrackingService.delay(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + pub.getPublishedAssessmentId(), true), earliestDelayInstant); + } for (Object sectionObj : pub.getSectionSet()){ PublishedSectionData sectionData = (PublishedSectionData) sectionObj; for (Object itemObj : sectionData.getItemSet()){ PublishedItemData itemData = (PublishedItemData) itemObj; - EventTrackingService.post(EventTrackingService.newEvent(SamigoConstants.EVENT_PUBLISHED_ASSESSMENT_SAVEITEM, "/sam/" + AgentFacade.getCurrentSiteId() + "/publish, publishedItemId=" + itemData.getItemIdString(), true)); + eventTrackingService.post(eventTrackingService.newEvent(SamigoConstants.EVENT_PUBLISHED_ASSESSMENT_SAVEITEM, "/sam/" + AgentFacade.getCurrentSiteId() + "/publish, publishedItemId=" + itemData.getItemIdString(), true)); try { Optional rubricAssociation = rubricsService.getRubricAssociation(RubricsConstants.RBCS_TOOL_SAMIGO, assessmentSettings.getAssessmentId().toString() + "." + itemData.getOriginalItemId().toString()); diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java index 9ddc165e8888..6df077992d2f 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java @@ -31,12 +31,12 @@ import lombok.extern.slf4j.Slf4j; import org.sakaiproject.component.cover.ComponentManager; +import org.sakaiproject.event.api.EventTrackingService; import org.sakaiproject.samigo.api.SamigoAvailableNotificationService; import org.sakaiproject.samigo.api.SamigoReferenceReckoner; import org.sakaiproject.samigo.util.SamigoConstants; import org.apache.commons.lang3.StringUtils; import org.sakaiproject.component.cover.ComponentManager; -import org.sakaiproject.event.cover.EventTrackingService; import org.sakaiproject.site.api.Site; import org.sakaiproject.site.cover.SiteService; import org.sakaiproject.spring.SpringBeanLocator; @@ -70,6 +70,12 @@ import org.sakaiproject.tool.cover.ToolManager; import org.sakaiproject.util.ResourceLoader; +import org.sakaiproject.tool.assessment.data.dao.assessment.ExtendedTime; +import org.sakaiproject.time.api.Time; +import java.util.ListIterator; +import java.time.Instant; +import org.sakaiproject.component.cover.ComponentManager; + @Slf4j public class RepublishAssessmentListener implements ActionListener { @@ -82,7 +88,10 @@ public class RepublishAssessmentListener implements ActionListener { private TaskService taskService = ComponentManager.get(TaskService.class);; private static final ResourceLoader rl = new ResourceLoader("org.sakaiproject.tool.assessment.bundle.AssessmentSettingsMessages"); private final SamigoAvailableNotificationService samigoAvailableNotificationService = ComponentManager.get(SamigoAvailableNotificationService.class); - + private EventTrackingService eventTrackingService; + public RepublishAssessmentListener(){ + eventTrackingService = ComponentManager.get(EventTrackingService.class); + } public void processAction(ActionEvent ae) throws AbortProcessingException { AssessmentBean assessmentBean = (AssessmentBean) ContextUtil .lookupBean("assessmentBean"); @@ -94,7 +103,7 @@ public void processAction(ActionEvent ae) throws AbortProcessingException { // Go to database to get the newly updated data. The data inside beans might not be up to date. PublishedAssessmentFacade assessment = publishedAssessmentService.getPublishedAssessment(publishedAssessmentId); - EventTrackingService.post(EventTrackingService.newEvent(SamigoConstants.EVENT_PUBLISHED_ASSESSMENT_REPUBLISH, "siteId=" + AgentFacade.getCurrentSiteId() + ", publishedAssessmentId=" + publishedAssessmentId, true)); + eventTrackingService.post(eventTrackingService.newEvent(SamigoConstants.EVENT_PUBLISHED_ASSESSMENT_REPUBLISH, "siteId=" + AgentFacade.getCurrentSiteId() + ", publishedAssessmentId=" + publishedAssessmentId, true)); assessment.setStatus(AssessmentBaseIfc.ACTIVE_STATUS); publishedAssessmentService.saveAssessment(assessment); @@ -105,15 +114,16 @@ public void processAction(ActionEvent ae) throws AbortProcessingException { if (author.getIsRepublishAndRegrade() && hasGradingData) { regradeRepublishedAssessment(publishedAssessmentService, assessment); } - - EventTrackingService.post(EventTrackingService.newEvent(SamigoConstants.EVENT_PUBLISHED_ASSESSMENT_REPUBLISH, "siteId=" + AgentFacade.getCurrentSiteId() + ", publishedAssessmentId=" + publishedAssessmentId, true)); + PublishedAssessmentSettingsBean publishedAssessmentSettings = (PublishedAssessmentSettingsBean) ContextUtil.lookupBean("publishedSettings"); + postUserNotification(assessment, publishedAssessmentSettings); + eventTrackingService.post(eventTrackingService.newEvent(SamigoConstants.EVENT_PUBLISHED_ASSESSMENT_REPUBLISH, "siteId=" + AgentFacade.getCurrentSiteId() + ", publishedAssessmentId=" + publishedAssessmentId, true)); assessment.setStatus(AssessmentBaseIfc.ACTIVE_STATUS); publishedAssessmentService.saveAssessment(assessment); updateGB(assessment); PublishRepublishNotificationBean publishRepublishNotification = (PublishRepublishNotificationBean) ContextUtil.lookupBean("publishRepublishNotification"); - PublishedAssessmentSettingsBean publishedAssessmentSettings = (PublishedAssessmentSettingsBean) ContextUtil.lookupBean("publishedSettings"); + PublishAssessmentListener publishAssessmentListener = new PublishAssessmentListener(); String subject = publishRepublishNotification.getNotificationSubject(); String notificationMessage = publishAssessmentListener.getNotificationMessage(publishRepublishNotification, publishedAssessmentSettings.getTitle(), publishedAssessmentSettings.getReleaseTo(), @@ -173,6 +183,39 @@ public void processAction(ActionEvent ae) throws AbortProcessingException { samigoAvailableNotificationService.scheduleAssessmentAvailableNotification(publishedAssessmentId); author.setOutcome("author"); } + + private void postUserNotification(PublishedAssessmentFacade assessment, PublishedAssessmentSettingsBean publishedAssessmentSettings){ + + List extendedTimes = publishedAssessmentSettings.getExtendedTimes(); + Instant instant = assessment.getStartDate().toInstant(); + if (instant.isBefore(Instant.now())) { + eventTrackingService.post(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_UPDATE_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true)); + if(publishedAssessmentSettings.getExtendedTimesSize() != 0){ + ListIterator it = extendedTimes.listIterator(); + while (it.hasNext()){ + ExtendedTime exTime = (ExtendedTime) it.next(); + Instant startInstant = exTime.getStartDate().toInstant(); + if(startInstant.isAfter(Instant.now())) { + eventTrackingService.delay(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true), startInstant); + } + } + } + } else { + eventTrackingService.delay(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true), instant); + if(publishedAssessmentSettings.getExtendedTimesSize() != 0){ + ListIterator it = extendedTimes.listIterator(); + while (it.hasNext()){ + ExtendedTime exTime = (ExtendedTime) it.next(); + Instant startInstant = exTime.getStartDate().toInstant(); + if(startInstant.isBefore(Instant.now())) { + eventTrackingService.post(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_UPDATE_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true)); + }else if(startInstant.isAfter(Instant.now()) && !instant.equals(startInstant)){ + eventTrackingService.delay(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true), startInstant); + } + } + } + } + } private void regradeRepublishedAssessment (PublishedAssessmentService pubService, PublishedAssessmentFacade publishedAssessment) { Map publishedItemHash = pubService.preparePublishedItemHash(publishedAssessment); diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java index 3990b5f57f24..14ab7d9195e8 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java @@ -26,6 +26,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import java.time.Instant; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; @@ -38,7 +39,7 @@ import org.apache.commons.lang3.math.NumberUtils; import org.sakaiproject.component.cover.ComponentManager; import org.sakaiproject.component.cover.ServerConfigurationService; -import org.sakaiproject.event.cover.EventTrackingService; +import org.sakaiproject.event.api.EventTrackingService; import org.sakaiproject.samigo.api.SamigoAvailableNotificationService; import org.sakaiproject.samigo.api.SamigoReferenceReckoner; import org.sakaiproject.samigo.util.SamigoConstants; @@ -83,6 +84,12 @@ import org.sakaiproject.tool.cover.ToolManager; import org.sakaiproject.util.ResourceLoader; +import org.sakaiproject.tool.assessment.data.dao.assessment.ExtendedTime; +import org.sakaiproject.time.api.Time; +import java.util.ListIterator; +import org.sakaiproject.tool.assessment.data.dao.assessment.ExtendedTime; +import org.sakaiproject.component.cover.ComponentManager; +import org.sakaiproject.component.cover.ComponentManager; /** *

Title: Samigo

2 *

Description: Sakai Assessment Manager

@@ -100,10 +107,9 @@ public class SavePublishedSettingsListener private CalendarServiceHelper calendarService = IntegrationContextFactory.getInstance().getCalendarServiceHelper(); private static final ResourceLoader rb = new ResourceLoader("org.sakaiproject.tool.assessment.bundle.AssessmentSettingsMessages"); private final SamigoAvailableNotificationService samigoAvailableNotificationService = ComponentManager.get(SamigoAvailableNotificationService.class); + private EventTrackingService eventTrackingService; - public SavePublishedSettingsListener() - { - } + public SavePublishedSettingsListener() {} public void processAction(ActionEvent ae) throws AbortProcessingException { @@ -124,13 +130,19 @@ public void processAction(ActionEvent ae) throws AbortProcessingException retractNow = true; } - EventTrackingService.post(EventTrackingService.newEvent(SamigoConstants.EVENT_PUBLISHED_ASSESSMENT_SETTING_EDIT, "siteId=" + AgentFacade.getCurrentSiteId() + ", publishedAssessmentId=" + assessmentId, true)); + eventTrackingService.post(eventTrackingService.newEvent(SamigoConstants.EVENT_PUBLISHED_ASSESSMENT_SETTING_EDIT, "siteId=" + AgentFacade.getCurrentSiteId() + ", publishedAssessmentId=" + assessmentId, true)); boolean error = checkPublishedSettings(assessmentService, assessmentSettings, context, retractNow); if (error){ assessmentSettings.setOutcome("editPublishedAssessmentSettings"); return; } + + //userNotification + ExtendedTimeFacade extendedTimeFacade = PersistenceService.getInstance().getExtendedTimeFacade(); + List oldExtendedTimes = extendedTimeFacade.getEntriesForPub(assessment.getData()); + Date oldStartDate = assessment.getAssessmentAccessControl().getStartDate(); + boolean isTitleChanged = isTitleChanged(assessmentSettings, assessment); boolean isScoringTypeChanged = isScoringTypeChanged(assessmentSettings, assessment); SaveAssessmentSettings saveAssessmentSettings = new SaveAssessmentSettings(); @@ -148,7 +160,7 @@ public void processAction(ActionEvent ae) throws AbortProcessingException return; } - ExtendedTimeFacade extendedTimeFacade = PersistenceService.getInstance().getExtendedTimeFacade(); + extendedTimeFacade.saveEntriesPub(assessmentService.getBasicInfoOfPublishedAssessment(assessmentId.toString()), assessmentSettings.getExtendedTimes()); assessment.setLastModifiedBy(AgentFacade.getAgentString()); @@ -205,12 +217,14 @@ public void processAction(ActionEvent ae) throws AbortProcessingException log.warn(ex.getMessage(), ex); assessment.setInstructorNotification( SamigoConstants.NOTI_PREF_INSTRUCTOR_EMAIL_DEFAULT ); } - + + postUserNotification(assessmentSettings, assessment , oldExtendedTimes, oldStartDate); + // l. FINALLY: save the assessment assessmentService.saveAssessment(assessment); saveAssessmentSettings.updateAttachment(assessment.getAssessmentAttachmentList(), assessmentSettings.getAttachmentList(),(AssessmentIfc)assessment.getData(), false); - EventTrackingService.post(EventTrackingService.newEvent(SamigoConstants.EVENT_PUBLISHED_ASSESSMENT_SETTING_EDIT, "siteId=" + AgentFacade.getCurrentSiteId() + ", pubAssessmentId=" + assessmentSettings.getAssessmentId(), true)); + eventTrackingService.post(eventTrackingService.newEvent(SamigoConstants.EVENT_PUBLISHED_ASSESSMENT_SETTING_EDIT, "siteId=" + AgentFacade.getCurrentSiteId() + ", pubAssessmentId=" + assessmentSettings.getAssessmentId(), true)); AuthorBean author = (AuthorBean) ContextUtil.lookupBean("author"); AuthorizationBean authorization = (AuthorizationBean) ContextUtil.lookupBean("authorization"); @@ -239,6 +253,61 @@ public void processAction(ActionEvent ae) throws AbortProcessingException samigoAvailableNotificationService.scheduleAssessmentAvailableNotification(String.valueOf(assessmentId)); } + + private void postUserNotification(PublishedAssessmentSettingsBean assessmentSettings, PublishedAssessmentFacade assessment, List oldExtendedTimes, Date oldStartDate){ + + if(assessment.getStatus() != AssessmentBaseIfc.RETRACT_FOR_EDIT_STATUS){ + Date newStartDate = assessmentSettings.getStartDate(); + + Boolean flag = false; + + + if(!newStartDate.equals(oldStartDate)){ + eventTrackingService.cancelDelays("siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), SamigoConstants.EVENT_ASSESSMENT_AVAILABLE); + if (newStartDate.toInstant().isAfter(Instant.now())) { + eventTrackingService.delay(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessmentSettings.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true), newStartDate.toInstant()); + //delete existing alerts + eventTrackingService.post(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_DELETE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true)); + }else { + eventTrackingService.post(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_UPDATE_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true)); + } + flag = true; + } + eventTrackingService.cancelDelays("siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(),SamigoConstants.EVENT_ASSESSMENT_AVAILABLE); + if(assessmentSettings.getExtendedTimesSize() != oldExtendedTimes.size()){ + if(!flag){ + eventTrackingService.post(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_UPDATE_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true)); + flag = true; + } + ListIterator newtimes = assessmentSettings.getExtendedTimes().listIterator(); + while (newtimes.hasNext()){ + ExtendedTime newExTime = (ExtendedTime) newtimes.next(); + if(newExTime.getStartDate().toInstant().isAfter(Instant.now())){ + eventTrackingService.delay(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessmentSettings.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true), newExTime.getStartDate().toInstant()); + } + } + }else { + ListIterator oldtimes = oldExtendedTimes.listIterator(); + ListIterator newtimes = assessmentSettings.getExtendedTimes().listIterator(); + while(oldtimes.hasNext()){ + ExtendedTime oldExTime = (ExtendedTime) oldtimes.next(); + while (newtimes.hasNext()){ + ExtendedTime newExTime = (ExtendedTime) newtimes.next(); + if(!newExTime.equals(oldExTime)){ + if(!flag){ + eventTrackingService.post(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_UPDATE_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true)); + flag = true; + } + if(newExTime.getStartDate().toInstant().isAfter(Instant.now())){ + eventTrackingService.delay(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessmentSettings.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true), newExTime.getStartDate().toInstant()); + } + } + } + } + } + } + } + public boolean checkPublishedSettings(PublishedAssessmentService assessmentService, PublishedAssessmentSettingsBean assessmentSettings, FacesContext context, boolean retractNow) { boolean error = false; // Title diff --git a/samigo/samigo-services/src/java/org/sakaiproject/tool/assessment/TestsAndQuizzesUserNotificationHandler.java b/samigo/samigo-services/src/java/org/sakaiproject/tool/assessment/TestsAndQuizzesUserNotificationHandler.java new file mode 100644 index 000000000000..ddd70e658d28 --- /dev/null +++ b/samigo/samigo-services/src/java/org/sakaiproject/tool/assessment/TestsAndQuizzesUserNotificationHandler.java @@ -0,0 +1,373 @@ +package org.sakaiproject.tool.assessment; + +import java.time.Instant; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.hibernate.SessionFactory; +import org.sakaiproject.authz.api.AuthzGroupService; +import org.sakaiproject.component.cover.ComponentManager; +import org.sakaiproject.event.api.Event; +import org.sakaiproject.event.api.EventTrackingService; +import org.sakaiproject.exception.IdUnusedException; +import org.sakaiproject.memory.api.Cache; +import org.sakaiproject.messaging.api.UserNotificationData; +import org.sakaiproject.messaging.api.AbstractUserNotificationHandler; +import org.sakaiproject.samigo.util.SamigoConstants; +import org.sakaiproject.site.api.Site; +import org.sakaiproject.site.api.SiteService; + + +import org.sakaiproject.time.api.Time; +import org.sakaiproject.tool.api.Session; +import org.sakaiproject.tool.api.SessionManager; +import org.sakaiproject.tool.assessment.data.dao.assessment.ExtendedTime; +import org.sakaiproject.tool.assessment.data.ifc.assessment.AssessmentAccessControlIfc; +import org.sakaiproject.tool.assessment.facade.ExtendedTimeFacade; +import org.sakaiproject.tool.assessment.facade.PublishedAssessmentFacade; +import org.sakaiproject.tool.assessment.services.PersistenceService; +import org.sakaiproject.tool.assessment.services.assessment.PublishedAssessmentService; +import org.springframework.stereotype.Component; +import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.support.TransactionTemplate; + +import javax.annotation.Resource; + +import static org.sakaiproject.samigo.util.SamigoConstants.*; + + + +/* + * Note: Restoring of soft deleted Assessments does not recreate bullhorn alerts! + */ + +@Slf4j +@Component +public class TestsAndQuizzesUserNotificationHandler extends AbstractUserNotificationHandler { + + public static Pattern idPattern = Pattern.compile("siteId=(\\S*),\\s*\\S*\\s*publishedAssessmentId=(\\S*)", Pattern.CASE_INSENSITIVE); + private PublishedAssessmentService publishedAssessmentService = new PublishedAssessmentService(); + + @Resource + private SiteService siteService; + + @Resource + private AuthzGroupService authzGroupService; + + @Resource + private SessionManager sessionManager; + + @Resource(name = "org.sakaiproject.springframework.orm.hibernate.GlobalTransactionManager") + private PlatformTransactionManager transactionManager; + @Resource(name = "org.sakaiproject.springframework.orm.hibernate.GlobalSessionFactory") + private SessionFactory sessionFactory; + private EventTrackingService eventTrackingService; + + + public TestsAndQuizzesUserNotificationHandler(){ + super(); + eventTrackingService = ComponentManager.get(EventTrackingService.class); + } + + @Override + public List getHandledEvents() { + return Arrays.asList(EVENT_ASSESSMENT_AVAILABLE, EVENT_PUBLISHED_ASSESSMENT_RETRACTED, EVENT_ASSESSMENT_UPDATE_AVAILABLE,EVENT_ASSESSMENT_DELETE, EVENT_PUBLISHED_ASSESSMENT_REMOVE); + } + + + @Override + public Optional> handleEvent(Event e) { + + String from = e.getUserId(); + String ref = e.getResource(); + + + List refParts = regexHelper(ref); + String siteId = refParts.get(0); + String publishedAssessmentId = refParts.get(1); + + PublishedAssessmentFacade pub = null; + try { + pub = publishedAssessmentService.getPublishedAssessment(publishedAssessmentId, true); + }catch(Exception e1){ + log.error(e1.getMessage()); + } + String releaseTo = pub.getAssessmentAccessControl().getReleaseTo(); + + ExtendedTimeFacade extendedTimeFacade = PersistenceService.getInstance().getExtendedTimeFacade(); + List extendedTimes = extendedTimeFacade.getEntriesForPub(pub.getData()); + + Map selectedGroups = pub.getReleaseToGroups(); + + + if (!releaseTo.equals("Anonymous Users")) { + try { + switch (e.getEvent()) { + case EVENT_ASSESSMENT_AVAILABLE: + checkForDelays(pub, extendedTimes,siteId, e.getUserId()); + return Optional.of(handleAdd(from,ref, siteId, pub, extendedTimes, selectedGroups, releaseTo)); + case EVENT_ASSESSMENT_UPDATE_AVAILABLE: + checkForDelays(pub, extendedTimes,siteId,e.getUserId()); + return Optional.of(handleUpdate(from, ref, siteId,pub, extendedTimes, selectedGroups, releaseTo)); + case EVENT_PUBLISHED_ASSESSMENT_RETRACTED: + case EVENT_ASSESSMENT_DELETE: + case EVENT_PUBLISHED_ASSESSMENT_REMOVE: + return Optional.of(deleteAlerts(siteId, pub)); + default: + return Optional.empty(); + } + } catch (Exception ex) { + log.error("Failed to handleEvent for Test&Quizzes userNotification alert", ex); + } + } + return Optional.empty(); + } + + + private List handleAdd(String from, String ref ,String siteId, PublishedAssessmentFacade assignment, List extendedTimes, Map selectedGroups, String releaseTo) + throws Exception { + List bhEvents = new ArrayList<>(); + + Instant startDateInstant = assignment.getStartDate().toInstant(); + Site site = siteService.getSite(siteId); + String title = assignment.getTitle(); + + Collection groupsUsers = null; + + if (releaseTo.equals(AssessmentAccessControlIfc.RELEASE_TO_SELECTED_GROUPS)) { + groupsUsers = getUsersInSelectedGroups(siteId, selectedGroups); + } + + for (String to : site.getUsersIsAllowed(AUTHZ_TAKE_ASSESSMENT)) { + // If this is a grouped assignment, is 'to' in one of the groups? + if ((releaseTo.equals(site.getTitle()) || (groupsUsers != null && groupsUsers.contains(to))) && (!from.equals(to) && !securityService.isSuperUser(to)) && checkTime(startDateInstant,extendedTimes, to, siteId) && !bhAlreadyExistsForUser(ref, to)) { + //link to tool + String url = site.getUrl() + "/tool/" + site.getToolForCommonId("sakai.samigo").getId(); + bhEvents.add(new UserNotificationData(from, to, siteId, title, url)); + } + } + return bhEvents; + } + + private List handleUpdate(String from, String ref, String siteId, PublishedAssessmentFacade assignment, List extendedTimes, Map selectedGroups, String releaseTo) + throws Exception { + Site site = siteService.getSite(siteId); + Set siteUsers = site.getUsersIsAllowed(AUTHZ_TAKE_ASSESSMENT); + + Collection groupsUsers = null; + + if (releaseTo.equals(AssessmentAccessControlIfc.RELEASE_TO_SELECTED_GROUPS)) { + groupsUsers = getUsersInSelectedGroups(siteId, selectedGroups); + } + + if(!siteUsers.isEmpty()){ + try{ + TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager); + transactionTemplate.execute(status -> { + sessionFactory.getCurrentSession().createQuery("delete UserNotification where EVENT in :events and REF = :ref and TO_USER in :toUsers") + .setParameterList("events", new String[]{EVENT_ASSESSMENT_AVAILABLE, EVENT_ASSESSMENT_UPDATE_AVAILABLE}) + .setString("ref", ref) + .setParameterList("toUsers", siteUsers).executeUpdate(); + return null; + }); + }catch (Exception e2){ + log.error("failed to delete TestAndQuizzes userNotification alerts: " + e2.getMessage()); + } + } + + Instant startDateInstant = assignment.getStartDate().toInstant(); + String title = assignment.getTitle(); + + List bhEvents = new ArrayList<>(); + if (!releaseTo.equals("Anonymous Users")) { + for (String to : siteUsers) { + // If this is a grouped assignment, is 'to' in one of the groups? + if ((releaseTo.equals(siteId) || (groupsUsers != null && groupsUsers.contains(to))) && (!from.equals(to) && !securityService.isSuperUser(to)) && checkTime(startDateInstant, extendedTimes, to, siteId) && !bhAlreadyExistsForUser(ref, to)) { + //link to tool + String url = site.getUrl() + "/tool/" + site.getToolForCommonId("sakai.samigo").getId(); + bhEvents.add(new UserNotificationData(from, to, siteId, title, url)); + } + } + return bhEvents; + } + return bhEvents; + } + + private List deleteAlerts(String siteId, PublishedAssessmentFacade assignment) + throws IdUnusedException { + Site site = siteService.getSite(siteId); + Set users = site.getUsersIsAllowed(AUTHZ_TAKE_ASSESSMENT); + List bhEvents = new ArrayList<>(); + // Clean out all the alerts for the site users. + + String ref = "siteId="+siteId+", assessmentId=" +assignment.getAssessmentId()+", publishedAssessmentId="+ assignment.getPublishedAssessmentId(); + if(!users.isEmpty()){ + try{ + TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager); + transactionTemplate.execute(status -> { + sessionFactory.getCurrentSession().createQuery("delete UserNotification where EVENT in :events and REF = :ref and TO_USER in :toUsers") + .setParameterList("events", new String[]{EVENT_ASSESSMENT_AVAILABLE, EVENT_ASSESSMENT_UPDATE_AVAILABLE}) + .setString("ref", ref) + .setParameterList("toUsers", users).executeUpdate(); + return null; + }); + }catch (Exception e3){ + log.error("failed to delete TestAndQuizzes UserNotificationData data " + e3.getMessage()); + } + } + + + eventTrackingService.cancelDelays(ref, EVENT_ASSESSMENT_AVAILABLE); + return bhEvents; + } + + /* + * user overrides group exception + * select first extended time of list for user exceptions; for multiple group exception the last is picked --> related to issues SAK-45277, SAK-44729 + */ + + private boolean checkTime(Instant startDateInstant , List extendedTimes, String to, String siteId){ + ListIterator times = extendedTimes.listIterator(); + boolean first = true; + boolean result = true; + boolean exTimeIsSet =false; + + while(times.hasNext()) { + ExtendedTime exTime = (ExtendedTime) times.next(); + String user = exTime.getUser(); + + Set set = new HashSet(); + set.add(getGroupRef(siteId, exTime.getGroup())); + Collection groupUsers = authzGroupService.getAuthzUsersInGroups(set); + + + Instant startInstant = exTime.getStartDate().toInstant(); + + if (startInstant.isBefore(Instant.now()) && (( user != null && user.equals(to) && first) || (first && groupUsers != null && groupUsers.contains(to)))) { + result = true; + exTimeIsSet = true; + if(!StringUtils.isEmpty(user) && first){ + first = false; + } + } else if (startInstant.isAfter(Instant.now()) && ((user != null && user.equals(to) && first) || (first && groupUsers != null && groupUsers.contains(to)))) { + result = false; + exTimeIsSet = true; + if(!StringUtils.isEmpty(user) && first){ + first = false; + } + } + } + if(!exTimeIsSet && startDateInstant.isAfter(Instant.now())){ + result = false; + } + return result; + } + + /* + * sakai allows only one active delay for a certain reference + * after first event is fired after publishing --> check if a new delay should be created + */ + + private void checkForDelays(PublishedAssessmentFacade assignment,List extendedTimes,String siteId, String userId){ + Instant earliestDelayInstant = null; + if(assignment.getStartDate().toInstant().isAfter(Instant.now())){ + earliestDelayInstant = assignment.getStartDate().toInstant(); + } + if(extendedTimes.size() != 0){ + ListIterator it = extendedTimes.listIterator(); + while (it.hasNext()){ + ExtendedTime exTime = (ExtendedTime) it.next(); + Instant exStartInstant = exTime.getStartDate().toInstant(); + if(exStartInstant.isAfter(Instant.now()) && (earliestDelayInstant != null && exStartInstant.isBefore(earliestDelayInstant))){ + earliestDelayInstant = exStartInstant; + + }else if(earliestDelayInstant != null && exStartInstant.isAfter(earliestDelayInstant)){ + //leave empty + }else if(exStartInstant.isAfter(Instant.now())){ + earliestDelayInstant = exStartInstant; + } + } + } + if(earliestDelayInstant != null){ + // creating a new delay after an already delayed event, the sessionUserId is different from the original author of the assessment + Session session = sessionManager.getCurrentSession(); + boolean flag = false; + String tmpSessionUserId = null; + if(session.getUserId() != userId){ + tmpSessionUserId = session.getUserId(); + session.setUserId(userId); + flag = true; + } + Event event = eventTrackingService.newEvent(EVENT_ASSESSMENT_AVAILABLE, "siteId=" + siteId + ", assessmentId=" + assignment.getAssessmentId() + ", publishedAssessmentId=" + assignment.getPublishedAssessmentId(), true); + eventTrackingService.delay(event, earliestDelayInstant); + if(flag){ + session.setUserId(tmpSessionUserId); + } + } + } + + private boolean bhAlreadyExistsForUser(String ref, String toUser){ + TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager); + return transactionTemplate.execute(status -> { + Long bhWithRef = (Long) sessionFactory.getCurrentSession() + .createQuery("select count(*) from UserNotification where ref = :ref and event = :event and toUser = :toUser") + .setString("ref", ref).setString("event", EVENT_ASSESSMENT_AVAILABLE).setString("toUser", toUser).uniqueResult(); + return bhWithRef > 0; + }); + } + + private Collection removeDuplicates(Collection list){ + ArrayList newList = new ArrayList(); + for (T element : list) { + if (!newList.contains(element)) { + newList.add(element); + } + } + return newList; + } + + private String getGroupRef(String siteId, String groupId){ + return "/site/" + siteId + "/group/" + groupId; + } + + private Collection getUsersInSelectedGroups(String siteId, Map selectedGroups){ + String[] groups = null; + Set groupIds = new HashSet(); + Collection groupsUsers = null; + + for(Map.Entry entry: selectedGroups.entrySet()){ + String id = getGroupRef(siteId, entry.getKey()); + groupIds.add(id); + } + groupsUsers = authzGroupService.getAuthzUsersInGroups(groupIds); + groupsUsers = removeDuplicates(groupsUsers); + return groupsUsers; + + } + + public static List regexHelper(String ref){ + Matcher matcher = idPattern.matcher(ref); + String siteId = null; + String publishedAssessmentId = null; + List response = new ArrayList(); + + while (matcher.find()) { + if (matcher.group(1) != null) { + siteId = matcher.group(1); + response.add(siteId); + } + if (matcher.group(2) != null) { + publishedAssessmentId = matcher.group(2); + response.add(publishedAssessmentId); + } + } + return response; + + } + + + +} diff --git a/webcomponents/bundle/src/main/bundle/sui-notifications.properties b/webcomponents/bundle/src/main/bundle/sui-notifications.properties index f21e3c60e3c5..9aa815e90f9a 100644 --- a/webcomponents/bundle/src/main/bundle/sui-notifications.properties +++ b/webcomponents/bundle/src/main/bundle/sui-notifications.properties @@ -15,6 +15,8 @@ motd=Message of the Day no_notifications=No notifications profile=Social show=Show +samigoCreated = Created/updated new assessment "{0}" in "{1}" +sam=Tests&Quizzes diff --git a/webcomponents/tool/src/main/frontend/js/sui-notifications/sui-notifications.js b/webcomponents/tool/src/main/frontend/js/sui-notifications/sui-notifications.js index 15dd880235a4..6f8f7382db2e 100644 --- a/webcomponents/tool/src/main/frontend/js/sui-notifications/sui-notifications.js +++ b/webcomponents/tool/src/main/frontend/js/sui-notifications/sui-notifications.js @@ -85,6 +85,8 @@ class SuiNotifications extends SakaiElement { this._decorateAnnouncementNotification(noti); } else if (toolEventPrefix === "commons") { this._decorateCommonsNotification(noti); + } else if (toolEventPrefix === "sam") { + this._decorateSamigoNotification(noti); } } @@ -139,6 +141,13 @@ class SuiNotifications extends SakaiElement { noti.title = this.i18n.academic_comment_graded.replace('{0}', noti.siteTitle); } + _decorateSamigoNotification(noti) { + + if (noti.event === "sam.assessment.available" || noti.event === "sam.assessment.update.available") { + noti.title = this.i18n.samigoCreated.replace('{0}', noti.title).replace('{1}', noti.siteTitle); + } + } + fireLoadedEvent() { this.dispatchEvent(new CustomEvent("notifications-loaded", { detail: { count: this.notifications.filter(n => !n.viewed).length }, bubbles: true })); } From b574c58814bfb49a325e4686557ed4b70b002b2b Mon Sep 17 00:00:00 2001 From: JulianJanetschek <54806745+jkjanetschek@users.noreply.github.com> Date: Tue, 26 Sep 2023 15:31:48 +0200 Subject: [PATCH 02/35] Update SamigoConstants.java --- .../java/org/sakaiproject/samigo/util/SamigoConstants.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/samigo/samigo-api/src/java/org/sakaiproject/samigo/util/SamigoConstants.java b/samigo/samigo-api/src/java/org/sakaiproject/samigo/util/SamigoConstants.java index 570b37828b50..e6ac38a47177 100644 --- a/samigo/samigo-api/src/java/org/sakaiproject/samigo/util/SamigoConstants.java +++ b/samigo/samigo-api/src/java/org/sakaiproject/samigo/util/SamigoConstants.java @@ -91,9 +91,7 @@ public final class SamigoConstants { public static final String EVENT_PUBLISHED_ASSESSMENT_SETTING_EDIT = "sam.pubsetting.edit"; public static final String EVENT_PUBLISHED_ASSESSMENT_UNINDEXITEM = "sam.pubassessment.unindexitem"; public static final String EVENT_PUBLISHED_ASSESSMENT_RETRACTED = "sam.pubassessment.retracted"; - public static final String EVENT_PUBLISHED_ASSESSMENT_REPUBLISH_AVAILABLE = "sam.pubassessment.republish.available"; - public static final String EVENT_PUBLISHED_ASSESSMENT_SETTING_EDIT_BULLHORN = "sam.pubsetting.edit.bullhorn"; - public static final String EVENT_UPDATE_PUBLISHED_ASSESSMENT_OPENDATE = "sam.pubassessment.update.opendate"; + //Question pool events public static final String EVENT_QUESTIONPOOL_QUESTIONMOVED = "sam.questionpool.questionmoved"; From e19e0f0a2a72b389dd3066925a76e6e2aba7ec7d Mon Sep 17 00:00:00 2001 From: JulianJanetschek <54806745+jkjanetschek@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:55:21 +0200 Subject: [PATCH 03/35] Update samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/EditAssessmentListener.java Co-authored-by: Adrian Fish --- .../assessment/ui/listener/author/EditAssessmentListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/EditAssessmentListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/EditAssessmentListener.java index f7e6e2012a34..62c449b93166 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/EditAssessmentListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/EditAssessmentListener.java @@ -101,7 +101,7 @@ public void processAction(ActionEvent ae) throws AbortProcessingException EventTrackingService.cancelDelays("siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), EVENT_ASSESSMENT_AVAILABLE); EventTrackingService.post(EventTrackingService.newEvent(EVENT_PUBLISHED_ASSESSMENT_RETRACTED,"siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId() ,true)); } - }catch (Exception e){ + } catch (Exception e) { log.warn("Could not get published Assessment for id {}", assessmentId); } } From 2e9e6cae019100eb86a3bb9afb3e2c19dc89af2a Mon Sep 17 00:00:00 2001 From: JulianJanetschek <54806745+jkjanetschek@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:55:26 +0200 Subject: [PATCH 04/35] Update samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/EditAssessmentListener.java Co-authored-by: Adrian Fish --- .../assessment/ui/listener/author/EditAssessmentListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/EditAssessmentListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/EditAssessmentListener.java index 62c449b93166..c2e503321240 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/EditAssessmentListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/EditAssessmentListener.java @@ -95,7 +95,7 @@ public void processAction(ActionEvent ae) throws AbortProcessingException if((assessmentId != null && assessmentBean.getAssessment() == null) || (assessmentId != null && assessmentBean.getAssessment() != null && assessmentBean.getAssessment().getAssessmentBaseId() != null && !Long.toString(assessmentBean.getAssessment().getAssessmentBaseId()).equals(assessmentId))){ PublishedAssessmentService publishedAssessmentService = new PublishedAssessmentService(); - try{ + try { PublishedAssessmentFacade assessment = publishedAssessmentService.getPublishedAssessment(assessmentId); if(!Objects.equals(assessment.getStatus(), AssessmentIfc.RETRACT_FOR_EDIT_STATUS)){ EventTrackingService.cancelDelays("siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), EVENT_ASSESSMENT_AVAILABLE); From 7b428afe83696234f909e406e63c3100276bfcc0 Mon Sep 17 00:00:00 2001 From: JulianJanetschek <54806745+jkjanetschek@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:55:34 +0200 Subject: [PATCH 05/35] Update samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/EditAssessmentListener.java Co-authored-by: Adrian Fish --- .../assessment/ui/listener/author/EditAssessmentListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/EditAssessmentListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/EditAssessmentListener.java index c2e503321240..e9afad790ec2 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/EditAssessmentListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/EditAssessmentListener.java @@ -97,7 +97,7 @@ public void processAction(ActionEvent ae) throws AbortProcessingException PublishedAssessmentService publishedAssessmentService = new PublishedAssessmentService(); try { PublishedAssessmentFacade assessment = publishedAssessmentService.getPublishedAssessment(assessmentId); - if(!Objects.equals(assessment.getStatus(), AssessmentIfc.RETRACT_FOR_EDIT_STATUS)){ + if (!Objects.equals(assessment.getStatus(), AssessmentIfc.RETRACT_FOR_EDIT_STATUS)) { EventTrackingService.cancelDelays("siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), EVENT_ASSESSMENT_AVAILABLE); EventTrackingService.post(EventTrackingService.newEvent(EVENT_PUBLISHED_ASSESSMENT_RETRACTED,"siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId() ,true)); } From 5e92c36baa2cc26822bd3d58f331bb516da1fdcc Mon Sep 17 00:00:00 2001 From: JulianJanetschek <54806745+jkjanetschek@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:55:40 +0200 Subject: [PATCH 06/35] Update samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/EditAssessmentListener.java Co-authored-by: Adrian Fish --- .../ui/listener/author/EditAssessmentListener.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/EditAssessmentListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/EditAssessmentListener.java index e9afad790ec2..ecb8b06aa715 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/EditAssessmentListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/EditAssessmentListener.java @@ -92,8 +92,10 @@ public void processAction(ActionEvent ae) throws AbortProcessingException //check if draft - if((assessmentId != null && assessmentBean.getAssessment() == null) || (assessmentId != null && assessmentBean.getAssessment() != null && assessmentBean.getAssessment().getAssessmentBaseId() != null - && !Long.toString(assessmentBean.getAssessment().getAssessmentBaseId()).equals(assessmentId))){ + if ((assessmentId != null && assessmentBean.getAssessment() == null) + || (assessmentId != null && assessmentBean.getAssessment() != null + && assessmentBean.getAssessment().getAssessmentBaseId() != null + && !Long.toString(assessmentBean.getAssessment().getAssessmentBaseId()).equals(assessmentId))) { PublishedAssessmentService publishedAssessmentService = new PublishedAssessmentService(); try { PublishedAssessmentFacade assessment = publishedAssessmentService.getPublishedAssessment(assessmentId); From 3a524abe956a36953c636a05d638180ddb063216 Mon Sep 17 00:00:00 2001 From: JulianJanetschek <54806745+jkjanetschek@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:55:45 +0200 Subject: [PATCH 07/35] Update samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/PublishAssessmentListener.java Co-authored-by: Adrian Fish --- .../ui/listener/author/PublishAssessmentListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/PublishAssessmentListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/PublishAssessmentListener.java index e5010a7e7bc3..8a41a50d74f6 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/PublishAssessmentListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/PublishAssessmentListener.java @@ -291,7 +291,7 @@ private void publish(AssessmentFacade assessment, eventTrackingService.post(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + pub.getPublishedAssessmentId(), true)); } else { Instant earliestDelayInstant = instant; - if(assessmentSettings.getExtendedTimesSize() != 0){ + if (assessmentSettings.getExtendedTimesSize() != 0) { ListIterator it = extendedTimes.listIterator(); boolean postEvent = false; while (it.hasNext()){ From f21e572cf37547db69615d903494a7d25901b361 Mon Sep 17 00:00:00 2001 From: JulianJanetschek <54806745+jkjanetschek@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:56:10 +0200 Subject: [PATCH 08/35] Update samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java Co-authored-by: Adrian Fish --- .../ui/listener/author/SavePublishedSettingsListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java index 14ab7d9195e8..ca8e20afe1d9 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java @@ -289,7 +289,7 @@ private void postUserNotification(PublishedAssessmentSettingsBean assessmentSett }else { ListIterator oldtimes = oldExtendedTimes.listIterator(); ListIterator newtimes = assessmentSettings.getExtendedTimes().listIterator(); - while(oldtimes.hasNext()){ + while (oldtimes.hasNext()) { ExtendedTime oldExTime = (ExtendedTime) oldtimes.next(); while (newtimes.hasNext()){ ExtendedTime newExTime = (ExtendedTime) newtimes.next(); From 1e885a629cfa3a457b069ea10f3f7d53c766da73 Mon Sep 17 00:00:00 2001 From: JulianJanetschek <54806745+jkjanetschek@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:56:15 +0200 Subject: [PATCH 09/35] Update samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java Co-authored-by: Adrian Fish --- .../ui/listener/author/SavePublishedSettingsListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java index ca8e20afe1d9..97ae1397a9c4 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java @@ -291,7 +291,7 @@ private void postUserNotification(PublishedAssessmentSettingsBean assessmentSett ListIterator newtimes = assessmentSettings.getExtendedTimes().listIterator(); while (oldtimes.hasNext()) { ExtendedTime oldExTime = (ExtendedTime) oldtimes.next(); - while (newtimes.hasNext()){ + while (newtimes.hasNext()) { ExtendedTime newExTime = (ExtendedTime) newtimes.next(); if(!newExTime.equals(oldExTime)){ if(!flag){ From a0c7f042168d3d781079ac72a5c9164de183ed6d Mon Sep 17 00:00:00 2001 From: JulianJanetschek <54806745+jkjanetschek@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:56:20 +0200 Subject: [PATCH 10/35] Update samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java Co-authored-by: Adrian Fish --- .../ui/listener/author/SavePublishedSettingsListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java index 97ae1397a9c4..26e138a16913 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java @@ -293,7 +293,7 @@ private void postUserNotification(PublishedAssessmentSettingsBean assessmentSett ExtendedTime oldExTime = (ExtendedTime) oldtimes.next(); while (newtimes.hasNext()) { ExtendedTime newExTime = (ExtendedTime) newtimes.next(); - if(!newExTime.equals(oldExTime)){ + if (!newExTime.equals(oldExTime)) { if(!flag){ eventTrackingService.post(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_UPDATE_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true)); flag = true; From ce079b2182efd69e5267819067a8a4919665d3aa Mon Sep 17 00:00:00 2001 From: JulianJanetschek <54806745+jkjanetschek@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:56:26 +0200 Subject: [PATCH 11/35] Update samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java Co-authored-by: Adrian Fish --- .../ui/listener/author/SavePublishedSettingsListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java index 26e138a16913..12869219522a 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java @@ -294,7 +294,7 @@ private void postUserNotification(PublishedAssessmentSettingsBean assessmentSett while (newtimes.hasNext()) { ExtendedTime newExTime = (ExtendedTime) newtimes.next(); if (!newExTime.equals(oldExTime)) { - if(!flag){ + if (!flag) { eventTrackingService.post(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_UPDATE_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true)); flag = true; } From 83c3ea174c06284c9264bff15ba9b77a2aaf5c92 Mon Sep 17 00:00:00 2001 From: JulianJanetschek <54806745+jkjanetschek@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:56:31 +0200 Subject: [PATCH 12/35] Update samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java Co-authored-by: Adrian Fish --- .../ui/listener/author/SavePublishedSettingsListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java index 12869219522a..0353617c7ed4 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java @@ -298,7 +298,7 @@ private void postUserNotification(PublishedAssessmentSettingsBean assessmentSett eventTrackingService.post(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_UPDATE_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true)); flag = true; } - if(newExTime.getStartDate().toInstant().isAfter(Instant.now())){ + if (newExTime.getStartDate().toInstant().isAfter(Instant.now())) { eventTrackingService.delay(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessmentSettings.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true), newExTime.getStartDate().toInstant()); } } From 06370392a456e3547f8133d22add14b20530ecff Mon Sep 17 00:00:00 2001 From: JulianJanetschek <54806745+jkjanetschek@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:56:43 +0200 Subject: [PATCH 13/35] Update samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/PublishAssessmentListener.java Co-authored-by: Adrian Fish --- .../ui/listener/author/PublishAssessmentListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/PublishAssessmentListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/PublishAssessmentListener.java index 8a41a50d74f6..62610e2a4afa 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/PublishAssessmentListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/PublishAssessmentListener.java @@ -297,7 +297,7 @@ private void publish(AssessmentFacade assessment, while (it.hasNext()){ ExtendedTime exTime = (ExtendedTime) it.next(); Instant startInstant = exTime.getStartDate().toInstant(); - if(startInstant.isBefore(Instant.now()) && !postEvent) { + if (startInstant.isBefore(Instant.now()) && !postEvent) { postEvent = true; } else if (startInstant.isBefore(instant)) { earliestDelayInstant = startInstant; From 79f0567634010a7baa92cf89d32220b80908b504 Mon Sep 17 00:00:00 2001 From: JulianJanetschek <54806745+jkjanetschek@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:56:54 +0200 Subject: [PATCH 14/35] Update samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/PublishAssessmentListener.java Co-authored-by: Adrian Fish --- .../ui/listener/author/PublishAssessmentListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/PublishAssessmentListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/PublishAssessmentListener.java index 62610e2a4afa..b7f376510fc3 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/PublishAssessmentListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/PublishAssessmentListener.java @@ -303,7 +303,7 @@ private void publish(AssessmentFacade assessment, earliestDelayInstant = startInstant; } } - if(postEvent) { + if (postEvent) { eventTrackingService.post(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + pub.getPublishedAssessmentId(), true)); } } From fbaa0757c284c52b62bcfde42256419279d1bb90 Mon Sep 17 00:00:00 2001 From: JulianJanetschek <54806745+jkjanetschek@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:57:10 +0200 Subject: [PATCH 15/35] Update samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/PublishAssessmentListener.java Co-authored-by: Adrian Fish --- .../ui/listener/author/PublishAssessmentListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/PublishAssessmentListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/PublishAssessmentListener.java index b7f376510fc3..d57eda0b4f25 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/PublishAssessmentListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/PublishAssessmentListener.java @@ -294,7 +294,7 @@ private void publish(AssessmentFacade assessment, if (assessmentSettings.getExtendedTimesSize() != 0) { ListIterator it = extendedTimes.listIterator(); boolean postEvent = false; - while (it.hasNext()){ + while (it.hasNext()) { ExtendedTime exTime = (ExtendedTime) it.next(); Instant startInstant = exTime.getStartDate().toInstant(); if (startInstant.isBefore(Instant.now()) && !postEvent) { From f6d3ee0647a60b8a748655ec239ae995bd6adeb1 Mon Sep 17 00:00:00 2001 From: JulianJanetschek <54806745+jkjanetschek@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:57:36 +0200 Subject: [PATCH 16/35] Update samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java Co-authored-by: Adrian Fish --- .../ui/listener/author/RepublishAssessmentListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java index 6df077992d2f..454d1645f6b8 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java @@ -89,7 +89,7 @@ public class RepublishAssessmentListener implements ActionListener { private static final ResourceLoader rl = new ResourceLoader("org.sakaiproject.tool.assessment.bundle.AssessmentSettingsMessages"); private final SamigoAvailableNotificationService samigoAvailableNotificationService = ComponentManager.get(SamigoAvailableNotificationService.class); private EventTrackingService eventTrackingService; - public RepublishAssessmentListener(){ + public RepublishAssessmentListener() { eventTrackingService = ComponentManager.get(EventTrackingService.class); } public void processAction(ActionEvent ae) throws AbortProcessingException { From 3839fa67106c28d767dfa99543ef642f1f41c16c Mon Sep 17 00:00:00 2001 From: JulianJanetschek <54806745+jkjanetschek@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:57:47 +0200 Subject: [PATCH 17/35] Update samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java Co-authored-by: Adrian Fish --- .../ui/listener/author/RepublishAssessmentListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java index 454d1645f6b8..1fd229dc0a77 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java @@ -192,7 +192,7 @@ private void postUserNotification(PublishedAssessmentFacade assessment, Publishe eventTrackingService.post(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_UPDATE_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true)); if(publishedAssessmentSettings.getExtendedTimesSize() != 0){ ListIterator it = extendedTimes.listIterator(); - while (it.hasNext()){ + while (it.hasNext()) { ExtendedTime exTime = (ExtendedTime) it.next(); Instant startInstant = exTime.getStartDate().toInstant(); if(startInstant.isAfter(Instant.now())) { From 6260a7b4e85841576faff6f65c42cbb0e89e19d3 Mon Sep 17 00:00:00 2001 From: JulianJanetschek <54806745+jkjanetschek@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:57:57 +0200 Subject: [PATCH 18/35] Update samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java Co-authored-by: Adrian Fish --- .../ui/listener/author/RepublishAssessmentListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java index 1fd229dc0a77..771113eab1b3 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java @@ -184,7 +184,7 @@ public void processAction(ActionEvent ae) throws AbortProcessingException { author.setOutcome("author"); } - private void postUserNotification(PublishedAssessmentFacade assessment, PublishedAssessmentSettingsBean publishedAssessmentSettings){ + private void postUserNotification(PublishedAssessmentFacade assessment, PublishedAssessmentSettingsBean publishedAssessmentSettings) { List extendedTimes = publishedAssessmentSettings.getExtendedTimes(); Instant instant = assessment.getStartDate().toInstant(); From 8186b7da9df39a64ec3d0c62125cce0fbde4244d Mon Sep 17 00:00:00 2001 From: JulianJanetschek <54806745+jkjanetschek@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:58:06 +0200 Subject: [PATCH 19/35] Update samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java Co-authored-by: Adrian Fish --- .../ui/listener/author/RepublishAssessmentListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java index 771113eab1b3..18f767af6aa6 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java @@ -195,7 +195,7 @@ private void postUserNotification(PublishedAssessmentFacade assessment, Publishe while (it.hasNext()) { ExtendedTime exTime = (ExtendedTime) it.next(); Instant startInstant = exTime.getStartDate().toInstant(); - if(startInstant.isAfter(Instant.now())) { + if (startInstant.isAfter(Instant.now())) { eventTrackingService.delay(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true), startInstant); } } From 59b6b64c73d5ad48c2d46944be848dd23839132d Mon Sep 17 00:00:00 2001 From: JulianJanetschek <54806745+jkjanetschek@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:58:16 +0200 Subject: [PATCH 20/35] Update samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java Co-authored-by: Adrian Fish --- .../ui/listener/author/RepublishAssessmentListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java index 18f767af6aa6..079022898c7b 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java @@ -209,7 +209,7 @@ private void postUserNotification(PublishedAssessmentFacade assessment, Publishe Instant startInstant = exTime.getStartDate().toInstant(); if(startInstant.isBefore(Instant.now())) { eventTrackingService.post(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_UPDATE_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true)); - }else if(startInstant.isAfter(Instant.now()) && !instant.equals(startInstant)){ + } else if(startInstant.isAfter(Instant.now()) && !instant.equals(startInstant)) { eventTrackingService.delay(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true), startInstant); } } From c1ccfa3a81a3da8b18c8c7d15e834909d51627ba Mon Sep 17 00:00:00 2001 From: JulianJanetschek <54806745+jkjanetschek@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:58:28 +0200 Subject: [PATCH 21/35] Update samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java Co-authored-by: Adrian Fish --- .../ui/listener/author/RepublishAssessmentListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java index 079022898c7b..e5ca912edfad 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java @@ -207,7 +207,7 @@ private void postUserNotification(PublishedAssessmentFacade assessment, Publishe while (it.hasNext()){ ExtendedTime exTime = (ExtendedTime) it.next(); Instant startInstant = exTime.getStartDate().toInstant(); - if(startInstant.isBefore(Instant.now())) { + if (startInstant.isBefore(Instant.now())) { eventTrackingService.post(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_UPDATE_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true)); } else if(startInstant.isAfter(Instant.now()) && !instant.equals(startInstant)) { eventTrackingService.delay(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true), startInstant); From eba23f2bd094c0994c70fd4fdfe7466b1dbf9f17 Mon Sep 17 00:00:00 2001 From: JulianJanetschek <54806745+jkjanetschek@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:58:39 +0200 Subject: [PATCH 22/35] Update samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java Co-authored-by: Adrian Fish --- .../ui/listener/author/RepublishAssessmentListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java index e5ca912edfad..80ca69a7f492 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java @@ -202,7 +202,7 @@ private void postUserNotification(PublishedAssessmentFacade assessment, Publishe } } else { eventTrackingService.delay(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true), instant); - if(publishedAssessmentSettings.getExtendedTimesSize() != 0){ + if (publishedAssessmentSettings.getExtendedTimesSize() != 0) { ListIterator it = extendedTimes.listIterator(); while (it.hasNext()){ ExtendedTime exTime = (ExtendedTime) it.next(); From 5f5804a972361d7031311f0ba066ce5af5510bc4 Mon Sep 17 00:00:00 2001 From: JulianJanetschek <54806745+jkjanetschek@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:58:49 +0200 Subject: [PATCH 23/35] Update samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java Co-authored-by: Adrian Fish --- .../ui/listener/author/RepublishAssessmentListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java index 80ca69a7f492..c3387a34c95d 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java @@ -204,7 +204,7 @@ private void postUserNotification(PublishedAssessmentFacade assessment, Publishe eventTrackingService.delay(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true), instant); if (publishedAssessmentSettings.getExtendedTimesSize() != 0) { ListIterator it = extendedTimes.listIterator(); - while (it.hasNext()){ + while (it.hasNext()) { ExtendedTime exTime = (ExtendedTime) it.next(); Instant startInstant = exTime.getStartDate().toInstant(); if (startInstant.isBefore(Instant.now())) { From 1c9aec56f66b9b047621ef8e07833cd7b8f88c4f Mon Sep 17 00:00:00 2001 From: JulianJanetschek <54806745+jkjanetschek@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:58:59 +0200 Subject: [PATCH 24/35] Update samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java Co-authored-by: Adrian Fish --- .../ui/listener/author/SavePublishedSettingsListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java index 0353617c7ed4..66bd36d8a93a 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java @@ -254,7 +254,7 @@ public void processAction(ActionEvent ae) throws AbortProcessingException } - private void postUserNotification(PublishedAssessmentSettingsBean assessmentSettings, PublishedAssessmentFacade assessment, List oldExtendedTimes, Date oldStartDate){ + private void postUserNotification(PublishedAssessmentSettingsBean assessmentSettings, PublishedAssessmentFacade assessment, List oldExtendedTimes, Date oldStartDate) { if(assessment.getStatus() != AssessmentBaseIfc.RETRACT_FOR_EDIT_STATUS){ Date newStartDate = assessmentSettings.getStartDate(); From 55ce9e1e05ce2cab1688cc0d14c090a706d679c7 Mon Sep 17 00:00:00 2001 From: JulianJanetschek <54806745+jkjanetschek@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:59:15 +0200 Subject: [PATCH 25/35] Update samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java Co-authored-by: Adrian Fish --- .../ui/listener/author/SavePublishedSettingsListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java index 66bd36d8a93a..1c8f1aba9ec9 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java @@ -256,7 +256,7 @@ public void processAction(ActionEvent ae) throws AbortProcessingException private void postUserNotification(PublishedAssessmentSettingsBean assessmentSettings, PublishedAssessmentFacade assessment, List oldExtendedTimes, Date oldStartDate) { - if(assessment.getStatus() != AssessmentBaseIfc.RETRACT_FOR_EDIT_STATUS){ + if (assessment.getStatus() != AssessmentBaseIfc.RETRACT_FOR_EDIT_STATUS) { Date newStartDate = assessmentSettings.getStartDate(); Boolean flag = false; From e81b412a60429f9ac821c4abeffeb2cea6d3cbc1 Mon Sep 17 00:00:00 2001 From: JulianJanetschek <54806745+jkjanetschek@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:59:25 +0200 Subject: [PATCH 26/35] Update samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java Co-authored-by: Adrian Fish --- .../ui/listener/author/SavePublishedSettingsListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java index 1c8f1aba9ec9..5331d690edbf 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java @@ -262,7 +262,7 @@ private void postUserNotification(PublishedAssessmentSettingsBean assessmentSett Boolean flag = false; - if(!newStartDate.equals(oldStartDate)){ + if (!newStartDate.equals(oldStartDate)) { eventTrackingService.cancelDelays("siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), SamigoConstants.EVENT_ASSESSMENT_AVAILABLE); if (newStartDate.toInstant().isAfter(Instant.now())) { eventTrackingService.delay(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessmentSettings.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true), newStartDate.toInstant()); From 7c45b7ecf979be1ff47a76793320166359fe9399 Mon Sep 17 00:00:00 2001 From: JulianJanetschek <54806745+jkjanetschek@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:59:34 +0200 Subject: [PATCH 27/35] Update samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java Co-authored-by: Adrian Fish --- .../ui/listener/author/SavePublishedSettingsListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java index 5331d690edbf..1d975cf47aa8 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java @@ -268,7 +268,7 @@ private void postUserNotification(PublishedAssessmentSettingsBean assessmentSett eventTrackingService.delay(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessmentSettings.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true), newStartDate.toInstant()); //delete existing alerts eventTrackingService.post(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_DELETE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true)); - }else { + } else { eventTrackingService.post(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_UPDATE_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true)); } flag = true; From 00c1e8a8d794cff8c710bfd1469877f5ede37c21 Mon Sep 17 00:00:00 2001 From: JulianJanetschek <54806745+jkjanetschek@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:59:44 +0200 Subject: [PATCH 28/35] Update samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java Co-authored-by: Adrian Fish --- .../ui/listener/author/SavePublishedSettingsListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java index 1d975cf47aa8..040b13f0bc9d 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java @@ -274,7 +274,7 @@ private void postUserNotification(PublishedAssessmentSettingsBean assessmentSett flag = true; } eventTrackingService.cancelDelays("siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(),SamigoConstants.EVENT_ASSESSMENT_AVAILABLE); - if(assessmentSettings.getExtendedTimesSize() != oldExtendedTimes.size()){ + if (assessmentSettings.getExtendedTimesSize() != oldExtendedTimes.size()) { if(!flag){ eventTrackingService.post(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_UPDATE_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true)); flag = true; From d459b6e70a70cc102281aadce0fff02f7d13c9d4 Mon Sep 17 00:00:00 2001 From: JulianJanetschek <54806745+jkjanetschek@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:59:56 +0200 Subject: [PATCH 29/35] Update samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java Co-authored-by: Adrian Fish --- .../ui/listener/author/SavePublishedSettingsListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java index 040b13f0bc9d..b866d368d911 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java @@ -275,7 +275,7 @@ private void postUserNotification(PublishedAssessmentSettingsBean assessmentSett } eventTrackingService.cancelDelays("siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(),SamigoConstants.EVENT_ASSESSMENT_AVAILABLE); if (assessmentSettings.getExtendedTimesSize() != oldExtendedTimes.size()) { - if(!flag){ + if (!flag) { eventTrackingService.post(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_UPDATE_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true)); flag = true; } From 3eb7d1cce0e1336de62c3631fe0d5a0eea6c301e Mon Sep 17 00:00:00 2001 From: JulianJanetschek <54806745+jkjanetschek@users.noreply.github.com> Date: Thu, 28 Sep 2023 13:00:05 +0200 Subject: [PATCH 30/35] Update samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java Co-authored-by: Adrian Fish --- .../ui/listener/author/SavePublishedSettingsListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java index b866d368d911..734500e12ed7 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java @@ -280,7 +280,7 @@ private void postUserNotification(PublishedAssessmentSettingsBean assessmentSett flag = true; } ListIterator newtimes = assessmentSettings.getExtendedTimes().listIterator(); - while (newtimes.hasNext()){ + while (newtimes.hasNext()) { ExtendedTime newExTime = (ExtendedTime) newtimes.next(); if(newExTime.getStartDate().toInstant().isAfter(Instant.now())){ eventTrackingService.delay(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessmentSettings.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true), newExTime.getStartDate().toInstant()); From 0763e13b0a2f3000eea7803eebbc0e87e0f3a270 Mon Sep 17 00:00:00 2001 From: JulianJanetschek <54806745+jkjanetschek@users.noreply.github.com> Date: Thu, 28 Sep 2023 13:00:15 +0200 Subject: [PATCH 31/35] Update samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java Co-authored-by: Adrian Fish --- .../ui/listener/author/SavePublishedSettingsListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java index 734500e12ed7..e05972783cbf 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java @@ -282,7 +282,7 @@ private void postUserNotification(PublishedAssessmentSettingsBean assessmentSett ListIterator newtimes = assessmentSettings.getExtendedTimes().listIterator(); while (newtimes.hasNext()) { ExtendedTime newExTime = (ExtendedTime) newtimes.next(); - if(newExTime.getStartDate().toInstant().isAfter(Instant.now())){ + if (newExTime.getStartDate().toInstant().isAfter(Instant.now())) { eventTrackingService.delay(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessmentSettings.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true), newExTime.getStartDate().toInstant()); } } From b56dc908633cbe783aa538c3fca561f633df118a Mon Sep 17 00:00:00 2001 From: JulianJanetschek <54806745+jkjanetschek@users.noreply.github.com> Date: Thu, 28 Sep 2023 13:00:37 +0200 Subject: [PATCH 32/35] Update samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java Co-authored-by: Adrian Fish --- .../ui/listener/author/SavePublishedSettingsListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java index e05972783cbf..cac0a43e36f2 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java @@ -286,7 +286,7 @@ private void postUserNotification(PublishedAssessmentSettingsBean assessmentSett eventTrackingService.delay(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessmentSettings.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true), newExTime.getStartDate().toInstant()); } } - }else { + } else { ListIterator oldtimes = oldExtendedTimes.listIterator(); ListIterator newtimes = assessmentSettings.getExtendedTimes().listIterator(); while (oldtimes.hasNext()) { From b5516ef92c72be4a113e0ab5a7e4b2190cace9d6 Mon Sep 17 00:00:00 2001 From: Adrian Fish Date: Thu, 28 Sep 2023 12:24:07 +0100 Subject: [PATCH 33/35] Update samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java --- .../ui/listener/author/RepublishAssessmentListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java index c3387a34c95d..141a1e079fc2 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java @@ -190,7 +190,7 @@ private void postUserNotification(PublishedAssessmentFacade assessment, Publishe Instant instant = assessment.getStartDate().toInstant(); if (instant.isBefore(Instant.now())) { eventTrackingService.post(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_UPDATE_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true)); - if(publishedAssessmentSettings.getExtendedTimesSize() != 0){ + if (publishedAssessmentSettings.getExtendedTimesSize() != 0) { ListIterator it = extendedTimes.listIterator(); while (it.hasNext()) { ExtendedTime exTime = (ExtendedTime) it.next(); From 62406c8e593795c6ed9706ef66af2d379ff8c135 Mon Sep 17 00:00:00 2001 From: Adrian Fish Date: Thu, 28 Sep 2023 12:24:40 +0100 Subject: [PATCH 34/35] Update samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java --- .../ui/listener/author/RepublishAssessmentListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java index 141a1e079fc2..abcf5d1e25b7 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/RepublishAssessmentListener.java @@ -209,7 +209,7 @@ private void postUserNotification(PublishedAssessmentFacade assessment, Publishe Instant startInstant = exTime.getStartDate().toInstant(); if (startInstant.isBefore(Instant.now())) { eventTrackingService.post(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_UPDATE_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true)); - } else if(startInstant.isAfter(Instant.now()) && !instant.equals(startInstant)) { + } else if (startInstant.isAfter(Instant.now()) && !instant.equals(startInstant)) { eventTrackingService.delay(eventTrackingService.newEvent(SamigoConstants.EVENT_ASSESSMENT_AVAILABLE, "siteId=" + AgentFacade.getCurrentSiteId() + ", assessmentId=" + assessment.getAssessmentId() + ", publishedAssessmentId=" + assessment.getPublishedAssessmentId(), true), startInstant); } } From 6a5ea186db7ea1e1b78d561083ba7051e5ee3eb0 Mon Sep 17 00:00:00 2001 From: JulianJanetschek <54806745+jkjanetschek@users.noreply.github.com> Date: Thu, 28 Sep 2023 13:44:19 +0200 Subject: [PATCH 35/35] Update SavePublishedSettingsListener.java fix: lookup eventTrackingService via ComponentManager --- .../ui/listener/author/SavePublishedSettingsListener.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java index cac0a43e36f2..aa3cb3ceb454 100644 --- a/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java +++ b/samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/SavePublishedSettingsListener.java @@ -89,7 +89,7 @@ import java.util.ListIterator; import org.sakaiproject.tool.assessment.data.dao.assessment.ExtendedTime; import org.sakaiproject.component.cover.ComponentManager; -import org.sakaiproject.component.cover.ComponentManager; + /** *

Title: Samigo

2 *

Description: Sakai Assessment Manager

@@ -109,7 +109,9 @@ public class SavePublishedSettingsListener private final SamigoAvailableNotificationService samigoAvailableNotificationService = ComponentManager.get(SamigoAvailableNotificationService.class); private EventTrackingService eventTrackingService; - public SavePublishedSettingsListener() {} + public SavePublishedSettingsListener() { + eventTrackingService = ComponentManager.get(EventTrackingService.class); + } public void processAction(ActionEvent ae) throws AbortProcessingException {