protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); try { SetResourceText(); LoadGradingList(); if (!pageHasErrors) { if (SPWeb.ID != AssignmentProperties.SPWebGuid) { Response.Redirect(SlkUtilities.UrlCombine(SPWeb.Url, Request.Path + "?" + Request.QueryString.ToString())); } AddReactivationCheck(); lblTitle.Text = Server.HtmlEncode(AssignmentProperties.Title); lblDescription.Text = SlkUtilities.ClickifyLinks(Server.HtmlEncode(AssignmentProperties.Description).Replace("\r\n", "<br />\r\n")); if (AssignmentProperties.PointsPossible.HasValue) { lblPointsValue.Text = AssignmentProperties.PointsPossible.Value.ToString(Constants.RoundTrip, NumberFormatInfo); } SPTimeZone timeZone = SPWeb.RegionalSettings.TimeZone; lblStartValue.Text = FormatDateForDisplay(timeZone.UTCToLocalTime(AssignmentProperties.StartDate)); if (AssignmentProperties.DueDate.HasValue) { lblDueValue.Text = FormatDateForDisplay(timeZone.UTCToLocalTime(AssignmentProperties.DueDate.Value)); } tblAutoReturn.Visible = AssignmentProperties.AutoReturn; tblAnswers.Visible = AssignmentProperties.ShowAnswersToLearners; tgrAutoReturn.Visible = tblAutoReturn.Visible || tblAnswers.Visible; } } catch (ThreadAbortException) { // make sure this exception isn't caught throw; } catch (Exception ex) { contentPanel.Visible = false; errorBanner.AddException(SlkStore, ex); } }
void WriteSummary(HtmlTextWriter htmlTextWriter, string urlQueryString) { htmlTextWriter.Write("<td height=\"100%\" style=\"height:100%; width :"); htmlTextWriter.Write(SummaryWidth.ToString(CultureInfo.InvariantCulture)); htmlTextWriter.Write("\">"); // Get the ServerRelativeUrl for QueryResultPage string urlString = SlkUtilities.UrlCombine(SPWeb.ServerRelativeUrl, Constants.SlkUrlPath, Constants.QuerySetPage); //Append the QueryString Values urlString += urlQueryString; WriteFrame(htmlTextWriter, urlString.ToString(), "_AlwpQuerySummary", false); htmlTextWriter.Write("</td>"); }
void AssignToSelf(bool useReferrerSource) { try { string source = null; if (useReferrerSource) { source = Request.UrlReferrer.ToString(); } else { source = SourceHidden.Value; } Guid learnerAssignmentGuidId = AssignmentProperties.CreateSelfAssignment(SlkStore, SPWeb, package.Location, OrganizationIndex); string url = SlkUtilities.UrlCombine(SPWeb.ServerRelativeUrl, Constants.SlkUrlPath, "Lobby.aspx"); url = String.Format(CultureInfo.InvariantCulture, "{0}?{1}={2}&{3}={4}", url, FramesetQueryParameter.LearnerAssignmentId, learnerAssignmentGuidId.ToString(), "Source", System.Web.HttpUtility.UrlEncode(source)); Response.Redirect(url, true); } catch (ThreadAbortException) { // Calling Response.Redirect throws a ThreadAbortException which will // flag an error in the next step if we don't do this. throw; } catch (SafeToDisplayException e) { errorBanner.Clear(); errorBanner.AddError(ErrorType.Error, e.Message); } catch (Exception ex) { contentPanel.Visible = false; errorBanner.AddException(SlkStore, ex); } }
private void SetUpAssignmentSiteLink() { // for the assignment site, if the user doesn't have permission to view it // we'll catch the exception and hide the row bool previousValue = SPSecurity.CatchAccessDeniedException; SPSecurity.CatchAccessDeniedException = false; try { using (SPSite assignmentSite = new SPSite(AssignmentProperties.SPSiteGuid, SPContext.Current.Site.Zone)) { using (SPWeb assignmentWeb = assignmentSite.OpenWeb(AssignmentProperties.SPWebGuid)) { // If the assignment is in a different SPWeb redirect to it. if (SPWeb.ID != assignmentWeb.ID) { Response.Redirect(SlkUtilities.UrlCombine(assignmentWeb.Url, Request.Path + "?" + Request.QueryString.ToString())); } lnkSite.Text = Server.HtmlEncode(assignmentWeb.Title); lnkSite.NavigateUrl = assignmentWeb.ServerRelativeUrl; } } } catch (UnauthorizedAccessException) { lblSiteValue.Text = PageCulture.Resources.LobbyInvalidSite; lblSiteValue.Visible = true; } catch (FileNotFoundException) { lblSiteValue.Text = PageCulture.Resources.LobbyInvalidSite; lblSiteValue.Visible = true; } finally { SPSecurity.CatchAccessDeniedException = previousValue; } }
private string GenerateRedirectUrl() { string redirectUrl; bool fromLobbyPage = (Request.QueryString["fl"] == "true"); if (fromLobbyPage) { string baseUrl = SlkUtilities.UrlCombine(SPWeb.ServerRelativeUrl, Constants.SlkUrlPath, "Lobby.aspx"); redirectUrl = string.Format("{0}?{1}={2}&{3}={4}", baseUrl, FramesetQueryParameter.LearnerAssignmentId, LearnerAssignmentGuid.ToString(), QueryStringKeys.Source, RawSourceUrl); } else { // From ALWP, return there redirectUrl = SourceUrl; if (string.IsNullOrEmpty(redirectUrl)) { redirectUrl = SPWeb.Url; } } return(redirectUrl); }
protected void slkButtonEdit_Click(object sender, EventArgs e) { try { SaveGradingList(SaveAction.SaveOnly); string url = SlkUtilities.UrlCombine(SPWeb.ServerRelativeUrl, Constants.SlkUrlPath, "AssignmentProperties.aspx"); url = String.Format(CultureInfo.InvariantCulture, "{0}?AssignmentId={1}", url, AssignmentId.ToString()); Response.Redirect(url, true); } catch (ThreadAbortException) { // Calling Response.Redirect throws a ThreadAbortException which will // flag an error in the next step if we don't do this. throw; } catch (Exception ex) { pageHasErrors = true; errorBanner.AddException(SlkStore, ex); } }
/// <summary> /// Get AssignmentListWebPart Properties and Renders Webpart /// </summary> /// <param name="htmlTextWriter">HtmlTextWriter</param> private void RenderAssignmentList(HtmlTextWriter htmlTextWriter) { int cols = DisplaySummary ? 2 : 1; //Set the QuerySetOverride Property DefaultQuerySetIfRequired(); //Validates the Alwp Properties ValidateAlwpProperties(); string observerRoleLearnerKey = GetLearnerKey(observerRoleLearnerLogin); //Adjust the Height to Fit width of zone string wpHeightStyle = "height: {0};"; string height = string.IsNullOrEmpty(Height) ? Constants.WebPartHeight : Height.ToString(CultureInfo.InvariantCulture); wpHeightStyle = string.Format(CultureInfo.InvariantCulture, wpHeightStyle, height); // create a unique name for the query results iframe based on // the web part's GUID. test this by having two ALWP web parts on the same page //and ensuring that selecting a query in one doesn't affect the other and vice versa // write a comment to help locate this Web Part when viewing HTML source htmlTextWriter.Write("<!-- Begin ALWP -->"); htmlTextWriter.Write("<script type=\"text/javascript\">var scope{0} = '{1}';</script>", frameId, FindScope()); htmlTextWriter.Write("<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" border=\"0\" style=\""); htmlTextWriter.Write(wpHeightStyle); htmlTextWriter.Write("\">"); htmlTextWriter.Write("<tr valign=\"top\">"); StringBuilder queryString = BaseQueryString(); string sourceParameter = HttpUtility.UrlEncode(Page.Request.Url.ToString()); string queryResultsUrl; if (DisplaySummary) { queryString.AppendFormat("&{0}={1}&{2}={3}", QueryStringKeys.QuerySet, QuerySetOverride, QueryStringKeys.Source, sourceParameter); queryResultsUrl = SlkUtilities.UrlCombine(SPWeb.Url, Constants.BlankGifUrl); WriteSummary(htmlTextWriter, queryString.ToString()); } else { queryString.AppendFormat("&{0}={1}", QueryStringKeys.Query, defaultQueryName); queryResultsUrl = SlkUtilities.UrlCombine(SPWeb.ServerRelativeUrl, Constants.SlkUrlPath, Constants.QueryResultPage); queryResultsUrl += queryString.ToString(); } if (forObserver) { queryResultsUrl = string.Format(CultureInfo.InvariantCulture, "{0}&{1}=true", queryResultsUrl, QueryStringKeys.ForObserver); } if (queryResultsUrl.Contains(Constants.BlankGifUrl) == false) { queryResultsUrl = string.Format("{0}&{1}={2}", queryResultsUrl, QueryStringKeys.Source, sourceParameter); } WriteQueryResults(htmlTextWriter, queryResultsUrl); htmlTextWriter.Write("</tr>"); // write a row containing a separator line htmlTextWriter.Write("<tr><td class=\"ms-partline\" colspan=\"2\"><img src=\""); htmlTextWriter.Write(Constants.BlankGifUrl); htmlTextWriter.Write("\" width=\"1\" height=\"1\" alt=\"\" /></td></tr>"); // write a row that adds extra vertical space htmlTextWriter.Write("<tr><td class=\"ms-partline\" colspan=\"2\"><img src=\""); htmlTextWriter.Write(Constants.BlankGifUrl); htmlTextWriter.Write("\" width=\"1\" height=\"1\" alt=\"\" /></td></tr>"); htmlTextWriter.Write("</table>"); // write a comment to help locate this Web Part when viewing HTML source htmlTextWriter.Write("<!-- End ALWP -->"); htmlTextWriter.WriteLine(); }