Skip to content

Commit

Permalink
SAK-20612 applied patch from DAvid R-M
Browse files Browse the repository at this point in the history
git-svn-id: https://source.sakaiproject.org/svn/sections/trunk@93246 66ffb92e-73f9-0310-93c1-f5514f145a0a
  • Loading branch information
axxter99 committed May 25, 2011
1 parent 827bcbe commit ac87a03
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 6 deletions.
11 changes: 10 additions & 1 deletion sections/sections-app-util/src/bundle/sections.properties
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,13 @@ add_section_successful={0} {1} been successfully created\! You may now assign T
edit_student_sections_instructions=To assign this student to a section, click Assign. \
You may only assign a student to one section within each category. \
If the student is already a member of a section in a category, they wil be removed \
from that section if you assign them to a new section.
from that section if you assign them to a new section.
#
# Control closed sections
#
section_close_title=Section Tool Closed
section_close_desc=This tool is closed. You will be able to access the sections tool at the date and time your faculty specified.
section_close_opendate=Open Date:
section_open_info=Close sections tool for students until Open Date:
section_refresh_info=Refresh the page to see the groups after the due date.
error_date_format=Error with the Date/Time format
11 changes: 10 additions & 1 deletion sections/sections-app-util/src/bundle/sections_ca.properties
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,13 @@ section_start_time=Hora d'inici
student_view_instructions_switch=Per canviar de secci\u00F3, a l'enlla\u00E7 "canvia", feu clic a sobre de la secci\u00F3 a la qual us vulgueu despla\u00E7ar. Sortireu autom\u00E0ticament de la secci\u00F3 actual d'aquest tipus de secci\u00F3.
student_view_header_time=Temps/Dies
add_section_successful={0} {1} s'han creat satisfact\u00F2riament\! Ara podeu assignar AP i alumnes a la {2} escollint els enlla\u00E7os de la secci\u00F3.
edit_student_sections_instructions=Per assignar aquest alumne a la secci\u00F3, feu clic a Assigna. Nom\u00E9s podeu assignar un alumne a una secci\u00F3 dins de cada categoria. Si l'alumne ja \u00E9s membre d'una secci\u00F3 en una categoria, ser\u00E0 suprimit d'aquella secci\u00F3 si l'assigna a una nova secci\u00F3.
edit_student_sections_instructions=Per assignar aquest alumne a la secci\u00F3, feu clic a Assigna. Nom\u00E9s podeu assignar un alumne a una secci\u00F3 dins de cada categoria. Si l'alumne ja \u00E9s membre d'una secci\u00F3 en una categoria, ser\u00E0 suprimit d'aquella secci\u00F3 si l'assigna a una nova secci\u00F3.
#
# Control closed sections
#
section_close_title=Aplicaci\u00F3 Grups tancada
section_close_desc=Aquesta aplicaci\u00F3 troba tancada temporalment. Podr\u00E0 accedir a les opcions d'informaci\u00F3gesti\u00F3 dels seus grups a l'hora i data indicada pel seu professor.
section_close_opendate=Data d'obertura:
section_open_info=Tancar ferramenta grups per als alumnes fins la data d'obertura:
section_refresh_info=Quan arribe la data d'obertura, refresque la p\u00E0gina per vore els grups.
error_date_format=Errada en el format de la Data/Hora
11 changes: 10 additions & 1 deletion sections/sections-app-util/src/bundle/sections_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,13 @@ edit_student_over_max_warning_try=Ha intentado incluir {0} estudiantes en el gru
roster_page_header=Pertenencia de estudiantes
student_view_join_sc=(Uni\u00f3n {0})
student_view_switch_sc=(Cambio a {0})
edit_student_sections_instructions=Para asignar este estudiante a un grupo, pulse en Asignar. Puede asisgnar solamente un estudiante a un grupo de cada categor\u00EDa. Si el estudiante ya es miembro de un grupo en una categor\u00EDa, ser\u00E1 eliminado de dicho grupo si lo asigna a un grupo nuevo.
edit_student_sections_instructions=Para asignar este estudiante a un grupo, pulse en Asignar. Puede asisgnar solamente un estudiante a un grupo de cada categor\u00EDa. Si el estudiante ya es miembro de un grupo en una categor\u00EDa, ser\u00E1 eliminado de dicho grupo si lo asigna a un grupo nuevo.
#
# Control closed sections
#
section_close_title=Aplicaci\u00F3n Grupos Cerrada
section_close_desc=Esta aplicaci\u00F3n encuentra cerrada temporalmente. Podr\u00E1 acceder a las opciones de informaci\u00F3n y gesti\u00F3n de sus grupos a la fecha y hora indicada por su profesor.
section_close_opendate=Fecha de Apertura:
section_open_info=Cerrar herramienta grupos para alumnos hasta la Fecha de Apertura..:
section_refresh_info=Llegada la hora de apertura, refresque la p\u00E1gina para ver los grupos.
error_date_format=Error en el formato de la Fecha/Hora
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.sakaiproject.tool.section;

