private void SetUpSubmitButtons(bool enableSubmitFiles, bool enableSubmit) { //Check if non e-learning and enable the appropriate button accordingly if (AssignmentProperties.RootActivityId == null) { slkButtonSubmitFiles.Visible = true; slkButtonSubmitFiles.Text = PageCulture.Resources.LobbySubmitFilesText; slkButtonSubmitFiles.ToolTip = PageCulture.Resources.LobbySubmitFilesToolTip; slkButtonSubmitFiles.ImageUrl = Constants.ImagePath + Constants.NewDocumentIcon; slkButtonSubmitFiles.AccessKey = PageCulture.Resources.LobbySubmitFilesAccessKey; slkButtonSubmitFiles.Enabled = enableSubmitFiles; if (enableSubmitFiles) { string url = string.Format(CultureInfo.InvariantCulture, "{0}{1}FilesUploadPage.aspx?fl=true&LearnerAssignmentId={2}&{3}={4}", SPWeb.Url, Constants.SlkUrlPath, LearnerAssignmentGuidId.ToString(), QueryStringKeys.Source, RawSourceUrl); slkButtonSubmitFiles.NavigateUrl = url; slkButtonSubmitFiles.Target = "_self"; } slkButtonSubmit.Visible = true; } else { slkButtonSubmitFiles.Visible = false; } slkButtonSubmit.Enabled = enableSubmit; }
[SuppressMessage("Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods")] // parameters are validated protected void AppendContentFrameDetails(LearningSession session, StringBuilder sb) { FramesetUtil.ValidateNonNullParameter("sb", sb); FramesetUtil.ValidateNonNullParameter("session", session); // The URL for attempt-based content frames is: // http://<...basicWebApp>/Content.aspx/<AssignmentView>/<LearnerAssignmentId>/otherdata/ // the otherdata depends on the view sb.Append(String.Format(CultureInfo.InvariantCulture, "/{0}", Convert.ToInt32(AssignmentView, NumberFormatInfo.InvariantInfo))); StoredLearningSession slsSession = session as StoredLearningSession; if (slsSession == null) { // Not attempt-based view } else { sb.AppendFormat("/{0}", LearnerAssignmentGuidId.ToString()); // In review & ra views, append the current activity id if ((slsSession.View == SessionView.Review) || (slsSession.View == SessionView.RandomAccess)) { sb.AppendFormat("/{0}", FramesetUtil.GetStringInvariant(slsSession.CurrentActivityId)); } } }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); try { // setting default title pageTitle.Text = PageCulture.Resources.LobbyBeginAssignmentText; pageTitleInTitlePage.Text = PageCulture.Resources.LobbyBeginAssignmentText; SetResourceText(); LearnerAssignmentState learnerAssignmentStatus = LearnerAssignmentProperties.Status.Value; startAssignment = (Request.QueryString[startQueryStringName] == "true"); if (AssignmentProperties.IsNonELearning) { HandleNonELearningAssignment(); } if (startAssignment && learnerAssignmentStatus == LearnerAssignmentState.NotStarted) { LearnerAssignmentProperties.Start(); learnerAssignmentStatus = LearnerAssignmentProperties.Status.Value; } ClientScript.RegisterClientScriptBlock(this.GetType(), "lblStatusValue", "var lblStatusValue = \"" + lblStatusValue.ClientID + "\";", true); StringBuilder clientScript = new StringBuilder(); string submittedJavascript = string.Format("slkSubmittedUrl = '{0}{1}SubmittedFiles.aspx?LearnerAssignmentId=';", SPWeb.Url, Constants.SlkUrlPath); clientScript.AppendLine(submittedJavascript); string sourceUrl = string.Format("slkSourceUrl = '&source={0}';", HttpUtility.UrlEncode(Page.Request.RawUrl)); clientScript.AppendLine(sourceUrl); ClientScript.RegisterClientScriptBlock(this.GetType(), "openSubmittedFiles", clientScript.ToString(), true); if (learnerAssignmentStatus == LearnerAssignmentState.Completed && AssignmentProperties.AutoReturn == true) { // assignment was probably changed to be "auto-return" after this learner submitted it; we'll // re-submit now to invoke the auto-return mechanism; note that we use // LearnerAssignmentState.Completed instead of LearnerAssignmentState.Final because // the latter would throw a security-related exception (learner's aren't allowed to move their // learner assignments into Final state) -- using Completed works because // SlkStore.ChangeLearnerAssignmentState performs auto-return even if the current state is // LearnerAssignmentState.Completed LearnerAssignmentProperties.Submit(); // Set the property to null so that it will refresh the next time it is referenced LearnerAssignmentProperties = null; } SetUpDisplayValues(learnerAssignmentStatus); SetUpForAssignmentState(learnerAssignmentStatus); tgrAutoReturn.Visible = AssignmentProperties.AutoReturn; contentPanel.Visible = true; } catch (InvalidOperationException ex) { SlkStore.LogException(ex); errorBanner.AddException(SlkStore, new SafeToDisplayException(PageCulture.Resources.LobbyInvalidLearnerAssignmentId, LearnerAssignmentGuidId.ToString())); contentPanel.Visible = false; } catch (ThreadAbortException) { // Calling Response.Redirect throws a ThreadAbortException which needs to be rethrown throw; } catch (Exception exception) { errorBanner.AddException(SlkStore, exception); contentPanel.Visible = false; } }
/// <summary> Generates the url to view the submitted files. </summary> private string GenerateUrlForAssignmentReview() { DropBoxManager manager = new DropBoxManager(AssignmentProperties); AssignmentFile[] assignmentFiles = manager.LastSubmittedFiles(true); if (assignmentFiles.Length != 1) { return(string.Format("{0}{1}SubmittedFiles.aspx?LearnerAssignmentId={2}", SPWeb.Url, Constants.SlkUrlPath, LearnerAssignmentGuidId.ToString())); } else { return(assignmentFiles[0].Url); } }
/// <summary> /// Send the non-elearning content to the response. Non-elearning content is any content other than /// scorm or lrm content. It is an error to call this method when the current learner assignment is elearning content. /// In some cases, this method will end the response. /// </summary> private void SendNonElearningContent() { // Get the cached learner assignment properties LearnerAssignmentProperties la = GetLearnerAssignment(); SharePointFileLocation spFileLocation; if (!SharePointFileLocation.TryParse(la.Assignment.Location, out spFileLocation)) { // location was not valid RegisterError(SlkFrameset.FRM_DocumentNotFoundTitleHtml, SlkFrameset.FRM_DocumentNotFound, false); return; } // Find the location of the document in the Sharepoint Document Library and go there string documentUrl = GetNonElearningDocumentUrl(spFileLocation); // Special case handling for HTML files: // * Launch directly from the document library, not from the Cache // * Add the LearnerAssignmentId to the Query portion of the URL so that we pass the learning context down to the content // This enables us to have more advanced behavior (CMI Tracking, scoring, completion status) for "Non-ELearning" documents. // It is a first step towards a more comprehensive strategy for adding educational workflow to all types of documents. if (documentUrl.EndsWith("html", StringComparison.OrdinalIgnoreCase) || documentUrl.EndsWith("htm", StringComparison.OrdinalIgnoreCase)) { string redirectUrl = String.Format("{0}?{1}={2}", documentUrl, FramesetQueryParameter.LearnerAssignmentId, LearnerAssignmentGuidId.ToString()); Response.Clear(); Response.Redirect(redirectUrl, true); // ends response } string framesetPath = GetFramesetPath(); Response.Clear(); using (CachedSharePointFile cachedFile = new CachedSharePointFile(SlkStore.SharePointCacheSettings, spFileLocation, true)) { // If the current request URL does not include the file name of the file, then this request is the first frameset rendering. // That means this will redirect to a URL that does include the filename of the file. This redirection allows the browser to // properly handle the content. if (String.IsNullOrEmpty(framesetPath)) { string redirectUrl = GetNonElearningFrameUrl(cachedFile.FileName); cachedFile.Dispose(); Response.Redirect(redirectUrl, true); // ends response } // This is the first actual access of the file. If it doesn't exist, the exception will be caught by the Page_load method. SetMimeType(cachedFile.FileName); // If this file is using IIS Compability mode, then we get the stream from the cached file and write it to the // response, otherwise, use TransmitFile. if (UseCompatibilityMode(cachedFile.FileName)) { WriteIisCompatibilityModeToResponse(cachedFile.GetFileStream()); } else { cachedFile.TransmitFile(Response); } } }