From 284d3494d1c8b9cfcd9c13a00d72c2fc0563dfd0 Mon Sep 17 00:00:00 2001
From: uhensler <urs.hensler@frentix.com>
Date: Mon, 18 Nov 2019 12:17:14 +0100
Subject: [PATCH] OO-4349: Show the link to "evidence of achievement" in the
 course tool bar

Show the link even if the course contains no assessable course elements.
---
 .../course/run/CourseRuntimeController.java   | 40 +++----------------
 1 file changed, 5 insertions(+), 35 deletions(-)

diff --git a/src/main/java/org/olat/course/run/CourseRuntimeController.java b/src/main/java/org/olat/course/run/CourseRuntimeController.java
index c4306696961..e24714de79c 100644
--- a/src/main/java/org/olat/course/run/CourseRuntimeController.java
+++ b/src/main/java/org/olat/course/run/CourseRuntimeController.java
@@ -85,7 +85,6 @@ import org.olat.course.ICourse;
 import org.olat.course.archiver.ArchiverMainController;
 import org.olat.course.archiver.FullAccessArchiverCallback;
 import org.olat.course.area.CourseAreasController;
-import org.olat.course.assessment.AssessmentChangedEvent;
 import org.olat.course.assessment.AssessmentModule;
 import org.olat.course.assessment.ui.mode.AssessmentModeListController;
 import org.olat.course.assessment.ui.mode.AssessmentModeSecurityCallback;
@@ -684,25 +683,11 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im
 
 		// Personal tools on right side
 		CourseConfig cc = course.getCourseConfig();
-		if ((course.hasAssessableNodes() || cc.isCertificateEnabled()) && !isGuestOnly && !assessmentLock && userCourseEnv != null) {
-			// link to efficiency statements should
-			// - not appear when not configured in course configuration
-			// - not appear when configured in course configuration but no assessable
-			// node exist
-			// - appear but dimmed when configured, assessable node exist but no
-			// assessment data exists for user
-			// - appear as link when configured, assessable node exist and assessment
-			// data exists for user
-			efficiencyStatementsLink = LinkFactory.createToolLink("efficiencystatement",translate("command.efficiencystatement"), this, "o_icon_certificate");
-			efficiencyStatementsLink.setVisible(cc.isEfficencyStatementEnabled() || cc.isCertificateEnabled());
+		if ((cc.isEfficencyStatementEnabled() || cc.isCertificateEnabled()) && !isGuestOnly && !assessmentLock
+				&& userCourseEnv != null && userCourseEnv.isParticipant()) {
+			efficiencyStatementsLink = LinkFactory.createToolLink("efficiencystatement",
+					translate("command.efficiencystatement"), this, "o_icon_certificate");
 			myCourse.addComponent(efficiencyStatementsLink);
-			if(cc.isEfficencyStatementEnabled() || cc.isCertificateEnabled()) {
-				boolean certification = userCourseEnv.hasEfficiencyStatementOrCertificate(false);
-				efficiencyStatementsLink.setVisible(certification);
-			}
-		}
-		if (efficiencyStatementsLink != null && userCourseEnv != null && !userCourseEnv.isParticipant()) {
-			efficiencyStatementsLink.setVisible(false);
 		}
 		
 		if (!isGuestOnly && !assessmentLock) {
@@ -941,16 +926,6 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im
 	public void event(Event event) {
 		if(event instanceof CourseConfigEvent) {				
 			processCourseConfigEvent((CourseConfigEvent)event);
-		} else if (event instanceof AssessmentChangedEvent) {
-			String assessmentChangeType = event.getCommand();
-			AssessmentChangedEvent ace = (AssessmentChangedEvent) event;
-			if(!isGuestOnly && efficiencyStatementsLink != null && ace.getIdentityKey().equals(getIdentity().getKey())
-					&& assessmentChangeType.equals(AssessmentChangedEvent.TYPE_EFFICIENCY_STATEMENT_CHANGED)) {
-				// update tools, maybe efficiency statement link has changed
-				UserCourseEnvironmentImpl uce = getUserCourseEnvironment();
-				boolean certification = uce.hasEfficiencyStatementOrCertificate(true);
-				efficiencyStatementsLink.setEnabled(certification);
-			}
 		} else if (event instanceof EntryChangedEvent ) {
 			EntryChangedEvent repoEvent = (EntryChangedEvent) event;
 			if (repoEvent.isMe(getRepositoryEntry())) {
@@ -1735,7 +1710,7 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im
 			listenTo(identityOverviewCtrl);
 			pushController(ureq, translate("command.learning.path"), identityOverviewCtrl);
 			currentToolCtr = identityOverviewCtrl;
-			setActiveTool(efficiencyStatementsLink);
+			setActiveTool(learninPathLink);
 		} else {
 			delayedClose = Delayed.learningPath;
 		}
@@ -2067,11 +2042,6 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im
 					ICourse course = CourseFactory.loadCourse(getRepositoryEntry());
 					CourseConfig cc = course.getCourseEnvironment().getCourseConfig();
 					efficiencyStatementsLink.setVisible(cc.isEfficencyStatementEnabled() || cc.isCertificateEnabled());
-					if(cc.isEfficencyStatementEnabled() || cc.isCertificateEnabled()) {
-						UserCourseEnvironmentImpl uce = getUserCourseEnvironment();
-						boolean certification = uce.hasEfficiencyStatementOrCertificate(false);
-						efficiencyStatementsLink.setEnabled(certification);
-					}
 					toolbarPanel.setDirty(true);
 				}
 				break;
-- 
GitLab