Skip to content
Snippets Groups Projects
Commit ac464be7 authored by strentini's avatar strentini
Browse files

OLAT-6391 : fixed: Peekview of structure coursenode with custom HTML-page...

OLAT-6391 : fixed: Peekview of structure coursenode with custom HTML-page results in RS as long as no HMTL-page is defined

(applied patch FXOLAT-145)

--HG--
branch : uzhFixes711
parent 67df6336
No related branches found
No related tags found
No related merge requests found
......@@ -56,6 +56,7 @@ import org.olat.course.editor.NodeEditController;
import org.olat.course.editor.StatusDescription;
import org.olat.course.groupsandrights.CourseGroupManager;
import org.olat.course.groupsandrights.CourseRights;
import org.olat.course.nodes.sp.SPEditController;
import org.olat.course.nodes.sp.SPPeekviewController;
import org.olat.course.nodes.st.STCourseNodeEditController;
import org.olat.course.nodes.st.STCourseNodeRunController;
......@@ -263,7 +264,22 @@ public class STCourseNode extends AbstractAccessableCourseNode implements Assess
*/
if (oneClickStatusCache != null) { return oneClickStatusCache[0]; }
return StatusDescription.NOERROR;
ModuleConfiguration config = getModuleConfiguration();
StatusDescription sd = StatusDescription.NOERROR;
if (STCourseNodeEditController.CONFIG_VALUE_DISPLAY_FILE.equals(config.getStringValue(STCourseNodeEditController.CONFIG_KEY_DISPLAY_TYPE))){
String fileName = (String) config.get(STCourseNodeEditController.CONFIG_KEY_FILE);
if (fileName == null || !StringHelper.containsNonWhitespace(fileName)){
String shortKey = "error.missingfile.short";
String longKey = "error.missingfile.long";
String[] params = new String[] { this.getShortTitle() };
String translPackage = Util.getPackageName(SPEditController.class);
sd = new StatusDescription(StatusDescription.ERROR, shortKey, longKey, params, translPackage);
sd.setDescriptionForUnit(getIdent());
// set which pane is affected by error
sd.setActivateableViewIdentifier(STCourseNodeEditController.PANE_TAB_ST_CONFIG);
}
}
return sd;
}
/**
......
......@@ -61,31 +61,32 @@ public class SPPeekviewController extends BasicController {
super(ureq, wControl);
// just display the page
String file = config.getStringValue(SPEditController.CONFIG_KEY_FILE);
String fileLC = file.toLowerCase();
if (fileLC.endsWith(".html") || fileLC.endsWith(".htm") || fileLC.endsWith(".xhtml")) {
// Render normal view but scaled down to 75%
SinglePageController spController = new SinglePageController(ureq, wControl,
userCourseEnv.getCourseEnvironment().getCourseFolderContainer(),
file, null,
config.getBooleanEntry(SPEditController.CONFIG_KEY_ALLOW_RELATIVE_LINKS), ores);
// but add scaling to fit preview into minimized space
spController.setScaleFactorAndHeight(0.75f, 400, true);
listenTo(spController);
putInitialPanel(spController.getInitialComponent());
} else {
// Render a download link for file
VFSContainer courseFolder = userCourseEnv.getCourseEnvironment().getCourseFolderContainer();
VFSItem downloadItem = courseFolder.resolve(file);
if (file != null && downloadItem instanceof VFSLeaf) {
DownloadComponent downloadComp = new DownloadComponent("downloadComp", (VFSLeaf) downloadItem);
VelocityContainer peekviewVC = createVelocityContainer("peekview");
peekviewVC.put("downloadComp", downloadComp);
putInitialPanel(peekviewVC);
Component resPanel = new Panel("empty"); // empty panel to use if no file could be found
if (file != null) {
String fileLC = file.toLowerCase();
if (fileLC.endsWith(".html") || fileLC.endsWith(".htm") || fileLC.endsWith(".xhtml")) {
// Render normal view but scaled down to 75%
SinglePageController spController = new SinglePageController(ureq, wControl,
userCourseEnv.getCourseEnvironment().getCourseFolderContainer(),
file, null,
config.getBooleanEntry(SPEditController.CONFIG_KEY_ALLOW_RELATIVE_LINKS), ores);
// but add scaling to fit preview into minimized space
spController.setScaleFactorAndHeight(0.75f, 400, true);
listenTo(spController);
resPanel = spController.getInitialComponent();
} else {
// boy, can't find file, use an empty panel
putInitialPanel(new Panel("empty"));
// Render a download link for file
VFSContainer courseFolder = userCourseEnv.getCourseEnvironment().getCourseFolderContainer();
VFSItem downloadItem = courseFolder.resolve(file);
if (file != null && downloadItem instanceof VFSLeaf) {
DownloadComponent downloadComp = new DownloadComponent("downloadComp", (VFSLeaf) downloadItem);
VelocityContainer peekviewVC = createVelocityContainer("peekview");
peekviewVC.put("downloadComp", downloadComp);
resPanel = peekviewVC;
}
}
}
putInitialPanel(resPanel);
}
/**
......
......@@ -64,7 +64,7 @@ import org.olat.modules.ModuleConfiguration;
public class STCourseNodeEditController extends ActivateableTabbableDefaultController implements ControllerEventListener {
private static final String PANE_TAB_ST_SCORECALCULATION = "pane.tab.st_scorecalculation";
private static final String PANE_TAB_ST_CONFIG = "pane.tab.st_config";
public static final String PANE_TAB_ST_CONFIG = "pane.tab.st_config";
private static final String PANE_TAB_ACCESSIBILITY = "pane.tab.accessibility";
/** configuration key for the filename */
......@@ -294,6 +294,7 @@ public class STCourseNodeEditController extends ActivateableTabbableDefaultContr
// Let other config values from old config setup remain in config,
// maybe used when user switches back to other config (OLAT-5610)
}
fireEvent(ureq, NodeEditController.NODECONFIG_CHANGED_EVENT);
}
} else if (source == scoreEasyForm) {
......
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