Skip to content

Commit 4bf16bf

Browse files
marktriggsern
authored andcommitted
SAK-33335 When importing from site, treat Gradebook and GradebookNG as synonyms (sakaiproject#5237)
If the target site has GradebookNG while the source site Gradebook Classic (or vice versa) we'll still import one into the other.
1 parent aec6178 commit 4bf16bf

File tree

3 files changed

+50
-5
lines changed

3 files changed

+50
-5
lines changed

site-manage/site-manage-tool/tool/pom.xml

+4
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@
101101
<groupId>commons-io</groupId>
102102
<artifactId>commons-io</artifactId>
103103
</dependency>
104+
<dependency>
105+
<groupId>org.apache.commons</groupId>
106+
<artifactId>commons-lang3</artifactId>
107+
</dependency>
104108
<dependency>
105109
<groupId>org.jmock</groupId>
106110
<artifactId>jmock-legacy</artifactId>

site-manage/site-manage-tool/tool/src/java/org/sakaiproject/site/tool/SiteAction.java

+39-2
Original file line numberDiff line numberDiff line change
@@ -2893,6 +2893,36 @@ public int compare(String s1, String s2) {
28932893
context.put("selectedTools", selectedTools);
28942894
}
28952895

2896+
// SAK-33335
2897+
//
2898+
// If the old site has either Gradebook or GradebookNG,
2899+
// and the new site has either Gradebook or GradebookNG,
2900+
// we should allow the gradebook to import (even if the
2901+
// old site used Gradebook and the new site uses
2902+
// GradebookNG, or vice versa).
2903+
List<String> targetSiteToolIds = selectedTools;
2904+
List<String> sourceSiteToolIds = allImportableToolIdsInOriginalSites;
2905+
2906+
List<String> gradebooksInTargetSite = new ArrayList<String>();
2907+
for (String toolId : targetSiteToolIds) {
2908+
if (org.apache.commons.lang3.StringUtils.equalsAny(toolId, "sakai.gradebook.tool", "sakai.gradebookng")) {
2909+
gradebooksInTargetSite.add(toolId);
2910+
}
2911+
}
2912+
2913+
if (gradebooksInTargetSite.size() == 1) {
2914+
// If we only have one of the Gradebooks, we
2915+
// need to make sure that it's represented in
2916+
// the source site (so we get the option to
2917+
// import)
2918+
String targetSiteGradebook = gradebooksInTargetSite.get(0);
2919+
2920+
if (!sourceSiteToolIds.contains(targetSiteGradebook)) {
2921+
sourceSiteToolIds.add(targetSiteGradebook);
2922+
}
2923+
}
2924+
2925+
28962926
//get all known tool names from the sites selected to import from (importSites) and the selectedTools list
28972927
Map<String,Set<String>> toolNames = this.getToolNames(selectedTools, importSites);
28982928

@@ -15479,11 +15509,18 @@ private Map<String, Set<String>> getSiteImportToolsWithContent(List<Site> sites,
1547915509
Set<String> toolsWithContent = new HashSet<>();
1548015510

1548115511
for(String toolId: toolIds) {
15482-
if(site.getToolForCommonId(toolId) != null) {
15483-
15512+
if(site.getToolForCommonId(toolId) != null ||
15513+
(org.apache.commons.lang3.StringUtils.equalsAny(toolId, "sakai.gradebook.tool", "sakai.gradebookng") &&
15514+
(site.getToolForCommonId("sakai.gradebook.tool") != null || site.getToolForCommonId("sakai.gradebookng") != null)))
15515+
{
1548415516
//check the tool has content
1548515517
if(hasContent(toolId, site.getId())) {
1548615518
toolsWithContent.add(toolId);
15519+
} else {
15520+
if (org.apache.commons.lang3.StringUtils.equalsAny(toolId, "sakai.gradebook.tool", "sakai.gradebookng") &&
15521+
hasContent("sakai.gradebook.tool", site.getId()) || hasContent("sakai.gradebookng", site.getId())) {
15522+
toolsWithContent.add(toolId);
15523+
}
1548715524
}
1548815525
}
1548915526
}

site-manage/site-manage-tool/tool/src/webapp/vm/sitesetup/chef_site-importSites.vm

+7-3
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,19 @@
108108
#foreach ($pageTool in $pageTools)
109109
#if ($pageTool.getTool().getId() == $toolId)
110110
#set($toolFound = true)
111+
#elseif (($toolId == "sakai.gradebook.tool" || $toolId == "sakai.gradebookng") && ($pageTool.getTool().getId() == "sakai.gradebook.tool" || $pageTool.getTool().getId() == "sakai.gradebookng"))
112+
#set($toolFound = true)
111113
#end
112114
#end
113115
#end
114116

115117
#set ($toolsWithContent = $!siteToolsWithContent.get($site.getId()))
116-
#if(!$toolsWithContent.contains($toolId))
118+
#if(($toolId == "sakai.gradebook.tool" || $toolId == "sakai.gradebookng") && ($toolsWithContent.contains("sakai.gradebook.tool") || $toolsWithContent.contains("sakai.gradebookng")))
119+
## Take the default
120+
#elseif(!$toolsWithContent.contains($toolId))
117121
#set($toolFound = false)
118-
#end
119-
122+
#end
123+
120124
#if ($toolFound)
121125
<input type="checkbox" id="toolSite$toolCount$siteCount" name="$toolId" value="$site.Id" #if($!selectedSites.contains($site.Id))checked="checked"#end />
122126
<label class="skip" for="toolSite$toolCount$siteCount">$tlang.getString('import.choose.label1') $toolTitle $tlang.getString('import.choose.label2') $validator.escapeHtml($site.getTitle())</label>

0 commit comments

Comments
 (0)