Esempio n. 1
0
        public ActionResult exportStudentAnswers()
        {
            List <StudentTestQuestionAnswerModel> model =
                System.Web.HttpContext.Current.Session["Questions"] as List <StudentTestQuestionAnswerModel>;
            List <String> lines = new List <string>();

            lines.Add(String.Format("Username: {0}; Date: {1}", User.Identity.Name, DateTime.Now));
            lines.Add("\n<<<--------------------Questions-------------------->>>");
            model.ForEach(cur => lines.Add(cur.ToString()));
            //Helper.ExportToTextFile(Response, lines);
            MemoryStream memoryStream = HelpingClass.ExportToTextFile(lines);

            return(File(memoryStream.GetBuffer(), "text/plain", User.Identity.Name + ".gaadw.txt"));
        }
Esempio n. 2
0
        public ActionResult exportAllStudentMarks(String ID)
        {
            List <ViewStudentMarks> marksies = System.Web.HttpContext.Current.Session["modelViewStudentMarks"] as List <ViewStudentMarks>;

            if (marksies == null)
            {
                marksies = getMarksModel(int.Parse(ID));
            }

            List <String> lines = new List <string>();

            lines.Add(String.Format("Username: {0}; Date: {1}\n", User.Identity.Name, DateTime.Now));
            lines.Add("Username\tMark\n");
            marksies.ForEach(cur => lines.Add(String.Format("{0}\t{1}\n", cur.Name, cur.Presentage).ToString()));

            MemoryStream memoryStream = HelpingClass.ExportToTextFile(lines);

            return(File(memoryStream.GetBuffer(), "text/plain", User.Identity.Name + ".txt"));
        }