Example #1
0
        public bool Add(ExamType examType)
        {
            db.ExamTypes.Add(examType);
            bool isSave = db.SaveChanges() > 0;

            return(isSave);
        }
Example #2
0
        public ExamMainWin(SimulationPaper simulationPaper, ExamType examType) : this()
        {
            //SimulationPaper = simulationPaper;
            this.ExamType = examType;

            this.DataContext = new ExamMainWinVM(GridContent, ExamType);
        }
Example #3
0
        public IActionResult CreateExam(ExamQuestionModel model)
        {
            if (ModelState.IsValid)
            {
                Exam exam = new Exam();
                exam.Content     = model.Exam.Content;
                exam.CreatedDate = DateTime.Now;
                exam.Title       = model.Exam.Title;
                exam.Questions   = model.Questions;

                _examService.Save(exam);


                ExamType examType = new ExamType();

                if (examType.Id == 0)
                {
                    examType.Id = 1;
                }
                else
                {
                    examType.Id = examType.Id + 1;
                }
                examType.Content     = model.Exam.Content;
                examType.CreatedDate = DateTime.Now;
                examType.Title       = model.Exam.Title;
                examType.Questions   = model.Questions;

                _examTypeService.Save(examType);
            }


            return(RedirectToAction("GetExamList"));
        }
 public IActionResult Upsert(ExamType et)
 {
     if (ModelState.IsValid)
     {
         if (et.Id == null)
         {
             _db.ExamType.Add(new ExamType()
             {
                 Id = Guid.NewGuid().ToString(), Name = et.Name
             });
             _db.SaveChanges();
             return(RedirectToAction("index"));
         }
         var oldEt = _db.ExamType.FirstOrDefault(x => x.Id == et.Id);
         if (oldEt != null)
         {
             try
             {
                 oldEt.Name = et.Name;
                 _db.ExamType.Update(oldEt);
                 _db.SaveChanges();
                 return(RedirectToAction("index"));
             }
             catch (Exception e)
             {
                 ModelState.AddModelError("", e.Message);
             }
         }
         ModelState.AddModelError("", "Error");
     }
     return(View(et));
 }
Example #5
0
        public async Task <ActionResult <ExamType> > PostExamType(ExamType examType)
        {
            _context.ExamType.Add(examType);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetExamType", new { id = examType.Id }, examType));
        }
Example #6
0
        public async Task <IActionResult> PutExamType(int id, ExamType examType)
        {
            if (id != examType.Id)
            {
                return(BadRequest());
            }

            _context.Entry(examType).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ExamTypeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #7
0
        public void insert(ExamType examType)
        {
            examType.BaseKey = this.getMaxKeyValue();
            String sql = "insert into examType(BaseKey,TestType,Item) \n"
                         + "values(@BaseKey,@TestType,@Item)";

            SqlParameter[] parameters =
            {
                new SqlParameter("@BaseKey",  examType.BaseKey),
                new SqlParameter("@TestType", examType.TestType),
                new SqlParameter("@Item",     examType.Item)
            };

            try
            {
                dbConnection.ExecuteNonQuery(sql);
            }
            catch (Exception)
            {
            }
            finally
            {
                dbConnection.Close();
            }
        }
Example #8
0
        public ActionResult AddExamType(int?id, FormCollection collection, string alertMessage, string IsEdit)
        {
            ExamType _examType = new ExamType();

            try
            {
                if (IsEdit == "1")
                {
                    var examEdit = examTypeRepository.GetByDatabaseID(id.Value);
                    TryUpdateModel(examEdit, collection);
                    examTypeRepository.Update(examEdit);
                }
                else
                {
                    TryUpdateModel(_examType, collection);
                    if (examTypeRepository.ExistExamName(_examType.EName))
                    {
                        alertMessage = "添加失败 此类型已存在!";
                        return(View(_examType));
                    }
                    examTypeRepository.Save(_examType);
                }

                alertMessage             = "操作成功!";
                ViewData["alertMessage"] = alertMessage;
                return(RedirectToAction("ExamIndex"));
            }
            catch (RuleException ex)
            {
                throw new RuleException(ex.Message, ex);
            }
        }
Example #9
0
        public JsonResult AddExamType(string name)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                return(Json(ErrorModel.InputError));
            }

            var typeBll = new ExamTypeBll();

            var condition = string.Format("TypeName='{0}'", name.Trim());

            if (typeBll.Exists(condition))
            {
                return(Json(ErrorModel.ExistSameItem));
            }

            var typeModel = new ExamType {
                TypeName = name
            };

            typeBll.Insert(typeModel);

            if (typeModel.Id > 0)
            {
                DataUpdateLog.SingleUpdate(typeof(ExamType).Name, typeModel.Id, DataUpdateType.Insert);

                return(Json(ErrorModel.GetDataSuccess(typeModel.Id)));
            }

            return(Json(ErrorModel.OperateFailed));
        }