import java.io.IOException;
import java.util.Calendar;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
Expand All @@ -12,6 +13,9 @@
import org.sakaiproject.section.api.facade.manager.Authn;
import org.sakaiproject.section.api.facade.manager.Authz;
import org.sakaiproject.section.api.facade.manager.Context;
import org.sakaiproject.section.api.SectionManager;
import org.sakaiproject.component.section.sakai.SectionManagerImpl;
import org.sakaiproject.tool.section.jsf.backingbean.StudentViewBean;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.WebApplicationContext;

Expand Down Expand Up @@ -44,7 +48,16 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) {
path.append("/overview.jsf");
} else if (viewOwnSections) {
if(log.isDebugEnabled()) log.debug("Sending user to the student view page");
path.append("/studentView.jsf");
//Control if the access to the groups is closed
SectionManager sm = (SectionManager)ac.getBean("org.sakaiproject.section.api.SectionManager");
Calendar open = sm.getOpenDate(siteContext);
Calendar now = Calendar.getInstance();
if (now.before(open)) {
System.out.println("SECTIONS: Grupos Cerrados...");
path.append("/closed.jsf");
}else {
path.append("/studentView.jsf");
};
} else {
// The role filter has not been invoked yet, so this could happen here
path.append("/noRole.jsp");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ public void doFilter(ServletRequest servletRequest, ServletResponse response, Fi
} else if (authz.isViewOwnSectionsAllowed(userUid, siteContext)
&& authzFilterConfigBean.getViewOwnSections().contains(pageName)) {
isAuthorized = true;
} else if (pageName.contains("closed")) {
isAuthorized = true;
}

// SAK-13408 - This fix addresses the problem of the filter receiving a blank field on WebSphere.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
import org.sakaiproject.section.api.SectionManager;
import org.sakaiproject.section.api.SectionManager.ExternalIntegrationConfig;
import org.sakaiproject.tool.section.jsf.JsfUtil;

import java.util.Calendar;
import java.util.Date;
import java.text.SimpleDateFormat;
/**
* Controls the options page.
*
Expand All @@ -47,7 +49,10 @@ public class OptionsBean extends CourseDependentBean implements Serializable {
private String management;
private boolean confirmMode;
private boolean managementToggleEnabled;

private boolean openSwitch;
private Calendar openDate;
private boolean errorflag;

public void init() {
// We don't need to initialize the bean when we're in confirm mode
if(confirmMode) {
Expand All @@ -71,6 +76,12 @@ public void init() {
} else {
management = INTERNAL;
}
this.openDate = sm.getOpenDate(getCourse().getSiteContext());
if (this.openDate!=null){
openSwitch=true;
} else {
openSwitch=false;
}
}

public String confirmExternallyManaged() {
Expand All @@ -82,6 +93,9 @@ public String update() {
}

public String update(boolean checkForConfirmation) {
if (errorflag) {
return "options";
}
if(!isSectionOptionsManagementEnabled()) {
// This should never happen
log.warn("Updating section options not permitted for user " + getUserUid());
Expand All @@ -106,6 +120,9 @@ public String update(boolean checkForConfirmation) {
// If we're externally managed, these will automatically be set to false
if(INTERNAL.equals(management) || management == null) {
getSectionManager().setJoinOptions(courseUuid, selfRegister, selfSwitch);
// Update the open date
if (!openSwitch) {this.openDate=null;};
getSectionManager().setOpenDate(courseUuid,openDate);
}

// TODO Customize the message depending on the action taken
Expand All @@ -129,6 +146,13 @@ public void setSelfSwitch(boolean selfSwitch) {
this.selfSwitch = selfSwitch;
}

public boolean isOpenSwitch() {
return openSwitch;
}

public void setOpenSwitch(boolean openSwitch) {
this.openSwitch = openSwitch;
}
/**
* See http://issues.apache.org/jira/browse/MYFACES-570 for the reason for this boolean/String hack
* @return
Expand Down Expand Up @@ -158,5 +182,28 @@ public void setConfirmMode(boolean confirmMode) {
public boolean isManagementToggleEnabled() {
return managementToggleEnabled;
}
public String getOpenDate() {
if (openDate == null) {
return null;
} else {
SimpleDateFormat sd = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss a");
return sd.format(openDate.getTime());
}
}

public void setOpenDate(String date){
if (date==null || date.length()==0) {
this.openDate=null;
}else{
SimpleDateFormat sd = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss a");
Calendar p = Calendar.getInstance();
try {
p.setTime(sd.parse(date));
} catch (Exception e){
JsfUtil.addErrorMessage(JsfUtil.getLocalizedMessage("error_date_format"));
errorflag=true;
};
this.openDate=p;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
<to-view-id>/overview.jsp</to-view-id>
<redirect/>
</navigation-case>
<navigation-case>
<from-outcome>closed</from-outcome>
<to-view-id>/closed.jsp</to-view-id>
<redirect/>
</navigation-case>
<navigation-case>
<from-outcome>editSection</from-outcome>
<to-view-id>/editSection.jsp</to-view-id>
Expand Down
9 changes: 9 additions & 0 deletions sections/sections-app/src/webapp/common/js/sections.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,26 @@ function updateOptionBoxes(externallyManaged) {
}
var selfJoin = document.getElementById("optionsForm:selfRegister");
var selfSwitch = document.getElementById("optionsForm:selfSwitch");
var openSwitch = document.getElementById("optionsForm:openSwitch");
var openDate = document.getElementById("optionsForm:openDate");

if(externallyManaged.value=='external') {
// Automatic section management is selected
selfJoin.checked = false;
selfJoin.disabled = true;
selfSwitch.checked = false;
selfSwitch.disabled = true;
openSwitch.checked = false;
openSwitch.disabled = true;
openDate.value = "";
openDate.disabled = true;
} else {
// Manual section management is selected
selfJoin.disabled = false;
selfSwitch.disabled = false;
openSwitch.disabled = false;
openDate.disabled = false;
calendar.disabled = false;
}
}

Expand Down
8 changes: 8 additions & 0 deletions sections/sections-app/src/webapp/common/options.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@
<h:selectBooleanCheckbox id="selfSwitch" value="#{optionsBean.selfSwitch}" disabled="#{optionsBean.confirmMode || ! optionsBean.sectionOptionsManagementEnabled}"/>
<h:outputLabel for="selfSwitch" value="#{msgs.options_self_switch_label}"/>
</t:div>
<t:div styleClass="indent">
<h:selectBooleanCheckbox id="openSwitch" value="#{optionsBean.openSwitch}" disabled="#{optionsBean.confirmMode || ! optionsBean.sectionOptionsManagementEnabled}"/>
<h:outputText value="#{msgs.section_open_info}"/>
<h:inputText id="openDate" value="#{optionsBean.openDate}" disabled="#{optionsBean.confirmMode || ! optionsBean.sectionOptionsManagementEnabled}"/>
<script src="/samigo/jsf/widget/datepicker/datepicker.js" type="text/javascript"></script>
<img id="calendar" onclick="javascript:var cal = new calendar2(document.getElementById('optionsForm:openDate'), cal_gen_date2_dm, cal_prs_date2_dm);cal.year_scroll = true;cal.time_comp = true;cal.popup('','/samigo/html/');"
width="16" height="16" style="cursor:pointer;" src="/samigo/images/calendar/cal.gif" border="0" />
</t:div>
</t:div>

<t:div styleClass="act verticalPadding">
Expand Down

0 comments on commit ac87a03

Please sign in to comment.