diff --git a/src/main/java/org/olat/course/assessment/AssessedIdentitiesTableDataModel.java b/src/main/java/org/olat/course/assessment/AssessedIdentitiesTableDataModel.java index 2dcd268278abaf8172406fcab2b5cc3414305080..fa0762f3ec92221db946b57ff35ccb2847b6e998 100644 --- a/src/main/java/org/olat/course/assessment/AssessedIdentitiesTableDataModel.java +++ b/src/main/java/org/olat/course/assessment/AssessedIdentitiesTableDataModel.java @@ -25,288 +25,14 @@ package org.olat.course.assessment; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.concurrent.ConcurrentMap; - -import org.olat.core.gui.components.table.BooleanColumnDescriptor; -import org.olat.core.gui.components.table.ColumnDescriptor; -import org.olat.core.gui.components.table.CustomRenderColumnDescriptor; -import org.olat.core.gui.components.table.DefaultColumnDescriptor; -import org.olat.core.gui.components.table.DefaultTableDataModel; -import org.olat.core.gui.components.table.TableController; -import org.olat.core.gui.translator.Translator; -import org.olat.core.id.Identity; -import org.olat.core.util.Util; -import org.olat.course.certificate.CertificateLight; -import org.olat.course.certificate.model.CertificateLightPack; -import org.olat.course.certificate.ui.DownloadCertificateCellRenderer; -import org.olat.course.nodes.AssessableCourseNode; -import org.olat.course.nodes.STCourseNode; -import org.olat.course.nodes.ta.StatusForm; -import org.olat.course.nodes.ta.StatusManager; -import org.olat.course.properties.CoursePropertyManager; -import org.olat.course.run.scoring.ScoreEvaluation; -import org.olat.properties.Property; -import org.olat.user.UserManager; -import org.olat.user.propertyhandlers.UserPropertyHandler; - /** * This class is used as identifier for user properties configuration, don't move it, don't delete it. * * Initial Date: Jun 23, 2004 * @author gnaegi */ -public class AssessedIdentitiesTableDataModel extends DefaultTableDataModel<AssessedIdentityWrapper> { - - private int colCount; - private AssessableCourseNode courseNode; - - private static final String COL_NAME = "name"; - private static final String COL_DETAILS = "details"; - private static final String COL_ATTEMPTS = "attempts"; - private static final String COL_SCORE = "score"; - //fxdiff VCRP-4: assessment overview with max score - private static final String COL_MINSCORE = "minScore"; - private static final String COL_MAXSCORE = "maxScore"; - private static final String COL_PASSED = "passed"; - private static final String COL_STATUS = "status"; - private static final String COL_INITIAL_LAUNCH = "initialLaunch"; - private static final String COL_LAST_SCORE_DATE = "lastScoreDate"; - private static final String COL_CERTIFICATE = "certificate"; +public class AssessedIdentitiesTableDataModel { - private List<String> colMapping; - private List<String> userPropertyNameList; - private final boolean isAdministrativeUser; - private final List<UserPropertyHandler> userPropertyHandlers; public static final String usageIdentifyer = AssessedIdentitiesTableDataModel.class.getCanonicalName(); - private final Translator translator; - - private ConcurrentMap<Long, CertificateLight> certificates; - - /** - * - * @param objects - * @param courseNode - * @param locale - * @param isAdministrativeUser - */ - public AssessedIdentitiesTableDataModel(List<AssessedIdentityWrapper> objects, ConcurrentMap<Long, CertificateLight> certificates, - AssessableCourseNode courseNode, Locale locale, boolean isAdministrativeUser) { - super(objects); - this.courseNode = courseNode; - this.setLocale(locale); - this.translator = Util.createPackageTranslator(this.getClass(), locale); - this.certificates = certificates; - - this.isAdministrativeUser = isAdministrativeUser; - userPropertyHandlers = UserManager.getInstance().getUserPropertyHandlersFor(usageIdentifyer, isAdministrativeUser); - - colCount = 0; // default - colMapping = new ArrayList<String>(); - // store all configurable column positions in a lookup array - if(isAdministrativeUser) { - colMapping.add(colCount++, COL_NAME); - } - - Iterator <UserPropertyHandler> propHandlerIterator = userPropertyHandlers.iterator(); - userPropertyNameList = new ArrayList<String>(); - while (propHandlerIterator.hasNext()) { - String propHandlerName = propHandlerIterator.next().getName(); - userPropertyNameList.add(propHandlerName); - colMapping.add(colCount++, propHandlerName); - } - - if (courseNode != null) { - if (courseNode.hasDetails()) { - colMapping.add(colCount++, COL_DETAILS); - } - if (courseNode.hasAttemptsConfigured()) { - colMapping.add(colCount++, COL_ATTEMPTS); - } - if (courseNode.hasScoreConfigured()) { - colMapping.add(colCount++, COL_SCORE); - colMapping.add(colCount++, COL_MINSCORE); - colMapping.add(colCount++, COL_MAXSCORE); - } - if (courseNode.hasStatusConfigured()) { - colMapping.add(colCount++, COL_STATUS); - } - if (courseNode.hasPassedConfigured()) { - colMapping.add(colCount++, COL_PASSED); - } - colMapping.add(colCount++, COL_INITIAL_LAUNCH); - colMapping.add(colCount++, COL_LAST_SCORE_DATE); - } - - colMapping.add(colCount++, COL_CERTIFICATE); - } - - public void setCertificates(ConcurrentMap<Long, CertificateLight> certificates) { - this.certificates = certificates; - } - - public void putCertificate(CertificateLight certificate) { - if(certificates != null) { - certificates.put(certificate.getIdentityKey(), certificate); - } - } - - public boolean replaceWrapper(AssessedIdentityWrapper wrappedIdentity) { - boolean replaced = false; - int index = getObjects().indexOf(wrappedIdentity); - if(index >= 0 && index < getObjects().size()) { - getObjects().set(index, wrappedIdentity); - replaced = true; - } - return replaced; - } - - /** - * @see org.olat.core.gui.components.table.TableDataModel#getColumnCount() - */ - @Override - public int getColumnCount() { - return colCount; - } - - /** - * @see org.olat.core.gui.components.table.TableDataModel#getValueAt(int, int) - */ - @Override - public Object getValueAt(int row, int col) { - AssessedIdentityWrapper wrappedIdentity = getObject(row); - Identity identity = wrappedIdentity.getIdentity(); - - // lookup the column name first and - // deliver value based on the column name - String colName = colMapping.get(col); - if (colName.equals(COL_NAME)) { - return identity.getName(); - } else if (userPropertyNameList.contains(colName)) { - return identity.getUser().getProperty(colName, getLocale()); - } else if (colName.equals(COL_DETAILS)) { - return wrappedIdentity.getDetailsListView(); - } else if (colName.equals(COL_ATTEMPTS)) { - return wrappedIdentity.getNodeAttempts(); - } else if (colName.equals(COL_SCORE)) { - ScoreEvaluation scoreEval = wrappedIdentity.getUserCourseEnvironment().getScoreAccounting().evalCourseNode(courseNode); - if (scoreEval == null) { - scoreEval = ScoreEvaluation.EMPTY_EVALUATION; - } - return scoreEval.getScore(); - } else if (colName.equals(COL_MINSCORE)) { - if(!(courseNode instanceof STCourseNode)) { - return courseNode.getMinScoreConfiguration(); - } - return ""; - } else if (colName.equals(COL_MAXSCORE)) { - if(!(courseNode instanceof STCourseNode)) { - return courseNode.getMaxScoreConfiguration(); - } - return ""; - } else if (colName.equals(COL_STATUS)) { - return getStatusFor(courseNode, wrappedIdentity); - } else if (colName.equals(COL_PASSED)) { - ScoreEvaluation scoreEval = wrappedIdentity.getUserCourseEnvironment().getScoreAccounting().evalCourseNode(courseNode); - if (scoreEval == null) { - scoreEval = ScoreEvaluation.EMPTY_EVALUATION; - } - return scoreEval.getPassed(); - } else if (colName.equals(COL_INITIAL_LAUNCH)) { - return wrappedIdentity.getInitialLaunchDate(); - } else if (colName.equals(COL_LAST_SCORE_DATE)) { - return wrappedIdentity.getLastModified(); - } else if(colName.equals(COL_CERTIFICATE)) { - if(certificates != null) { - CertificateLight certificate = certificates.get(identity.getKey()); - if(certificate != null) { - return new CertificateLightPack(certificate, identity); - } - } - return null; - } else { - return "error"; - } - } - - /** - * Return task Status (not_ok,ok,working_on) for a certain user and course - * @param assessableCourseNode - * @param wrappedIdentity - * @return - */ - private String getStatusFor(AssessableCourseNode assessableCourseNode, AssessedIdentityWrapper wrappedIdentity) { - - CoursePropertyManager cpm = wrappedIdentity.getUserCourseEnvironment().getCourseEnvironment().getCoursePropertyManager(); - Property statusProperty; - Translator trans = Util.createPackageTranslator(StatusForm.class, getLocale()); - statusProperty = cpm.findCourseNodeProperty(assessableCourseNode, wrappedIdentity.getIdentity(), null, StatusManager.PROPERTY_KEY_STATUS); - if (statusProperty == null) { - String value = trans.translate(StatusForm.PROPERTY_KEY_UNDEFINED); - return value; - } else { - String value = trans.translate(StatusForm.STATUS_LOCALE_PROPERTY_PREFIX + statusProperty.getStringValue()); - return value; - } - } - /** - * Adds all ColumnDescriptors to the userListCtr. - * @param userListCtr - * @param actionCommand - * @param isNodeOrGroupFocus - */ - public void addColumnDescriptors(TableController userListCtr, String actionCommand, boolean isNodeOrGroupFocus, boolean certificate) { - String editCmd = null; - if (courseNode == null || courseNode.isEditableConfigured()) { - editCmd = actionCommand; // only selectable if editable - } - int columnCount = 0; - - if(isAdministrativeUser) { - userListCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.header.name", columnCount++, editCmd, getLocale())); - } - - for (int i = 0; i < userPropertyHandlers.size(); i++) { - UserPropertyHandler userPropertyHandler = userPropertyHandlers.get(i); - boolean visible = UserManager.getInstance().isMandatoryUserProperty(usageIdentifyer , userPropertyHandler); - userListCtr.addColumnDescriptor(visible, userPropertyHandler.getColumnDescriptor(columnCount++, editCmd, getLocale())); - } - if ( (courseNode != null) && isNodeOrGroupFocus) { - if (courseNode.hasDetails()) { - String headerKey = courseNode.getDetailsListViewHeaderKey(); - userListCtr.addColumnDescriptor((headerKey == null ? false : true), - new DefaultColumnDescriptor(headerKey == null ? "table.header.details" : headerKey, columnCount++, null, getLocale())); - } - if (courseNode.hasAttemptsConfigured()) { - userListCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.header.attempts", columnCount++, null, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT)); - } - if (courseNode.hasScoreConfigured()) { - userListCtr.addColumnDescriptor(new CustomRenderColumnDescriptor("table.header.score", columnCount++, null, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, - new ScoreCellRenderer())); - userListCtr.addColumnDescriptor(false, new CustomRenderColumnDescriptor("table.header.min", columnCount++, null, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, - new ScoreCellRenderer())); - userListCtr.addColumnDescriptor(new CustomRenderColumnDescriptor("table.header.max", columnCount++, null, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, - new ScoreCellRenderer())); - } - if (courseNode.hasStatusConfigured()) { - userListCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.header.status", columnCount++, null, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT)); - } - if (courseNode.hasPassedConfigured()) { - userListCtr.addColumnDescriptor(new BooleanColumnDescriptor("table.header.passed", columnCount++, translator.translate("passed.true"), - translator.translate("passed.false"))); - } - userListCtr.addColumnDescriptor(false, new DefaultColumnDescriptor("table.header.initialLaunchDate", columnCount++, null, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT)); - userListCtr.addColumnDescriptor(false, new DefaultColumnDescriptor("table.header.lastScoreDate", columnCount++, null, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT)); - } - - if(certificate) { - CustomRenderColumnDescriptor statColdesc = new CustomRenderColumnDescriptor("table.header.certificate", columnCount++, null, getLocale(), - ColumnDescriptor.ALIGNMENT_LEFT, new DownloadCertificateCellRenderer()); - userListCtr.addColumnDescriptor(statColdesc); - } - } } \ No newline at end of file diff --git a/src/main/java/org/olat/course/assessment/ui/tool/IdentityAssessmentOverviewController.java b/src/main/java/org/olat/course/assessment/ui/tool/IdentityAssessmentOverviewController.java index c3eb3e7b824688e2fa8c52eca16199e0e79e5a64..53f02284b96a44af545d909a559ad1789527f832 100644 --- a/src/main/java/org/olat/course/assessment/ui/tool/IdentityAssessmentOverviewController.java +++ b/src/main/java/org/olat/course/assessment/ui/tool/IdentityAssessmentOverviewController.java @@ -123,7 +123,7 @@ public class IdentityAssessmentOverviewController extends FormBasicController { * @param assessmentCourseNodes List of maps containing the node assessment data using the AssessmentManager keys */ public IdentityAssessmentOverviewController(UserRequest ureq, WindowControl wControl, List<AssessmentNodeData> assessmentCourseNodes) { - super(ureq, wControl); + super(ureq, wControl, LAYOUT_BAREBONE); setTranslator(Util.createPackageTranslator(AssessmentModule.class, getLocale(), getTranslator())); runStructure = null; @@ -135,6 +135,7 @@ public class IdentityAssessmentOverviewController extends FormBasicController { preloadedNodesList = assessmentCourseNodes; initForm(ureq); + loadModel(); } public boolean isRoot(CourseNode node) { diff --git a/src/main/java/org/olat/course/certificate/ui/CertificatesWizardController.java b/src/main/java/org/olat/course/certificate/ui/CertificatesWizardController.java deleted file mode 100644 index c50bb3775af333b435b2175e31f6b99d16a92f27..0000000000000000000000000000000000000000 --- a/src/main/java/org/olat/course/certificate/ui/CertificatesWizardController.java +++ /dev/null @@ -1,137 +0,0 @@ -/** - * <a href="http://www.openolat.org"> - * OpenOLAT - Online Learning and Training</a><br> - * <p> - * Licensed under the Apache License, Version 2.0 (the "License"); <br> - * you may not use this file except in compliance with the License.<br> - * You may obtain a copy of the License at the - * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a> - * <p> - * Unless required by applicable law or agreed to in writing,<br> - * software distributed under the License is distributed on an "AS IS" BASIS, <br> - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> - * See the License for the specific language governing permissions and <br> - * limitations under the License. - * <p> - * Initial code contributed and copyrighted by<br> - * frentix GmbH, http://www.frentix.com - * <p> - */ -package org.olat.course.certificate.ui; - -import java.util.List; - -import org.olat.core.gui.UserRequest; -import org.olat.core.gui.components.Component; -import org.olat.core.gui.components.link.Link; -import org.olat.core.gui.components.link.LinkFactory; -import org.olat.core.gui.control.Controller; -import org.olat.core.gui.control.Event; -import org.olat.core.gui.control.WindowControl; -import org.olat.core.gui.control.controller.BasicController; -import org.olat.core.gui.control.generic.wizard.Step; -import org.olat.core.gui.control.generic.wizard.StepRunnerCallback; -import org.olat.core.gui.control.generic.wizard.StepsMainRunController; -import org.olat.core.gui.control.generic.wizard.StepsRunContext; -import org.olat.course.CourseFactory; -import org.olat.course.ICourse; -import org.olat.course.assessment.AssessedIdentitiesTableDataModel; -import org.olat.course.assessment.AssessedIdentityWrapper; -import org.olat.course.certificate.CertificateTemplate; -import org.olat.course.certificate.CertificatesManager; -import org.olat.course.certificate.model.CertificateInfos; -import org.olat.repository.RepositoryEntry; -import org.springframework.beans.factory.annotation.Autowired; - -/** - * - * Initial date: 28.10.2014<br> - * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com - * - */ -public class CertificatesWizardController extends BasicController { - - private Link startButton; - private StepsMainRunController wizardCtrl; - - private final boolean hasAssessableNodes; - private final RepositoryEntry courseEntry; - private final AssessedIdentitiesTableDataModel dataModel; - - @Autowired - private CertificatesManager certificatesManager; - - public CertificatesWizardController(UserRequest ureq, WindowControl wControl, - AssessedIdentitiesTableDataModel dataModel, RepositoryEntry courseEntry, boolean hasAssessableNodes) { - super(ureq, wControl); - - this.dataModel = dataModel; - this.courseEntry = courseEntry; - this.hasAssessableNodes = hasAssessableNodes; - - startButton = LinkFactory.createButton("generate.certificate", null, this); - startButton.setTranslator(getTranslator()); - putInitialPanel(startButton); - getInitialComponent().setSpanAsDomReplaceable(true); - } - - @Override - protected void doDispose() { - // - } - - @Override - protected void event(UserRequest ureq, Component source, Event event) { - if(startButton == source) { - doStartWizard(ureq); - } - } - - @Override - protected void event(UserRequest ureq, Controller source, Event event) { - if(wizardCtrl == source) { - if(event == Event.CANCELLED_EVENT || event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) { - getWindowControl().pop(); - removeAsListenerAndDispose(wizardCtrl); - wizardCtrl = null; - if(event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) { - fireEvent(ureq, Event.DONE_EVENT); - } - } - } - super.event(ureq, source, event); - } - - private void doStartWizard(UserRequest ureq) { - List<AssessedIdentityWrapper> datas = dataModel.getObjects(); - Certificates_1_SelectionStep start = new Certificates_1_SelectionStep(ureq, courseEntry, datas, hasAssessableNodes); - StepRunnerCallback finish = new StepRunnerCallback() { - @Override - public Step execute(UserRequest uureq, WindowControl wControl, StepsRunContext runContext) { - @SuppressWarnings("unchecked") - List<CertificateInfos> assessedIdentitiesInfos = (List<CertificateInfos>)runContext.get("infos"); - if(assessedIdentitiesInfos != null && assessedIdentitiesInfos.size() > 0) { - doGenerateCertificates(assessedIdentitiesInfos); - return StepsMainRunController.DONE_MODIFIED; - } - return StepsMainRunController.DONE_UNCHANGED; - } - }; - - wizardCtrl = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, - translate("certificates.wizard.title"), "o_sel_certificates_wizard"); - listenTo(wizardCtrl); - getWindowControl().pushAsModalDialog(wizardCtrl.getInitialComponent()); - } - - private void doGenerateCertificates(List<CertificateInfos> assessedIdentitiesInfos) { - ICourse course = CourseFactory.loadCourse(courseEntry); - Long templateKey = course.getCourseConfig().getCertificateTemplate(); - CertificateTemplate template = null; - if(templateKey != null) { - template = certificatesManager.getTemplateById(templateKey); - } - - certificatesManager.generateCertificates(assessedIdentitiesInfos, courseEntry, template, true); - } -} \ No newline at end of file diff --git a/src/test/java/org/olat/selenium/AssessmentTest.java b/src/test/java/org/olat/selenium/AssessmentTest.java index a36fb1a4c7077c5f6a7bf5f8b1228f7b5ccda0fb..08371f751c8be721d869c1cea68c8bb834015ee6 100644 --- a/src/test/java/org/olat/selenium/AssessmentTest.java +++ b/src/test/java/org/olat/selenium/AssessmentTest.java @@ -758,7 +758,8 @@ public class AssessmentTest { .openMyEfficiencyStatement() .assertOnEfficiencyStatmentPage() .assertOnCertificateAndStatements(courseTitle) - .selectStatement(courseTitle).selectStatementSegment() + .selectStatement(courseTitle) + .selectStatementSegment() .assertOnCourseDetails(testNodeTitle, true); } @@ -862,7 +863,7 @@ public class AssessmentTest { * The author reviews the documents, use the assessment tool * for group within the course element to set passed to the * group.</br> - * The 2 participants check if they sucessfully passed the task. + * The 2 participants check if they successfully passed the task. * * * @param authorLoginPage diff --git a/src/test/java/org/olat/selenium/page/course/AssessmentToolPage.java b/src/test/java/org/olat/selenium/page/course/AssessmentToolPage.java index 933fc6bb700e5596866566916107545fbec99819..c90e2ee9d3f627f4e321ff91b912a61736cd5cdf 100644 --- a/src/test/java/org/olat/selenium/page/course/AssessmentToolPage.java +++ b/src/test/java/org/olat/selenium/page/course/AssessmentToolPage.java @@ -84,7 +84,7 @@ public class AssessmentToolPage { * @return */ public AssessmentToolPage selectCourseNode(String nodeTitle) { - By rowsBy = By.xpath("//div[contains(@class,'o_table_wrapper')]//table//tr[td[contains(text(),'" + nodeTitle + "')]]//td//a[contains(@href,'cmd.select.node')]"); + By rowsBy = By.xpath("//div[contains(@class,'o_table_wrapper')]//table//tr[td/span[contains(text(),'" + nodeTitle + "')]]/td/a[contains(@href,'cmd.select.node')]"); List<WebElement> rowEls = browser.findElements(rowsBy); Assert.assertEquals(1, rowEls.size()); rowEls.get(0).click(); @@ -100,7 +100,7 @@ public class AssessmentToolPage { * @return */ public AssessmentToolPage assertUserPassedCourseNode(String nodeTitle) { - By rowsBy = By.xpath("//div[contains(@class,'o_table_wrapper')]//table//tr[td[contains(text(),'" + nodeTitle + "')]]"); + By rowsBy = By.xpath("//div[contains(@class,'o_table_wrapper')]//table//tr[td/span[contains(text(),'" + nodeTitle + "')]]"); List<WebElement> rowEls = browser.findElements(rowsBy); Assert.assertEquals(1, rowEls.size()); By passedBy = By.cssSelector("td span.o_state.o_passed"); diff --git a/src/test/java/org/olat/selenium/page/user/EfficiencyStatementPage.java b/src/test/java/org/olat/selenium/page/user/EfficiencyStatementPage.java index 013edf1eb1d4ea7d34e93149e29c05e454ea6ea8..b2342e0c9e7eac49b2fddbb050b704fa14fa603a 100644 --- a/src/test/java/org/olat/selenium/page/user/EfficiencyStatementPage.java +++ b/src/test/java/org/olat/selenium/page/user/EfficiencyStatementPage.java @@ -115,7 +115,7 @@ public class EfficiencyStatementPage { * @return */ public EfficiencyStatementPage assertOnCourseDetails(String testNodeTitle, boolean passed) { - By courseCertificateBy = By.xpath("//div[contains(@class,'o_efficiencystatement')]//table//tr[td[contains(text(),'" + testNodeTitle + "')]]"); + By courseCertificateBy = By.xpath("//div[contains(@class,'o_efficiencystatement')]//table//tr[td/span[contains(text(),'" + testNodeTitle + "')]]"); List<WebElement> certifiatesTable = browser.findElements(courseCertificateBy); Assert.assertFalse(certifiatesTable.isEmpty());