Skip to content

Commit

Permalink
SAK-32440 - Site Info Show LTI Config When Requested (sakaiproject#4623)
Browse files Browse the repository at this point in the history
  • Loading branch information
csev authored Jul 20, 2017
1 parent 35ba55e commit be0c508
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public interface LTIService {
"allowsecret:radio:label=bl_allowsecret:choices=disallow,allow:only=lti1",
"frameheight:integer:label=bl_frameheight",
"allowframeheight:radio:label=bl_allowframeheight:choices=disallow,allow",
"siteinfoconfig:radio:label=bl_siteinfoconfig:choices=bypass,config",
"privacy:header:fields=sendname,sendemailaddr",
"sendname:checkbox:label=bl_sendname",
"sendemailaddr:checkbox:label=bl_sendemailaddr",
Expand Down Expand Up @@ -255,6 +256,7 @@ public interface LTIService {
String LTI_TOOL_PROXY_BINDING = "tool_proxy_binding";
// End of BLTI-230 - LTI 2.0
String LTI_PL_LAUNCH = "pl_launch";
String LTI_SITEINFOCONFIG = "siteinfoconfig";
String LTI_PL_LINKSELECTION = "pl_linkselection";
String LTI_PL_FILEITEM = "pl_fileitem";
String LTI_PL_IMPORTITEM = "pl_importitem";
Expand Down
3 changes: 3 additions & 0 deletions basiclti/basiclti-impl/src/bundle/ltiservice.properties
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ bl_frameheight=Frame Height
bl_allowframeheight=Allow frame height to be changed
bl_allowframeheight_allow=Allow
bl_allowframeheight_disallow=Do not allow
bl_siteinfoconfig=Configuration dialog when tool is selected
bl_siteinfoconfig_bypass=Bypass configuration dialog
bl_siteinfoconfig_config=Show configuration dialog
bl_newpage=Launch in Popup
bl_newpage_off=Never launch in Popup
bl_newpage_on=Always launch in Popup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1336,6 +1336,8 @@ public String buildMainPanelContext(VelocityPortlet portlet,
addIntoStateVisitedTemplates(state, indexString);

template = buildContextForTemplate(getPrevVisitedTemplate(state), Integer.valueOf(indexString), portlet, context, data, state);

M_log.debug("buildMainPanelContext template={}", template);
return template;

} // buildMainPanelContext
Expand Down Expand Up @@ -1485,7 +1487,8 @@ private String buildContextForTemplate(String preIndex, int index, VelocityPortl

List unJoinableSiteTypes = (List) state.getAttribute(STATE_DISABLE_JOINABLE_SITE_TYPE);


M_log.debug("buildContextForTemplate index={}", index);

switch (index) {
case 0:
/*
Expand Down Expand Up @@ -2896,10 +2899,15 @@ public int compare(JoinableGroup g1, JoinableGroup g2){
if (state.getAttribute(STATE_LTITOOL_SELECTED_LIST) != null)
{
HashMap<String, Map<String, Object>> currentLtiTools = (HashMap<String, Map<String, Object>>) state.getAttribute(STATE_LTITOOL_SELECTED_LIST);
HashMap<String, Map<String, Object>> dialogLtiTools = new HashMap<String, Map<String, Object>> ();

for (Map.Entry<String, Map<String, Object>> entry : currentLtiTools.entrySet() ) {
Map<String, Object> toolMap = entry.getValue();
String toolId = entry.getKey();
// get the proper html for tool input
// get the configuration html for tool is post-add configuration has been requested (by Laura)
String showDialog = toolMap.get(LTIService.LTI_SITEINFOCONFIG).toString();
if ( ! "1".equals(showDialog) ) continue;

String ltiToolId = toolMap.get("id").toString();
String[] contentToolModel=m_ltiService.getContentModel(Long.valueOf(ltiToolId), site.getId());
// attach the ltiToolId to each model attribute, so that we could have the tool configuration page for multiple tools
Expand All @@ -2910,9 +2918,10 @@ public int compare(JoinableGroup g1, JoinableGroup g2){
Map<String, Object> ltiTool = m_ltiService.getTool(Long.valueOf(ltiToolId), site.getId());
String formInput=m_ltiService.formInput(ltiTool, contentToolModel);
toolMap.put("formInput", formInput);
currentLtiTools.put(ltiToolId, toolMap);
// Add the entry to the tools that need a dialog
dialogLtiTools.put(ltiToolId, toolMap);
}
context.put("ltiTools", currentLtiTools);
context.put("ltiTools", dialogLtiTools);
context.put("ltiService", m_ltiService);
context.put("oldLtiTools", state.getAttribute(STATE_LTITOOL_EXISTING_SELECTED_LIST));
}
Expand Down Expand Up @@ -6650,6 +6659,7 @@ public void doContinue(RunData data) {
String direction = "continue";
String option = params.getString("option");

M_log.debug("doContinue index={} option={}", index, option);
actionForTemplate(direction, index, params, state, data);
if (state.getAttribute(STATE_MESSAGE) == null) {
if (index == 36 && ("add").equals(option)) {
Expand Down Expand Up @@ -9325,6 +9335,8 @@ private void actionForTemplate(String direction, int index,
// SAK-16600 change to new template for tool editing
if (index==3) { index= 4;}

M_log.debug("actionForTemplate index={} direction={}", index, direction);

switch (index) {
case 0:
/*
Expand Down Expand Up @@ -11662,7 +11674,7 @@ private void getFeatures(ParameterParser params, SessionState state, String cont
boolean goToToolConfigPage = false;
boolean homeSelected = false;
// lti tool selection
boolean ltiToolSelected = false;
boolean ltiToolNeedsConfig = false;

// Add new pages and tools, if any
if (params.getStrings("selectedTools") == null && params.getStrings("selectedLtiTools") == null) {
Expand All @@ -11682,22 +11694,27 @@ private void getFeatures(ParameterParser params, SessionState state, String cont
else if (toolId.startsWith(LTITOOL_ID_PREFIX))
{
String ltiToolId = toolId.substring(LTITOOL_ID_PREFIX.length());
// whether there is any lti tool been selected
Map<String,Object> toolMap = ltiTools.get(ltiToolId);
if ( toolMap == null ) continue;

// Decide if any LTI tools need a configuration dialog
String showDialog = toolMap.get(LTIService.LTI_SITEINFOCONFIG).toString();
if (existingLtiIds == null)
{
ltiToolSelected = true;
ltiToolNeedsConfig = true;
}
else
{
if (!existingLtiIds.keySet().contains(ltiToolId))
if (!existingLtiIds.keySet().contains(ltiToolId) && "1".equals(showDialog))
{
// there are some new lti tool(s) selected
ltiToolSelected = true;
// there are some new lti tool(s) selected that need a configuration dialog
ltiToolNeedsConfig = true;
}
}


// add tool entry to list
ltiSelectedTools.put(ltiToolId, ltiTools.get(ltiToolId));
ltiSelectedTools.put(ltiToolId, toolMap);
}
else
{
Expand Down Expand Up @@ -11799,7 +11816,7 @@ else if ("sakai.mailbox".equals(toolId)) {
if (state.getAttribute(STATE_IMPORT) != null) {
// go to import tool page
state.setAttribute(STATE_TEMPLATE_INDEX, "27");
} else if (goToToolConfigPage || ltiToolSelected) {
} else if (goToToolConfigPage || ltiToolNeedsConfig) {
state.setAttribute(STATE_MULTIPLE_TOOL_INSTANCE_SELECTED, Boolean.valueOf(goToToolConfigPage));
// go to the configuration page for multiple instances of tools
state.setAttribute(STATE_TEMPLATE_INDEX, "26");
Expand Down

0 comments on commit be0c508

Please sign in to comment.