diff --git a/tool/src/java/org/sakaiproject/attendance/tool/Attendance.properties b/tool/src/java/org/sakaiproject/attendance/tool/Attendance.properties index 75e16b2e..4fc935a3 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/Attendance.properties +++ b/tool/src/java/org/sakaiproject/attendance/tool/Attendance.properties @@ -156,6 +156,7 @@ group-choice.nullValid=Entire Site #Settings Page attendance.settings.header = Attendance Settings attendance.settings.active.status.header = Edit Status Settings +attendance.settings.comment.header = Edit Comment Settings attendance.settings.grading.header = Edit Grade Settings attendance.settings.grading.info = These settings control the grading options. Enter a value for the total points possible to enable grading across the tool. attendance.settings.grading.max.points.possible = Total Points Possible @@ -198,7 +199,11 @@ attendance.settings.grading.save = Save Settings attendance.settings.edit.status.save.error = There was an error trying to save status settings. attendance.settings.edit.status.save.success = Status settings have been saved successfully. +attendance.settings.edit.comment.save.success = Comment settings have been saved successfully. +attendance.settings.edit.comment.save.error = There was an error trying to save comment settings. attendance.settings.edit.status.info = Drag and drop the statuses below or change the number in the box to reorder them. Statuses that have been checked are active and will be shown throughout the attendance tool. +attendance.settings.edit.comment.info = +attendance.settings.edit.save = Save Settings attendance.settings.show.comments.label = Show comments to students 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 9ecc10ac..aaa63f88 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/pages/SettingsPage.html +++ b/tool/src/java/org/sakaiproject/attendance/tool/pages/SettingsPage.html @@ -23,7 +23,7 @@

- +

@@ -34,6 +34,19 @@

+
+

+
+ +
+ +
+

