Skip to content
Snippets Groups Projects
Commit e5cdc010 authored by srosse's avatar srosse
Browse files

Merge OpenOLAT 10.4 to OpenOLAT default branch with 00004ac58f437341a592c1c5771b9e6b335fc38c

parents 575546d0 a245d0f8
No related branches found
No related tags found
No related merge requests found
Showing
with 91 additions and 11 deletions
...@@ -65,6 +65,9 @@ public class WebDAVModule extends AbstractSpringModule implements ConfigOnOff { ...@@ -65,6 +65,9 @@ public class WebDAVModule extends AbstractSpringModule implements ConfigOnOff {
@Value("${webdav.learners.bookmarks.enabled:true}") @Value("${webdav.learners.bookmarks.enabled:true}")
private boolean enableLearnersBookmarksCourse; private boolean enableLearnersBookmarksCourse;
/**
* Enable courses in WebDAV for participants and coaches
*/
@Value("${webdav.learners.participatingCourses.enabled:true}") @Value("${webdav.learners.participatingCourses.enabled:true}")
private boolean enableLearnersParticipatingCourses; private boolean enableLearnersParticipatingCourses;
......
...@@ -8,6 +8,6 @@ webdav.link=WebDAV Links anzeigen ...@@ -8,6 +8,6 @@ webdav.link=WebDAV Links anzeigen
webdav.module=WebDAV Zugang webdav.module=WebDAV Zugang
webdav.on=ein webdav.on=ein
webdav.termsfolders=Kurse nach Semesterdaten gruppieren webdav.termsfolders=Kurse nach Semesterdaten gruppieren
webdav.for.learners.participants=Zugriff für Studenten Kursen webdav.for.learners.participants=Zugriff für Studenten / Betreuer Kursen
webdav.for.learners.bookmarks=Zugriff für Studenten Favoriten webdav.for.learners.bookmarks=Zugriff für Studenten / Betreuer Favoriten
webdav.prepend.reference=Kursreferenz zu Titel voranstellen webdav.prepend.reference=Kursreferenz zu Titel voranstellen
\ No newline at end of file
...@@ -8,6 +8,6 @@ webdav.link=Show WebDAV links ...@@ -8,6 +8,6 @@ webdav.link=Show WebDAV links
webdav.module=WebDAV access webdav.module=WebDAV access
webdav.on=enabled webdav.on=enabled
webdav.termsfolders=Group courses by semester terms webdav.termsfolders=Group courses by semester terms
webdav.for.learners.participants=Enable access for courses where user is participant webdav.for.learners.participants=Enable access for courses where user is participant or coach
webdav.for.learners.bookmarks=Enable for courses that users marked as favorite webdav.for.learners.bookmarks=Enable for courses that users marked as favorite
webdav.prepend.reference=Prepend course reference to title webdav.prepend.reference=Prepend course reference to title
\ No newline at end of file
...@@ -4,8 +4,8 @@ admin.menu.title.alt=Acc\u00E8s WebDAV ...@@ -4,8 +4,8 @@ admin.menu.title.alt=Acc\u00E8s WebDAV
admin.webdav.description=Gr\u00E2ce \u00E0 WebDAV, les dossiers OpenOLAT peuvent appara\u00EEtre sur votre bureau local et \u00EAtre utilis\u00E9s. Vous devez configurer cette fonction pour la rendre disponible \u00E0 tous les utilisateurs du syst\u00E8me. S'il vous pla\u00EEt lisez l'aide contextuelle pour plus d'informations. admin.webdav.description=Gr\u00E2ce \u00E0 WebDAV, les dossiers OpenOLAT peuvent appara\u00EEtre sur votre bureau local et \u00EAtre utilis\u00E9s. Vous devez configurer cette fonction pour la rendre disponible \u00E0 tous les utilisateurs du syst\u00E8me. S'il vous pla\u00EEt lisez l'aide contextuelle pour plus d'informations.
core.webdav=WebDAV core.webdav=WebDAV
webdav.digest=Utilise l'authentification Digest pour l'acc\u00E8s HTTP webdav.digest=Utilise l'authentification Digest pour l'acc\u00E8s HTTP
webdav.for.learners.bookmarks=Acc\u00E8s aux favoris pour les \u00E9tudiants webdav.for.learners.bookmarks=Acc\u00E8s aux favoris pour les utilisateurs
webdav.for.learners.participants=Acc\u00E8s aux cours pour les \u00E9tudiants webdav.for.learners.participants=Acc\u00E8s aux cours pour les \u00E9tudiants et coachs
webdav.link=Montre les liens WebDAV webdav.link=Montre les liens WebDAV
webdav.module=Acc\u00E8s WebDAV webdav.module=Acc\u00E8s WebDAV
webdav.on=on webdav.on=on
......
...@@ -32,6 +32,10 @@ import java.net.URLEncoder; ...@@ -32,6 +32,10 @@ import java.net.URLEncoder;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Period;
import java.time.ZoneId;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
...@@ -132,6 +136,21 @@ public class Formatter { ...@@ -132,6 +136,21 @@ public class Formatter {
} }
} }
/**
* adds the given period in day/month/years to the baseLineDate and formats it in a short format, e.g. 05.12.2015 or 12/05/2015
*
* @param baseLineDate the date
* @return a String with the formatted date
*/
public String formatDateRelative(Date baseLineDate, int days, int months, int years) {
if (baseLineDate == null) return null;
LocalDate date = LocalDateTime.ofInstant(baseLineDate.toInstant(),ZoneId.systemDefault()).toLocalDate();
Period period = Period.of(years, months, days);
LocalDate relativeDate = date.plus(period);
Date result = Date.from(relativeDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
return formatDate(result);
}
/** /**
* Formats the given date in a medium sized format, e.g. 12. Dezember 2015 or December 12, 2015 * Formats the given date in a medium sized format, e.g. 12. Dezember 2015 or December 12, 2015
* *
......
...@@ -78,10 +78,10 @@ class CoursefolderWebDAVMergeSource extends WebDAVMergeSource { ...@@ -78,10 +78,10 @@ class CoursefolderWebDAVMergeSource extends WebDAVMergeSource {
List<RepositoryEntry> editorEntries = repositoryManager.queryByOwner(getIdentity(), "CourseModule"); List<RepositoryEntry> editorEntries = repositoryManager.queryByOwner(getIdentity(), "CourseModule");
appendCourses(editorEntries, true, containers, useTerms, terms, noTermContainer, prependReference, duplicates); appendCourses(editorEntries, true, containers, useTerms, terms, noTermContainer, prependReference, duplicates);
//add courses as participant //add courses as participant and coaches
if(webDAVModule.isEnableLearnersParticipatingCourses()) { if(webDAVModule.isEnableLearnersParticipatingCourses()) {
List<RepositoryEntry> participantEntries = repositoryManager.getLearningResourcesAsStudent(getIdentity(), "CourseModule", 0, -1); List<RepositoryEntry> entries = repositoryManager.getLearningResourcesAsParticipantAndCoach(getIdentity(), "CourseModule");
appendCourses(participantEntries, false, containers, useTerms, terms, noTermContainer, prependReference, duplicates); appendCourses(entries, false, containers, useTerms, terms, noTermContainer, prependReference, duplicates);
} }
//add bookmarked courses //add bookmarked courses
......
...@@ -210,6 +210,7 @@ public class CertificatePhantomWorker { ...@@ -210,6 +210,7 @@ public class CertificatePhantomWorker {
private void fillCertificationInfos(VelocityContext context) { private void fillCertificationInfos(VelocityContext context) {
Formatter format = Formatter.getInstance(locale); Formatter format = Formatter.getInstance(locale);
context.put("dateFormatter", format);
if(dateCertification == null) { if(dateCertification == null) {
context.put("dateCertification", ""); context.put("dateCertification", "");
...@@ -218,6 +219,7 @@ public class CertificatePhantomWorker { ...@@ -218,6 +219,7 @@ public class CertificatePhantomWorker {
context.put("dateCertification", formattedDateCertification); context.put("dateCertification", formattedDateCertification);
String formattedDateCertificationLong= format.formatDateLong(dateCertification); String formattedDateCertificationLong= format.formatDateLong(dateCertification);
context.put("dateCertificationLong", formattedDateCertificationLong); context.put("dateCertificationLong", formattedDateCertificationLong);
context.put("dateCertificationRaw", dateCertification);
} }
if(dateFirstCertification == null) { if(dateFirstCertification == null) {
...@@ -227,6 +229,7 @@ public class CertificatePhantomWorker { ...@@ -227,6 +229,7 @@ public class CertificatePhantomWorker {
context.put("dateFirstCertification", formattedDateFirstCertification); context.put("dateFirstCertification", formattedDateFirstCertification);
String formattedDateFirstCertificationLong = format.formatDate(dateFirstCertification); String formattedDateFirstCertificationLong = format.formatDate(dateFirstCertification);
context.put("dateFirstCertificationLong", formattedDateFirstCertificationLong); context.put("dateFirstCertificationLong", formattedDateFirstCertificationLong);
context.put("dateFirstCertificationRaw", dateFirstCertification);
} }
} }
......
...@@ -200,7 +200,7 @@ public class BCCourseNodeEditForm extends FormBasicController implements Control ...@@ -200,7 +200,7 @@ public class BCCourseNodeEditForm extends FormBasicController implements Control
VFSContainer selectedContainer = (VFSContainer) course.getCourseFolderContainer().resolve(subpath); VFSContainer selectedContainer = (VFSContainer) course.getCourseFolderContainer().resolve(subpath);
updatePublisher(selectedContainer); updatePublisher(selectedContainer);
node.getModuleConfiguration().setStringValue(BCCourseNodeEditController.CONFIG_SUBPATH, subpath); node.getModuleConfiguration().setStringValue(BCCourseNodeEditController.CONFIG_SUBPATH, subpath);
subPath.setValue(event.getCommand()); subPath.setValue(subpath);
fireEvent(ureq, NodeEditController.NODECONFIG_CHANGED_EVENT); fireEvent(ureq, NodeEditController.NODECONFIG_CHANGED_EVENT);
} }
......
...@@ -22,7 +22,7 @@ package org.olat.course.nodes.bc; ...@@ -22,7 +22,7 @@ package org.olat.course.nodes.bc;
import org.olat.core.gui.control.Event; import org.olat.core.gui.control.Event;
/** /**
* *
* Initial date: 26.01.2016<br> * Initial date: 26.01.2016<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
* *
...@@ -31,7 +31,7 @@ public class SelectFolderEvent extends Event { ...@@ -31,7 +31,7 @@ public class SelectFolderEvent extends Event {
private static final long serialVersionUID = -181496177465081875L; private static final long serialVersionUID = -181496177465081875L;
private String subpath; private String subpath;
public SelectFolderEvent(String subpath) { public SelectFolderEvent(String subpath) {
super("select-folder"); super("select-folder");
this.subpath = subpath; this.subpath = subpath;
......
...@@ -326,6 +326,7 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im ...@@ -326,6 +326,7 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im
if(run != null) { if(run != null) {
addCustomCSS(ureq); addCustomCSS(ureq);
run.toolCtrDone(ureq); run.toolCtrDone(ureq);
currentToolCtr = null;
} }
} }
......
...@@ -1886,6 +1886,36 @@ public class RepositoryManager extends BasicManager { ...@@ -1886,6 +1886,36 @@ public class RepositoryManager extends BasicManager {
return repoEntries; return repoEntries;
} }
/**
* Gets all learning resources where the user is in a learning group as participant.
* @param identity
* @return list of RepositoryEntries
*/
public List<RepositoryEntry> getLearningResourcesAsParticipantAndCoach(Identity identity, String type) {
StringBuilder sb = new StringBuilder(1200);
sb.append("select v from ").append(RepositoryEntry.class.getName()).append(" as v ")
.append(" inner join fetch v.olatResource as res ")
.append(" inner join fetch v.statistics as statistics")
.append(" left join fetch v.lifecycle as lifecycle")
.append(" inner join v.groups as relGroup")
.append(" inner join relGroup.group as baseGroup")
.append(" inner join baseGroup.members as membership")
.append(" where (v.access>=3 or (v.access=").append(RepositoryEntry.ACC_OWNERS).append(" and v.membersOnly=true))")
.append(" and membership.identity.key=:identityKey and membership.role in('").append(GroupRoles.participant.name()).append("','").append(GroupRoles.coach.name()).append("')");
if(StringHelper.containsNonWhitespace(type)) {
sb.append(" and res.resName=:resourceType");
}
TypedQuery<RepositoryEntry> query = dbInstance.getCurrentEntityManager()
.createQuery(sb.toString(), RepositoryEntry.class)
.setParameter("identityKey", identity.getKey());
if(StringHelper.containsNonWhitespace(type)) {
query.setParameter("resourceType", type);
}
return query.getResultList();
}
public List<RepositoryEntry> getLearningResourcesAsBookmark(Identity identity, Roles roles, String type, int firstResult, int maxResults, RepositoryEntryOrder... orderby) { public List<RepositoryEntry> getLearningResourcesAsBookmark(Identity identity, Roles roles, String type, int firstResult, int maxResults, RepositoryEntryOrder... orderby) {
if(roles.isGuestOnly()) { if(roles.isGuestOnly()) {
return Collections.emptyList(); return Collections.emptyList();
......
...@@ -19,6 +19,9 @@ ...@@ -19,6 +19,9 @@
*/ */
package org.olat.core.util; package org.olat.core.util;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringEscapeUtils;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
...@@ -56,4 +59,25 @@ public class FormatterTest { ...@@ -56,4 +59,25 @@ public class FormatterTest {
String ugly = "guido/\\:? .|*\"\"<><guidoöäü"; String ugly = "guido/\\:? .|*\"\"<><guidoöäü";
Assert.assertEquals("guido%2F%5C%3A%3F+.%7C*%22%22%3C%3E%3Cguido%C3%B6%C3%A4%C3%BC", Formatter.makeStringFilesystemSave(ugly)); Assert.assertEquals("guido%2F%5C%3A%3F+.%7C*%22%22%3C%3E%3Cguido%C3%B6%C3%A4%C3%BC", Formatter.makeStringFilesystemSave(ugly));
} }
@Test
public void testDateRelative() {
//zero to add
Formatter formatter = Formatter.getInstance(Locale.GERMAN);
Date base = new GregorianCalendar(1935, 2, 29).getTime();
Assert.assertEquals(formatter.formatDate(base), formatter.formatDateRelative(base, 0,0,0));
//add 3 years in the past
Date basePlusThreeY = new GregorianCalendar(1938, 2, 29).getTime();
Assert.assertEquals(formatter.formatDate(basePlusThreeY), formatter.formatDateRelative(base, 0,0,3));
//add 5 days at 29 feb (leap year)
base = new GregorianCalendar(2016, 1, 29).getTime();
Date basePlusFiveD = new GregorianCalendar(2016, 2, 5).getTime();
Assert.assertEquals(formatter.formatDate(basePlusFiveD), formatter.formatDateRelative(base, 5,0,0));
//add three moth
base = new GregorianCalendar(2016, 4, 15).getTime();
Date baseThreeM = new GregorianCalendar(2016, 7, 15).getTime();
Assert.assertEquals(formatter.formatDate(baseThreeM), formatter.formatDateRelative(base, 0,3,0));
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment