use of org.olat.core.gui.translator.Translator in project OpenOLAT by OpenOLAT.
the class ProjectBrokerExportGenerator method createCourseResultsOverviewTable.
/**
* The results from assessable nodes are written to one row per user into an excel-sheet. An
* assessable node will only appear if it is producing at least one of the
* following variables: score, passed, attempts, comments.
*
* @param identities
* @param myNodes
* @param course
* @param locale
* @return String
*/
public static String createCourseResultsOverviewTable(CourseNode courseNode, ICourse course, Locale locale) {
Translator translator = Util.createPackageTranslator(ProjectBrokerControllerFactory.class, locale);
StringBuilder table = new StringBuilder();
ProjectBrokerModuleConfiguration moduleConfig = new ProjectBrokerModuleConfiguration(courseNode.getModuleConfiguration());
ProjectBrokerManager projectBrokerManager = CoreSpringFactory.getImpl(ProjectBrokerManager.class);
// load project-list
CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
Long projectBrokerId = projectBrokerManager.getProjectBrokerId(cpm, courseNode);
if (projectBrokerId != null) {
List<Project> projects = projectBrokerManager.getProjectListBy(projectBrokerId);
// build table-header
table.append(createHeaderLine(translator, moduleConfig));
// loop over all projects
for (Project project : projects) {
table.append(createProjectDataLine(translator, project, moduleConfig, translator));
}
} else {
log.debug("projectBrokerId is null, courseNode=" + courseNode + " , course=" + course);
}
return table.toString();
}
use of org.olat.core.gui.translator.Translator in project OpenOLAT by OpenOLAT.
the class VideoCourseNodeConfiguration method getLinkText.
@Override
public String getLinkText(Locale locale) {
Translator fallback = Util.createPackageTranslator(CourseNodeConfiguration.class, locale);
Translator translator = Util.createPackageTranslator(this.getClass(), locale, fallback);
return translator.translate("title_video");
}
use of org.olat.core.gui.translator.Translator in project OpenOLAT by OpenOLAT.
the class QTI12To21Converter method convertItemBasics.
private void convertItemBasics(Item item, AssessmentItemBuilder itemBuilder) {
AssessmentItem assessmentItem = itemBuilder.getAssessmentItem();
if (StringHelper.containsNonWhitespace(item.getTitle())) {
assessmentItem.setTitle(item.getTitle());
}
if (StringHelper.containsNonWhitespace(item.getLabel())) {
assessmentItem.setLabel(item.getLabel());
}
Question question = item.getQuestion();
String questionText = question.getQuestion().renderAsHtmlForEditor();
questionText = blockedHtml(questionText);
if (StringHelper.isHtml(questionText)) {
itemBuilder.setQuestion(questionText);
} else {
itemBuilder.setQuestion("<p>" + questionText + "</p>");
}
String hintText = question.getHintText();
if (StringHelper.containsNonWhitespace(hintText)) {
ModalFeedbackBuilder hint = itemBuilder.createHint();
Translator translator = Util.createPackageTranslator(QTIModule.class, locale);
hint.setTitle(translator.translate("render.hint"));
hint.setText(hintText);
}
String solutionText = question.getSolutionText();
if (StringHelper.containsNonWhitespace(solutionText)) {
ModalFeedbackBuilder solution = itemBuilder.createCorrectSolutionFeedback();
solutionText = blockedHtml(solutionText);
solution.setText(solutionText);
}
String feedbackMastery = QTIEditHelper.getFeedbackMasteryText(item);
if (StringHelper.containsNonWhitespace(feedbackMastery)) {
ModalFeedbackBuilder feedback = itemBuilder.createCorrectFeedback();
feedbackMastery = blockedHtml(feedbackMastery);
feedback.setText(feedbackMastery);
}
String feedbackFail = QTIEditHelper.getFeedbackFailText(item);
if (StringHelper.containsNonWhitespace(feedbackFail)) {
ModalFeedbackBuilder feedback = itemBuilder.createIncorrectFeedback();
feedbackFail = blockedHtml(feedbackFail);
feedback.setText(feedbackFail);
}
}
use of org.olat.core.gui.translator.Translator in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_11_0_0 method checkEssay.
private boolean checkEssay(RepositoryEntry testEntry) {
if (qtiEssayMap.containsKey(testEntry.getKey())) {
return qtiEssayMap.get(testEntry.getKey()).booleanValue();
}
TestFileResource fr = new TestFileResource();
fr.overrideResourceableId(testEntry.getOlatResource().getResourceableId());
TransientIdentity pseudoIdentity = new TransientIdentity();
pseudoIdentity.setName("transient");
Translator translator = Util.createPackageTranslator(QTIModule.class, Locale.ENGLISH);
try {
QTIEditorPackage qtiPackage = new QTIEditorPackageImpl(pseudoIdentity, fr, null, translator);
if (qtiPackage.getQTIDocument() != null && qtiPackage.getQTIDocument().getAssessment() != null) {
Assessment ass = qtiPackage.getQTIDocument().getAssessment();
// Sections with their Items
List<Section> sections = ass.getSections();
for (Section section : sections) {
List<Item> items = section.getItems();
for (Item item : items) {
String ident = item.getIdent();
if (ident != null && ident.startsWith("QTIEDIT:ESSAY")) {
qtiEssayMap.put(testEntry.getKey(), Boolean.TRUE);
return true;
}
}
}
}
} catch (OLATRuntimeException e) {
log.warn("QTI without content in repository entry: " + testEntry.getKey(), e);
}
qtiEssayMap.put(testEntry.getKey(), Boolean.FALSE);
return false;
}
use of org.olat.core.gui.translator.Translator in project OpenOLAT by OpenOLAT.
the class UserManagerImplTest method shouldDisplayDefaultIfHasNoEmail.
@Test
public void shouldDisplayDefaultIfHasNoEmail() {
Translator translatorMock = mock(Translator.class);
when(translatorMock.translate(any())).thenReturn(UNUSED_EMAIL);
String email = sut.getUserDisplayEmail(null, translatorMock);
assertThat(email).isEqualTo(UNUSED_EMAIL);
}
Aggregations