Пример #1
0
        public JsonResult DeleteConfirmConnection(int idclass, int id1, int id2, int act)
        {
            AjaxResponseModel option = new AjaxResponseModel();

            var db = new Models.DataModels.CourseDataBaseEntities();

            foreach (var i in db.StudentConnections)
            {
                if (i.Connection.ClassificationId == idclass &&
                    ((i.Connection.ParentConceptId == id1 && i.Connection.ChildConceptId == id2) ||
                     (i.Connection.ParentConceptId == null && i.Connection.ChildConceptId == id2 && id1 == -1))
                    )
                {
                    if (act == 0)
                    {
                        db.Connections.Remove(i.Connection);
                        db.StudentConnections.Remove(i);
                        break;
                    }
                    i.Status = 1;
                    i.Rating = 1;
                    break;
                }
            }
            db.SaveChanges();
            JsonResult res = Json(option);

            res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            return(res);
        }
Пример #2
0
        public JsonResult CheckConnection(int idclass, int id1, int id2)
        {
            AjaxResponseModel option = new AjaxResponseModel();

            var db      = new Models.DataModels.CourseDataBaseEntities();
            int isvalid = 1;

            foreach (var i in db.StudentConnections)
            {
                if (i.Connection.ClassificationId == idclass &&
                    ((i.Connection.ParentConceptId == id1 && i.Connection.ChildConceptId == id2) ||
                     (i.Connection.ParentConceptId == null && i.Connection.ChildConceptId == id2 && id1 == -1))
                    )
                {
                    if (i.Status == 0)
                    {
                        isvalid = 0;
                    }
                }
            }
            option.Length = isvalid;
            JsonResult res = Json(option);

            res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            return(res);
        }
Пример #3
0
        public JsonResult EmptyConcepts()
        {
            AjaxResponseModel option = new AjaxResponseModel();

            var db = new Models.DataModels.CourseDataBaseEntities();

            List <string> enames = new List <string>();
            List <string> eid    = new List <string>();

            List <string> names = new List <string>();
            List <string> id    = new List <string>();

            foreach (var i in db.Connections)
            {
                if (i.Concept != null && !names.Contains(i.Concept.Name))
                {
                    names.Add(i.Concept.Name);
                    id.Add((i.Id).ToString());
                }
                if (i.Concept1 != null && !names.Contains(i.Concept1.Name))
                {
                    names.Add(i.Concept1.Name);
                    id.Add((i.Id).ToString());
                }
            }

            foreach (var i in db.Concepts)
            {
                if (names.Count() == 0)
                {
                    enames.Add(i.Name);
                    eid.Add((i.Id).ToString());
                }
                for (int j = 0; j < names.Count(); j++)
                {
                    if (!names.Contains(i.Name))
                    {
                        enames.Add(i.Name);
                        eid.Add((i.Id).ToString());
                    }
                }
            }


            option.Data   = enames.ToArray();
            option.Length = enames.Count;
            option.Value  = eid.ToArray();
            JsonResult res = Json(option);

            res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            return(res);
        }
Пример #4
0
        public JsonResult AddConnection(int idclass, int id1, int id2)
        {
            AjaxResponseModel option = new AjaxResponseModel();
            List <string>     names  = new List <string>();
            List <string>     id     = new List <string>();

            var db = new Models.DataModels.CourseDataBaseEntities();

            Connection connection;

            if (id1 == -1)
            {
                connection = db.Connections.Add(new Connection()
                {
                    ChildConceptId   = id2,
                    ClassificationId = idclass
                });
            }
            else
            {
                connection = db.Connections.Add(new Connection()
                {
                    ChildConceptId   = id2,
                    ParentConceptId  = id1,
                    ClassificationId = idclass
                });
            }

            var studentId = DataManager.DefineUser(HttpContext).Id;

            db.StudentConnections.Add(new StudentConnection()
            {
                Status       = 0,
                ConnectionId = connection.Id,
                StudentId    = studentId,//DistantLearningSystem.Models.Authorization.AuthorizedObject.Id,
                AddedDate    = DateTime.Now,
                Rating       = 0,
            });

            db.SaveChanges();

            option.Data   = names.ToArray();
            option.Length = names.Count;
            option.Value  = id.ToArray();
            JsonResult res = Json(option);

            res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            return(res);
        }
Пример #5
0
        public JsonResult Classifications()
        {
            AjaxResponseModel option = new AjaxResponseModel();

            var           db    = new Models.DataModels.CourseDataBaseEntities();
            List <string> bases = new List <string>();
            List <string> id    = new List <string>();

            foreach (var i in db.Classifications)
            {
                bases.Add(i.Base);
                id.Add((i.Id).ToString());
            }
            option.Data   = bases.ToArray();
            option.Length = bases.Count;
            option.Value  = id.ToArray();
            JsonResult res = Json(option);

            res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            return(res);
        }
