use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.
the class AssessmentModeListModel method getValueAt.
@Override
public Object getValueAt(AssessmentMode mode, int col) {
switch(Cols.values()[col]) {
case status:
{
List<String> warnings = null;
Status status = mode.getStatus();
try {
if (StringHelper.containsNonWhitespace(mode.getStartElement())) {
ICourse course = CourseFactory.loadCourse(mode.getRepositoryEntry());
CourseNode node = course.getRunStructure().getNode(mode.getStartElement());
if (node == null) {
warnings = new ArrayList<>(2);
warnings.add(translator.translate("warning.missing.start.element"));
}
}
if (StringHelper.containsNonWhitespace(mode.getElementList())) {
ICourse course = CourseFactory.loadCourse(mode.getRepositoryEntry());
String elements = mode.getElementList();
for (String element : elements.split(",")) {
CourseNode node = course.getRunStructure().getNode(element);
if (node == null) {
if (warnings == null) {
warnings = new ArrayList<>(2);
}
warnings.add(translator.translate("warning.missing.element"));
break;
}
}
}
} catch (CorruptedCourseException e) {
log.error("", e);
if (warnings == null) {
warnings = new ArrayList<>(2);
}
warnings.add(translator.translate("cif.error.corrupted"));
}
return new EnhancedStatus(status, warnings);
}
case course:
return mode.getRepositoryEntry().getDisplayname();
case externalId:
return mode.getRepositoryEntry().getExternalId();
case externalRef:
return mode.getRepositoryEntry().getExternalRef();
case name:
return mode.getName();
case begin:
return mode.getBegin();
case end:
return mode.getEnd();
case leadTime:
return mode.getLeadTime();
case followupTime:
return mode.getFollowupTime();
case target:
return mode.getTargetAudience();
case start:
{
boolean canStart = mode.isManualBeginEnd();
if (canStart) {
canStart = coordinationService.canStart(mode);
}
return canStart;
}
case stop:
{
boolean canStop = mode.isManualBeginEnd();
if (canStop) {
canStop = coordinationService.canStop(mode);
}
return canStop;
}
}
return null;
}
use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.
the class CertificatesSelectionController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
;
int colPos = 0;
if (isAdministrativeUser) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.name", CertificatesSelectionDataModel.USERNAME_COL));
}
List<UserPropertyHandler> userPropertyHandlers = userManager.getUserPropertyHandlersFor(AssessedIdentitiesTableDataModel.usageIdentifyer, isAdministrativeUser);
List<UserPropertyHandler> resultingPropertyHandlers = new ArrayList<UserPropertyHandler>();
// followed by the users fields
for (int i = 0; i < userPropertyHandlers.size(); i++) {
UserPropertyHandler userPropertyHandler = userPropertyHandlers.get(i);
boolean visible = userManager.isMandatoryUserProperty(AssessedIdentitiesTableDataModel.usageIdentifyer, userPropertyHandler);
resultingPropertyHandlers.add(userPropertyHandler);
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(visible, userPropertyHandler.i18nColumnDescriptorLabelKey(), colPos++, false, null));
}
if (hasAssessableNodes) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.passed", CertificatesSelectionDataModel.PASSED_COL, new PassedCellRenderer()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.score", CertificatesSelectionDataModel.SCORE_COL));
}
tableModel = new CertificatesSelectionDataModel(columnsModel, resultingPropertyHandlers);
Set<Integer> preselectedRows = new HashSet<>();
ICourse course = CourseFactory.loadCourse(courseEntry);
CourseNode rootNode = course.getRunStructure().getRootNode();
List<CertificateInfos> infos = new ArrayList<>(datas.size());
int count = 0;
for (AssessedIdentityWrapper data : datas) {
ScoreEvaluation scoreEval = data.getUserCourseEnvironment().getScoreAccounting().getScoreEvaluation(rootNode);
Float score = scoreEval == null ? null : scoreEval.getScore();
Boolean passed = scoreEval == null ? null : scoreEval.getPassed();
Identity assessedIdentity = data.getIdentity();
infos.add(new CertificateInfos(assessedIdentity, score, passed));
if (passed != null && passed.booleanValue()) {
preselectedRows.add(new Integer(count));
}
count++;
}
tableModel.setObjects(infos);
tableEl = uifactory.addTableElement(getWindowControl(), "selection", tableModel, getTranslator(), formLayout);
tableEl.setMultiSelect(true);
tableEl.setSelectAllEnable(true);
tableEl.setMultiSelectedIndex(preselectedRows);
}
use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.
the class AssessmentCourseStatisticsSmallController method updateStatistics.
public void updateStatistics() {
ICourse course = CourseFactory.loadCourse(courseEntry);
String rootNodeIdent = course.getRunStructure().getRootNode().getIdent();
SearchAssessedIdentityParams params = new SearchAssessedIdentityParams(courseEntry, rootNodeIdent, null, assessmentCallback);
numOfAssessedIdentities = assessmentToolManager.getNumberOfAssessedIdentities(getIdentity(), params);
mainVC.contextPut("numOfAssessedIdentities", numOfAssessedIdentities);
memberStatistics = assessmentToolManager.getNumberOfParticipants(getIdentity(), params);
mainVC.contextPut("numOfParticipants", memberStatistics.getNumOfParticipants());
if (assessmentCallback.canAssessNonMembers()) {
mainVC.contextPut("numOfOtherUsers", memberStatistics.getNumOfOtherUsers());
}
AssessmentStatistics stats = assessmentToolManager.getStatistics(getIdentity(), params);
mainVC.contextPut("scoreAverage", AssessmentHelper.getRoundedScore(stats.getAverageScore()));
numOfPassed = stats.getCountPassed();
mainVC.contextPut("numOfPassed", numOfPassed);
int total = memberStatistics.getTotal();
int percentPassed = total == 0 ? 0 : Math.round(100.0f * (stats.getCountPassed() / total));
mainVC.contextPut("percentPassed", percentPassed);
numOfFailed = stats.getCountFailed();
mainVC.contextPut("numOfFailed", numOfFailed);
int percentFailed = total == 0 ? 0 : Math.round(100.0f * (stats.getCountFailed() / total));
mainVC.contextPut("percentFailed", percentFailed);
int numOfParticipantLaunches = memberStatistics.getNumOfParticipantsLoggedIn();
mainVC.contextPut("numOfParticipantLaunches", numOfParticipantLaunches);
if (assessmentCallback.canAssessNonMembers()) {
int numOfOtherUserLaunches = memberStatistics.getLoggedIn();
mainVC.contextPut("numOfOtherUserLaunches", numOfOtherUserLaunches);
}
}
use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.
the class CertificationNotificationHandler method createSubscriptionInfo.
@Override
public SubscriptionInfo createSubscriptionInfo(Subscriber subscriber, Locale locale, Date compareDate) {
SubscriptionInfo si = null;
Publisher p = subscriber.getPublisher();
if (!NotificationsUpgradeHelper.checkCourse(p)) {
// course don't exist anymore
NotificationsManager.getInstance().deactivate(p);
return NotificationsManager.getInstance().getNoSubscriptionInfo();
}
try {
Date latestNews = p.getLatestNewsDate();
Identity identity = subscriber.getIdentity();
Translator trans = Util.createPackageTranslator(CertificateController.class, locale);
// can't be loaded when already deleted
if (NotificationsManager.getInstance().isPublisherValid(p) && compareDate.before(latestNews)) {
Long courseId = new Long(p.getData());
final ICourse course = CourseFactory.loadCourse(courseId);
if (courseStatus(course)) {
// course admins or users with the course right to have full access to
// the assessment tool will have full access to user tests
RepositoryEntry entry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
List<Certificate> certificates = certificatesManager.getCertificatesForNotifications(identity, entry, latestNews);
for (Certificate certificate : certificates) {
Date modDate = certificate.getCreationDate();
Identity assessedIdentity = certificate.getIdentity();
String fullname = userManager.getUserDisplayName(assessedIdentity);
String desc = trans.translate("notifications.desc", new String[] { fullname });
String urlToSend = null;
String businessPath = null;
if (p.getBusinessPath() != null) {
businessPath = p.getBusinessPath() + "[assessmentTool:0][Identity:" + assessedIdentity.getKey() + "]";
urlToSend = BusinessControlFactory.getInstance().getURLFromBusinessPathString(businessPath);
}
SubscriptionListItem subListItem = new SubscriptionListItem(desc, urlToSend, businessPath, modDate, "o_icon_certificate");
if (si == null) {
String title = trans.translate("notifications.header", new String[] { course.getCourseTitle() });
si = new SubscriptionInfo(subscriber.getKey(), p.getType(), new TitleItem(title, "o_icon_certificate"), null);
}
si.addSubscriptionListItem(subListItem);
}
}
}
if (si == null) {
si = NotificationsManager.getInstance().getNoSubscriptionInfo();
}
return si;
} catch (Exception e) {
log.error("Error while creating assessment notifications", e);
return NotificationsManager.getInstance().getNoSubscriptionInfo();
}
}
use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.
the class VCCourseNode method createNodeRunConstructionResult.
@Override
public NodeRunConstructionResult createNodeRunConstructionResult(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv, NodeEvaluation ne, String nodecmd) {
updateModuleConfigDefaults(false);
// check if user is moderator of the virtual classroom
Roles roles = ureq.getUserSession().getRoles();
boolean moderator = roles.isOLATAdmin();
Long key = userCourseEnv.getCourseEnvironment().getCourseResourceableId();
if (!moderator) {
if (roles.isInstitutionalResourceManager() | roles.isAuthor()) {
RepositoryManager rm = RepositoryManager.getInstance();
ICourse course = CourseFactory.loadCourse(key);
RepositoryEntry re = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
if (re != null) {
moderator = rm.isOwnerOfRepositoryEntry(ureq.getIdentity(), re);
if (!moderator) {
moderator = rm.isInstitutionalRessourceManagerFor(ureq.getIdentity(), ureq.getUserSession().getRoles(), re);
}
}
}
}
// load configuration
final String providerId = getModuleConfiguration().getStringValue(CONF_PROVIDER_ID);
VCProvider provider = providerId == null ? VCProviderFactory.createDefaultProvider() : VCProviderFactory.createProvider(providerId);
VCConfiguration config = handleConfig(provider);
// create run controller
Controller runCtr = new VCRunController(ureq, wControl, key + "_" + getIdent(), getShortName(), getLongTitle(), config, provider, moderator, userCourseEnv.isCourseReadOnly());
Controller controller = TitledWrapperHelper.getWrapper(ureq, wControl, runCtr, this, "o_vc_icon");
return new NodeRunConstructionResult(controller);
}
Aggregations