/// <summary> /// Display the assignment file link and URL /// </summary> /// <param name="file">The assignment file</param> /// <param name="counter">The number of the file</param> private void DisplayFileLink(AssignmentFile file, int counter) { HyperLink fileLink = new HyperLink(); fileLink.ID = "file" + counter.ToString(CultureInfo.InvariantCulture); fileLink.Text = file.Name; fileLink.Style.Add("display", string.Empty); DropBoxEditMode editMode = Status == LearnerAssignmentState.Completed ? DropBoxEditMode.Edit : DropBoxEditMode.View; DropBoxEditDetails editDetails = dropBox.GenerateDropBoxEditDetails(file, SPWeb, editMode, returnUrl); fileLink.NavigateUrl = editDetails.Url; if (string.IsNullOrEmpty(editDetails.OnClick) == false) { fileLink.Attributes.Add("onclick", editDetails.OnClick + "return false;"); } else { if (SlkStore.Settings.DropBoxSettings.OpenSubmittedInSameWindow) { fileLink.Attributes.Add("onclick", "window.top.location='" + editDetails.Url + "';"); } } FilePanel.Controls.Add(new LiteralControl("<div>")); FilePanel.Controls.Add(fileLink); FilePanel.Controls.Add(new LiteralControl("</div>")); }
private void LoadLastAssignmentAttempt() { DropBoxManager dropBoxManager = new DropBoxManager(AssignmentProperties); AssignmentFile[] files = dropBoxManager.LastSubmittedFiles(true); if (files.Length > 0) { LiteralControl literal = new LiteralControl(string.Format("<table><tr><th>{0}</th><th>{1}</th></tr>", PageCulture.Resources.IncludeTitle, PageCulture.Resources.CtrlLabelUploadDocumentName)); pnlOldFiles.Controls.Add(literal); foreach (AssignmentFile file in files) { pnlOldFiles.Controls.Add(new LiteralControl("<tr><td>")); CheckBox check = new CheckBox(); check.ID = "check" + file.Id.ToString(CultureInfo.InvariantCulture); check.Checked = false; includes.Add(check); pnlOldFiles.Controls.Add(check); pnlOldFiles.Controls.Add(new LiteralControl("</td><td>")); HyperLink fileLink = new HyperLink(); fileLink.Text = file.Name; DropBoxEditMode editMode = DropBoxEditMode.Edit; DropBoxEditDetails editDetails = dropBoxManager.GenerateDropBoxEditDetails(file, SPWeb, editMode, Page.Request.RawUrl); fileLink.NavigateUrl = editDetails.Url; if (string.IsNullOrEmpty(editDetails.OnClick) == false) { fileLink.Attributes.Add("onclick", editDetails.OnClick + "return false;"); } pnlOldFiles.Controls.Add(fileLink); pnlOldFiles.Controls.Add(new LiteralControl("</td></tr>")); } pnlOldFiles.Controls.Add(new LiteralControl("</table>")); } }
private void SetupFileAction(AssignmentFile file, SlkButton button, bool includeReload) { DropBoxManager dropBoxMgr = new DropBoxManager(AssignmentProperties); DropBoxEditMode editMode = DropBoxEditMode.Edit; switch (LearnerAssignmentProperties.Status) { case LearnerAssignmentState.Completed: case LearnerAssignmentState.Final: editMode = DropBoxEditMode.View; break; } DropBoxEditDetails editDetails = dropBoxMgr.GenerateDropBoxEditDetails(file, SPWeb, editMode, Page.Request.RawUrl); string script = editDetails.OnClick; if (string.IsNullOrEmpty(script)) { if (includeReload) { script = string.Format(CultureInfo.InvariantCulture, "window.location='{0}&{1}=true';", CurrentUrl, startQueryStringName); } } else { if (LearnerAssignmentProperties.Status == LearnerAssignmentState.NotStarted && includeReload) { script = string.Format(CultureInfo.InvariantCulture, "{0}window.location='{1}&{2}=true';return false;", script, CurrentUrl, startQueryStringName); } else { script = script + "return false;"; } } button.OnClientClick = script; button.NavigateUrl = editDetails.Url; }