Ejemplo n.º 1
0
        public void UpdateAnswerById(AnswerDTO answerDto)
        {
            AnswerDTO  a      = new AnswerDTO();
            AnswerCRUD answer = new AnswerCRUD();

            answer.Update(answerDto);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// יצירת שאלה
 /// </summary>
 /// <param name="question"></param>
 /// <returns></returns>
 public static bool CreateQuestion(QuestionVM question, int userId)
 {
     using (var ctx = new testitprojectEntities())
     {
         var q = QuestionCRUD.CreateQuestion(ctx, question, userId);
         foreach (var ans in question.Answers)
         {
             AnswerCRUD.CreateAnswer(ctx, q, ans);
         }
         ctx.SaveChanges();
         return(true);
     }
 }
Ejemplo n.º 3
0
 public static bool CreateQuestion(QuestionVM question)
 {
     using (var ctx = new checkTestEntities1())
     {
         var q = QuestionCRUD.CreateQuestion(ctx, question);
         foreach (var ans in question.Answers)
         {
             AnswerCRUD.CreateAnswer(ctx, q, ans);
         }
         ctx.SaveChanges();
         return(true);
     }
 }
Ejemplo n.º 4
0
 public static bool CreateTest(TestVM testvm)
 {
     using (checkTestEntities1 ctx = new checkTestEntities1())
     {
         Test test = TestCRUD.CreateTest(ctx, testvm);
         foreach (var quest in testvm.questionArr)
         {
             quest.categoryId = testvm.categoriId;
             var question = QuestionCRUD.CreateQuestion(ctx, quest);
             foreach (var ans in quest.Answers)
             {
                 if (ans.answerDescription != null)
                 {
                     AnswerCRUD.CreateAnswer(ctx, question, ans);
                 }
             }
             QuestionForTestCRUD.CreateQuestionForTest(ctx, question, test, quest.nikud);
         }
         ctx.SaveChanges();
         return(true);
     }
 }
Ejemplo n.º 5
0
        public bool suggestQuestion(QuestionVM newQuestion, int userId)
        {
            newQuestion.categoryId = 1;                                  //TODO
            //newQuestion.questionDescription = "תעבוד?";
            QuestionCRUD.CreateQuestion(Entity.db, newQuestion, userId); //הוספת השאלה למאגר
            Question newq = Entity.db.Questions.FirstOrDefault(q => q.questionDescription == newQuestion.questionDescription);

            //newq.Answers = null;
            foreach (var ans in newQuestion.Answers)
            {
                if (ans.answerDescription != null)
                {
                    AnswerCRUD.CreateAnswer(Entity.db, newq, ans);//הוספת התשובות למאגר
                    newq.Answers.Add(Entity.db.Answers.FirstOrDefault(a => a.answerDescription == ans.answerDescription));
                }
            }

            //List<AnswerVM> answersvm = new List<AnswerVM>();
            //foreach (var a in newq.Answers)
            //{
            //    answersvm.Add(new AnswerVM()
            //    {
            //        answerDescription = a.answerDescription,
            //        answerId = a.answerId,
            //        isCorrect = a.isCorrect
            //    });
            //}
            //newQuestion = new QuestionVM()
            //{
            //    questionDescription = newq.questionDescription,
            //    Answers = answersvm,
            //    categoryId = newq.categoriId,
            //    isPrivate = newq.isPrivate,
            //    nikud = 0,
            //    questionId = newq.questionId,
            //    teacherId = 25//to change
            //};

            //if (Entity.db.Questions.FirstOrDefault(q => newQuestion.questionId == q.questionId) == null)
            //{
            //    newQuestion.categoryId = 1;//TODO
            //    newQuestion.questionDescription = "מה איתך?";
            //    questionid = 18;
            //}
            //else
            //{
            //
            // newQuestion.categoryId = 1;//TODO
            //  questionid = Entity.db.Questions.FirstOrDefault(q => newq.questionId == q.questionId).questionId;
            // }

            Entity.db.SaveChanges();
            //      int categoryid = newq.categoriId;

            //int questionid = Entity.db.Questions.FirstOrDefault(q => newQuestion.questionId == q.questionId).questionId;
            // string category = "מתמטיקה";//לשנותתת - זה נפל פה!!!
            //string category = Entity.db.Categories.FirstOrDefault(c => c.categoryId == categoryid).ToString();

            string htmlText = @"
                    <head> 
                        <style> 
                            body{background-color:cadetblue;direction:rtl;text-align:center;}
                            h1,h3,p{font-size:20px; text-align:center;color:blue;}
                        </style>
                    </head>
                    <body>";

            htmlText += "<h1>מנהל המאגר היקר  </h1><p>" + "הרי לפניך הצעת שאלה חדשה למאגר השאלות </p>" + "<h3>נושא השאלה :" + newq.categoriId + "</h3></br><h3> " + newq.questionDescription + " </h3></br>";
            List <Answer> answers = Entity.db.Answers.Where(a => a.questionId == newq.questionId).ToList();
            int           num     = 0;

            foreach (var item in newq.Answers)
            {
                htmlText += "<h4>תשובה   " + ++num + ". <p>" + item.answerDescription + " </p></h4>";
            }
            htmlText += "</br><a href='http://localhost:4200/Questionauto/" + newq.questionId + "'>הוסף עכשיו</a>";
            htmlText += "</body>";
            //htmlText += " <img src='cid:G:/ל סיון/C#IDEAL/GUI/UploadFile/.JPG'></body>";
            Class1.SendEmail(htmlText, "הצעת שאלה חדשה  ", "");

            return(true);
        }
Ejemplo n.º 6
0
        public int AddAnswer(AnswerDTO dto)
        {
            AnswerCRUD answer = new AnswerCRUD();

            return(answer.Add(dto));
        }
Ejemplo n.º 7
0
        public void DeleteAnswerById(int id)
        {
            AnswerCRUD answer = new AnswerCRUD();

            answer.Delete(id);
        }
Ejemplo n.º 8
0
        public List <AnswerDTO> GetAnswerByQuestionId(int questonId)
        {
            AnswerCRUD answers = new AnswerCRUD();

            return(answers.GetByQuestionId(questonId));
        }
Ejemplo n.º 9
0
        public AnswerDTO GetAnswerById(int answerId)     // вывод ответа по ID
        {
            AnswerCRUD answer = new AnswerCRUD();

            return(answer.GetById(answerId));
        }