use of org.olat.core.gui.components.velocity.VelocityContainer in project OpenOLAT by OpenOLAT.
the class HTMLEditorController method initEditorForm.
private void initEditorForm(VFSContainer bContainer, String relFilePath, CustomLinkTreeModel linkTreeModel, String mPath, boolean editorCheck, boolean versions, boolean withButtons) {
this.baseContainer = bContainer;
this.fileRelPath = relFilePath;
this.mediaPath = mPath;
this.versionsEnabled = versions;
this.buttonsEnabled = withButtons;
this.customLinkTreeModel = linkTreeModel;
this.editorCheckEnabled = editorCheck;
// make sure the filename doesn't start with a slash
this.fileName = ((relFilePath.charAt(0) == '/') ? relFilePath.substring(1) : relFilePath);
this.fileLeaf = (VFSLeaf) bContainer.resolve(fileName);
if (fileLeaf == null)
throw new AssertException("file::" + getFileDebuggingPath(bContainer, relFilePath) + " does not exist!");
long size = fileLeaf.getSize();
if (size > FolderConfig.getMaxEditSizeLimit()) {
// limit to reasonable size, see OO-57
fileToLargeError = translate("plaintext.error.tolarge", new String[] { (size / 1000) + "", (FolderConfig.getMaxEditSizeLimit() / 1000) + "" });
this.body = "";
this.editable = false;
return;
}
// check if someone else is already editing the file
if (fileLeaf instanceof LocalFileImpl) {
// Cast to LocalFile necessary because the VFSItem is missing some
// ID mechanism that identifies an item within the system
OLATResourceable lockResourceable = createLockResourceable(fileLeaf);
// OLAT-5066: the use of "fileName" gives users the (false) impression that the file they wish to access
// is already locked by someone else. Since the lock token must be smaller than 50 characters we us an
// MD5 hash of the absolute file path which will always be 32 characters long and virtually unique.
String lockToken = createLockToken(bContainer, relFilePath);
lock = CoordinatorManager.getInstance().getCoordinator().getLocker().acquireLock(lockResourceable, getIdentity(), lockToken);
VelocityContainer vc = (VelocityContainer) flc.getComponent();
if (!lock.isSuccess()) {
vc.contextPut("locked", Boolean.TRUE);
String fullname = UserManager.getInstance().getUserDisplayName(lock.getOwner());
vc.contextPut("lockOwner", fullname);
editable = false;
return;
} else {
vc.contextPut("locked", Boolean.FALSE);
}
}
// Parse the content of the page
this.body = parsePage(fileLeaf);
}
use of org.olat.core.gui.components.velocity.VelocityContainer in project OpenOLAT by OpenOLAT.
the class MembersPrintController method initFormMemberList.
private void initFormMemberList(String name, String label, List<Identity> members) {
List<Member> memberWrappers = members.stream().map(m -> createMember(m)).collect(Collectors.toList());
VelocityContainer listVC = createVelocityContainer("printList");
listVC.contextPut("label", label);
listVC.contextPut("avatarBaseURL", avatarBaseURL);
listVC.contextPut("members", memberWrappers);
listVC.contextPut("typecss", "o_" + name);
listVC.contextPut("userPropertyPrintHandlers", userPropertyPrintHandlers);
// add lookup table so the avatar properties can be read out from the member object that contains the full list of attributes
Map<String, Integer> handlerLookupMap = new HashMap<String, Integer>();
for (int i = userPropertyPrintHandlers.size(); i-- > 0; ) {
UserPropertyHandler handler = userPropertyPrintHandlers.get(i);
handlerLookupMap.put(handler.getName(), i);
}
listVC.contextPut("handlerLookupMap", handlerLookupMap);
mainVC.put(name, listVC);
}
use of org.olat.core.gui.components.velocity.VelocityContainer in project OpenOLAT by OpenOLAT.
the class GTAParticipantController method setSolutions.
private void setSolutions(UserRequest ureq, Task assignedTask) {
DueDate availableDate = getSolutionDueDate(assignedTask);
boolean visible = availableDate == null || (availableDate.getDueDate() != null && availableDate.getDueDate().compareTo(new Date()) <= 0);
if (visible) {
File documentsDir = gtaManager.getSolutionsDirectory(courseEnv, gtaNode);
VFSContainer documentsContainer = gtaManager.getSolutionsContainer(courseEnv, gtaNode);
if ((availableDate != null && !availableDate.isRelative() && gtaNode.getModuleConfiguration().getBooleanSafe(GTACourseNode.GTASK_SAMPLE_SOLUTION_VISIBLE_ALL, false)) || TaskHelper.hasDocuments(documentsDir)) {
solutionsCtrl = new DirectoryController(ureq, getWindowControl(), documentsDir, documentsContainer, "run.solutions.description", "bulk.solutions", "solutions");
listenTo(solutionsCtrl);
mainVC.put("solutions", solutionsCtrl.getInitialComponent());
}
} else {
VelocityContainer waitVC = createVelocityContainer("wait_for_solutions");
mainVC.put("solutions", waitVC);
}
}
use of org.olat.core.gui.components.velocity.VelocityContainer in project OpenOLAT by OpenOLAT.
the class QTI12ItemStatisticsController method initItem.
protected void initItem(StatisticsItem itemStats) {
Series series = seriesfactory.getSeries(item, itemStats);
VelocityContainer vc = createVelocityContainer("hbar_item");
vc.contextPut("series", series);
mainVC.put("questionChart", vc);
mainVC.contextPut("series", series);
}
use of org.olat.core.gui.components.velocity.VelocityContainer in project OpenOLAT by OpenOLAT.
the class QTI21OnyxAssessmentStatisticsController method initScoreHistogram.
private void initScoreHistogram(StatisticAssessment stats) {
VelocityContainer scoreHistogramVC = createVelocityContainer("histogram_score");
scoreHistogramVC.contextPut("datas", BarSeries.datasToString(stats.getScores()));
mainVC.put("scoreHistogram", scoreHistogramVC);
}
Aggregations