Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In your call to the external tool's authoring page, you will need to add a parameter that tells the external server the return or save-content url. That way when the user clicks save on the external tool, they can be returned to LAMS to save the tool. The external tool should add a extra parameter for the external content id, so it can be saved in the LAMS content instance and used for future references to this tool content. 

Code Block

/**
	 * Default method when no dispatch parameter is specified. It is expected
	 * that the parameter <code>toolContentID</code> will be passed in. This
	 * will be used to retrieve content for this tool.
	 *
	 */
	protected ActionForward unspecified(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {

		// Extract toolContentID, contentFolderID and ToolAccessMode from parameters.
		Long toolContentID = new Long(WebUtil.readLongParam(request,AttributeNames.PARAM_TOOL_CONTENT_ID));
		String contentFolderID = WebUtil.readStrParam(request,AttributeNames.PARAM_CONTENT_FOLDER_ID);
		ToolAccessMode mode = WebUtil.readToolAccessModeParam(request, KEY_MODE,true);

		// set up mdlForumService
		if (mdlForumService == null) {
			mdlForumService = MdlForumServiceProxy.getMdlForumService(this.getServlet().getServletContext());
		}

		// retrieving MdlForum with given toolContentID
		// if is a new instance, customCSV should be passed, and used for the course url, otherwise the saved value should be used
		MdlForum mdlForum = mdlForumService.getMdlForumByContentId(toolContentID);

		// Getting the custom csv from the request
		String customCSV = WebUtil.readStrParam(request, "customCSV", true);
		String userFromCSV = null;
		String courseFromCSV = null;
		String sectionFromCSV = null;
		if(customCSV==null && mdlForum==null)
		{
			logger.error("CustomCSV required if mdlForum is null");
			throw new ToolException("CustomCSV required if mdlForum is null");
		}
		else if (customCSV!=null)
		{
			String splitCSV[] = customCSV.split(",");
			if (splitCSV.length != 3)
			{
				logger.error("mdlForum tool customCSV not in required (user,course,courseURL) form: " + customCSV);
				throw new ToolException("mdlForum tool cusomCSV not in required (user,course,courseURL) form: " + customCSV);
			}
			else
			{
				userFromCSV = splitCSV[0];
				courseFromCSV = splitCSV[1];
				sectionFromCSV = splitCSV[2];
			}
		}

		if (mdlForum == null)
		{
			mdlForum = mdlForumService.copyDefaultContent(toolContentID);
			mdlForum.setExtUsername(userFromCSV);
			mdlForum.setExtCourseId(courseFromCSV);
			mdlForum.setExtSection(sectionFromCSV);
			mdlForum.setCreateDate(new Date());
		}


		if (mode != null && mode.isTeacher()) {
			// Set the defineLater flag so that learners cannot use content
			// while we
			// are editing. This flag is released when updateContent is called.
			mdlForum.setDefineLater(true);
			mdlForumService.saveOrUpdateMdlForum(mdlForum);
		}

		// if no external content id, open the mdl author page, otherwise, open the edit page
		try{

			// If the mdlForum has a saved course url, use it, otherwise use the one giving in the request in customCSV
			//String courseUrlToBeUsed = (mdlForum.getExtCourseUrl() != null) ? mdlForum.getExtCourseUrl() : courseUrlFromCSV;

			String responseUrl = mdlForumService.getConfigItem(MdlForumConfigItem.KEY_EXTERNAL_SERVER_URL).getConfigValue();
			responseUrl += RELATIVE_MOODLE_AUTHOR_URL;
			String returnUpdateUrl = URLEncoder.encode(
					TOOL_APP_URL + "/authoring.do?dispatch=updateContent" + "&"
					+AttributeNames.PARAM_TOOL_CONTENT_ID + "=" + toolContentID.toString(), "UTF8"
					);
			responseUrl +=  "&lamsUpdateURL=" + returnUpdateUrl;


			if (mdlForum.getExtSection() != null)
			{
				responseUrl +=  "&section=" + mdlForum.getExtSection();
			}
			else
			{
				responseUrl +=  "&section=" + sectionFromCSV;
			}

			if (mdlForum.getExtToolContentId()!=null)
			{
				responseUrl += "&update=" + mdlForum.getExtToolContentId().toString();
			}
			else
			{
				responseUrl += "&add=forum";
			}

			if (mdlForum.getExtCourseId() != null)
			{
				responseUrl +="&course=" + mdlForum.getExtCourseId();
			}
			else
			{
				responseUrl +="&course=" + courseFromCSV;
			}

			log.debug("Sending to moodle forum edit page: " + responseUrl);

			response.sendRedirect(responseUrl);
		}
		catch (Exception e)
		{
			log.error("Could not redirect to mdl forum authoring", e);
		}
		return null;
	}

Export Learning Design

How to implement export and import tool contentTo export a LAMS learning design, the authoring tool content needs to be serialised into a file so it can be imported again later in a different context. LAMS will go through a sequence and call each tool to output its tool content. This is made a bit more complicated for tool adapter tools, since they do not have the content stored locally, they only have an external content id. When the call is made to export the tool adapter content they have to call the external tool adapter servlet to request the content in a server to server call.

...