Example #10
0
        public ActionResult DeleteConfirmed(int id)
        {
            if (Session["ID"] != null)
            {
                var typeName = (string)Session["Type"]; var type = db.EmployeeTypes.Where(x => x.Type == typeName).FirstOrDefault();
                if (type.AddSchoolManagingTools == true)
                {
                    ExamType examType = db.ExamTypes.Find(id);
                    db.ExamTypes.Remove(examType);
                    try
                    {
                        db.SaveChanges();
                    }
                    catch
                    {
                        ViewBag.error        = "يوجد مدخلات اخرى متعلقة بهذا النوع يرجى تغييرها قبل الحذف";
                        ViewBag.TitleSideBar = "ExamTypes";

                        return(View(examType));
                    }
                    return(RedirectToAction("Index"));
                }
                return(RedirectToAction("Default", "Home"));
            }
            return(RedirectToAction("Index", "Home"));
        }
        public IHttpActionResult PutExamType(int id, ExamType examType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != examType.ExamTypeId)
            {
                return(BadRequest());
            }

            db.Entry(examType).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ExamTypeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        private static string DisplayColorClass(this ExamType value)
        {
            string colorClass = string.Empty;

            switch (value)
            {
            case ExamType.Base:
                colorClass = Constants.BASE_TYPE_COLOR_CLASS;
                break;

            case ExamType.Intermediate:
                colorClass = Constants.INTERMEDIATE_TYPE_COLOR_CLASS;
                break;

            case ExamType.Advanced:
                colorClass = Constants.ADVANCED_TYPE_COLOR_CLASS;
                break;

            default:
                colorClass = Constants.UNKNOWN_TYPE_COLOR_CLASS;
                break;
            }

            return(colorClass);
        }
        public static string GetIconForExamType(ExamType type)
        {
            string result = string.Empty;

            switch (type)
            {
            case ExamType.Base:
                result = Constants.BASE_TYPE_ICO;
                break;

            case ExamType.Intermediate:
                result = Constants.INTERMEDIATE_TYPE_ICO;
                break;

            case ExamType.Advanced:
                result = Constants.ADVANCED_TYPE_ICO;
                break;

            default:
                result = Constants.UNKNOWN_TYPE_ICO;
                break;
            }

            return(result);
        }
        private bool IsBlankAnswer()
        {
            ExamType examinationType = (ExamType)_examList.Single(e => e.ExamId == _examId).ExaminationType;

            if (examinationType == ExamType.MultipleChoice)
            {
                if (chkChoice1.Checked == false && chkChoice2.Checked == false &&
                    chkChoice3.Checked == false && chkChoice4.Checked == false)
                {
                    return(true);
                }
            }
            else if (examinationType == ExamType.TrueOrFalse)
            {
                if (chkTrue.Checked == false && chkFalse.Checked == false)
                {
                    return(true);
                }
            }
            else if (examinationType == ExamType.TypeTheAnswer)
            {
                if (string.IsNullOrWhiteSpace(txtAnswer.Text))
                {
                    txtAnswer.Focus();
                    return(true);
                }
            }

            return(false);
        }
