Пример #1
0
        private async void SubmitAssignmentAsync()
        {
            _submitEvent.CreateSolutionBinary(_submitEvent.GetSolutionBinary());
            _submitEvent.AssignmentId = SelectedAssignment;
            _submitEvent.CourseId     = SelectedCourse;

            var task         = AsyncServiceClient.SubmitAssignment(_submitEvent, _authToken);
            var confirmation = await task;

            SubmitAssignmentCompleted(confirmation);
        }
Пример #2
0
        private void Continue(object param)
        {
            Result = MessageBoxResult.OK;

            //submit the solution to OSBIDE
            _submitEvent.CreateSolutionBinary();
            _submitEvent.AssignmentId = SelectedAssignment;
            IsLoading = true;
            EventLog eventLog = new EventLog(_submitEvent);

            _client.SubmitAssignmentAsync(_submitEvent.AssignmentId, eventLog, _authToken);
        }
Пример #3
0
        public override void SolutionSubmitted(object sender, SubmitAssignmentArgs e)
        {
            base.SolutionSubmitted(sender, e);

            var submit = new SubmitEvent
            {
                AssignmentId = e.AssignmentId,
                SolutionName = string.Empty,
            };

            submit.CreateSolutionBinary(submit.GetSolutionBinary());

            //let others know that we have a new event
            NotifyEventCreated(this, new EventCreatedArgs(submit));

            CheckInterventionStatus();
        }
Пример #4
0
        private static SubmitEvent CreateSubmitEvent()
        {
            var submit = new SubmitEvent
            {
                //SolutionName = "C:/SubmissionTest/Source/TestSolution.sln",
                CourseId     = 4,
                AssignmentId = 3,
                SenderId     = 1,
                Sender       = new User
                {
                    FirstName = "Test",
                    LastName  = "User"
                }
            };
            //submit.GetSolutionBinary();
            string path = "testfile.txt";

            using (StreamWriter sw = File.CreateText(path))
            {
                sw.WriteLine("CourseId = 4");
                sw.WriteLine("AssignmentId = 3");
                sw.WriteLine("SenderId = 1");
                sw.WriteLine("Name = Test User");
            }
            var stream = new MemoryStream();

            using (var zip = new ZipFile())
            {
                zip.AddFile(path);
                zip.Save(stream);
                stream.Position = 0;

                submit.CreateSolutionBinary(stream.ToArray());
            }
            File.Delete(path);
            return(submit);
        }
Пример #5
0
        public ActionResult SubmitAssignmentFile(HttpPostedFileBase file)
        {
            //make sure that we have both a course id and assignment id
            int assignmentId = 0;
            int courseId     = 0;

            Int32.TryParse(Request.Form["AssignmentId"], out assignmentId);
            Int32.TryParse(Request.Form["CourseId"], out courseId);

            if (courseId < 1 || assignmentId < 1)
            {
                return(RedirectToAction("MyCourses"));
            }

            //get file information and continue if not null
            if (file != null)
            {
                //create submit event
                SubmitEvent submitEvent = new SubmitEvent();

                if (file.ContentLength > 0 && file.ContentLength < 5000000) //limit size to 5 MB
                {
                    submitEvent.SolutionName = Path.GetFileName(file.FileName);

                    byte[] fileData = null;
                    using (var binaryReader = new BinaryReader(file.InputStream))
                    {
                        fileData = binaryReader.ReadBytes(file.ContentLength);
                    }

                    MemoryStream stream = new MemoryStream();
                    using (ZipFile zip = new ZipFile())
                    {
                        zip.AddEntry(submitEvent.SolutionName, fileData);
                        zip.Save(stream);
                        stream.Position = 0;
                    }
                    //add the solution data to the event
                    submitEvent.CreateSolutionBinary(stream.ToArray());
                }
                else
                {
                    //TODO: handle specific errors
                    return(RedirectToAction("GenericError", "Error"));
                }

                submitEvent.AssignmentId = assignmentId;
                //create event log with solution to submit
                EventLog eventLog = new EventLog(submitEvent);
                eventLog.Sender   = CurrentUser;
                eventLog.SenderId = CurrentUser.Id;
                //create client to submit assignment to the db
                OsbideWebService client = new OsbideWebService();
                client.SubmitAssignment(assignmentId, eventLog, CurrentUser);

                return(RedirectToAction("Details", new { id = courseId }));
            }
            else
            {
                //TODO: handle specific errors
                return(RedirectToAction("GenericError", "Error"));
            }
        }