Пример #6
0
        public JsonResult Concepts(int data)
        {
            AjaxResponseModel option = new AjaxResponseModel();

            var           db    = new Models.DataModels.CourseDataBaseEntities();
            List <string> names = new List <string>();
            List <string> id    = new List <string>();

            foreach (var i in db.Connections)
            {
                if (i.ClassificationId == data && i.ParentConceptId == null)
                {
                    names.Add(i.Concept.Name);
                    id.Add((i.Concept.Id).ToString());
                }
            }
            option.Data   = names.ToArray();
            option.Length = names.Count;
            option.Value  = id.ToArray();
            JsonResult res = Json(option);

            res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            return(res);
        }
        // просто отчеты
        public void Report1()
        {
            // шаблон
            HttpContext.Response.ContentType = "application/pdf";
            HttpContext.Response.AddHeader("content-disposition", "attachment;filename=Краткая информация про студентов.pdf");
            HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            var document = new Document(PageSize.A4);

            PdfWriter.GetInstance(document, HttpContext.Response.OutputStream);
            document.Open();
            var db = new Models.DataModels.CourseDataBaseEntities();
            // шаблон

            // сколько объектов добавлено, 0 элемент - общее количество
            List <int> count_added = new List <int>();
            // иницализация
            List <List <Student> > groups = new List <List <Student> >();

            for (int i = 0; i < 7; i++)
            {
                groups.Add(new List <Student>());
                count_added.Add(0);
            }

            // распределяем студентов по группам, потом отсюда отображать будем
            foreach (var i in db.Students)
            {
                if (i.StudentGroup.Name == "ПИ-12-1")
                {
                    groups[1].Add(i);
                }
                if (i.StudentGroup.Name == "ПИ-12-2")
                {
                    groups[2].Add(i);
                }
                if (i.StudentGroup.Name == "ПИ-12-3")
                {
                    groups[3].Add(i);
                }
                if (i.StudentGroup.Name == "ПИ-12-4")
                {
                    groups[4].Add(i);
                }
                if (i.StudentGroup.Name == "ПИ-12-5")
                {
                    groups[5].Add(i);
                }
                if (i.StudentGroup.Name == "ПИ-12-6")
                {
                    groups[6].Add(i);
                }
            }
            // считаем сколько по группам добавлено объктов
            foreach (var i in db.Concepts)
            {
                count_added[i.Student.StudentGroup.Name[i.Student.StudentGroup.Name.Length - 1] - '0']++;
            }
            foreach (var i in db.Definitions)
            {
                count_added[i.Student.StudentGroup.Name[i.Student.StudentGroup.Name.Length - 1] - '0']++;
            }
            foreach (var i in db.StudentConnections)
            {
                count_added[i.Student.StudentGroup.Name[i.Student.StudentGroup.Name.Length - 1] - '0']++;
            }
            foreach (var i in db.References)
            {
                count_added[i.Student.StudentGroup.Name[i.Student.StudentGroup.Name.Length - 1] - '0']++;
            }
            foreach (var i in db.Classifications)
            {
                count_added[i.Student.StudentGroup.Name[i.Student.StudentGroup.Name.Length - 1] - '0']++;
            }
            foreach (var i in db.Formulations)
            {
                count_added[i.Student.StudentGroup.Name[i.Student.StudentGroup.Name.Length - 1] - '0']++;
            }
            // сколько в сумме
            count_added[0] = count_added[1] + count_added[2] + count_added[3] + count_added[4] + count_added[5] + count_added[6];

            document.AddAuthor("Admin");
            document.AddTitle("Общая информация о студентах");
            document.AddCreationDate();

            // не трогать, для отображения русских букв!!!
            string   sylfaenpath = Environment.GetEnvironmentVariable("SystemRoot") + "\\fonts\\sylfaen.ttf";
            BaseFont sylfaen     = BaseFont.CreateFont(sylfaenpath, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);

            iTextSharp.text.Font head      = new iTextSharp.text.Font(sylfaen, 12f, iTextSharp.text.Font.NORMAL, iTextSharp.text.Color.BLUE);
            iTextSharp.text.Font normal    = new iTextSharp.text.Font(sylfaen, 10f, iTextSharp.text.Font.NORMAL, iTextSharp.text.Color.BLACK);
            iTextSharp.text.Font underline = new iTextSharp.text.Font(sylfaen, 10f, iTextSharp.text.Font.UNDERLINE, iTextSharp.text.Color.BLACK);
            // не трогать, для отображения русских букв!!!


            document.Add(new Paragraph("Список студентов, их общей информации, а также их оценки за добавленные объекты различных типов. Дата последнего посещения и оценки за активность позволяют быстро оценить общую и текущую активность и успешность студента, а также сравнить таковую с другими студентами", head));
            document.Add(new Paragraph(" ", normal));
            document.Add(new Paragraph(" ", normal));

            // задаем кол-во столбцов
            PdfPTable table = new PdfPTable(5);

            // заполняем шапку
            table.AddCell(new Phrase("Группа", normal));
            table.AddCell(new Phrase("ФИО студента", normal));
            table.AddCell(new Phrase("Последнее посещение", normal));
            table.AddCell(new Phrase("Тип объекта", normal));
            table.AddCell(new Phrase("Оценка", normal));


            groups[1].Sort((x, y) => x.LastName.CompareTo(y.LastName));
            groups[2].Sort((x, y) => x.LastName.CompareTo(y.LastName));
            groups[3].Sort((x, y) => x.LastName.CompareTo(y.LastName));
            groups[4].Sort((x, y) => x.LastName.CompareTo(y.LastName));
            groups[5].Sort((x, y) => x.LastName.CompareTo(y.LastName));
            groups[6].Sort((x, y) => x.LastName.CompareTo(y.LastName));

            // заполняем таблицу
            for (int k = 1; k < 7; k++)
            {
                for (int i = 0; i < groups[k].Count(); i++)
                {
                    foreach (var j in db.Formulations)
                    {
                        if (j.Student.Id == groups[k][i].Id)
                        {
                            if (j.Status == 0)
                            {
                                continue;
                            }
                            table.AddCell(new Phrase(groups[k][i].StudentGroup.Name, normal));
                            table.AddCell(new Phrase((groups[k][i].LastName + " " + groups[k][i].Name), normal));
                            table.AddCell(new Phrase(groups[k][i].LastVisitDate.ToString(), normal));
                            table.AddCell(new Phrase("Формулировка", normal));
                            table.AddCell(j.Status.ToString());
                        }
                    }
                    foreach (var j in db.Definitions)
                    {
                        if (j.Student.Id == groups[k][i].Id)
                        {
                            if (j.Status == 0)
                            {
                                continue;
                            }
                            table.AddCell(new Phrase(groups[k][i].StudentGroup.Name, normal));
                            table.AddCell(new Phrase((groups[k][i].LastName + " " + groups[k][i].Name), normal));
                            table.AddCell(new Phrase(groups[k][i].LastVisitDate.ToString(), normal));
                            table.AddCell(new Phrase("Определение", normal));
                            table.AddCell(j.Status.ToString());
                        }
                    }
                    foreach (var j in db.Concepts)
                    {
                        if (j.Student.Id == groups[k][i].Id)
                        {
                            if (j.Status == 0)
                            {
                                continue;
                            }
                            table.AddCell(new Phrase(groups[k][i].StudentGroup.Name, normal));
                            table.AddCell(new Phrase((groups[k][i].LastName + " " + groups[k][i].Name), normal));
                            table.AddCell(new Phrase(groups[k][i].LastVisitDate.ToString(), normal));
                            table.AddCell(new Phrase("Понятие", normal));
                            table.AddCell(j.Status.ToString());
                        }
                    }
                    foreach (var j in db.Classifications)
                    {
                        if (j.Student.Id == groups[k][i].Id)
                        {
                            if (j.Status == 0)
                            {
                                continue;
                            }
                            table.AddCell(new Phrase(groups[k][i].StudentGroup.Name, normal));
                            table.AddCell(new Phrase((groups[k][i].LastName + " " + groups[k][i].Name), normal));
                            table.AddCell(new Phrase(groups[k][i].LastVisitDate.ToString(), normal));
                            table.AddCell(new Phrase("Классификация", normal));
                            table.AddCell(j.Status.ToString());
                        }
                    }
                    foreach (var j in db.StudentConnections)
                    {
                        if (j.Student.Id == groups[k][i].Id)
                        {
                            if (j.Status == 0)
                            {
                                continue;
                            }
                            table.AddCell(new Phrase(groups[k][i].StudentGroup.Name, normal));
                            table.AddCell(new Phrase((groups[k][i].LastName + " " + groups[k][i].Name), normal));
                            table.AddCell(new Phrase(groups[k][i].LastVisitDate.ToString(), normal));
                            table.AddCell(new Phrase("Связь", normal));
                            table.AddCell(j.Status.ToString());
                        }
                    }
                }
            }

            document.Add(table);

            document.Add(new Paragraph("Отчет сформирован " + DateTime.Now.ToString(), head));
            document.Close();
            HttpContext.Response.Write(document);
            HttpContext.Response.End();
        }