Example #15
0
 private bool FillGrid(ExamType type)
 {
     try
     {
         DataTable exams = DBUtil.DataSet.Tables["Exam"];
         IEnumerable<DataRow> query;
         if (type == ExamType.REVIEW)
         {
             query =
                 from exam in exams.AsEnumerable()
                 select exam;
         }
         else
         {
             query =
                 from exam in exams.AsEnumerable()
                 where exam.Field<int>("Type") == (int)type
                 select exam;
         }
         foreach (DataRow row in query)
         {
             DataRow patient = DBUtil.DataSet.Tables["Patient"].Rows[row.Field<int>("PtID")];
             ExamListGrid.Items.Add(new GridRow
             {
                 Patient = patient.Field<string>("Name"),
                 Exam = row.Field<string>("Name"),
                 PatientID = row.Field<int>("PtID"),
                 Date = row.Field<DateTime>("Date"),
                 ExamID = row.Field<int>("ExamID"),
             });
         }
         return true;
     }
     catch { return false; }
 }
        private void SetScore()
        {
            ExamType examinationType = (ExamType)_examList.Single(e => e.ExamId == _examId).ExaminationType;

            if (examinationType == ExamType.MultipleChoice)
            {
                if (chkChoice1.Checked == false && chkChoice2.Checked == false &&
                    chkChoice3.Checked == false && chkChoice4.Checked == false)
                {
                    _examineeAnswer = null;
                }
            }
            else if (examinationType == ExamType.TrueOrFalse)
            {
                if (chkTrue.Checked == false && chkFalse.Checked == false)
                {
                    _examineeAnswer = null;
                }
            }
            else if (examinationType == ExamType.TypeTheAnswer)
            {
                _examineeAnswer = string.IsNullOrWhiteSpace(txtAnswer.Text) == true ? null : txtAnswer.Text;
            }

            _examAnswer                  = _examineeExamList[_index].ExamineeAnswer.Single(e => e.QuestionId == _questionBank.QuestionId);
            _examAnswer.Answer           = _examineeAnswer;
            _examAnswer.DateTimeAnswered = _dateTime;

            if (string.Compare(_correctAnswer, _examineeAnswer, false) == 0)
            {
                _examScore++;
                _examAnswer.IsCorrect = true;
            }
        }
Example #17
0
 private void ExaminationTypeListviewItemSelected(object sender, SelectedItemChangedEventArgs e)
 {
     if (e.SelectedItem == null)
     {
         return;
     }
     examType = e.SelectedItem as ExamType;
 }
