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

Merge remote-tracking branch 'origin/OpenOLAT_12.5'

parents 8d94b1b4 0ce086eb
No related branches found
No related tags found
No related merge requests found
Showing
with 97 additions and 11 deletions
...@@ -48,6 +48,7 @@ import org.olat.core.gui.translator.Translator; ...@@ -48,6 +48,7 @@ import org.olat.core.gui.translator.Translator;
import org.olat.core.id.Identity; import org.olat.core.id.Identity;
import org.olat.core.id.Roles; import org.olat.core.id.Roles;
import org.olat.core.logging.AssertException; import org.olat.core.logging.AssertException;
import org.olat.core.util.StringHelper;
import org.olat.core.util.ZipUtil; import org.olat.core.util.ZipUtil;
import org.olat.core.util.vfs.Quota; import org.olat.core.util.vfs.Quota;
import org.olat.core.util.vfs.VFSConstants; import org.olat.core.util.vfs.VFSConstants;
...@@ -68,11 +69,12 @@ public class CmdUnzip extends BasicController implements FolderCommand { ...@@ -68,11 +69,12 @@ public class CmdUnzip extends BasicController implements FolderCommand {
super(ureq, wControl); super(ureq, wControl);
} }
@Override
public Controller execute(FolderComponent folderComponent, UserRequest ureq, WindowControl wContr, Translator trans) { public Controller execute(FolderComponent folderComponent, UserRequest ureq, WindowControl wContr, Translator trans) {
this.translator = trans; this.translator = trans;
FileSelection selection = new FileSelection(ureq, folderComponent.getCurrentContainerPath()); FileSelection selection = new FileSelection(ureq, folderComponent.getCurrentContainerPath());
VFSContainer currentContainer = folderComponent.getCurrentContainer(); VFSContainer currentContainer = folderComponent.getCurrentContainer();
if (!(currentContainer.canWrite() == VFSConstants.YES)) if (currentContainer.canWrite() != VFSConstants.YES)
throw new AssertException("Cannot unzip to folder. Writing denied."); throw new AssertException("Cannot unzip to folder. Writing denied.");
//check if command is executed on a file containing invalid filenames or paths - checks if the resulting folder has a valid name //check if command is executed on a file containing invalid filenames or paths - checks if the resulting folder has a valid name
...@@ -81,7 +83,7 @@ public class CmdUnzip extends BasicController implements FolderCommand { ...@@ -81,7 +83,7 @@ public class CmdUnzip extends BasicController implements FolderCommand {
return null; return null;
} }
List<String> lockedFiles = new ArrayList<String>(); List<String> lockedFiles = new ArrayList<>();
for (String sItem:selection.getFiles()) { for (String sItem:selection.getFiles()) {
VFSItem vfsItem = currentContainer.resolve(sItem); VFSItem vfsItem = currentContainer.resolve(sItem);
if (vfsItem instanceof VFSLeaf) { if (vfsItem instanceof VFSLeaf) {
...@@ -181,7 +183,19 @@ public class CmdUnzip extends BasicController implements FolderCommand { ...@@ -181,7 +183,19 @@ public class CmdUnzip extends BasicController implements FolderCommand {
VFSContainer zipContainer = currentContainer.createChildContainer(sZipContainer); VFSContainer zipContainer = currentContainer.createChildContainer(sZipContainer);
if (zipContainer == null) { if (zipContainer == null) {
if(versioning) { if(versioning) {
zipContainer =(VFSContainer)currentContainer.resolve(sZipContainer); VFSItem resolvedItem = currentContainer.resolve(sZipContainer);
if(resolvedItem instanceof VFSContainer) {
zipContainer = (VFSContainer)resolvedItem;
} else {
String numberedFilename = findContainerName(currentContainer, sZipContainer);
if(StringHelper.containsNonWhitespace(numberedFilename)) {
zipContainer = currentContainer.createChildContainer(numberedFilename);
}
if(zipContainer == null) {// we try our best
wControl.setError(translator.translate("unzip.alreadyexists", new String[] {sZipContainer}));
return false;
}
}
} else { } else {
// folder already exists... issue warning // folder already exists... issue warning
wControl.setError(translator.translate("unzip.alreadyexists", new String[] {sZipContainer})); wControl.setError(translator.translate("unzip.alreadyexists", new String[] {sZipContainer}));
...@@ -212,6 +226,19 @@ public class CmdUnzip extends BasicController implements FolderCommand { ...@@ -212,6 +226,19 @@ public class CmdUnzip extends BasicController implements FolderCommand {
} }
return true; return true;
} }
private String findContainerName(VFSContainer container, String filename) {
String newName = filename;
VFSItem newFile = container.resolve(newName);
for(int count=1; newFile != null && count < 999 ; count++) {
newName = filename + "_" + count;
newFile = container.resolve(newName);
}
if(newFile == null) {
return newName;
}
return null;
}
@Override @Override
public int getStatus() { public int getStatus() {
......
...@@ -73,5 +73,12 @@ public interface DateChooser extends TextElement { ...@@ -73,5 +73,12 @@ public interface DateChooser extends TextElement {
* @param dateChooser A date chooser * @param dateChooser A date chooser
*/ */
public void setDefaultValue(DateChooser dateChooser); public void setDefaultValue(DateChooser dateChooser);
/**
* This will set the default time to 23:59 instead of 00:00
*
* @param endOfDay
*/
public void setDefaultTimeAtEndOfDay(boolean endOfDay);
} }
\ No newline at end of file
...@@ -61,6 +61,7 @@ public class JSDateChooser extends TextElementImpl implements DateChooser { ...@@ -61,6 +61,7 @@ public class JSDateChooser extends TextElementImpl implements DateChooser {
private Locale locale; private Locale locale;
private boolean dateChooserTimeEnabled; private boolean dateChooserTimeEnabled;
private boolean defaultTimeAtEndOfDay;
private String forValidDateErrorKey; private String forValidDateErrorKey;
private boolean checkForValidDate; private boolean checkForValidDate;
private int minute; private int minute;
...@@ -238,6 +239,15 @@ public class JSDateChooser extends TextElementImpl implements DateChooser { ...@@ -238,6 +239,15 @@ public class JSDateChooser extends TextElementImpl implements DateChooser {
this.dateChooserTimeEnabled = dateChooserTimeEnabled; this.dateChooserTimeEnabled = dateChooserTimeEnabled;
} }
public boolean isDefaultTimeAtEndOfDay() {
return defaultTimeAtEndOfDay;
}
@Override
public void setDefaultTimeAtEndOfDay(boolean defaultTimeAtEndOfDay) {
this.defaultTimeAtEndOfDay = defaultTimeAtEndOfDay;
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.olat.core.gui.components.form.flexible.impl.elements.DateChooser#getDateChooserDateFormat() * @see org.olat.core.gui.components.form.flexible.impl.elements.DateChooser#getDateChooserDateFormat()
*/ */
......
...@@ -93,6 +93,10 @@ class JSDateChooserComponent extends FormBaseComponentImpl { ...@@ -93,6 +93,10 @@ class JSDateChooserComponent extends FormBaseComponentImpl {
public boolean isDateChooserTimeEnabled() { public boolean isDateChooserTimeEnabled() {
return element.isDateChooserTimeEnabled(); return element.isDateChooserTimeEnabled();
} }
public boolean isDefaultTimeAtEndOfDay() {
return element.isDefaultTimeAtEndOfDay();
}
public Translator getElementTranslator() { public Translator getElementTranslator() {
return element.getTranslator(); return element.getTranslator();
......
...@@ -132,7 +132,12 @@ class JSDateChooserRenderer extends DefaultComponentRenderer { ...@@ -132,7 +132,12 @@ class JSDateChooserRenderer extends DefaultComponentRenderer {
int hour, minute; int hour, minute;
Date currentDate = jsdcc.getDate(); Date currentDate = jsdcc.getDate();
if(currentDate == null) { if(currentDate == null) {
hour = minute = 0; if(jsdcc.isDefaultTimeAtEndOfDay()) {
hour = 23;
minute = 59;
} else {
hour = minute = 0;
}
} else { } else {
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
cal.setTime(currentDate); cal.setTime(currentDate);
......
...@@ -247,6 +247,7 @@ public class ConditionConfigEasyController extends FormBasicController implement ...@@ -247,6 +247,7 @@ public class ConditionConfigEasyController extends FormBasicController implement
toDate.setExampleKey("form.easy.example.edate", null); toDate.setExampleKey("form.easy.example.edate", null);
toDate.setDateChooserTimeEnabled(true); toDate.setDateChooserTimeEnabled(true);
toDate.setDisplaySize(toDate.getExampleDateString().length()); toDate.setDisplaySize(toDate.getExampleDateString().length());
toDate.setDefaultTimeAtEndOfDay(true);
dateSubContainer.add(toDate); dateSubContainer.add(toDate);
dateSwitch = uifactory.addCheckboxesHorizontal("dateSwitch", null, formLayout, new String[] { "ison" }, new String[] { translate("form.easy.dateSwitch") }); dateSwitch = uifactory.addCheckboxesHorizontal("dateSwitch", null, formLayout, new String[] { "ison" }, new String[] { translate("form.easy.dateSwitch") });
......
...@@ -46,7 +46,8 @@ ...@@ -46,7 +46,8 @@
formDispatchFieldId: '$r.formDispatchFieldId', formDispatchFieldId: '$r.formDispatchFieldId',
maxAssociations: $interaction.maxAssociations, maxAssociations: $interaction.maxAssociations,
leftData: {#foreach($choice1 in $orderedSet1) #if($foreach.count > 1),#end $choice1.identifier:$choice1.matchMax #end}, leftData: {#foreach($choice1 in $orderedSet1) #if($foreach.count > 1),#end $choice1.identifier:$choice1.matchMax #end},
rightData: {#foreach($choice2 in $orderedSet2) #if($foreach.count > 1),#end $choice2.identifier:$choice2.matchMax #end} rightData: {#foreach($choice2 in $orderedSet2) #if($foreach.count > 1),#end $choice2.identifier:$choice2.matchMax #end},
unansweredColumn: 'o_match_true_false_unanswered'
}); });
}); });
</script> </script>
......
(function ($) { (function ($) {
$.fn.matchInteraction = function(options) { $.fn.matchInteraction = function(options) {
"use strict";
var settings = $.extend({ var settings = $.extend({
responseIdentifier: null, responseIdentifier: null,
formDispatchFieldId: null, formDispatchFieldId: null,
maxAssociations: 1, maxAssociations: 1,
unansweredColumn: null,
leftData: {}, leftData: {},
rightData: {}, rightData: {},
leftMap: {}, leftMap: {},
...@@ -38,11 +40,11 @@ ...@@ -38,11 +40,11 @@
}); });
recalculate(settings); recalculate(settings);
updateDisabledStates(settings); updateDisabledStates(settings);
}; }
function queryInputElements(responseIdentifier) { function queryInputElements(responseIdentifier) {
return jQuery('input[name=qtiworks_response_' + responseIdentifier + ']'); return jQuery('input[name=qtiworks_response_' + responseIdentifier + ']');
}; }
function withCheckbox(settings, inputElement, callback) { function withCheckbox(settings, inputElement, callback) {
var directedPair = inputElement.value; var directedPair = inputElement.value;
...@@ -50,7 +52,7 @@ ...@@ -50,7 +52,7 @@
var left = settings.leftMap[splitPair[0]]; var left = settings.leftMap[splitPair[0]];
var right = settings.rightMap[splitPair[1]]; var right = settings.rightMap[splitPair[1]];
callback(inputElement, directedPair, left, right); callback(inputElement, directedPair, left, right);
}; }
/** /**
* Left -> source (set 0) * Left -> source (set 0)
...@@ -76,7 +78,7 @@ ...@@ -76,7 +78,7 @@
} }
}); });
}); });
}; }
/** /**
* Left -> source (set 0) * Left -> source (set 0)
...@@ -102,7 +104,7 @@ ...@@ -102,7 +104,7 @@
} }
}); });
}); });
}; }
function checkMatch(settings, inputElement) { function checkMatch(settings, inputElement) {
withCheckbox(settings, inputElement, function(inputElement, directedPair, left, right) { withCheckbox(settings, inputElement, function(inputElement, directedPair, left, right) {
...@@ -153,6 +155,35 @@ ...@@ -153,6 +155,35 @@
right.matchCount--; right.matchCount--;
} }
updateDisabledStates(settings); updateDisabledStates(settings);
if(!inputElement.checked && settings.unansweredColumn != null) {
checkUnanswered(settings, inputElement);
}
}); });
} }
function checkUnanswered(settings, inputElement) {
var jInputElement = jQuery(inputElement);
var inputRightId = jInputElement.attr('value').split(" ")[0];
var numOfSelectedBox = 0;
var unansweredCheckbox = null;
queryInputElements(settings.responseIdentifier).each(function() {
withCheckbox(settings, this, function(element, directedPair, left, right) {
var jElement = jQuery(element);
var elementRightId = jElement.attr('value').split(" ")[0];
if(inputRightId === elementRightId) {
if(element.checked) {
numOfSelectedBox++;
} else if(jElement.closest("." + settings.unansweredColumn).length == 1) {
unansweredCheckbox = element;
}
}
});
});
if(numOfSelectedBox == 0 && unansweredCheckbox != null) {
unansweredCheckbox.checked = true;
}
}
}( jQuery )); }( jQuery ));
\ No newline at end of file
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