/// <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>"));
        }
示例#2
0
        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>"));
            }
        }
示例#3
0
        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;
        }
示例#4
0
        /// <summary>Generate the drop box edit details.</summary>
        /// <param name="file">The file to edit.</param>
        /// <param name="web">The web the file is in.</param>
        /// <param name="mode">The open mode.</param>
        /// <param name="sourceUrl">The source page.</param>
        /// <returns></returns>
        public DropBoxEditDetails GenerateDropBoxEditDetails(AssignmentFile file, SPWeb web, DropBoxEditMode mode, string sourceUrl)
        {
            DropBoxEditDetails details = new DropBoxEditDetails();

            // Set default details
            details.Url = file.Url;
            details.OnClick = EditJavascript(file, web);

            try
            {
                bool isIpad = SlkUtilities.IsIpad();
                if (settings.UseOfficeWebApps)
                {
                    if (file.IsOfficeFile)
                    {
                        if (settings.OpenOfficeInIpadApp && isIpad)
                        {
                            details.Url = file.GenerateOfficeProtocolUrl(web, sourceUrl);
                            details.OnClick = null;
                        }
                        else if (mode == DropBoxEditMode.Edit)
                        {
                            // Document must be 2010 format to be edited in office web apps
                            if (file.IsOwaCompatible)
                            {
                                details.Url = file.GenerateOfficeAppsEditUrl(web, sourceUrl);
                                details.OnClick = null;
                            }
                        }
                        // Use Office Web Apps viewer for office files except for Excel which does not support it for pre 2010 worksheets
                        else if (file.Extension.ToUpperInvariant() != "XLS")
                        {
                            details.Url = file.GenerateOfficeAppsViewUrl(web, sourceUrl);
                            details.OnClick = null;
                        }
                    }
                }
                else if (settings.OpenOfficeInIpadApp && isIpad)
                {
                    details.Url = file.GenerateOfficeProtocolUrl(web, sourceUrl);
                    details.OnClick = null;
                }
            }
            catch (ArgumentOutOfRangeException)
            {
                // Not valid for office web apps
                details.Url = file.Url;
                details.OnClick = EditJavascript(file, web);
            }

            return details;
        }