Example #18
0
        public ActionResult DeleteConfirmed(int id)
        {
            ExamType examType = db.ExamTypes.Find(id);

            db.ExamTypes.Remove(examType);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #19
0
        public bool delete(int id)
        {
            var examType = new ExamType();

            examType          = db.ExamTypes.FirstOrDefault(ex => ex.Id == id);
            examType.isDelete = true;
            return(Update(examType));
        }
Example #20
0
        public ExamMainWinVM(Grid mainContent, ExamType eTtype) : this()
        {
            views = new Dictionary <string, FrameworkElement>();

            _mainContent = mainContent;

            CheckWindowContent(eTtype);
        }
Example #21
0
 public Exam(TimeSpan dur,String student, Teacher teacher, String subject, ExamType type)
 {
     _duration = dur;
     _teacher = teacher;
     _subject = subject;
     _type=type;
     _student=student;
 }
Example #22
0
 public ExamListPage(MainWindow mnWindow, ExamType type)
 {
     InitializeComponent();
     AppWindow = mnWindow;
     Type = type;
     if(FillGrid(type))
         FileHandler = new FileAccessHandler();
 }
Example #23
0
        public bool Update(ExamType examType)
        {
            db.ExamTypes.Attach(examType);
            db.Entry(examType).State = EntityState.Modified;
            bool isUpdate = db.SaveChanges() > 0;

            return(isUpdate);
        }
Example #24
0
 public Exam(TimeSpan dur, String student, Teacher teacher, String subject, ExamType type)
 {
     _duration = dur;
     _teacher  = teacher;
     _subject  = subject;
     _type     = type;
     _student  = student;
 }
        public async Task <IEnumerable <Exam> > GetExamsByTypeAndCategoryAsync(ExamType type, string category)
        {
            var exams = _exams
                        .Where(x => x.Type == type)
                        .Where(x => x.Category == category)
                        .ToList();

            return(await Task.FromResult(exams));
        }
Example #26
0
 public Exam(int examID, int ptID, ExamType type)
 {
     ExamID = examID;
     PtID = ptID;
     Type = type;
     ExamDataAccess = new ExamDA(this);
     Images = new List<NMImage>();
     SetupExam(PtID, ExamID);
 }
Example #27
0
        public static void SeedDefaultValues(ApplicationDbContext context)
        {
            context.Database.EnsureCreated();

            // Look for any Subject.
            if (context.Subjects.Any())
            {
                return;   // DB has been seeded
            }

            var subjects = new Subject[]
            {
                new Subject {
                    Code = "", Name = "Algebra", Description = "Study of mathematical symbols and the rules for manipulating these symbols; it is a unifying thread of almost all of mathematics."
                },
                new Subject {
                    Code = "", Name = "Trigonometry", Description = "Study of relationships involving lengths and angles of triangles."
                },
                new Subject {
                    Code = "", Name = "Analytic Geometry", Description = "Study of geometry using a coordinate system."
                },
                new Subject {
                    Code = "", Name = "Differential Calculus", Description = "Subfield of calculus concerned with the study of the rates at which quantities change."
                },
                new Subject {
                    Code = "", Name = "Integral Calculus", Description = "Subfield of calculus concerned with the study of the notion of an integral, its properties and methods of calculation."
                },
            };

            // Add values to Subjects
            context.Subjects.AddRange(subjects);

            // Save all changes in the database
            context.SaveChanges();

            // Look for any Exam Type.
            if (context.ExamTypes.Any())
            {
                return;   // DB has been seeded
            }

            var examTypes = new ExamType[]
            {
                new ExamType {
                    Name = "Identification"
                },
                new ExamType {
                    Name = "Multiple Choice"
                }
            };

            // Add values to ExamTypes
            context.ExamTypes.AddRange(examTypes);

            // Save all changes in the database
            context.SaveChanges();
        }
 private void AddExamTypeIfNotExists(ExamType examType)
 {
     if (_context.ExamTypes.Equals(examType))
     {
         return;
     }
     _context.ExamTypes.Add(examType);
     _context.SaveChanges();
 }
Example #29
0
 public Examination(int id, DateTime date, Subject subjectId, ExamType exam, Group groupId, Session sessionId)
 {
     Id        = id;
     Date      = date;
     SubjectId = subjectId ?? throw new ArgumentNullException(nameof(subjectId));
     Exam      = exam;
     GroupId   = groupId ?? throw new ArgumentNullException(nameof(groupId));
     SessionId = sessionId ?? throw new ArgumentNullException(nameof(sessionId));
 }
Example #30
0
 public IActionResult Delete(int id)
 {
     if (this.CurrentUserIsAdministrator())
     {
         ExamType examType = this.DatabaseContext.ExamTypeForId(id);
         examType.DeleteFromContext(this.DatabaseContext);
         this.SaveDatabaseContext();
     }
     return(RedirectToAction("index"));
 }
Example #31
0
 public ActionResult Edit([Bind(Include = "Id,Type")] ExamType examType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(examType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(examType));
 }
Example #32
0
 public ReportSession(Session sessionId, Group groupId, Student studentId, Subject subjectId, ExamType examType, DateTime date, StudentGrade grade)
 {
     SessionId = sessionId ?? throw new ArgumentNullException(nameof(sessionId));
     GroupId   = groupId ?? throw new ArgumentNullException(nameof(groupId));
     StudentId = studentId ?? throw new ArgumentNullException(nameof(studentId));
     SubjectId = subjectId ?? throw new ArgumentNullException(nameof(subjectId));
     ExamType  = examType;
     Date      = date;
     Grade     = grade;
 }
Example #33
0
 public IActionResult Update(ExamType examType)
 {
     if (CurrentUser?.Admin == true)
     {
         unitOfWork.ExamTypeRepository.Update(examType);
         unitOfWork.Save();
         return(Ok(examType));
     }
     return(Unauthorized());
 }
Example #34
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            ExamType examType = await db.ExamType.FindAsync(id);

            examType.IsDeleted = true;
            //db.ExamTypes.Remove(examType);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Example #35
0
 public Exam(Time begin, TimeSpan dur, String student, Teacher teacher, String subject,
     ExamType type, Teacher assesor, String room)
 {
     _beginTime = begin;
     _duration = dur;
     _teacher = teacher;
     _subject = subject;
     _type = type;
     _student = student;
     _type = type;
     _assesor = assesor;
     _room = room;
 }
 private void rdb_fixed_number_questions_CheckedChanged(object sender, EventArgs e)
 {
     if (rdb_fixed_number_questions.Checked)
     {
         num_exam_number.Enabled = true;
         this.examType = ExamType.SelectedNumber;
     }
     else
     {
         num_exam_number.Enabled = false;
         this.examType = ExamType.SelectedSections;
     }
 }
 private void rdb_selected_sections_CheckedChanged(object sender, EventArgs e)
 {
     if (rdb_selected_sections.Checked)
     {
         clb_section_options.Enabled = true;
         btn_deselect_all.Enabled = true;
         btn_select_all.Enabled = true;
         this.examType = ExamType.SelectedSections;
     }
     else
     {
         clb_section_options.Enabled = false; 
         btn_deselect_all.Enabled = false;
         btn_select_all.Enabled = false;
         this.examType = ExamType.SelectedNumber;
     }
 }
Example #38
0
        private bool LoadTemplate(ref XmlNodeList pageNodes, ExamType type)
        {
            try
            {
                bool rtrn = false;
                switch (type)
                {
                    case ExamType.REVIEW:
                        break;
                    case ExamType.PULMONARY:
                        rtrn = ParsePulmonaryTemplate(ref pageNodes);
                        break;
                }

                return rtrn;
            }
            catch (Exception e) { MessageBox.Show(e.ToString()); return false; }
        }
Example #39
0
 public void DefAnnotations(CanvasPage page, IExam exam, ExamType type, Template temp)
 {
     if (type == ExamType.REVIEW)
         return;
     var headers = temp.GetHeaders(exam.TempID, page.Name);
     var footers = temp.GetFooters(exam.TempID, page.Name);
     if(headers != null && footers != null)
     {
         switch(type)
         {
             case ExamType.PULMONARY:
                 DefPulmAnnots(ref headers, ref footers, page, (exam as VQExam), temp);
                 break;
         }
     }
     SetAnnotations(page, headers, footers);
     //page.SetAnnotations(headers, footers);
 }
Example #40
0
        public bool LookUpTemplate(int tempID, ExamType type)
        {
            //TODO: parse XML information from template in database
            //based on the template id
            try
            {
                if (type != ExamType.REVIEW)
                {
                    DataRow row = DBUtil.DataSet.Template[tempID];
                    string path = row.Field<string>("AnnotationData");
                    XmlDocument doc = new XmlDocument();
                    XmlNodeList pageNodes;

                    Console.Out.WriteLine("template path: " + path);
                    doc.Load(path);
                    pageNodes = doc.GetElementsByTagName("Page");
                    if (pageNodes == null)
                        MessageBox.Show("null nodes");
                    return LoadTemplate(ref pageNodes, type);
                }
                return false;
            }
            catch (Exception e) { MessageBox.Show(e.ToString()); return false; }
        }
Example #41
0
 /******************************************************************************
  * Open Exam Use Case
  *****************************************************************************/
 public bool OpenExam(int examID, int patientID, ExamType type)
 {
     try
     {
         AttributesForm form = null;
         Exam = CreateExam(examID, patientID, type);
         ExamTemplate = new Template();
         //if (type != ExamType.REVIEW)
         //{
             form = new AttributesForm(SubmitAttributes, Exam);
             form.Visibility = Visibility.Visible;
         //}
         //else
        // {
          //   PrepareForProcessing();
         //}
         return true;
     }
     catch (Exception e) { System.Windows.MessageBox.Show("There was a problem opening exam: " + e.ToString()); return false; }
 }
Example #42
0
 private IExam CreateExam(int examID, int patientID, ExamType type)
 {
     try
     {
         IExam exam = null;
         switch (type)
         {
             case ExamType.REVIEW:
                 exam = new Exam(examID, patientID, type);
                 break;
             case ExamType.PULMONARY:
                 exam = new VQExam(examID, patientID, type);
                 break;
         }
         return exam;
     }
     catch (Exception e) { System.Windows.MessageBox.Show("There was an error creating the exam reference: " + e.ToString()); return null; }
 }
Example #43
0
        public VQExam(int examID, int ptID, ExamType type) : base (examID, ptID, type)
        {

        }
Example #44
0
 public ExamElementEventArgs(ExamElement element, ExamType type)
 {
     this.Element = element;
     this.Type = type;
 }