diff --git a/api/pom.xml b/api/pom.xml index 16a6776a..8ffd15a9 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -20,7 +20,7 @@ attendance org.sakaiproject.attendance - 23-SNAPSHOT + 25-SNAPSHOT attendance - API @@ -45,8 +45,8 @@ hibernate-core - commons-lang - commons-lang + org.apache.commons + commons-lang3 diff --git a/api/src/java/org/sakaiproject/attendance/model/AttendanceUserGroupStats.java b/api/src/java/org/sakaiproject/attendance/model/AttendanceUserGroupStats.java index b6daee30..0536b65d 100644 --- a/api/src/java/org/sakaiproject/attendance/model/AttendanceUserGroupStats.java +++ b/api/src/java/org/sakaiproject/attendance/model/AttendanceUserGroupStats.java @@ -18,9 +18,8 @@ import lombok.AllArgsConstructor; import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; /** * Created by james on 7/11/17. @@ -29,49 +28,11 @@ @Data @NoArgsConstructor @AllArgsConstructor +@EqualsAndHashCode public class AttendanceUserGroupStats { private static final long serialVersionUID = 1L; private String userID; private String groupId; private AttendanceSite attendanceSite; - - - public AttendanceUserGroupStats(String userID, AttendanceSite attendanceSite) { - this.userID = userID; - this.attendanceSite = attendanceSite; - } - - @Override - public boolean equals (final Object obj) { - if(obj == null) { - return false; - } - - if(obj == this) { - return true; - } - - if(obj.getClass() != getClass()) { - return false; - } - - final AttendanceUserGroupStats other = (AttendanceUserGroupStats) obj; - return new EqualsBuilder() - .appendSuper(super.equals(obj)) - .append(this.userID, other.userID) - .append(this.groupId, other.groupId) - .append(this.attendanceSite, other.attendanceSite) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder() - .appendSuper(super.hashCode()) - .append(this.userID) - .append(this.groupId) - .append(this.attendanceSite.getId()) - .toHashCode(); - } } diff --git a/impl/pom.xml b/impl/pom.xml index 5b281a71..51f99c02 100644 --- a/impl/pom.xml +++ b/impl/pom.xml @@ -20,7 +20,7 @@ attendance org.sakaiproject.attendance - 23-SNAPSHOT + 25-SNAPSHOT attendance - Implementation @@ -58,12 +58,12 @@ ehcache-core - commons-lang - commons-lang + org.apache.commons + commons-lang3 - commons-configuration - commons-configuration + org.apache.commons + commons-configuration2 org.hibernate diff --git a/impl/src/java/org/sakaiproject/attendance/impl/AttendanceGradebookProviderImpl.java b/impl/src/java/org/sakaiproject/attendance/impl/AttendanceGradebookProviderImpl.java index 7a5a8ee2..4776af7f 100644 --- a/impl/src/java/org/sakaiproject/attendance/impl/AttendanceGradebookProviderImpl.java +++ b/impl/src/java/org/sakaiproject/attendance/impl/AttendanceGradebookProviderImpl.java @@ -28,7 +28,6 @@ import org.sakaiproject.grading.api.CategoryDefinition; import org.sakaiproject.grading.api.ConflictingAssignmentNameException; import org.sakaiproject.grading.api.GradingService; -import org.sakaiproject.tool.api.Tool; import org.sakaiproject.tool.api.ToolManager; import java.util.HashMap; diff --git a/impl/src/java/org/sakaiproject/attendance/logic/SakaiProxyImpl.java b/impl/src/java/org/sakaiproject/attendance/logic/SakaiProxyImpl.java index 934998a0..8f3842e3 100644 --- a/impl/src/java/org/sakaiproject/attendance/logic/SakaiProxyImpl.java +++ b/impl/src/java/org/sakaiproject/attendance/logic/SakaiProxyImpl.java @@ -20,24 +20,18 @@ import lombok.Setter; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.sakaiproject.authz.api.*; import org.sakaiproject.component.api.ServerConfigurationService; -import org.sakaiproject.entity.api.ResourceProperties; -import org.sakaiproject.entity.api.ResourcePropertiesEdit; import org.sakaiproject.event.api.EventTrackingService; import org.sakaiproject.exception.IdUnusedException; import org.sakaiproject.site.api.Group; 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.api.ToolManager; import org.sakaiproject.user.api.*; -import org.sakaiproject.util.ResourceLoader; -import org.w3c.dom.Document; -import org.w3c.dom.Element; import java.util.*; @@ -66,7 +60,6 @@ public String getCurrentSiteTitle() { return siteService.getSite(getCurrentSiteId()).getTitle(); } catch (IdUnusedException e) { log.error("getCurrentSiteTitle()", e); - e.printStackTrace(); return ""; } } @@ -242,7 +235,6 @@ public List getAvailableGroupsForSite(String siteId) { return returnList; } catch (IdUnusedException e) { log.error("getAvailableGroupIdsForSite " + siteId + " IdUnusedException"); - e.printStackTrace(); return new ArrayList(); } } @@ -262,7 +254,6 @@ public User getUser(String userId) { return userDirectoryService.getUser(userId); } catch (UserNotDefinedException e) { log.error("Unable to get user " + userId + " " + e); - e.printStackTrace(); return null; } } @@ -275,7 +266,6 @@ public final User getUserByEID(String userEid) { return userDirectoryService.getUserByEid(userEid); } catch (UserNotDefinedException e) { log.error("Unable to get user " + userEid + " " + e); - e.printStackTrace(); return null; } } @@ -333,7 +323,6 @@ public String getGroupTitle(String siteId, String groupId) { } } catch (IdUnusedException e) { log.error("Unable to get group title", e); - e.printStackTrace(); } return ""; } diff --git a/impl/src/java/org/sakaiproject/attendance/services/AttendanceStatCalc.java b/impl/src/java/org/sakaiproject/attendance/services/AttendanceStatCalc.java index 021ffd79..d4ebc00d 100644 --- a/impl/src/java/org/sakaiproject/attendance/services/AttendanceStatCalc.java +++ b/impl/src/java/org/sakaiproject/attendance/services/AttendanceStatCalc.java @@ -54,7 +54,7 @@ public void execute() { if("".equals(summary)) { log.info("AttendanceStatCalc no sites left to sync"); } else { - log.info("AttendanceStatCalc done, but there are errors\n" + summary); + log.info("AttendanceStatCalc done, but there are errors\n{}", summary); } } else { while(!ids.isEmpty()) { @@ -63,10 +63,10 @@ public void execute() { calculateStats(id); lastId = id > lastId ? id : lastId++; // never-ending loop protection } - log.info("AttendanceStatCalc in progress " + getSummary()); + log.info("AttendanceStatCalc in progress {}", getSummary()); ids = dao.getAttendanceSiteBatch(syncTime, lastId); } - log.info("AttendanceStatCalc finished " + getSummary()); + log.info("AttendanceStatCalc finished {}", getSummary()); log.info(getOverallSummary()); } @@ -105,22 +105,21 @@ private void calculateStats(Long id) { } } else { sitesWithNoUsers++; - log.debug("AttendanceSite, id: '" + id +"' has no users or Site, id: '" - + attendanceSite.getSiteID() +"' no longer exists."); + log.debug("AttendanceSite, id: '{}' has no users or Site, id: '{}' no longer exists.", id, attendanceSite.getSiteID()); } attendanceSite.setIsSyncing(false); attendanceLogic.updateAttendanceSite(attendanceSite); - log.debug("AttendanceSite synced with id: " + id); + log.debug("AttendanceSite synced with id: {}", id); sitesProcessed++; } else { - log.debug("AttendanceSite not marked as in progress" + id); + log.debug("AttendanceSite not marked as in progress{}", id); sitesNotMarked++; } } catch (Exception e) { sitesInError++; - log.warn("Error syncing AttendanceSite id: " + id, e); + log.warn("Error syncing AttendanceSite id: {}", id, e); } } @@ -154,8 +153,7 @@ private void calculateEventStats(AttendanceEvent event, Map userS userStats.put(record.getUserID(), array); } else { - log.debug("AttendanceRecord user no longer present in course, record id: '" + record.getId() - + "' and userID: " + record.getUserID()); + log.debug("AttendanceRecord user no longer present in course, record id: '{}' and userID: {}", record.getId(), record.getUserID()); } } @@ -177,7 +175,7 @@ private String getSummary() { private String getOverallSummary() { List inProgress = dao.getAttendanceSitesInSync(); - if(inProgress.size() > 0) { + if(!inProgress.isEmpty()) { String message = "%d AttendanceSite(s) currently marked in sync. IDs marked in sync: %s"; return String.format(message, inProgress.size(), inProgress); } diff --git a/impl/src/java/org/sakaiproject/attendance/services/AttendanceStatCalcJob.java b/impl/src/java/org/sakaiproject/attendance/services/AttendanceStatCalcJob.java index 6b42e3f0..484168a8 100644 --- a/impl/src/java/org/sakaiproject/attendance/services/AttendanceStatCalcJob.java +++ b/impl/src/java/org/sakaiproject/attendance/services/AttendanceStatCalcJob.java @@ -87,7 +87,7 @@ public void execute(JobExecutionContext context) { eventTrackingService.post(eventTrackingService.newEvent("attend.calc.job", safeEventLength(whoAmI.toString()), true)); - log.info("Start Job: " + whoAmI.toString()); + log.info("Start Job: {}", whoAmI); attendanceStatCalc.execute(); logoutFromSakai(); @@ -95,7 +95,7 @@ public void execute(JobExecutionContext context) { } public void loginToSakai(String whoAs, String jobName, String jobError) { - log.debug(jobName + " loginToSakai()"); + log.debug("{} loginToSakai()", jobName); UsageSession session = usageSessionService.startSession(whoAs, serverName, jobName); if (session == null) { @@ -115,7 +115,7 @@ public void loginToSakai(String whoAs, String jobName, String jobError) { } public void logoutFromSakai() { - log.debug(jobName + " Logging out of Sakai on " + serverName); + log.debug(jobName + " Logging out of Sakai on {}", serverName); eventTrackingService.post(eventTrackingService.newEvent(UsageSessionService.EVENT_LOGOUT, null, true)); usageSessionService.logout(); // safe to logout? what if other jobs are running? } diff --git a/pom.xml b/pom.xml index 54c5cc4d..9239e411 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ org.sakaiproject master - 23-SNAPSHOT + 25-SNAPSHOT @@ -78,28 +78,23 @@ org.apache.wicket wicket - 6.21.0 - pom + 9.17.0 + pom org.apache.wicket wicket-spring - 6.21.0 - - - org.apache.wicket - wicket-datetime - 6.21.0 - + 9.17.0 + org.apache.wicket wicket-extensions - 6.21.0 + 9.17.0 - commons-configuration - commons-configuration - 1.10 + org.apache.commons + commons-configuration2 + ${sakai.commons.configuration2.version} commons-logging diff --git a/tool/pom.xml b/tool/pom.xml index d4f06826..59978af3 100644 --- a/tool/pom.xml +++ b/tool/pom.xml @@ -22,7 +22,7 @@ attendance org.sakaiproject.attendance - 23-SNAPSHOT + 25-SNAPSHOT attendance - Tool @@ -58,16 +58,6 @@ - - org.apache.wicket - wicket-datetime - - - - joda-time - joda-time - ${joda.time.version} - org.apache.wicket wicket-extensions diff --git a/tool/src/java/org/sakaiproject/attendance/tool/Attendance.java b/tool/src/java/org/sakaiproject/attendance/tool/Attendance.java index 03da68a8..f25611ea 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/Attendance.java +++ b/tool/src/java/org/sakaiproject/attendance/tool/Attendance.java @@ -45,7 +45,10 @@ public class Attendance extends WebApplication { protected void init() { super.init(); - //Configure for Spring injection + // Disable the CSP header (we can handle this in root of application) + getCspSettings().blocking().disabled(); + + //Configure for Spring injection getComponentInstantiationListeners().add(new SpringComponentInjector(this)); //Don't throw an exception if we are missing a property, just fallback @@ -53,10 +56,6 @@ protected void init() { //Remove the wicket specific tags from the generated markup getMarkupSettings().setStripWicketTags(true); - - //Don't add any extra tags around a disabled link (default is ) - getMarkupSettings().setDefaultBeforeDisabledLink(null); - getMarkupSettings().setDefaultAfterDisabledLink(null); // On Wicket session timeout, redirect to main page getApplicationSettings().setPageExpiredErrorPage(Overview.class); diff --git a/tool/src/java/org/sakaiproject/attendance/tool/dataproviders/StudentDataProvider.java b/tool/src/java/org/sakaiproject/attendance/tool/dataproviders/StudentDataProvider.java index 8b50dcad..e149631a 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/dataproviders/StudentDataProvider.java +++ b/tool/src/java/org/sakaiproject/attendance/tool/dataproviders/StudentDataProvider.java @@ -17,7 +17,6 @@ package org.sakaiproject.attendance.tool.dataproviders; import org.apache.wicket.model.IModel; -import org.apache.wicket.model.Model; import org.sakaiproject.attendance.tool.models.DetachableUserModel; import org.sakaiproject.user.api.User; diff --git a/tool/src/java/org/sakaiproject/attendance/tool/models/ProfileImage.java b/tool/src/java/org/sakaiproject/attendance/tool/models/ProfileImage.java index a04b3baa..03d8d58f 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/models/ProfileImage.java +++ b/tool/src/java/org/sakaiproject/attendance/tool/models/ProfileImage.java @@ -11,6 +11,7 @@ public ProfileImage(String id, IModel urlModel) super( id, urlModel ); } + @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag( tag ); diff --git a/tool/src/java/org/sakaiproject/attendance/tool/pages/EventInputPage.html b/tool/src/java/org/sakaiproject/attendance/tool/pages/EventInputPage.html index d5ce7e43..38033032 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/pages/EventInputPage.html +++ b/tool/src/java/org/sakaiproject/attendance/tool/pages/EventInputPage.html @@ -36,13 +36,13 @@

-
+
- - - + + +
diff --git a/tool/src/java/org/sakaiproject/attendance/tool/pages/EventInputPage.java b/tool/src/java/org/sakaiproject/attendance/tool/pages/EventInputPage.java index ed7bfa77..e210e73b 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/pages/EventInputPage.java +++ b/tool/src/java/org/sakaiproject/attendance/tool/pages/EventInputPage.java @@ -1,23 +1,22 @@ package org.sakaiproject.attendance.tool.pages; import org.apache.commons.codec.binary.StringUtils; -import org.apache.wicket.Page; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.markup.html.form.AjaxButton; import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink; import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; -import org.apache.wicket.extensions.yui.calendar.DateTimeField; +import org.apache.wicket.extensions.markup.html.form.DateTextField; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.form.TextField; import org.apache.wicket.markup.html.panel.FeedbackPanel; import org.apache.wicket.model.*; import org.sakaiproject.attendance.model.AttendanceEvent; -import org.sakaiproject.attendance.tool.pages.EventView; -import org.sakaiproject.attendance.tool.pages.Overview; import org.sakaiproject.attendance.tool.util.AttendanceFeedbackPanel; -import org.sakaiproject.attendance.tool.util.ConfirmationLink; import org.sakaiproject.attendance.tool.util.PlaceholderBehavior; +import java.util.Date; + + public class EventInputPage extends BasePage{ private static final long serialVersionUID = 1L; private IModel eventModel; @@ -54,7 +53,7 @@ private Form createEventInputForm() { private static final long serialVersionUID = 1L; @Override - public void onSubmit(final AjaxRequestTarget target, final Form form) { + public void onSubmit(final AjaxRequestTarget target) { // decide where to go based on where we came from. String nextPage = EventInputPage.this.getNextPage(); if(StringUtils.equals(nextPage, EventInputPage.GRADING)) { @@ -72,18 +71,16 @@ public void onSubmit(final AjaxRequestTarget target, final Form form) { }; cancel.setDefaultFormProcessing(false); eventForm.add(cancel); - final TextField name = new TextField("name") { - @Override - protected void onInitialize(){ - super.onInitialize(); - add(new PlaceholderBehavior(getString("event.placeholder.name"))); - } - }; - final DateTimeField startDateTime = new DateTimeField("startDateTime"); + final TextField name = new TextField<>("name"); name.setRequired(true); + name.add(new PlaceholderBehavior(getString("event.placeholder.name"))); + + final DateTextField startDateTime = new DateTextField("startDateTime", null, "yyyy-MM-dd'T'HH:mm"); + eventForm.add(name); eventForm.add(startDateTime); return eventForm; + } private void processSave(AjaxRequestTarget target, Form form, boolean addAnother) { @@ -91,7 +88,8 @@ private void processSave(AjaxRequestTarget target, Form form, boolean addAnot e.setAttendanceSite(attendanceLogic.getCurrentAttendanceSite()); boolean result = attendanceLogic.updateAttendanceEvent(e); if(result){ - StringResourceModel temp = new StringResourceModel("attendance.add.success", null, new String[]{e.getName()}); + StringResourceModel temp = new StringResourceModel("attendance.add.success", this); + temp.setParameters(e.getName()); getSession().success(temp.getString()); } else { error(getString("attendance.add.failure")); @@ -107,8 +105,8 @@ private void processSave(AjaxRequestTarget target, Form form, boolean addAnot private AjaxSubmitLink createSubmitLink(final String id, final Form form, final boolean createAnother) { return new AjaxSubmitLink(id, form) { @Override - protected void onSubmit(AjaxRequestTarget target, Form form) { - super.onSubmit(target, form); + protected void onSubmit(AjaxRequestTarget target) { + super.onSubmit(target); processSave(target, form, createAnother); } @@ -118,7 +116,7 @@ public boolean isEnabled() { } @Override - protected void onError(AjaxRequestTarget target, Form form) { + protected void onError(AjaxRequestTarget target) { target.addChildren(form, FeedbackPanel.class); } diff --git a/tool/src/java/org/sakaiproject/attendance/tool/pages/EventView.java b/tool/src/java/org/sakaiproject/attendance/tool/pages/EventView.java index a733d5a7..2b70ac54 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/pages/EventView.java +++ b/tool/src/java/org/sakaiproject/attendance/tool/pages/EventView.java @@ -35,6 +35,7 @@ import org.apache.wicket.markup.repeater.Item; import org.apache.wicket.markup.repeater.ReuseIfModelsEqualStrategy; import org.apache.wicket.markup.repeater.data.DataView; +import org.apache.wicket.model.IModel; import org.apache.wicket.model.Model; import org.apache.wicket.model.PropertyModel; import org.apache.wicket.model.ResourceModel; @@ -157,7 +158,7 @@ public int compare(AttendanceStatus o1, AttendanceStatus o2) { } setAllForm.add(setAllStatus = new DropDownChoice<>("set-all-status", new Model<>(), activeStatuses, new EnumChoiceRenderer<>(this))); - setAllStatus.add(new AjaxFormSubmitBehavior("onchange") { + setAllStatus.add(new AjaxFormSubmitBehavior("change") { @Override protected void onSubmit(AjaxRequestTarget target) { super.onSubmit(target); @@ -249,10 +250,20 @@ public Object getDisplayValue(String s) { public String getIdValue(String s, int i) { return s; } + + @Override + public String getObject(String s, IModel> iModel) { + for (String groupId : groupIds) { + if (groupId.equals(s)) { + return s; + } + } + return null; + } }); groupChoice.setNullValid(true); - groupChoice.add(new AjaxFormSubmitBehavior("onchange") { + groupChoice.add(new AjaxFormSubmitBehavior("change") { @Override protected void onSubmit(AjaxRequestTarget target) { super.onSubmit(target); diff --git a/tool/src/java/org/sakaiproject/attendance/tool/pages/ExportPage.html b/tool/src/java/org/sakaiproject/attendance/tool/pages/ExportPage.html index d3f11f2e..cdc74c56 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/pages/ExportPage.html +++ b/tool/src/java/org/sakaiproject/attendance/tool/pages/ExportPage.html @@ -27,7 +27,7 @@

- +

@@ -38,7 +38,7 @@

- +
diff --git a/tool/src/java/org/sakaiproject/attendance/tool/pages/ExportPage.java b/tool/src/java/org/sakaiproject/attendance/tool/pages/ExportPage.java index c099499e..27902fcc 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/pages/ExportPage.java +++ b/tool/src/java/org/sakaiproject/attendance/tool/pages/ExportPage.java @@ -16,46 +16,43 @@ package org.sakaiproject.attendance.tool.pages; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.codec.binary.StringUtils; +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFCellStyle; +import org.apache.poi.hssf.usermodel.HSSFFont; +import org.apache.poi.hssf.usermodel.HSSFRow; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.ss.usermodel.Row; import org.apache.wicket.model.StringResourceModel; -import org.sakaiproject.component.cover.ServerConfigurationService; -import org.sakaiproject.attendance.logic.SakaiProxy; import org.sakaiproject.attendance.model.*; +import org.sakaiproject.component.cover.ServerConfigurationService; import org.sakaiproject.user.api.User; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.wicket.RestartResponseException; import org.apache.wicket.markup.head.IHeaderResponse; import org.apache.wicket.markup.head.JavaScriptHeaderItem; -import org.apache.wicket.markup.html.form.Button; import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.form.SubmitLink; import org.apache.wicket.model.LoadableDetachableModel; import org.apache.wicket.model.Model; import org.apache.wicket.util.lang.Bytes; -import org.apache.wicket.util.time.Duration; import org.apache.wicket.markup.html.link.DownloadLink; import org.apache.wicket.markup.html.form.upload.FileUpload; import org.apache.wicket.markup.html.form.upload.FileUploadField; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.markup.html.form.AjaxCheckBox; -import org.apache.poi.hssf.usermodel.*; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; -import org.apache.poi.hssf.usermodel.HSSFSheet; -import org.apache.poi.hssf.usermodel.HSSFRow; -import org.apache.poi.hssf.usermodel.HSSFCell; -import org.apache.poi.ss.usermodel.CellType; - import java.io.*; - +import java.time.Duration; import java.util.*; import java.util.Collections; import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import lombok.extern.slf4j.Slf4j; - /** * Created by james on 5/18/17. @@ -113,7 +110,7 @@ protected File load() { public void onSubmit() { setResponsePage(new ExportPage()); } - }).setCacheDuration(Duration.NONE).setDeleteAfterDownload(true)); + }).setCacheDuration(Duration.ZERO).setDeleteAfterDownload(true)); add(new UploadForm("form")); } @@ -173,8 +170,8 @@ public int compare(AttendanceEvent attendanceEvent, AttendanceEvent t1) { } }); int columnGetter = 3; //separate counter for columns in case there are comments, in which case the following loop's counter will increment differently. - for(int count=0; count rows = sheet.rowIterator(); if(rows.hasNext()){ //don't do anything with the Iterator unless it has something. final List headerRow = processHeaderRow(rows); List badIds = checkHeader(siteEventList, headerRow, errors); - checkHeader = badIds.size()<1; //if there are bad IDs, the header is bad [checkHeader = false] + checkHeader = badIds.isEmpty(); //if there are bad IDs, the header is bad [checkHeader = false] while(rows.hasNext()){ HSSFRow currentRow = (HSSFRow) rows.next(); commentsChanged = processOneDataRow(currentRow, usableIDs, headerRow, ICList, commentsChanged, errors); @@ -361,7 +354,7 @@ private List processHeaderRow(Iterator rows){ private List checkHeader(List siteEventList, List headerRow, List errors){ List siteEventListIds = getActualEventIds(siteEventList); List badIds = new ArrayList(); - for(int count = 3; count < headerRow.size() && headerRow.get(count).length()>0; count++){ //see if every ID in idTracker is in Attendance already + for(int count = 3; count < headerRow.size() && !headerRow.get(count).isEmpty(); count++){ //see if every ID in idTracker is in Attendance already Long getIdResult = getIdFromString(headerRow.get(count), errors); if(!siteEventListIds.contains(getIdResult)){ //if not, this header had bad IDs (events that Attendance doesn't have) badIds.add(getIdResult); //add the bad ID into the array. @@ -394,19 +387,20 @@ private List getActualEventIds (List siteEventList){ return usableIds; } - private void addErrorsToSession(List errors){ - for(int count = 0; count<4 && count0; count++){ + private void addErrorsToSession(List errors) { + for (int count = 0; count < Math.min(4, errors.size()); count++) { getSession().error(errors.get(count)); } - if(errors.size()>4){ - String howManyErrors = "" + (errors.size()-4); - getSession().error(new StringResourceModel("attendance.import.more.errors", null, new String[]{howManyErrors}).getString()); + + if (errors.size() > 4) { + String howManyErrors = String.valueOf(errors.size() - 4); + getSession().error(getString("attendance.import.more.errors", null, howManyErrors)); } } private boolean processOneDataRow(HSSFRow row, List usableIds, List headerRow, List ICList, boolean commentsChanged, List errors) { AttendanceSite attendanceSite = attendanceLogic.getAttendanceSite(sakaiProxy.getCurrentSiteId()); - List data = new ArrayList(); // container for the current row's data + List data = new ArrayList<>(); // container for the current row's data for (int countCells=0; countCells usableIds, List usableIds, List 0){ //add the newData comment to the ICL if it's not empty. + if(newData.getComment()!=null && !newData.getComment().isEmpty()){ //add the newData comment to the ICL if it's not empty. ICL.setComment(newData.getComment()); }else{ //if it IS empty, just throw in the old comment. ICL.setComment(checker.getComment()); @@ -485,12 +481,12 @@ private boolean processOneDataRow(HSSFRow row, List usableIds, List2){ - if(data.get(1).toString().length() > 0){ - errors.add(new StringResourceModel("attendance.import.fake.student", null, new String[]{data.get(1).toString()}).getString()); //when there's a fake student in Excel that isn't in Attendance + if(!data.get(1).isEmpty()){ + errors.add(new StringResourceModel("attendance.import.fake.student", this, Model.of(data.get(1).toString())).getString()); }else{ errors.add(getString("attendance.import.blank.row")); //when there's a blank row in Excel that has no data } diff --git a/tool/src/java/org/sakaiproject/attendance/tool/pages/ImportConfirmation.java b/tool/src/java/org/sakaiproject/attendance/tool/pages/ImportConfirmation.java index c79dd8b5..518b2d66 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/pages/ImportConfirmation.java +++ b/tool/src/java/org/sakaiproject/attendance/tool/pages/ImportConfirmation.java @@ -22,14 +22,12 @@ import java.util.*; import java.util.List; -import org.apache.wicket.AttributeModifier; import org.apache.wicket.RestartResponseException; import org.apache.wicket.markup.html.WebMarkupContainer; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.form.*; import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.form.SubmitLink; -import org.apache.wicket.markup.html.link.Link; import org.apache.wicket.markup.html.list.ListItem; import org.apache.wicket.markup.html.list.ListView; @@ -45,8 +43,6 @@ public class ImportConfirmation extends BasePage{ protected void onBeforeRender() { super.onBeforeRender(); disableLink(exportLink); - - add(new ImportConfirmation.UploadForm("form")); } private static final long serialVersionUID = 1L; @@ -58,16 +54,6 @@ protected void onBeforeRender() { public ImportConfirmation(List attendanceItemDataList, Boolean commentsChanged) { this.uploadICLList = attendanceItemDataList; - homepageLink = new Link("homepage-link2") { - private static final long serialVersionUID = 1L; - public void onClick() { - - setResponsePage(new Overview()); - } - }; - homepageLink.add(new Label("homepage-link-label",new ResourceModel("attendance.link.homepage")).setRenderBodyOnly(true)); - homepageLink.add(new AttributeModifier("title", new ResourceModel("attendance.link.homepage.tooltip"))); - add(homepageLink); if(this.role != null && this.role.equals("Student")) { throw new RestartResponseException(StudentView.class); @@ -184,36 +170,44 @@ private String changeStatString(String stat){ } private class UploadForm extends Form { + private Label lowerErrorAlert = new Label("lowerErrorAlert"); + private SubmitLink completeImport = new SubmitLink("submitLink") { + @Override + public void onSubmit() { + uploadICLList.forEach(item -> { + attendanceLogic.updateAttendanceRecord(item.getAttendanceRecord(), item.getOldStatus()); + attendanceLogic.updateAttendanceSite(item.getAttendanceSite()); + }); + success(getString("attendance.export.confirmation.import.save.success")); + setResponsePage(new Overview()); + } + }; public UploadForm(final String id) { super(id); - SubmitLink completeImport = new SubmitLink("submitLink") { - public void onSubmit() { - for (int i = 0; i < uploadICLList.size(); i++){ - boolean updated = attendanceLogic.updateAttendanceRecord(uploadICLList.get(i).getAttendanceRecord(), uploadICLList.get(i).getOldStatus()); - attendanceLogic.updateAttendanceSite(uploadICLList.get(i).getAttendanceSite()); - } - getSession().success(getString("attendance.export.confirmation.import.save.success")); - setResponsePage(new Overview()); - } - }; - Label lowerErrorAlert = new Label("lowerErrorAlert"); - if (!getSession().getFeedbackMessages().isEmpty()){ - completeImport.setEnabled(false); - lowerErrorAlert = new Label("lowerErrorAlert", getString("attendance.import.errors.exist")); - } - if(uploadICLList.size()<1){ - getSession().error(getString("attendance.export.import.save.noChange")); - completeImport.setEnabled(false); - } add(lowerErrorAlert); add(completeImport); add(new SubmitLink("submitLink2") { + @Override public void onSubmit() { setResponsePage(new ExportPage()); } }); } + + @Override + protected void onConfigure() { + super.onConfigure(); + + if (!getSession().getFeedbackMessages().isEmpty()) { + completeImport.setEnabled(false); + lowerErrorAlert.setDefaultModelObject(getString("attendance.import.errors.exist")); + } + if (uploadICLList != null && uploadICLList.isEmpty()) { + completeImport.setEnabled(false); + getSession().error(getString("attendance.export.import.save.noChange")); + } + } } } diff --git a/tool/src/java/org/sakaiproject/attendance/tool/pages/Overview.java b/tool/src/java/org/sakaiproject/attendance/tool/pages/Overview.java index b15b4bda..2d9bc827 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/pages/Overview.java +++ b/tool/src/java/org/sakaiproject/attendance/tool/pages/Overview.java @@ -20,22 +20,15 @@ import org.apache.wicket.Page; import org.apache.wicket.RestartResponseException; import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.ajax.form.OnChangeAjaxBehavior; import org.apache.wicket.ajax.markup.html.AjaxLink; -import org.apache.wicket.ajax.markup.html.form.AjaxButton; -import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; import org.apache.wicket.markup.html.WebMarkupContainer; import org.apache.wicket.markup.html.basic.Label; -import org.apache.wicket.extensions.markup.html.form.select.Select; -import org.apache.wicket.extensions.markup.html.form.select.SelectOption; -import org.apache.wicket.markup.html.form.DropDownChoice; import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.form.SubmitLink; import org.apache.wicket.markup.html.link.Link; import org.apache.wicket.markup.repeater.Item; import org.apache.wicket.markup.repeater.data.DataView; import org.apache.wicket.model.Model; -import org.apache.wicket.model.PropertyModel; import org.apache.wicket.model.ResourceModel; import org.apache.wicket.model.StringResourceModel; import org.sakaiproject.attendance.model.AttendanceEvent; @@ -44,11 +37,10 @@ import org.sakaiproject.attendance.model.Status; import org.sakaiproject.attendance.tool.dataproviders.AttendanceStatusProvider; import org.sakaiproject.attendance.tool.dataproviders.EventDataProvider; -import org.sakaiproject.attendance.tool.panels.EventInputPanel; import org.sakaiproject.attendance.tool.panels.PrintPanel; import org.sakaiproject.attendance.tool.util.ConfirmationLink; -import java.util.*; +import java.util.Date; /** * The overview page which lists AttendanceEvents and basic statistics of each @@ -101,8 +93,10 @@ private void createHeaders() { String addButtonText = (new ResourceModel("attendance.add.button")).getObject(); String takeAttendanceNowText = (new ResourceModel("attendance.now.button")).getObject(); - Label headerInfo = new Label("overview-header-info", new StringResourceModel("attendance.overview.header.info", - null, new Object[]{addButtonText, takeAttendanceNowText})); + Label headerInfo = new Label("overview-header-info", + new StringResourceModel("attendance.overview.header.info") + .setParameters(addButtonText, takeAttendanceNowText) + ); headerInfo.setEscapeModelStrings(false); //headers for the table @@ -232,22 +226,4 @@ protected void onSubmit() { add(takeAttendanceNowForm); } - private void createAddAttendanceItem() { - final Form addAttendanceItemForm = new Form("add-attendance-item-form"); - final AjaxButton addAttendanceItem = new AjaxButton("add-attendance-item") { - @Override - public void onSubmit(final AjaxRequestTarget target, final Form form) { - final ModalWindow window = getAddOrEditItemWindow(); - window.setTitle(new ResourceModel("attendance.add.header")); - window.setContent(new EventInputPanel(window.getContentId(), window, null)); - window.show(target); - } - }; - - addAttendanceItem.setDefaultFormProcessing(false); - addAttendanceItem.setOutputMarkupId(true); - addAttendanceItemForm.add(addAttendanceItem); - - add(addAttendanceItemForm); - } } diff --git a/tool/src/java/org/sakaiproject/attendance/tool/pages/SettingsPage.html b/tool/src/java/org/sakaiproject/attendance/tool/pages/SettingsPage.html index 1fe03ba9..99bf20f2 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/pages/SettingsPage.html +++ b/tool/src/java/org/sakaiproject/attendance/tool/pages/SettingsPage.html @@ -44,7 +44,7 @@

+ diff --git a/tool/src/java/org/sakaiproject/attendance/tool/pages/SettingsPage.java b/tool/src/java/org/sakaiproject/attendance/tool/pages/SettingsPage.java index 57717279..a587c32b 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/pages/SettingsPage.java +++ b/tool/src/java/org/sakaiproject/attendance/tool/pages/SettingsPage.java @@ -57,8 +57,8 @@ public SettingsPage() { AjaxSubmitLink submit = new AjaxSubmitLink("submit-link") { @Override - protected void onSubmit(AjaxRequestTarget target, Form form) { - super.onSubmit(target, form); + protected void onSubmit(AjaxRequestTarget target) { + super.onSubmit(target); target.add(feedbackPanel); } diff --git a/tool/src/java/org/sakaiproject/attendance/tool/pages/StudentOverview.java b/tool/src/java/org/sakaiproject/attendance/tool/pages/StudentOverview.java index cdaa691b..a85f98ee 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/pages/StudentOverview.java +++ b/tool/src/java/org/sakaiproject/attendance/tool/pages/StudentOverview.java @@ -30,6 +30,7 @@ import org.apache.wicket.markup.html.list.ListView; import org.apache.wicket.markup.repeater.Item; import org.apache.wicket.markup.repeater.data.DataView; +import org.apache.wicket.model.IModel; import org.apache.wicket.model.Model; import org.apache.wicket.model.PropertyModel; import org.apache.wicket.model.ResourceModel; @@ -168,10 +169,21 @@ public Object getDisplayValue(String s) { public String getIdValue(String s, int i) { return s; } + + @Override + public String getObject(String id, IModel> choices) { + // Logic to retrieve the appropriate group object based on 'id' + for (String s : groupIds) { + if (s.equals(id)) { + return s; + } + } + return null; // Return null if the group isn't found + } }); groupChoice.setNullValid(true); - groupChoice.add(new AjaxFormSubmitBehavior("onchange") { + groupChoice.add(new AjaxFormSubmitBehavior("change") { @Override protected void onSubmit(AjaxRequestTarget target) { super.onSubmit(target); diff --git a/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceGradeFormPanel.java b/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceGradeFormPanel.java index afdd2b71..1060538b 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceGradeFormPanel.java +++ b/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceGradeFormPanel.java @@ -162,7 +162,7 @@ public boolean isVisible() { NumberTextField maximum = new NumberTextField("maximumGrade"); maximum.setMinimum(0.1); maximum.setStep(0.1); - maximum.add(new AjaxFormComponentUpdatingBehavior("oninput") { + maximum.add(new AjaxFormComponentUpdatingBehavior("input") { @Override protected void onUpdate(AjaxRequestTarget target) { target.add(grading); @@ -241,7 +241,7 @@ public boolean isVisible(){ gradebook.add(gradebookCategories); gradebook.add(categoriesLabel); final RadioGroup useAutoGradingGroup = new RadioGroup<>("use-auto-grading-group", this.useAutoGrading); - useAutoGradingGroup.add(new AjaxFormComponentUpdatingBehavior("onchange") { + useAutoGradingGroup.add(new AjaxFormComponentUpdatingBehavior("change") { @Override protected void onUpdate(AjaxRequestTarget target) { target.add(gradingRulesPanel); @@ -283,13 +283,13 @@ public boolean isVisible() { AjaxSubmitLink submit = new AjaxSubmitLink("submit") { @Override - protected void onError(AjaxRequestTarget target, Form form) { + protected void onError(AjaxRequestTarget target) { target.add(pageFeedbackPanel); } @Override - protected void onSubmit(AjaxRequestTarget target, Form form) { - super.onSubmit(target, form); + protected void onSubmit(AjaxRequestTarget target) { + super.onSubmit(target); target.add(pageFeedbackPanel); } }; diff --git a/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceGradePanel.java b/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceGradePanel.java index af0a0172..6d6ed44b 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceGradePanel.java +++ b/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceGradePanel.java @@ -77,9 +77,13 @@ public void onSubmit() { if (result) { String grade = aG.getGrade() == null ? "null" : aG.getGrade().toString(); - getSession().info(new StringResourceModel("attendance.grade.update.success", null, new String[]{grade, displayName}).getString()); + StringResourceModel messageModel = new StringResourceModel("attendance.grade.update.success", this); + messageModel.setParameters(grade, displayName); + info(messageModel.getString()); } else { - getSession().error(new StringResourceModel("attendance.grade.update.failure", null, new String[]{displayName}).getString()); + StringResourceModel errorString = new StringResourceModel("attendance.grade.update.failure", this); + errorString.setParameters(displayName); + getSession().error(errorString); } } @@ -114,7 +118,7 @@ protected void onSubmit(AjaxRequestTarget target) { if(maximumGrade == null) { maximum = new Label("maximum", "/ -"); - points.add(new AttributeModifier("title", new StringResourceModel("attendance.grade.tooltip.disabled", null, new String[]{new ResourceModel("settings.link.label").getObject()}))); + points.add(new AttributeModifier("title", new StringResourceModel("attendance.grade.tooltip.disabled", this, Model.of(new ResourceModel("settings.link.label").getObject())))); } else { maximum = new Label("maximum", "/ "+ maximumGrade.toString()); } diff --git a/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceRecordFormDataPanel.java b/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceRecordFormDataPanel.java index e934f415..1304f001 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceRecordFormDataPanel.java +++ b/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceRecordFormDataPanel.java @@ -83,11 +83,13 @@ protected void onSubmit() { String[] resultMsgVars = new String[]{sakaiProxy.getUserSortName(aR.getUserID()), aR.getAttendanceEvent().getName(), getStatusString(aR.getStatus())}; StringResourceModel temp; if(result){ - temp = new StringResourceModel("attendance.record.save.success", null, resultMsgVars); + temp = new StringResourceModel("attendance.record.save.success", this); + temp.setParameters(resultMsgVars); getSession().info(temp.getString()); oldStatus = aR.getStatus(); } else { - temp = new StringResourceModel("attendance.record.save.failure", null, resultMsgVars); + temp = new StringResourceModel("attendance.record.save.failure", this); + temp.setParameters(resultMsgVars); getSession().error(temp.getString()); } } @@ -119,7 +121,7 @@ protected void populateItem(Item item) { final Status itemStatus = item.getModelObject().getStatus(); Radio statusRadio = new Radio("record-status", new Model(itemStatus)); item.add(statusRadio); - statusRadio.add(new AjaxFormSubmitBehavior(rF, "onclick") { + statusRadio.add(new AjaxFormSubmitBehavior(rF, "click") { protected void onSubmit(AjaxRequestTarget target) { target.appendJavaScript("attendance.recordFormRowSetup("+ this.getAttributes().getFormId() + ");"); for (Component c : ajaxTargets) { @@ -195,8 +197,8 @@ private void createCommentBox(final Form rF) { final AjaxSubmitLink saveComment = new AjaxSubmitLink("save-comment") { @Override - protected void onSubmit(AjaxRequestTarget target, Form form) { - super.onSubmit(target, form); + protected void onSubmit(AjaxRequestTarget target) { + super.onSubmit(target); if(recordIModel.getObject().getComment() != null && !recordIModel.getObject().getComment().equals("")) { noComment.setVisible(false); yesComment.setVisible(true); diff --git a/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceStatusFormPanel.java b/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceStatusFormPanel.java index f8375756..4736f0d3 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceStatusFormPanel.java +++ b/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceStatusFormPanel.java @@ -110,8 +110,8 @@ protected void populateItem(ListItem item) { AjaxSubmitLink submit = new AjaxSubmitLink("submit-link") { @Override - protected void onSubmit(AjaxRequestTarget target, Form form) { - super.onSubmit(target, form); + protected void onSubmit(AjaxRequestTarget target) { + super.onSubmit(target); target.add(pageFeedbackPanel); } diff --git a/tool/src/java/org/sakaiproject/attendance/tool/panels/EventInputPanel.html b/tool/src/java/org/sakaiproject/attendance/tool/panels/EventInputPanel.html index 97246b7d..41004fb3 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/panels/EventInputPanel.html +++ b/tool/src/java/org/sakaiproject/attendance/tool/panels/EventInputPanel.html @@ -34,18 +34,18 @@
- +
- - + - +
- \ No newline at end of file + diff --git a/tool/src/java/org/sakaiproject/attendance/tool/panels/EventInputPanel.java b/tool/src/java/org/sakaiproject/attendance/tool/panels/EventInputPanel.java index f3b469ff..1b2bf1cd 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/panels/EventInputPanel.java +++ b/tool/src/java/org/sakaiproject/attendance/tool/panels/EventInputPanel.java @@ -16,12 +16,13 @@ package org.sakaiproject.attendance.tool.panels; +import lombok.extern.slf4j.Slf4j; import org.apache.wicket.Page; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.markup.html.form.AjaxButton; import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink; import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; -import org.apache.wicket.extensions.yui.calendar.DateTimeField; +import org.apache.wicket.extensions.markup.html.form.DateTextField; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.form.TextField; @@ -31,9 +32,6 @@ import org.sakaiproject.attendance.tool.pages.EventView; import org.sakaiproject.attendance.tool.pages.Overview; import org.sakaiproject.attendance.tool.util.AttendanceFeedbackPanel; -import org.sakaiproject.attendance.tool.util.ConfirmationLink; -import org.sakaiproject.attendance.tool.util.PlaceholderBehavior; - /** * EventInputPanel is used to get AttendanceEvent settings for a new or existing AttendanceEvent @@ -41,6 +39,7 @@ * @author Leonardo Canessa [lcanessa1 (at) udayton (dot) edu] * @author David Bauer [dbauer1 (at) udayton (dot) edu] */ +@Slf4j public class EventInputPanel extends BasePanel { private static final long serialVersionUID = 1L; @@ -88,7 +87,7 @@ private Form createEventInputForm() { private static final long serialVersionUID = 1L; @Override - public void onSubmit(final AjaxRequestTarget target, final Form form) { + public void onSubmit(final AjaxRequestTarget target) { window.close(target); if(recursiveAddAnother) { // assumes will only occur from Overview page @@ -109,7 +108,8 @@ private void processSave(AjaxRequestTarget target, Form form, boolean addAnot boolean result = attendanceLogic.updateAttendanceEvent(e); if(result){ - StringResourceModel temp = new StringResourceModel("attendance.add.success", null, new String[]{e.getName()}); + StringResourceModel temp = new StringResourceModel("attendance.add.success", this); + temp.setParameters(e.getName()); getSession().success(temp.getString()); } else { error(getString("attendance.add.failure")); @@ -140,9 +140,8 @@ private void processSave(AjaxRequestTarget target, Form form, boolean addAnot private AjaxSubmitLink createSubmitLink(final String id, final Form form, final boolean createAnother) { return new AjaxSubmitLink(id, form) { @Override - protected void onSubmit(AjaxRequestTarget target, Form form) { - super.onSubmit(target, form); - + protected void onSubmit(AjaxRequestTarget target) { + super.onSubmit(target); processSave(target, form, createAnother); } @@ -152,7 +151,7 @@ public boolean isEnabled() { } @Override - protected void onError(AjaxRequestTarget target, Form form) { + protected void onError(AjaxRequestTarget target) { target.addChildren(form, FeedbackPanel.class); } @@ -167,18 +166,12 @@ public boolean isVisible() { }; } - private void createValues(Form event){ - final TextField name = new TextField("name") { - @Override - protected void onInitialize(){ - super.onInitialize(); - add(new PlaceholderBehavior(getString("event.placeholder.name"))); - } - }; - final DateTimeField startDateTime = new DateTimeField("startDateTime"); - + private void createValues(Form event) { + final TextField name = new TextField<>("name"); name.setRequired(true); + final DateTextField startDateTime = new DateTextField("startDateTime", "yyyy-MM-dd'T'HH:mm"); + event.add(name); event.add(startDateTime); } diff --git a/tool/src/java/org/sakaiproject/attendance/tool/panels/GradingRulesListPanel.java b/tool/src/java/org/sakaiproject/attendance/tool/panels/GradingRulesListPanel.java index 404cbfd9..e5886a17 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/panels/GradingRulesListPanel.java +++ b/tool/src/java/org/sakaiproject/attendance/tool/panels/GradingRulesListPanel.java @@ -18,6 +18,7 @@ import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.markup.html.form.AjaxButton; +import org.apache.wicket.markup.html.WebMarkupContainer; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.panel.FeedbackPanel; @@ -35,7 +36,7 @@ public class GradingRulesListPanel extends BasePanel { private static final long serialVersionUID = 1L; - Form regradeForm; + WebMarkupContainer regradeForm; private boolean needRegrade; @@ -73,10 +74,10 @@ protected void populateItem(Item item) { private static final long serialVersionUID = 1L; @Override - protected void onSubmit(AjaxRequestTarget target, Form form) { - super.onSubmit(target, form); + protected void onSubmit(AjaxRequestTarget target) { + super.onSubmit(target); - final boolean result = attendanceLogic.deleteGradingRule((GradingRule) form.getModelObject()); + final boolean result = attendanceLogic.deleteGradingRule((GradingRule) getForm().getModelObject()); if (result) { setNeedRegrade(true); @@ -89,7 +90,7 @@ protected void onSubmit(AjaxRequestTarget target, Form form) { } @Override - protected void onError(AjaxRequestTarget target, Form form) { + protected void onError(AjaxRequestTarget target) { target.add(GradingRulesListPanel.this.pageFeedbackPanel); } }); @@ -100,16 +101,14 @@ protected void onError(AjaxRequestTarget target, Form form) { add(rules); - this.regradeForm = new Form("regrade-form1"){ - @Override - public boolean isVisible() { - return getNeedRegrade(); - } - }; - regradeForm.add(new AjaxButton("regrade-submit1", regradeForm) { + // Use a WebMarkupContainer - it's simpler than a Form + this.regradeForm = new WebMarkupContainer("regrade-form1"); + this.regradeForm.setVisibilityAllowed(getNeedRegrade()); + + this.regradeForm.add(new AjaxButton("regrade-submit1") { @Override - protected void onSubmit(AjaxRequestTarget target, Form form) { - super.onSubmit(target, form); + protected void onSubmit(AjaxRequestTarget target) { + super.onSubmit(target); attendanceLogic.regradeAll(attendanceLogic.getCurrentAttendanceSite()); @@ -122,7 +121,7 @@ protected void onSubmit(AjaxRequestTarget target, Form form) { } @Override - protected void onError(AjaxRequestTarget target, Form form) { + protected void onError(AjaxRequestTarget target) { target.add(GradingRulesListPanel.this.pageFeedbackPanel); } }); diff --git a/tool/src/java/org/sakaiproject/attendance/tool/panels/GradingRulesPanel.java b/tool/src/java/org/sakaiproject/attendance/tool/panels/GradingRulesPanel.java index d7dc1a13..3a2fd68c 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/panels/GradingRulesPanel.java +++ b/tool/src/java/org/sakaiproject/attendance/tool/panels/GradingRulesPanel.java @@ -76,9 +76,9 @@ protected Component newMessageDisplayComponent(final String id, final FeedbackMe private static final long serialVersionUID = 1L; @Override - protected void onSubmit(final AjaxRequestTarget target, final Form form) { + protected void onSubmit(final AjaxRequestTarget target) { - final GradingRule gradingRule = (GradingRule) form.getModelObject(); + final GradingRule gradingRule = (GradingRule) getForm().getModelObject(); if (gradingRule.getStartRange() < 0) { pageFeedbackPanel.error(getString("attendance.grading.start.range.error")); @@ -97,7 +97,7 @@ protected void onSubmit(final AjaxRequestTarget target, final Form form) { } @Override - protected void onError(AjaxRequestTarget target, Form form) { + protected void onError(AjaxRequestTarget target) { target.add(pageFeedbackPanel); } }; diff --git a/tool/src/java/org/sakaiproject/attendance/tool/panels/PrintPanel.java b/tool/src/java/org/sakaiproject/attendance/tool/panels/PrintPanel.java index 7e8e4785..bf6b74fc 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/panels/PrintPanel.java +++ b/tool/src/java/org/sakaiproject/attendance/tool/panels/PrintPanel.java @@ -124,6 +124,14 @@ public Object getDisplayValue(String s) { public String getIdValue(String s, int i) { return s; } + + @Override + public String getObject(String id, IModel> choices) { + return choices.getObject().stream() + .filter(choice -> choice.equals(id)) + .findFirst() + .orElse(null); + } }); groupChoice.setNullValid(true); printForm.add(groupChoice); diff --git a/tool/src/java/org/sakaiproject/attendance/tool/util/AttendanceFeedbackPanel.java b/tool/src/java/org/sakaiproject/attendance/tool/util/AttendanceFeedbackPanel.java index 7fc78495..cc6daa82 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/util/AttendanceFeedbackPanel.java +++ b/tool/src/java/org/sakaiproject/attendance/tool/util/AttendanceFeedbackPanel.java @@ -19,8 +19,6 @@ import org.apache.wicket.AttributeModifier; import org.apache.wicket.Component; import org.apache.wicket.feedback.FeedbackMessage; -import org.apache.wicket.markup.html.WebMarkupContainer; -import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.panel.FeedbackPanel; /** @@ -43,10 +41,10 @@ protected Component newMessageDisplayComponent(final String id, final FeedbackMe message.getLevel() == FeedbackMessage.DEBUG || message.getLevel() == FeedbackMessage.FATAL || message.getLevel() == FeedbackMessage.WARNING){ - add(AttributeModifier.replace("class", "attendanceAlertMessage")); + add(AttributeModifier.replace("class", "attendanceAlertMessage alert alert-warning")); } else if(message.getLevel() == FeedbackMessage.INFO || message.getLevel() == FeedbackMessage.SUCCESS){ - add(AttributeModifier.replace("class", "attendanceMessageSuccess")); + add(AttributeModifier.replace("class", "attendanceMessageSuccess alert alert-success")); } return newMessageDisplayComponent; diff --git a/tool/src/webapp/css/attendance.css b/tool/src/webapp/css/attendance.css index 78b9e520..d234a7ae 100644 --- a/tool/src/webapp/css/attendance.css +++ b/tool/src/webapp/css/attendance.css @@ -145,19 +145,6 @@ table.itemListTable, table.eventViewTable, table.takeAttendanceTable { margin-left: 35px; } -thead tr .tablesorter-header:not(.sorter-false):not(.tablesorter-headerAsc):not(.tablesorter-headerDesc), table.itemListTable thead tr .header, table.takeAttendanceTable thead tr .header, th.tablesorter-headerUnsorted, tr.div-table-row > th.header:not(.headerSortDown):not(.headerSortUp) { - background: url(../images/bg.png) no-repeat bottom .5em right; - cursor: pointer; - padding-right: 24px; -} - -thead tr .tablesorter-headerAsc, table.itemListTable thead tr .headerSortUp, table.takeAttendanceTable thead tr .headerSortUp, th.headerSortUp { - background: url(../images/asc.png) no-repeat bottom .5em right; -} -thead tr .tablesorter-headerDesc, table.itemListTable thead tr .headerSortDown, table.takeAttendanceTable thead tr .headerSortDown, th.headerSortDown { - background: url(../images/desc.png) no-repeat bottom .5em right; -} - table.itemListTable, table.eventViewTable, table.takeAttendanceTable, div.eventFormContainer, form.addEditForm, .addComment h3, td.overviewGradeCol form { margin: 0; } @@ -607,15 +594,6 @@ label.addItemCaptions { top: 21%; } -#buttonSection > button.saveNewItem { - background: #17214A; - color: white; -} -#buttonSection > button.saveNewItem:hover { - background: #111837; - border-color: #124466; -} - ul.actions-dropdown { z-index: 90; } @@ -923,13 +901,6 @@ div.wicket-modal div.w_caption { height: auto; } -div.wicket-modal h3.w_captionText { - padding: 20px; - font-size: 1.5em; - position: relative; - height: auto; - color: var(--sakai-text-color-1); -} /* End janking */ div.wicket-modal div.w_content_3 div.messageSuccess, div.wicket-modal div.w_content_3 div.alertMessage { @@ -950,11 +921,6 @@ form.takeAttendanceNowForm input:hover { color: white; } -span.yui-skin-sam img { - margin-right: .5em; -} - - .cancel { background: #e54028; -webkit-border-radius: 3px; @@ -1087,8 +1053,3 @@ span.yui-skin-sam img { text-align: center; font-size: 1.3em; } - -div#startDateTime span.yui-skin-sam span.yui-calcontainer, div#startDateTime th.calweekdaycell, div#startDateTime td.calcell:not(.oom), div#startDateTime span.yui-skin-sam span.yui-calcontainer a:not(.calnavright):not(.calnavleft), div#startDateTime span.yui-skin-sam span.yui-calcontainer div.title { - background: var(--sakai-background-color-2); - color: var(--sakai-text-color-2); -} diff --git a/tool/src/webapp/javascript/attendanceRecordForm.js b/tool/src/webapp/javascript/attendanceRecordForm.js index c79ff1ac..341cb6fd 100644 --- a/tool/src/webapp/javascript/attendanceRecordForm.js +++ b/tool/src/webapp/javascript/attendanceRecordForm.js @@ -43,15 +43,12 @@ // Set up the whole page record forms attendance.recordFormSetup = function() { - var inputs = []; + let inputs = []; $("input[name='attendance-record-status-group']").each(function() { inputs.push(this); }); - var isStudentView = false; - if($("#studentView").size() > 0) { - isStudentView = true; - } + const isStudentView = document.getElementById("studentView") !== null; processInput(inputs, isStudentView); };