diff --git a/assignment/api/src/java/org/sakaiproject/assignment/api/AssignmentService.java b/assignment/api/src/java/org/sakaiproject/assignment/api/AssignmentService.java
index a6fb0acfbb2a..a870272ebebc 100644
--- a/assignment/api/src/java/org/sakaiproject/assignment/api/AssignmentService.java
+++ b/assignment/api/src/java/org/sakaiproject/assignment/api/AssignmentService.java
@@ -640,4 +640,10 @@ public String getDeepLinkWithPermissions(String context, String assignmentId, bo
void resetAssignment(Assignment assignment);
void postReviewableSubmissonAttachments(String submissionId);
+
+ /**
+ * This will return the internationalized title of the tool.
+ * This is used when creating a new gradebook item.
+ */
+ public String getToolTitle();
}
diff --git a/assignment/api/src/java/org/sakaiproject/assignment/api/AssignmentServiceConstants.java b/assignment/api/src/java/org/sakaiproject/assignment/api/AssignmentServiceConstants.java
index f861dce81111..1561a5d79939 100644
--- a/assignment/api/src/java/org/sakaiproject/assignment/api/AssignmentServiceConstants.java
+++ b/assignment/api/src/java/org/sakaiproject/assignment/api/AssignmentServiceConstants.java
@@ -28,6 +28,7 @@
public final class AssignmentServiceConstants {
+ public static final String ASSIGNMENT_TOOL_ID = "sakai.assignment.grades";
/**
* The type string for this application: should not change over time as it may be stored in various parts of persistent entities.
*/
diff --git a/assignment/impl/src/java/org/sakaiproject/assignment/impl/AssignmentGradeInfoProvider.java b/assignment/impl/src/java/org/sakaiproject/assignment/impl/AssignmentGradeInfoProvider.java
index 8a05c83cefb7..16984e8716fb 100644
--- a/assignment/impl/src/java/org/sakaiproject/assignment/impl/AssignmentGradeInfoProvider.java
+++ b/assignment/impl/src/java/org/sakaiproject/assignment/impl/AssignmentGradeInfoProvider.java
@@ -106,7 +106,10 @@ private Assignment getAssignment(String id) {
return assignment;
}
- public boolean isAssignmentDefined(String id) {
+ public boolean isAssignmentDefined(String externalAppName, String id) {
+ if (!externalAppName.equals(getAppKey()) && !externalAppName.equals(assignmentService.getToolTitle())) {
+ return false;
+ }
return getAssignment(id) != null;
}
diff --git a/assignment/impl/src/java/org/sakaiproject/assignment/impl/AssignmentServiceImpl.java b/assignment/impl/src/java/org/sakaiproject/assignment/impl/AssignmentServiceImpl.java
index e20379a5e5aa..00803a080746 100644
--- a/assignment/impl/src/java/org/sakaiproject/assignment/impl/AssignmentServiceImpl.java
+++ b/assignment/impl/src/java/org/sakaiproject/assignment/impl/AssignmentServiceImpl.java
@@ -81,6 +81,7 @@
import org.sakaiproject.taggable.api.TaggingProvider;
import org.sakaiproject.time.api.TimeService;
import org.sakaiproject.tool.api.SessionManager;
+import org.sakaiproject.tool.api.Tool;
import org.sakaiproject.tool.api.ToolManager;
import org.sakaiproject.user.api.CandidateDetailProvider;
import org.sakaiproject.user.api.User;
@@ -169,6 +170,19 @@ public String getLabel() {
return "assignment";
}
+ @Override
+ public String getToolTitle() {
+ Tool tool = toolManager.getTool(AssignmentServiceConstants.ASSIGNMENT_TOOL_ID);
+ String toolTitle = null;
+
+ if (tool == null)
+ toolTitle = "Assignments";
+ else
+ toolTitle = tool.getTitle();
+
+ return toolTitle;
+ }
+
@Override
public boolean willArchiveMerge() {
return true;
diff --git a/assignment/impl/src/test/org/sakaiproject/assignment/impl/AssignmentServiceTest.java b/assignment/impl/src/test/org/sakaiproject/assignment/impl/AssignmentServiceTest.java
index f08de5fab197..cf72cd6f0f5a 100644
--- a/assignment/impl/src/test/org/sakaiproject/assignment/impl/AssignmentServiceTest.java
+++ b/assignment/impl/src/test/org/sakaiproject/assignment/impl/AssignmentServiceTest.java
@@ -105,6 +105,11 @@ public void AssignmentServiceIsValid() {
Assert.assertNotNull(assignmentService);
}
+ @Test
+ public void checkAssignmentToolTitle() {
+ Assert.assertNotNull(assignmentService.getToolTitle());
+ }
+
@Test
public void addAndGetAssignment() {
String userId = UUID.randomUUID().toString();
diff --git a/assignment/impl/src/webapp/WEB-INF/components.xml b/assignment/impl/src/webapp/WEB-INF/components.xml
index 472ef7ac7b87..1a7517c654e7 100644
--- a/assignment/impl/src/webapp/WEB-INF/components.xml
+++ b/assignment/impl/src/webapp/WEB-INF/components.xml
@@ -42,6 +42,7 @@
+
diff --git a/assignment/tool/src/java/org/sakaiproject/assignment/tool/AssignmentAction.java b/assignment/tool/src/java/org/sakaiproject/assignment/tool/AssignmentAction.java
index 15295e785f34..54b115bf45e2 100644
--- a/assignment/tool/src/java/org/sakaiproject/assignment/tool/AssignmentAction.java
+++ b/assignment/tool/src/java/org/sakaiproject/assignment/tool/AssignmentAction.java
@@ -2775,7 +2775,7 @@ private void currentAssignmentGradebookIntegrationIntoContext(Context context, S
// filtering out those from Samigo
for (Iterator i = gradebookAssignments.iterator(); i.hasNext(); ) {
org.sakaiproject.service.gradebook.shared.Assignment gAssignment = (org.sakaiproject.service.gradebook.shared.Assignment) i.next();
- if (!gAssignment.isExternallyMaintained() || gAssignment.isExternallyMaintained() && gAssignment.getExternalAppName().equals(getToolTitle())) {
+ if (!gAssignment.isExternallyMaintained() || gAssignment.isExternallyMaintained() && gAssignment.getExternalAppName().equals(assignmentService.getToolTitle())) {
gradebookAssignmentsExceptSamigo.add(gAssignment);
// gradebook item has been associated or not
@@ -4751,22 +4751,6 @@ private String build_instructor_download_upload_all(VelocityPortlet portlet, Con
} // build_instructor_upload_all
- /**
- * * Retrieve tool title from Tool configuration file or use default
- * * (This should return i18n version of tool title if available)
- **/
- private String getToolTitle() {
- Tool tool = toolManager.getTool(ASSIGNMENT_TOOL_ID);
- String toolTitle = null;
-
- if (tool == null)
- toolTitle = "Assignments";
- else
- toolTitle = tool.getTitle();
-
- return toolTitle;
- }
-
/**
* integration with gradebook
*
@@ -4789,7 +4773,7 @@ private void integrateGradebook(SessionState state, String assignmentRef, String
// b. if Gradebook exists, just call addExternal and removeExternal and swallow any exception. The
// exception are indication that the assessment is already in the Gradebook or there is nothing
// to remove.
- String assignmentToolTitle = getToolTitle();
+ String assignmentToolTitle = assignmentService.getToolTitle();
String gradebookUid = toolManager.getCurrentPlacement().getContext();
if (gradebookService.isGradebookDefined(gradebookUid) && gradebookService.currentUserHasGradingPerm(gradebookUid)) {
diff --git a/edu-services/gradebook-service/api/src/java/org/sakaiproject/service/gradebook/shared/ExternalAssignmentProvider.java b/edu-services/gradebook-service/api/src/java/org/sakaiproject/service/gradebook/shared/ExternalAssignmentProvider.java
index 415667adfcb1..b4df4b110333 100644
--- a/edu-services/gradebook-service/api/src/java/org/sakaiproject/service/gradebook/shared/ExternalAssignmentProvider.java
+++ b/edu-services/gradebook-service/api/src/java/org/sakaiproject/service/gradebook/shared/ExternalAssignmentProvider.java
@@ -37,15 +37,12 @@ public interface ExternalAssignmentProvider {
/**
* Check if an assignment/assessment exists with the given identifier.
- * This will be in the form that is supplied to the Gradebook, so it
- * will need to be parsed. If the prefix is not recognized as matching
- * for this service, false is expected to be returned, even if there
- * may be an assignment with the prefixed id.
- * Note that this may seem strange but it is required because services
- * do not currently register their prefixes with the Gradebook, so the
- * external IDs are completely opaque and do not identify their source.
+ * If the externalAppName is not the tool's responsibility or if the
+ * id is not recognized as matching
+ * for this service, false is expected to be returned.
+ * @param externalId
*/
- boolean isAssignmentDefined(String id);
+ boolean isAssignmentDefined(String externalAppName, String externalId);
/**
* Check if the given assignment is grouped.
diff --git a/edu-services/gradebook-service/impl/src/java/org/sakaiproject/component/gradebook/GradebookExternalAssessmentServiceImpl.java b/edu-services/gradebook-service/impl/src/java/org/sakaiproject/component/gradebook/GradebookExternalAssessmentServiceImpl.java
index 9556a51f753a..62c857a63da0 100644
--- a/edu-services/gradebook-service/impl/src/java/org/sakaiproject/component/gradebook/GradebookExternalAssessmentServiceImpl.java
+++ b/edu-services/gradebook-service/impl/src/java/org/sakaiproject/component/gradebook/GradebookExternalAssessmentServiceImpl.java
@@ -517,7 +517,7 @@ public boolean isExternalAssignmentGrouped(String gradebookUid, String externalI
log.info("No assignment found for external assignment check: gradebookUid="+gradebookUid+", externalId="+externalId);
} else {
for (ExternalAssignmentProvider provider : getExternalAssignmentProviders().values()) {
- if (provider.isAssignmentDefined(externalId)) {
+ if (provider.isAssignmentDefined(assignment.getExternalAppName(), externalId)) {
providerResponded = true;
result = result || provider.isAssignmentGrouped(externalId);
}
@@ -546,7 +546,7 @@ public boolean isExternalAssignmentVisible(String gradebookUid, String externalI
log.info("No assignment found for external assignment check: gradebookUid="+gradebookUid+", externalId="+externalId);
} else {
for (ExternalAssignmentProvider provider : getExternalAssignmentProviders().values()) {
- if (provider.isAssignmentDefined(externalId)) {
+ if (provider.isAssignmentDefined(assignment.getExternalAppName(), externalId)) {
providerResponded = true;
result = result || provider.isAssignmentVisible(externalId, userId);
}
diff --git a/samigo/samigo-services/src/java/org/sakaiproject/tool/assessment/integration/helper/ifc/GradebookServiceHelper.java b/samigo/samigo-services/src/java/org/sakaiproject/tool/assessment/integration/helper/ifc/GradebookServiceHelper.java
index 7ef987be4619..803975547a53 100644
--- a/samigo/samigo-services/src/java/org/sakaiproject/tool/assessment/integration/helper/ifc/GradebookServiceHelper.java
+++ b/samigo/samigo-services/src/java/org/sakaiproject/tool/assessment/integration/helper/ifc/GradebookServiceHelper.java
@@ -68,4 +68,6 @@ public void updateExternalAssessmentComment(Long publishedAssessmentId, String s
public Long getExternalAssessmentCategoryId(String gradebookUId,
String publishedAssessmentId, GradebookExternalAssessmentService g);
+
+ public String getAppName();
}
diff --git a/samigo/samigo-services/src/java/org/sakaiproject/tool/assessment/integration/helper/integrated/AssessmentGradeInfoProvider.java b/samigo/samigo-services/src/java/org/sakaiproject/tool/assessment/integration/helper/integrated/AssessmentGradeInfoProvider.java
index 24c1ca4b71e4..d30c5861a625 100644
--- a/samigo/samigo-services/src/java/org/sakaiproject/tool/assessment/integration/helper/integrated/AssessmentGradeInfoProvider.java
+++ b/samigo/samigo-services/src/java/org/sakaiproject/tool/assessment/integration/helper/integrated/AssessmentGradeInfoProvider.java
@@ -50,6 +50,8 @@
import org.sakaiproject.tool.assessment.data.dao.authz.AuthorizationData;
import org.sakaiproject.tool.assessment.data.ifc.assessment.PublishedAssessmentIfc;
import org.sakaiproject.tool.assessment.facade.PublishedAssessmentFacade;
+import org.sakaiproject.tool.assessment.integration.context.IntegrationContextFactory;
+import org.sakaiproject.tool.assessment.integration.helper.ifc.GradebookServiceHelper;
import org.sakaiproject.tool.assessment.services.PersistenceService;
import org.sakaiproject.tool.assessment.services.assessment.PublishedAssessmentService;
import org.sakaiproject.user.api.UserDirectoryService;
@@ -110,15 +112,24 @@ private PublishedAssessmentIfc getPublishedAssessment(String id) {
return a;
}
- public boolean isAssignmentDefined(String id) {
- // SAM-3068 avoid looking up another tool's id
- if (!StringUtils.isNumeric(id)) {
+ public boolean isAssignmentDefined(String externalAppName, String id) {
+ // SAM-3068 avoid looking up another tool's id
+ if (!StringUtils.isNumeric(id)) {
return false;
- }
+ }
+
+ GradebookServiceHelper gbsHelper = IntegrationContextFactory.getInstance().getGradebookServiceHelper();
+ String toolName = gbsHelper.getAppName();
+ if (!StringUtils.equals(externalAppName, getAppKey()) && !StringUtils.equals(externalAppName, toolName)) {
+ return false;
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("Samigo provider isAssignmentDefined: " + id);
+ }
- log.debug("Samigo provider isAssignmentDefined: {}", id);
- Long longId = Long.parseLong(id);
- return PersistenceService.getInstance().getPublishedAssessmentFacadeQueries().isPublishedAssessmentIdValid(longId);
+ Long longId = Long.parseLong(id);
+ return PersistenceService.getInstance().getPublishedAssessmentFacadeQueries().isPublishedAssessmentIdValid(longId);
}
diff --git a/samigo/samigo-services/src/java/org/sakaiproject/tool/assessment/integration/helper/integrated/GradebookServiceHelperImpl.java b/samigo/samigo-services/src/java/org/sakaiproject/tool/assessment/integration/helper/integrated/GradebookServiceHelperImpl.java
index 192ab5fd33b2..f2f9553c906b 100644
--- a/samigo/samigo-services/src/java/org/sakaiproject/tool/assessment/integration/helper/integrated/GradebookServiceHelperImpl.java
+++ b/samigo/samigo-services/src/java/org/sakaiproject/tool/assessment/integration/helper/integrated/GradebookServiceHelperImpl.java
@@ -154,6 +154,26 @@ public boolean isAssignmentDefined(String assessmentTitle,
String gradebookUId = GradebookFacade.getGradebookUId();
return g.isAssignmentDefined(gradebookUId, assessmentTitle);
}
+
+ public String getAppName()
+ {
+ // Tool name code added by Josh Holtzman
+ Tool tool = ToolManager.getTool("sakai.samigo");
+ String appName = null;
+
+ if (tool == null)
+ {
+ log.warn(
+ "could not get tool named sakai.samigo, " +
+ "so we're going to assume we're called 'Tests & Quizzes'");
+ appName = "Tests & Quizzes";
+ }
+ else
+ {
+ appName = tool.getTitle();
+ }
+ return appName;
+ }
/**
* Add a published assessment to gradebook.
@@ -181,23 +201,6 @@ public boolean addToGradebook(PublishedAssessmentData publishedAssessment, Long
// g.isGradebookDefined(gradebookUId));
if (g.isGradebookDefined(gradebookUId))
{
-
- // Tool name code added by Josh Holtzman
- Tool tool = ToolManager.getTool("sakai.samigo");
- String appName = null;
-
- if (tool == null)
- {
- log.warn(
- "could not get tool named sakai.samigo, " +
- "so we're going to assume we're called 'Tests & Quizzes'");
- appName = "Tests & Quizzes";
- }
- else
- {
- appName = tool.getTitle();
- }
-
String title = StringEscapeUtils.unescapeHtml(publishedAssessment.getTitle());
if(!g.isAssignmentDefined(gradebookUId, title))
{
@@ -208,7 +211,7 @@ public boolean addToGradebook(PublishedAssessmentData publishedAssessment, Long
publishedAssessment.getTotalScore().doubleValue(),
publishedAssessment.getAssessmentAccessControl().
getDueDate(),
- appName, // Use the app name from sakai
+ getAppName(), // Use the app name from sakai
false,
categoryId);
added = true;