Skip to content

Commit

Permalink
Merge pull request sakaiproject#1261 from annuelo/SAK-29971
Browse files Browse the repository at this point in the history
SAK-29971 Add an anouncement about the open date by setting the notification level
  • Loading branch information
ern committed Dec 3, 2015
2 parents ac4dd6c + 2c1577a commit c102ae7
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,14 @@ public interface Assignment extends Entity, Comparable

public static final String ASSIGNMENT_RELEASERESUBMISSION_NOTIFICATION_VALUE = "assignment_releasereturn_notification_value";
public static final String ASSIGNMENT_RELEASERESUBMISSION_NOTIFICATION_NONE = "assignment_releasereturn_notification_none";
public static final String ASSIGNMENT_RELEASERESUBMISSION_NOTIFICATION_EACH = "assignment_releasereturn_notification_each";
public static final String ASSIGNMENT_RELEASERESUBMISSION_NOTIFICATION_EACH = "assignment_releasereturn_notification_each";

// the option of open date notification to students
public static final String ASSIGNMENT_OPENDATE_NOTIFICATION = "assignment_opendate_notification";
public static final String ASSIGNMENT_OPENDATE_NOTIFICATION_NONE = "assignment_opendate_notification_none";
public static final String ASSIGNMENT_OPENDATE_NOTIFICATION_LOW = "assignment_opendate_notification_low";
public static final String ASSIGNMENT_OPENDATE_NOTIFICATION_HIGH = "assignment_opendate_notification_high";