+ + + + 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 5def8516..d786b6fd 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/pages/SettingsPage.java +++ b/tool/src/java/org/sakaiproject/attendance/tool/pages/SettingsPage.java @@ -17,10 +17,15 @@ import org.apache.wicket.RestartResponseException; +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink; 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.model.Model; import org.apache.wicket.model.ResourceModel; -import org.sakaiproject.attendance.tool.panels.AttendanceGradeFormPanel; +import org.sakaiproject.attendance.model.AttendanceSite; +import org.sakaiproject.attendance.tool.panels.AttendanceCommentFormPanel; import org.sakaiproject.attendance.tool.panels.AttendanceStatusFormPanel; /** @@ -43,13 +48,37 @@ public SettingsPage() { Label headerSettings = new Label("header-settings", new ResourceModel("attendance.settings.header")); add(headerSettings); - createEditStatusesPanel(); + Model siteModel = new Model<>(attendanceLogic.getCurrentAttendanceSite()); + Form settingsForm = new Form<>("settings-form", siteModel); + + + settingsForm.add(createEditStatusesPanel(siteModel)); + settingsForm.add(createEditCommentPanel(siteModel)); + + AjaxSubmitLink submit = new AjaxSubmitLink("submit-link") { + @Override + protected void onSubmit(AjaxRequestTarget target, Form form) { + super.onSubmit(target, form); + target.add(feedbackPanel); + } + + }; + settingsForm.add(submit); + + add(settingsForm); + } - private void createEditStatusesPanel() { + private WebMarkupContainer createEditStatusesPanel(Model siteModel) { WebMarkupContainer allStatusesContainer = new WebMarkupContainer("all-statuses-container"); - allStatusesContainer.add(new AttendanceStatusFormPanel("edit-status-panel", feedbackPanel)); - add(allStatusesContainer); + allStatusesContainer.add(new AttendanceStatusFormPanel("edit-status-panel", feedbackPanel, siteModel)); + return allStatusesContainer; + } + + private WebMarkupContainer createEditCommentPanel(Model siteModel) { + WebMarkupContainer commentContainer = new WebMarkupContainer("comment-container"); + commentContainer.add(new AttendanceCommentFormPanel("edit-comment-panel", feedbackPanel, siteModel)); + return commentContainer; } } diff --git a/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceCommentFormPanel.html b/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceCommentFormPanel.html new file mode 100644 index 00000000..179a9930 --- /dev/null +++ b/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceCommentFormPanel.html @@ -0,0 +1,33 @@ + + + + + + +

+ +

+
+
+ +
+
+
+ + \ No newline at end of file diff --git a/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceCommentFormPanel.java b/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceCommentFormPanel.java new file mode 100644 index 00000000..a874f602 --- /dev/null +++ b/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceCommentFormPanel.java @@ -0,0 +1,72 @@ +/* + * * + * * Copyright (c) 2017, University of Dayton + * * + * * Licensed under the Educational Community License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * + * * http://opensource.org/licenses/ecl2 + * * + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ + +package org.sakaiproject.attendance.tool.panels; + +import lombok.extern.slf4j.Slf4j; +import org.apache.wicket.markup.html.form.CheckBox; +import org.apache.wicket.markup.html.form.Form; +import org.apache.wicket.markup.html.panel.FeedbackPanel; +import org.apache.wicket.model.*; +import org.sakaiproject.attendance.model.AttendanceSite; + +/** + * Created by Leonardo Canessa [lcanessa1 (at) udayton (dot) edu] + */ +@Slf4j +public class AttendanceCommentFormPanel extends BasePanel { + private static final long serialVersionUID = 1L; + + private Model attendanceSiteModel; + + public AttendanceCommentFormPanel(String id, FeedbackPanel feedbackPanel) { + super(id); + + this.attendanceSiteModel = new Model<>(attendanceLogic.getCurrentAttendanceSite()); + init(feedbackPanel); + } + + public AttendanceCommentFormPanel(String id, FeedbackPanel feedbackPanel, Model siteModel) { + super(id, siteModel); + + this.attendanceSiteModel = siteModel; + init(feedbackPanel); + } + + private void init(FeedbackPanel panel) { + enable(panel); + + Form editCommentSettingsForm = new Form("edit-comment-settings-form", new CompoundPropertyModel<>(this.attendanceSiteModel)) { + @Override + protected void onSubmit() { + final AttendanceSite aS = (AttendanceSite) getDefaultModelObject(); + boolean result = attendanceLogic.updateAttendanceSite(aS); + + if(result) { + getSession().success(getString("attendance.settings.edit.comment.save.success")); + } else { + getSession().error(getString("attendance.settings.edit.comment.save.error")); + } + + } + }; + + editCommentSettingsForm.add(new CheckBox("show-comments-to-students", new PropertyModel<>(this.attendanceSiteModel, "showCommentsToStudents"))); + add(editCommentSettingsForm); + } +} 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 f8738c90..9988ef78 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceGradeFormPanel.java +++ b/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceGradeFormPanel.java @@ -43,7 +43,6 @@ public class AttendanceGradeFormPanel extends BasePanel { private static final long serialVersionUID = 1L; - private FeedbackPanel pageFeedbackPanel; private boolean previousSendToGradebook; private String previousName; private Double previousMaxGrade; @@ -54,7 +53,7 @@ public class AttendanceGradeFormPanel extends BasePanel { public AttendanceGradeFormPanel(String id, FeedbackPanel pg) { super(id); - this.pageFeedbackPanel = pg; + enable(pg); init(); } 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 6d4a402e..bc101342 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceGradePanel.java +++ b/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceGradePanel.java @@ -38,7 +38,6 @@ public class AttendanceGradePanel extends BasePanel { private static final long serialVersionUID = 1L; private IModel agIModel; - private FeedbackPanel pageFeedbackPanel; private AttendanceSite attendanceSite; public AttendanceGradePanel(String id, AttendanceGrade aG, FeedbackPanel fP) { @@ -51,7 +50,7 @@ public AttendanceGradePanel(String id, AttendanceGrade aG, FeedbackPanel fP) { this.agIModel = new CompoundPropertyModel<>(aG); this.attendanceSite = agIModel.getObject().getAttendanceSite(); } - this.pageFeedbackPanel = fP; + enable(fP); init(); } 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 5dabb845..4bbb3a25 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceRecordFormDataPanel.java +++ b/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceRecordFormDataPanel.java @@ -52,7 +52,6 @@ public class AttendanceRecordFormDataPanel extends BasePanel { private boolean showCommentsToStudents; private List ajaxTargets = new ArrayList(); private String returnPage; - private FeedbackPanel pageFeedbackPanel; private Status oldStatus; private WebMarkupContainer commentContainer; @@ -66,7 +65,7 @@ public AttendanceRecordFormDataPanel(String id, IModel aR, St this.showCommentsToStudents = recordIModel.getObject().getAttendanceEvent().getAttendanceSite().getShowCommentsToStudents(); this.restricted = this.role != null && this.role.equals("Student"); this.returnPage = rP; - this.pageFeedbackPanel = fP; + enable(fP); this.ajaxTargets.add(this.pageFeedbackPanel); add(createRecordInputForm()); diff --git a/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceStatusFormPanel.html b/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceStatusFormPanel.html index 103630c8..24bd0bff 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceStatusFormPanel.html +++ b/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceStatusFormPanel.html @@ -28,7 +28,7 @@

- +

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 0e345fa9..6fd16712 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceStatusFormPanel.java +++ b/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceStatusFormPanel.java @@ -43,26 +43,31 @@ */ public class AttendanceStatusFormPanel extends BasePanel { private static final long serialVersionUID = 1L; - private IModel attendanceSiteIModel; - private FeedbackPanel pageFeedbackPanel; + private Model attendanceSiteModel; + private boolean subForm = true; public AttendanceStatusFormPanel(String id, FeedbackPanel feedbackPanel) { super(id); - this.pageFeedbackPanel = feedbackPanel; - this.attendanceSiteIModel = new Model(attendanceLogic.getCurrentAttendanceSite()); - init(); + + this.attendanceSiteModel = new Model<>(attendanceLogic.getCurrentAttendanceSite()); + init(feedbackPanel); + } + + public AttendanceStatusFormPanel(String id, FeedbackPanel feedbackPanel, Model attendanceSiteModel) { + super(id, attendanceSiteModel); + + this.attendanceSiteModel = attendanceSiteModel; + init(feedbackPanel); } - public AttendanceStatusFormPanel(String id, IModel attendanceSiteIModel, FeedbackPanel feedbackPanel) { - super(id, attendanceSiteIModel); - this.pageFeedbackPanel = feedbackPanel; - this.attendanceSiteIModel = attendanceSiteIModel; - init(); + public void setSubForm(boolean val) { + this.subForm = val; } - private void init() { + private void init(FeedbackPanel panel) { + enable(panel); - Form editStatusSettingsForm = new Form("edit-status-settings-form", new CompoundPropertyModel(this.attendanceSiteIModel)) { + Form editStatusSettingsForm = new Form("edit-status-settings-form", new CompoundPropertyModel<>(this.attendanceSiteModel)) { @Override protected void onSubmit() { AttendanceSite aS = (AttendanceSite) getDefaultModelObject(); @@ -76,7 +81,7 @@ protected void onSubmit() { }; add(editStatusSettingsForm); - final IModel> listModel = new PropertyModel>(this.attendanceSiteIModel, "attendanceStatuses") { + final IModel> listModel = new PropertyModel>(this.attendanceSiteModel, "attendanceStatuses") { @Override public List getObject() { List attendanceStatuses = new ArrayList((Set)super.getObject()); @@ -109,11 +114,13 @@ protected void onSubmit(AjaxRequestTarget target, Form form) { super.onSubmit(target, form); target.add(pageFeedbackPanel); } + + @Override + public boolean isVisible() { + return !subForm; + } }; editStatusSettingsForm.add(submit); - - editStatusSettingsForm.add(new CheckBox("show-comments-to-students", new PropertyModel(this.attendanceSiteIModel, "showCommentsToStudents"))); - } } diff --git a/tool/src/java/org/sakaiproject/attendance/tool/panels/BasePanel.java b/tool/src/java/org/sakaiproject/attendance/tool/panels/BasePanel.java index 3ce4dd10..dd4c4b37 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/panels/BasePanel.java +++ b/tool/src/java/org/sakaiproject/attendance/tool/panels/BasePanel.java @@ -17,6 +17,7 @@ package org.sakaiproject.attendance.tool.panels; import org.apache.log4j.Logger; +import org.apache.wicket.markup.html.panel.FeedbackPanel; import org.apache.wicket.markup.html.panel.Panel; import org.apache.wicket.model.IModel; import org.apache.wicket.model.ResourceModel; @@ -50,6 +51,8 @@ public class BasePanel extends Panel { protected String role; + protected FeedbackPanel pageFeedbackPanel; + public BasePanel(String id) { super(id); init(); @@ -60,6 +63,10 @@ public BasePanel(String id, IModel i){ init(); } + protected void enable(FeedbackPanel panel) { + this.pageFeedbackPanel = panel; + } + protected String getStatusString(Status s) { if(s == null) { return new ResourceModel("attendance.status.unknown").getObject(); 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 cbb0809b..404cbfd9 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/panels/GradingRulesListPanel.java +++ b/tool/src/java/org/sakaiproject/attendance/tool/panels/GradingRulesListPanel.java @@ -35,8 +35,6 @@ public class GradingRulesListPanel extends BasePanel { private static final long serialVersionUID = 1L; - FeedbackPanel pageFeedbackPanel; - Form regradeForm; private boolean needRegrade; @@ -44,7 +42,7 @@ public class GradingRulesListPanel extends BasePanel { public GradingRulesListPanel(String id, FeedbackPanel feedbackPanel, boolean needRegrade) { super(id); - this.pageFeedbackPanel = feedbackPanel; + enable(feedbackPanel); this.needRegrade = needRegrade; 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 24a7e567..d7dc1a13 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/panels/GradingRulesPanel.java +++ b/tool/src/java/org/sakaiproject/attendance/tool/panels/GradingRulesPanel.java @@ -37,14 +37,12 @@ public class GradingRulesPanel extends BasePanel { private static final long serialVersionUID = 1L; - private FeedbackPanel pageFeedbackPanel; - private GradingRulesListPanel gradingRulesListPanel; public GradingRulesPanel(String id) { super(id); - this.pageFeedbackPanel = new FeedbackPanel("rules-feedback"){ + enable(new FeedbackPanel("rules-feedback"){ @Override protected Component newMessageDisplayComponent(final String id, final FeedbackMessage message) { @@ -61,7 +59,7 @@ protected Component newMessageDisplayComponent(final String id, final FeedbackMe return newMessageDisplayComponent; } - }; + }); this.pageFeedbackPanel.setOutputMarkupId(true); add(this.pageFeedbackPanel); diff --git a/tool/src/webapp/css/attendance.css b/tool/src/webapp/css/attendance.css index e6422930..e8a053b9 100644 --- a/tool/src/webapp/css/attendance.css +++ b/tool/src/webapp/css/attendance.css @@ -237,7 +237,8 @@ th.takeAttendanceNameHeader { vertical-align: middle; } -div.addEditContainer, div.itemListContainer, div.takeAttendanceContainer, div.itemInfoContainer, div.activeStatusContainer, div.gradingContainer { +div.addEditContainer, div.itemListContainer, div.takeAttendanceContainer, div.itemInfoContainer, +div.activeStatusContainer, div.commentContainer, div.gradingContainer { border:1px solid #ccc; padding: 2.5em 2em 2em; vertical-align: top; @@ -269,14 +270,16 @@ div.itemInfoContainer { display: flex; } -div.addEditHeader, div.itemListHeader, div.takeAttendanceHeader, div.itemInfoHeader, div.activeStatusHeader, div.containerHeader { +div.addEditHeader, div.itemListHeader, div.takeAttendanceHeader, div.itemInfoHeader, +div.activeStatusHeader, div.commentHeader, div.containerHeader { background-color:#fff; position:absolute; top:-1em; left:.5em; } -h3.addEditHeader, h3.itemListHeader, h3.takeAttendanceHeader, h3.itemInfoHeader, h3.activeStatusHeader, h3.containerHeading { +h3.addEditHeader, h3.itemListHeader, h3.takeAttendanceHeader, h3.itemInfoHeader, +h3.activeStatusHeader, h3.commentHeader, h3.containerHeading { margin: 0; padding: 0 .5em; font-size: 1.4em; @@ -481,7 +484,7 @@ li.statusItemDisabled { background-color: #eee; } -p.editStatusInfo, p.editGradeInfo { +p.editStatusInfo, p.editGradeInfo, p.editCommentInfo { width: 60%; font-size: 1.2em; line-height: 1.5em; @@ -594,6 +597,10 @@ div.comment-container { position: relative; } +#settingsSave { + margin-left: 35px; +} + @media (min-width: 1205px) { .record-status-name { display: none;