Пример #1
0
        /// <summary>
        /// Called when the user selects the "submit assignment" menu option
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SubmitAssignmentCallback(object sender, EventArgs e)
        {
            IVsUIShell  uiShell = (IVsUIShell)GetService(typeof(SVsUIShell));
            Guid        clsid   = Guid.Empty;
            SubmitEvent evt     = new SubmitEvent();
            DTE2        dte     = (DTE2)this.GetService(typeof(SDTE));

            if (dte.Solution.FullName.Length == 0)
            {
                MessageBox.Show("No solution is currently open.");
                return;
            }
            object cacheItem = _cache[StringConstants.AuthenticationCacheKey];

            if (cacheItem != null && string.IsNullOrEmpty(cacheItem.ToString()) == false)
            {
                evt.SolutionName = dte.Solution.FullName;

                SubmitAssignmentViewModel vm = new SubmitAssignmentViewModel(
                    _cache[StringConstants.UserNameCacheKey] as string,
                    _cache[StringConstants.AuthenticationCacheKey] as string,
                    evt
                    );
                MessageBoxResult result = SubmitAssignmentWindow.ShowModalDialog(vm);

                //assume that data was changed and needs to be saved
                if (result == MessageBoxResult.OK)
                {
                }
            }
            else
            {
                MessageBox.Show("You must be logged into OSBIDE in order to submit an assignment.");
            }
        }
Пример #2
0
        // GET: SubmitAssignment
        public ActionResult SubmitAssignment(int id)
        {
            //List<Assignment> pass = new List<Assignment>();
            SubmitAssignmentViewModel svm = new SubmitAssignmentViewModel();
            Assignment assignment         = db.Assignments.ToList().Find(a => a.AssignmentID == id);

            svm.RetryRemaining = assignment.MaxAttempt - db.Submissions.ToList().FindAll(s => s.AssignmentID == id).Count();

            Module module = db.Modules.ToList().Find(m => m.ModuleCode == assignment.ModuleCode);

            svm.Module   = module.ModuleCode + " " + module.ModuleName;
            svm.IssuedBy = db.Lecturers.ToList().Find(lc => lc.StaffID == assignment.CreateBy).Name.ToString();

            //start a session to check which assignment student is viewing
            Session["assignmentId"] = id;

            if (Session["UploadError"] != null)
            {
                ModelState.AddModelError("UploadError", Session["UploadError"].ToString());
                Session.Remove("UploadError");
            }

            svm.assignment = assignment;

            //encode the richtext from the DB
            svm.assignment.Describe = AntiXssEncoder.HtmlEncode(svm.assignment.Describe, false);

            return(View(svm));
        }//end of get SubmitAssignment
Пример #3
0
        public static MessageBoxResult ShowModalDialog(SubmitAssignmentViewModel vm)
        {
            SubmitAssignmentWindow window = new SubmitAssignmentWindow();

            window.ViewModel = vm;
            window.ShowDialog();
            return(vm.Result);
        }
        private void SubmitAssignmentCallback(object sender, EventArgs e)
        {
            var evt = new SubmitEvent();
            var dte = (DTE2)GetService(typeof(SDTE));



            dte.Solution.Projects.DTE.Documents.SaveAll();

            var build = dte.Solution.SolutionBuild.BuildState;


            var result = MessageBox.Show(@"If you do not build your soultion, all your files may not be submitted, would you like to build? If not, you may still submit your assignment.", "", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                dte.Solution.SolutionBuild.Build(true);
            }

            if (dte.Solution.FullName.Length == 0)
            {
                MessageBox.Show(@"No solution is currently open.");
                return;
            }

            var cacheItem = _cache[StringConstants.AuthenticationCacheKey];

            if (cacheItem != null && string.IsNullOrEmpty(cacheItem.ToString()) == false)
            {
                evt.SolutionName = dte.Solution.FullName;

                var vm = new SubmitAssignmentViewModel(
                    _cache[StringConstants.UserNameCacheKey] as string,
                    _cache[StringConstants.AuthenticationCacheKey] as string,
                    evt
                    );
                SubmitAssignmentWindow.ShowModalDialog(vm);
            }
            else
            {
                MessageBox.Show(@"You must be logged into OSBLE+ in order to submit an assignment.");
            }
        }
Пример #5
0
        public IActionResult SubmitAssignment(SubmitAssignmentViewModel model)
        {
            string userId = null;

            if (_signInManager.IsSignedIn(HttpContext.User))
            {
                userId = _userManager.GetUserId(HttpContext.User);
            }
            if (ModelState.IsValid)
            {
                Assignment    assignment = _assignmentRepo.GetAssignment(Convert.ToInt32(model.AssignmentID));
                string        filename   = null;
                List <string> files      = new List <string>();
                if (model.Files != null)
                {
                    foreach (IFormFile file in model.Files)
                    {
                        string uploadsFolder = Path.Combine(_hostingEnvironment.WebRootPath, "submitted_assignments");
                        filename = Guid.NewGuid().ToString() + "_" + file.FileName;
                        files.Add(filename);
                        string filePath = Path.Combine(uploadsFolder, filename);
                        file.CopyTo(new FileStream(filePath, FileMode.Create));
                    }
                }
                SubmittedAssignment newAssignment = new SubmittedAssignment
                {
                    AssignmentID = Convert.ToInt32(model.AssignmentID),
                    AppUserID    = userId,
                    Title        = assignment.Title,
                    Description  = model.Description,
                    Files        = string.Join(",", files)
                };
                _submittedAssignmentRepo.Add(newAssignment);
                return(RedirectToAction("Home", new { id = assignment.ClassroomID, loadPartial = "Assignments" }));
            }
            return(View("NotFound"));
        }