/**
* Access if this is a group submission type of this Assignment.
*
Expand Down
4 changes: 4 additions & 0 deletions assignment/assignment-bundles/resources/assignment.properties
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,10 @@ send.submission.releasereturn.email.options=Released Resubmission Notification E
send.submission.releasereturn.email.none=Do not send notification email to student when the grade is released and resubmission is available
send.submission.releasereturn.email=Send notification email to student when the grade is released and resubmission is available

send.notification.opendate.email.none=Do not send email notification
send.notification.opendate.email.low=Send email notification on the open date to participants who have opted for it
send.notification.opendate.email.high=Send email notification on the open date to all participants

sendFeedback.show = Show settings for sending feedback
sendFeedback.hide = Hide settings for sending feedback
sendFeedback.label = Select user(s) to send feedback
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,10 @@ send.submission.releasereturn.email.options=Opcions del correu electr\u00f2nic d
send.submission.releasereturn.email.none=No envi\u00efs correu electr\u00f2nic de notificaci\u00f3 quan es publiqui la nota i es permetin reenviaments
send.submission.releasereturn.email=Envia el correu electr\u00f2nic de notificaci\u00f3

send.notification.opendate.email.none=No envi\u00efs notificaci\u00f3 per correu electr\u00f2nic
send.notification.opendate.email.low=Envia notificaci\u00f3 per correu electr\u00f2nic en la data d'obertura als participants que hagen optat per a\u00e7\u00f2
send.notification.opendate.email.hihg=Envia notificaci\u00f3 per correu electr\u00f2nic en la data d'obertura a tots els participants

# Peer Review
peerAssessmentSavedGrading=Els comentaris i/o les qualificacions s'han desat per\u00f2 no s'han enviat. Si no presenteu la revisi\u00f3 abans del termini, s'enviar\u00e0 de manera autom\u00e0tica.
peerAssessmentSavedSubmission=Els comentaris i/o les qualificacions s'han desat i presentat.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,10 @@ send.submission.releasereturn.email.options=Opciones de correo de env\u00edos de
send.submission.releasereturn.email.none=No enviar una notificaci\u00f3n por correo al alumno cuando se corrija la tarea y el alumno pueda realizar reenv\u00edos
send.submission.releasereturn.email=Enviar una notificaci\u00f3n por correo al alumno cuando se corrija la tarea y el alumno pueda realizar reenv\u00edos

send.notification.opendate.email.none=No enviar notificaci\u00f3n por correo
send.notification.opendate.email.low=Enviar notificaci\u00f3n por correo en la fecha de apertura a los participantes que hayan optado por ello
send.notification.opendate.email.high=Enviar notificaci\u00f3n por correo en la fecha de apertura a todos los participantes

sendFeedback.show=Mostrar opciones de env\u00edo de comentarios a m\u00faltiples usuarios (feedback)
sendFeedback.hide=Ocultar opciones de env\u00edo de comentarios a m\u00faltiples usuarios (feedback)
sendFeedback.label=Env\u00edo de comentarios a m\u00faltiples usuarios.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package org.sakaiproject.assignment.tool;

import au.com.bytecode.opencsv.CSVReader;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
Expand Down Expand Up @@ -56,6 +57,7 @@
import java.util.concurrent.ConcurrentSkipListSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
Expand All @@ -72,6 +74,7 @@
import org.sakaiproject.announcement.api.AnnouncementMessageHeaderEdit;
import org.sakaiproject.announcement.api.AnnouncementService;
import org.sakaiproject.assignment.api.Assignment;
import org.sakaiproject.assignment.api.Assignment.AssignmentAccess;
import org.sakaiproject.assignment.api.AssignmentConstants;
import org.sakaiproject.assignment.api.AssignmentContent;
import org.sakaiproject.assignment.api.AssignmentContentEdit;
Expand Down Expand Up @@ -140,6 +143,7 @@
import org.sakaiproject.exception.PermissionException;
import org.sakaiproject.exception.ServerOverloadException;
import org.sakaiproject.javax.PagingPosition;
import org.sakaiproject.message.api.MessageHeader;
import org.sakaiproject.scoringservice.api.ScoringAgent;
import org.sakaiproject.scoringservice.api.ScoringComponent;
import org.sakaiproject.scoringservice.api.ScoringService;
Expand Down Expand Up @@ -2519,8 +2523,10 @@ protected void setAssignmentFormContext(SessionState state, Context context)

context.put("name_CheckHideDueDate", NEW_ASSIGNMENT_CHECK_HIDE_DUE_DATE);
//don't show the choice when there is no Announcement tool yet
if (state.getAttribute(ANNOUNCEMENT_CHANNEL) != null)
if (state.getAttribute(ANNOUNCEMENT_CHANNEL) != null) {
context.put("name_CheckAutoAnnounce", ResourceProperties.NEW_ASSIGNMENT_CHECK_AUTO_ANNOUNCE);
context.put("name_OpenDateNotification", Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION);
}
context.put("name_CheckAddHonorPledge", NEW_ASSIGNMENT_CHECK_ADD_HONOR_PLEDGE);

// SAK-17606
Expand Down Expand Up @@ -2631,8 +2637,14 @@ protected void setAssignmentFormContext(SessionState state, Context context)
context.put("value_CheckHideDueDate", state.getAttribute(NEW_ASSIGNMENT_CHECK_HIDE_DUE_DATE));

// don't show the choice when there is no Announcement tool yet
if (state.getAttribute(ANNOUNCEMENT_CHANNEL) != null)
context.put("value_CheckAutoAnnounce", state.getAttribute(ResourceProperties.NEW_ASSIGNMENT_CHECK_AUTO_ANNOUNCE));
if (state.getAttribute(ANNOUNCEMENT_CHANNEL) != null) {
context.put("value_CheckAutoAnnounce", state.getAttribute(ResourceProperties.NEW_ASSIGNMENT_CHECK_AUTO_ANNOUNCE));
context.put("value_OpenDateNotification", state.getAttribute(Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION));
// the option values
context.put("value_opendate_notification_none", Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION_NONE);
context.put("value_opendate_notification_low", Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION_LOW);
context.put("value_opendate_notification_high", Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION_HIGH);
}

String s = (String) state.getAttribute(NEW_ASSIGNMENT_CHECK_ADD_HONOR_PLEDGE);
if (s == null) s = "1";
Expand Down Expand Up @@ -3108,6 +3120,11 @@ protected String build_instructor_preview_assignment_context(VelocityPortlet por
context.put("value_CheckAddDueDate", state.getAttribute(ResourceProperties.NEW_ASSIGNMENT_CHECK_ADD_DUE_DATE));
context.put("value_CheckHideDueDate", state.getAttribute(NEW_ASSIGNMENT_CHECK_HIDE_DUE_DATE));
context.put("value_CheckAutoAnnounce", state.getAttribute(ResourceProperties.NEW_ASSIGNMENT_CHECK_AUTO_ANNOUNCE));
context.put("Value_OpenDateNotification", state.getAttribute(Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION));
// the option values
context.put("value_opendate_notification_none", Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION_NONE);
context.put("value_opendate_notification_low", Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION_LOW);
context.put("value_opendate_notification_high", Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION_HIGH);
context.put("value_CheckAddHonorPledge", state.getAttribute(NEW_ASSIGNMENT_CHECK_ADD_HONOR_PLEDGE));
context.put("honor_pledge_text", ServerConfigurationService.getString("assignment.honor.pledge", rb.getString("gen.honple2")));

Expand Down Expand Up @@ -7360,6 +7377,21 @@ else if (sameAssignmentTitleInContext(assignmentRef, title, (String) state.getAt
{
state.setAttribute(ResourceProperties.NEW_ASSIGNMENT_CHECK_AUTO_ANNOUNCE, Boolean.FALSE.toString());
}

if (params.getString(Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION) != null) {
if (params.getString(Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION)
.equalsIgnoreCase(Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION_NONE)) {
state.setAttribute(Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION, Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION_NONE);
}
else if (params.getString(Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION)
.equalsIgnoreCase(Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION_LOW)) {
state.setAttribute(Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION, Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION_LOW);
}
else if (params.getString(Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION)
.equalsIgnoreCase(Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION_HIGH)) {
state.setAttribute(Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION, Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION_HIGH);
}
}

if (params.getString(NEW_ASSIGNMENT_CHECK_HIDE_DUE_DATE) != null
&& params.getString(NEW_ASSIGNMENT_CHECK_HIDE_DUE_DATE)
Expand Down Expand Up @@ -8179,6 +8211,8 @@ private void post_save_assignment(RunData data, String postOrSave)
boolean hideDueDate = "true".equals((String) state.getAttribute(NEW_ASSIGNMENT_CHECK_HIDE_DUE_DATE));

String checkAutoAnnounce = (String) state.getAttribute(ResourceProperties.NEW_ASSIGNMENT_CHECK_AUTO_ANNOUNCE);

String valueOpenDateNotification = (String) state.getAttribute(Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION);

String checkAddHonorPledge = (String) state.getAttribute(NEW_ASSIGNMENT_CHECK_ADD_HONOR_PLEDGE);

Expand Down Expand Up @@ -8407,7 +8441,7 @@ else if (groupChoice != null)
integrateWithCalendar(state, a, title, dueTime, checkAddDueTime, oldDueTime, aPropertiesEdit);

// the open date been announced
integrateWithAnnouncement(state, aOldTitle, a, title, openTime, checkAutoAnnounce, oldOpenTime);
integrateWithAnnouncement(state, aOldTitle, a, title, openTime, checkAutoAnnounce, valueOpenDateNotification, oldOpenTime);

// integrate with Gradebook
try
Expand Down Expand Up @@ -8901,7 +8935,7 @@ private void removeNonAssociatedExternalGradebookEntry(String context, String as
}
}

private void integrateWithAnnouncement(SessionState state, String aOldTitle, AssignmentEdit a, String title, Time openTime, String checkAutoAnnounce, Time oldOpenTime)
private void integrateWithAnnouncement(SessionState state, String aOldTitle, AssignmentEdit a, String title, Time openTime, String checkAutoAnnounce, String valueOpenDateNotification, Time oldOpenTime)
{
if (checkAutoAnnounce.equalsIgnoreCase(Boolean.TRUE.toString()))
{
Expand Down Expand Up @@ -8930,7 +8964,8 @@ private void integrateWithAnnouncement(SessionState state, String aOldTitle, Ass
{
updatedOpenDate = true;
}
if (!message.getAnnouncementHeader().getAccess().equals(a.getAccess()))
if ((message.getAnnouncementHeader().getAccess().equals(MessageHeader.MessageAccess.CHANNEL) && !a.getAccess().equals(AssignmentAccess.SITE))
|| (!message.getAnnouncementHeader().getAccess().equals(MessageHeader.MessageAccess.CHANNEL) && a.getAccess().equals(AssignmentAccess.SITE)))
{
updateAccess = true;
}
Expand Down Expand Up @@ -9039,8 +9074,29 @@ else if (a.getAccess() == Assignment.AssignmentAccess.GROUPED)
header.clearGroupAccess();
}


channel.commitMessage(message, m_notificationService.NOTI_NONE);
// save notification level if this is a future notification message
int notiLevel = NotificationService.NOTI_NONE;
String notification = "n";
if (Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION_LOW.equals(valueOpenDateNotification)) {
notiLevel = NotificationService.NOTI_OPTIONAL;
notification = "o";
}
else if (Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION_HIGH.equals(valueOpenDateNotification)) {
notiLevel = NotificationService.NOTI_REQUIRED;
notification = "r";
}

Time now = TimeService.newTime();
if (openDateAnnounced != null && now.before(oldOpenTime))
{
message.getPropertiesEdit().addProperty("notificationLevel", notification);
message.getPropertiesEdit().addPropertyToList("noti_history", now.toStringLocalFull()+"_"+notiLevel+"_"+openDateAnnounced);
}
else {
message.getPropertiesEdit().addPropertyToList("noti_history", now.toStringLocalFull()+"_"+notiLevel);
}

channel.commitMessage(message, notiLevel, "org.sakaiproject.announcement.impl.SiteEmailNotificationAnnc");
}

// commit related properties into Assignment object
Expand Down Expand Up @@ -9366,6 +9422,7 @@ private void editAssignmentProperties(AssignmentEdit a, String checkAddDueTime,
aPropertiesEdit.removeProperty(ResourceProperties.NEW_ASSIGNMENT_CHECK_ADD_DUE_DATE);
}
aPropertiesEdit.addProperty(ResourceProperties.NEW_ASSIGNMENT_CHECK_AUTO_ANNOUNCE, checkAutoAnnounce);

aPropertiesEdit.addProperty(NEW_ASSIGNMENT_ADD_TO_GRADEBOOK, addtoGradebook);
aPropertiesEdit.addProperty(AssignmentService.PROP_ASSIGNMENT_ASSOCIATE_GRADEBOOK_ASSIGNMENT, associateGradebookAssignment);

Expand Down Expand Up @@ -9935,8 +9992,21 @@ public void doEdit_assignment(RunData data)
ResourceProperties properties = a.getProperties();
state.setAttribute(ResourceProperties.NEW_ASSIGNMENT_CHECK_ADD_DUE_DATE, properties.getProperty(
ResourceProperties.NEW_ASSIGNMENT_CHECK_ADD_DUE_DATE));

state.setAttribute(ResourceProperties.NEW_ASSIGNMENT_CHECK_AUTO_ANNOUNCE, properties.getProperty(
ResourceProperties.NEW_ASSIGNMENT_CHECK_AUTO_ANNOUNCE));

String defaultNotification = ServerConfigurationService.getString("announcement.default.notification", "n");
if (defaultNotification.equalsIgnoreCase("r")) {
state.setAttribute(Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION, Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION_HIGH);
}
else if (defaultNotification.equalsIgnoreCase("o")) {
state.setAttribute(Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION, Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION_LOW);
}
else {
state.setAttribute(Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION, Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION_NONE);
}

state.setAttribute(NEW_ASSIGNMENT_CHECK_ADD_HONOR_PLEDGE, Integer.toString(a.getContent().getHonorPledge()));

state.setAttribute(AssignmentService.NEW_ASSIGNMENT_ADD_TO_GRADEBOOK, properties.getProperty(AssignmentService.NEW_ASSIGNMENT_ADD_TO_GRADEBOOK));
Expand Down Expand Up @@ -12417,6 +12487,17 @@ private void initializeAssignment(SessionState state)
state.setAttribute(NEW_ASSIGNMENT_DESCRIPTION, "");
state.setAttribute(ResourceProperties.NEW_ASSIGNMENT_CHECK_ADD_DUE_DATE, Boolean.FALSE.toString());
state.setAttribute(ResourceProperties.NEW_ASSIGNMENT_CHECK_AUTO_ANNOUNCE, Boolean.FALSE.toString());

String defaultNotification = ServerConfigurationService.getString("announcement.default.notification", "n");
if (defaultNotification.equalsIgnoreCase("r")) {
state.setAttribute(Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION, Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION_HIGH);
}
else if (defaultNotification.equalsIgnoreCase("o")) {
state.setAttribute(Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION, Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION_LOW);
}
else {
state.setAttribute(Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION, Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION_NONE);
}
// make the honor pledge not include as the default
state.setAttribute(NEW_ASSIGNMENT_CHECK_ADD_HONOR_PLEDGE, (Integer.valueOf(Assignment.HONOR_PLEDGE_NONE)).toString());

Expand Down Expand Up @@ -12519,6 +12600,7 @@ private void resetAssignment(SessionState state)
state.removeAttribute(NEW_ASSIGNMENT_DESCRIPTION);
state.removeAttribute(ResourceProperties.NEW_ASSIGNMENT_CHECK_ADD_DUE_DATE);
state.removeAttribute(ResourceProperties.NEW_ASSIGNMENT_CHECK_AUTO_ANNOUNCE);
state.removeAttribute(Assignment.ASSIGNMENT_OPENDATE_NOTIFICATION);
state.removeAttribute(NEW_ASSIGNMENT_CHECK_ADD_HONOR_PLEDGE);
state.removeAttribute(NEW_ASSIGNMENT_CHECK_HIDE_DUE_DATE);
state.removeAttribute(NEW_ASSIGNMENT_ADD_TO_GRADEBOOK);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,17 @@ $(document).ready(function() {
$("#site").prop("disabled", false);
}
}

function toggleAutoAnnounceOptions(checked){
var section = document.getElementById("selectAutoAnnounceOptions");
if(checked){
section.style.display="block";
resizeFrame('grow');
}else{
section.style.display="none";
resizeFrame('shrink');
}
}
</script>
<script type="text/javascript">
focus_path = [ '$fField' ];
Expand Down Expand Up @@ -639,14 +650,27 @@ $(document).ready(function() {
#if ($!name_CheckAutoAnnounce)
<p class="checkbox indnt2">
#if ($value_CheckAutoAnnounce.equals("true"))
<input id="$name_CheckAutoAnnounce" name="$name_CheckAutoAnnounce" type="checkbox" value="true" checked="checked" />
<input id="$name_CheckAutoAnnounce" name="$name_CheckAutoAnnounce" type="checkbox" value="true" checked="checked" onclick="toggleAutoAnnounceOptions(this.checked)" />
#else
<input id="$name_CheckAutoAnnounce" name="$name_CheckAutoAnnounce" type="checkbox" value="true" />
<input id="$name_CheckAutoAnnounce" name="$name_CheckAutoAnnounce" type="checkbox" value="true" onclick="toggleAutoAnnounceOptions(this.checked)" />
#end
<label for="$name_CheckAutoAnnounce">
$tlang.getString("gen.anntheope")
</label>
</p>
#if ($!$value_CheckAutoAnnounce.equals("true"))
<div id="selectAutoAnnounceOptions" class="indnt3">
#else
<div id="selectAutoAnnounceOptions" style="display:none" class="indnt3">
#end
<p class="checkbox indnt2">
<select name="$name_OpenDateNotification" id="$name_OpenDateNotification">
<option value="$value_opendate_notification_none" #if($value_OpenDateNotification.equals($value_opendate_notification_none)) selected="selected" #end>$tlang.getString('send.notification.opendate.email.none')</option>
<option value="$value_opendate_notification_low" #if($value_OpenDateNotification.equals($value_opendate_notification_low)) selected="selected" #end>$tlang.getString('send.notification.opendate.email.low')</option>
<option value="$value_opendate_notification_high" #if($value_OpenDateNotification.equals($value_opendate_notification_high)) selected="selected" #end>$tlang.getString('send.notification.opendate.email.high')</option>
</select>
</p>
</div>
#end
<p class="checkbox indnt2">
#if (!$!value_CheckAddHonorPledge.equals("1"))
Expand Down

0 comments on commit c102ae7

Please sign in to comment.