Ejemplo n.º 1
0
        public QuestionsDetailsView QuestionsEdit(Guid?QuestionId)
        {
            QuestionsDetailsView detail = new QuestionsDetailsView();

            try
            {
                var data = objQuestion.QuestionsEdit(QuestionId);
                detail.ID             = data.ID;
                detail.MasterQuestion = data.MasterQuestion;
                detail.Question       = data.Question;
                detail.Answer         = data.Answer;
                detail.ModifiedDate   = data.ModifiedDate;
                detail.OptionA        = data.OptionA;
                detail.OptionB        = data.OptionB;
                detail.OptionC        = data.OptionC;
                detail.OptionD        = data.OptionD;
                detail.OptionE        = data.OptionE;
                detail.IsMaster       = data.IsMaster;
                detail.QuestionBankID = data.QuestionBankID;
            }
            catch (Exception)
            {
                throw;
            }
            return(detail);
        }
Ejemplo n.º 2
0
        public APIResponse UpdateQuestion(QuestionsDetailsView questionsDetailsView)
        {
            APIResponse response = new APIResponse();

            response.Result = false;
            try
            {
                using (DBEntities testEngineEntities = new DBEntities())
                {
                    var data = testEngineEntities.QuestionsDetails.Where(x => x.ID == questionsDetailsView.ID && x.IsDeleted == false).FirstOrDefault();
                    if (data != null)
                    {
                        data.Answer         = questionsDetailsView.Answer;
                        data.OptionA        = questionsDetailsView.OptionA;
                        data.OptionB        = questionsDetailsView.OptionB;
                        data.OptionC        = questionsDetailsView.OptionC;
                        data.OptionD        = questionsDetailsView.OptionD;
                        data.OptionE        = questionsDetailsView.OptionE;
                        data.Question       = questionsDetailsView.Question;
                        data.MasterQuestion = questionsDetailsView.MasterQuestion;
                        data.ModifiedDate   = dateTime;;
                        testEngineEntities.SaveChanges();
                        response.Result = true;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(response);
        }
Ejemplo n.º 3
0
 void OnScrollComment(object sender, EventArgs args)
 {
     if (ViewModel.AnswersComment.Count > 0)
     {
         QuestionsDetailsView.ScrollTo(ViewModel.AnswersComment.First(), ScrollToPosition.Start, false);
     }
 }
Ejemplo n.º 4
0
        public List <QuestionsDetailsView> GetQuestionsList(Guid?QuestionId)
        {
            List <QuestionsDetailsView> detaillist = new List <QuestionsDetailsView>();

            try
            {
                var data = objQuestion.GetQuestionsList(QuestionId);
                if (data.Count > 0)
                {
                    data.ForEach(x =>
                    {
                        QuestionsDetailsView detail = new QuestionsDetailsView();
                        detail.ID             = x.ID;
                        detail.Question       = x.Question;
                        detail.Answer         = x.Answer;
                        detail.ModifiedDate   = x.ModifiedDate;
                        detail.OptionA        = x.OptionA;
                        detail.OptionB        = x.OptionB;
                        detail.OptionC        = x.OptionC;
                        detail.OptionD        = x.OptionD;
                        detail.OptionE        = x.OptionE;
                        detail.QuestionBankID = x.QuestionBankID;
                        detaillist.Add(detail);
                    });
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(detaillist);
        }
Ejemplo n.º 5
0
 private void OnResult(AnswersComment result)
 {
     if (result != null)
     {
         ViewModel.EditComment(result);
         QuestionsDetailsView.ScrollTo(ViewModel.AnswersComment.Last(), ScrollToPosition.Start, false);
     }
 }
Ejemplo n.º 6
0
        public APIResponse UpdateQuestion(QuestionsDetailsView questionsDetailsView)
        {
            APIResponse     aPIResponse     = new APIResponse();
            QuestionBankDAL questionBankDAL = new QuestionBankDAL();

            aPIResponse = questionBankDAL.UpdateQuestion(questionsDetailsView);

            return(aPIResponse);
        }
Ejemplo n.º 7
0
 public APIResponse UpdateQuestion(QuestionsDetailsView questionsDetailsView)
 {
     try
     {
         APIResponse = objQuestionBank.UpdateQuestion(questionsDetailsView);
     }
     catch (Exception ex)
     {
         throw;
     }
     return(APIResponse);
 }
Ejemplo n.º 8
0
        public QuestionsDetailsView QuestionsEdit(Guid?QuestionId)
        {
            QuestionsDetailsView detailsView = new QuestionsDetailsView();

            try
            {
                detailsView = objQuestionBank.QuestionsEdit(QuestionId);
            }
            catch (Exception ex)
            {
                throw;
            }
            return(detailsView);
        }
Ejemplo n.º 9
0
        public ActionResult UpdateQuestion(QuestionsDetailsView questionsDetailsView)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(apiUrl);
                var result = client.PostAsJsonAsync(apiUrl + "/QuestionBank/UpdateQuestion", questionsDetailsView).Result;
                if (result.IsSuccessStatusCode)
                {
                    var Result = result.Content.ReadAsStringAsync().Result;

                    APIResponse = JsonConvert.DeserializeObject <APIResponse>(Result);
                }
            }
            return(Json(APIResponse, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 10
0
        public ActionResult QuestionsEdit(Guid?QuestionId)
        {
            QuestionsDetailsView questionsDetailsView = new QuestionsDetailsView();

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(apiUrl);
                var result = client.GetAsync(apiUrl + "/QuestionBank/QuestionsEdit?QuestionId=" + QuestionId).Result;
                if (result.IsSuccessStatusCode)
                {
                    var Result = result.Content.ReadAsStringAsync().Result;

                    questionsDetailsView = JsonConvert.DeserializeObject <QuestionsDetailsView>(Result);
                }
            }
            return(Json(questionsDetailsView, JsonRequestBehavior.AllowGet));
        }
        public ActionResult UploadQuestionBank(string QuestionBankName, string Duration, string Description, bool Status)
        {
            string Result = "Failed";

            foreach (string file in Request.Files)
            {
                HttpPostedFileBase hpf           = Request.Files[file] as HttpPostedFileBase;
                string             fileextension = Path.GetExtension(hpf.FileName);
                var questionBankDetail           = new QuestionBankDetail();
                if (fileextension == ".xlsx" || fileextension == ".xls" || fileextension == ".csv")
                {
                    var dt = Common.ConvertFileToDateTable(hpf, "QuestionUploadFile");
                    List <QuestionsDetailsView> questionsDetailsView = new List <QuestionsDetailsView>();
                    var rowCount = dt.Rows.Count;
                    for (int i = 0; i < rowCount; i++)
                    {
                        QuestionsDetailsView questionDetail = new QuestionsDetailsView();
                        string Question = dt.Rows[i]["Question"] != DBNull.Value ? dt.Rows[i]["Question"].ToString().Trim().ToUpper() : string.Empty;
                        questionDetail.Question = Question;
                        string OptionA = dt.Rows[i]["OptionA"] != DBNull.Value ? dt.Rows[i]["OptionA"].ToString().Trim().ToUpper() : string.Empty;
                        questionDetail.OptionA = OptionA;
                        string OptionB = dt.Rows[i]["OptionB"] != DBNull.Value ? dt.Rows[i]["OptionB"].ToString().Trim().ToUpper() : string.Empty;
                        questionDetail.OptionB = OptionB;
                        string OptionC = dt.Rows[i]["OptionC"] != DBNull.Value ? dt.Rows[i]["OptionC"].ToString().Trim().ToUpper() : string.Empty;
                        questionDetail.OptionC = OptionC;
                        string OptionD = dt.Rows[i]["OptionD"] != DBNull.Value ? dt.Rows[i]["OptionD"].ToString().Trim().ToUpper() : string.Empty;
                        questionDetail.OptionC = OptionD;
                        string Answer = dt.Rows[i]["Answer"] != DBNull.Value ? dt.Rows[i]["Answer"].ToString().Trim().ToUpper() : string.Empty;
                        questionDetail.Answer = Answer;
                        if (questionDetail != null)
                        {
                            questionsDetailsView.Add(questionDetail);
                        }
                    }
                    if (questionsDetailsView.Any())
                    {
                        using (var client = new HttpClient())
                        {
                            questionBankDetail.Description      = Description;
                            questionBankDetail.QuestionBankName = QuestionBankName;
                            questionBankDetail.Status           = Status;
                            questionBankDetail.Duration         = new TimeSpan(0, 0, 13, 0, 0);
                            client.BaseAddress = new Uri(apiUrl);
                            var jsonSerialiser = new JavaScriptSerializer();
                            var json           = JsonConvert.SerializeObject(questionsDetailsView);
                            var responseTask   = client.GetAsync("QuestionBankUpload?QuestionsDetailsView=" + questionsDetailsView);
                            responseTask.Wait();
                            var result = responseTask.Result;
                            if (result.IsSuccessStatusCode)
                            {
                            }
                            else //web api sent error response
                            {
                                //log response status here..
                            }
                        }
                    }
                }
            }
            return(Json(""));
        }
Ejemplo n.º 12
0
        public ActionResult UploadQuestionBank(string QuestionBankName, string Duration, string Description, bool Status)
        {
            APIResponse response         = new APIResponse();
            int         duplicates       = 0;
            int         NoAnswer         = 0;
            int         NoOption         = 0;
            int         NoQuestion       = 0;
            int         MasterQuestionId = 1000;

            try
            {
                string Result = "Failed";
                logger.WriteToLogFile("UploadQuestionBank - Starts");

                foreach (string file in Request.Files)
                {
                    HttpPostedFileBase hpf                = Request.Files[file] as HttpPostedFileBase;
                    string             fileextension      = Path.GetExtension(hpf.FileName);
                    QuestionBankDetail questionBankDetail = new QuestionBankDetail();
                    questionBankDetail.questionsDetailsViews = new List <QuestionsDetailsView>();
                    if (fileextension == ".xlsx" || fileextension == ".xls" || fileextension == ".csv")
                    {
                        var dt = Common.ConvertFileToDateTable(hpf, "QuestionUploadFile");
                        List <QuestionsDetailsView> questionsDetailsView = new List <QuestionsDetailsView>();
                        var rowCount = dt.Rows.Count;
                        for (int i = 0; i < rowCount; i++)
                        {
                            QuestionsDetailsView questionDetail = new QuestionsDetailsView();
                            if (!string.IsNullOrEmpty(dt.Rows[i].ItemArray[0].ToString()))
                            {
                                string MasterQuestion = dt.Rows[i]["MasterQuestion"] != DBNull.Value ? dt.Rows[i]["MasterQuestion"].ToString().Trim().ToUpper() : string.Empty;
                                questionDetail.MasterQuestion = MasterQuestion.Trim();
                            }
                            string Question = dt.Rows[i]["Question"] != DBNull.Value ? dt.Rows[i]["Question"].ToString().Trim().ToUpper() : string.Empty;
                            questionDetail.Question = Question.Trim();
                            string OptionA = dt.Rows[i]["OptionA"] != DBNull.Value ? dt.Rows[i]["OptionA"].ToString().Trim().ToUpper() : string.Empty;
                            questionDetail.OptionA = OptionA.Trim();
                            string OptionB = dt.Rows[i]["OptionB"] != DBNull.Value ? dt.Rows[i]["OptionB"].ToString().Trim().ToUpper() : string.Empty;
                            questionDetail.OptionB = OptionB.Trim();
                            string OptionC = dt.Rows[i]["OptionC"] != DBNull.Value ? dt.Rows[i]["OptionC"].ToString().Trim().ToUpper() : string.Empty;
                            questionDetail.OptionC = OptionC.Trim();
                            string OptionD = dt.Rows[i]["OptionD"] != DBNull.Value ? dt.Rows[i]["OptionD"].ToString().Trim().ToUpper() : string.Empty;
                            questionDetail.OptionD = OptionD.Trim();
                            string OptionE = dt.Rows[i]["OptionE"] != DBNull.Value ? dt.Rows[i]["OptionE"].ToString().Trim().ToUpper() : string.Empty;
                            questionDetail.OptionE = OptionE.Trim();
                            string Answer = dt.Rows[i]["Answer"] != DBNull.Value ? dt.Rows[i]["Answer"].ToString().Trim().ToUpper() : string.Empty;
                            questionDetail.Answer = Answer.Trim();
                            if (questionDetail != null)
                            {
                                if (questionsDetailsView.Any(x => x.Question.Trim().ToUpper() == questionDetail.Question.Trim().ToUpper()))
                                {
                                    duplicates++;
                                }
                                else if (string.IsNullOrEmpty(questionDetail.Answer))
                                {
                                    NoAnswer++;
                                }
                                else if (string.IsNullOrEmpty(questionDetail.OptionA) && string.IsNullOrEmpty(questionDetail.OptionB) && string.IsNullOrEmpty(questionDetail.OptionC) && string.IsNullOrEmpty(questionDetail.OptionD) && string.IsNullOrEmpty(questionDetail.OptionE))
                                {
                                    NoOption++;
                                }
                                else if (string.IsNullOrEmpty(questionDetail.Question))
                                {
                                    NoQuestion++;
                                }
                                else
                                {
                                    questionsDetailsView.Add(questionDetail);
                                }
                            }
                        }

                        var duplicateserror = "Duplicates Questions : " + duplicates;
                        var noanserror      = "Question without Answer : " + NoAnswer;
                        var nooptionerror   = "Question without Option : " + NoOption;
                        var noquestionerror = "Question without Question : " + NoQuestion;
                        var ResultMessage   = "Question bank Upload Failed";
                        var AlertMessages   = "";
                        if (duplicates > 0 && NoAnswer == 0 && NoOption == 0 && NoQuestion == 0)
                        {
                            AlertMessages = " => " + duplicateserror;
                        }
                        else if (duplicates == 0 && NoAnswer > 0 && NoOption == 0 && NoQuestion == 0)
                        {
                            AlertMessages = " => " + noanserror;
                        }
                        else if (duplicates == 0 && NoAnswer == 0 && NoOption > 0 && NoQuestion == 0)
                        {
                            AlertMessages = " => " + nooptionerror;
                        }
                        else if (duplicates == 0 && NoAnswer == 0 && NoOption == 0 && NoQuestion > 0)
                        {
                            AlertMessages = " => " + nooptionerror;
                        }
                        else if (duplicates > 0 && NoAnswer > 0 && NoOption == 0 && NoQuestion == 0)
                        {
                            AlertMessages = " => " + duplicateserror + " || " + noanserror;
                        }
                        else if (duplicates > 0 && NoAnswer == 0 && NoOption > 0 && NoQuestion == 0)
                        {
                            AlertMessages = " => " + duplicateserror + " || " + nooptionerror;
                        }
                        else if (duplicates > 0 && NoAnswer == 0 && NoOption == 0 && NoQuestion > 0)
                        {
                            AlertMessages = " => " + duplicateserror + " || " + noquestionerror;
                        }
                        else if (duplicates == 0 && NoAnswer > 0 && NoOption == 0 && NoQuestion > 0)
                        {
                            AlertMessages = " => " + noanserror + " || " + noquestionerror;
                        }
                        else if (duplicates == 0 && NoAnswer == 0 && NoOption > 0 && NoQuestion > 0)
                        {
                            AlertMessages = " => " + nooptionerror + " || " + noquestionerror;
                        }
                        else if (duplicates > 0 && NoAnswer > 0 && NoOption > 0 && NoQuestion == 0)
                        {
                            AlertMessages = " => " + duplicateserror + " || " + noanserror + " || " + nooptionerror;
                        }
                        else if (duplicates > 0 && NoAnswer > 0 && NoOption == 0 && NoQuestion > 0)
                        {
                            AlertMessages = " => " + duplicateserror + " || " + noanserror + " || " + noquestionerror;
                        }
                        else if (duplicates > 0 && NoAnswer == 0 && NoOption > 0 && NoQuestion > 0)
                        {
                            AlertMessages = " => " + duplicateserror + " || " + nooptionerror + " || " + noquestionerror;
                        }
                        else if (duplicates == 0 && NoAnswer > 0 && NoOption > 0 && NoQuestion > 0)
                        {
                            AlertMessages = " => " + nooptionerror + " || " + noanserror + " || " + noquestionerror;
                        }
                        else if (duplicates > 0 && NoAnswer > 0 && NoOption > 0 && NoQuestion > 0)
                        {
                            AlertMessages = " => " + duplicateserror + " || " + noanserror + " || " + noquestionerror + " || " + nooptionerror;
                        }
                        if (questionsDetailsView.Any())
                        {
                            questionBankDetail.questionsDetailsViews = questionsDetailsView;
                            using (var client = new HttpClient())
                            {
                                questionBankDetail.Description      = Description;
                                questionBankDetail.QuestionBankName = QuestionBankName;
                                questionBankDetail.Status           = Status;
                                var splitData = Duration.Split(':');
                                int hour      = splitData.Length > 0 ? Convert.ToInt32(splitData[0]) : 0;
                                int minutes   = splitData.Length > 1 ? Convert.ToInt32(splitData[1]) : 0;
                                int sec       = splitData.Length > 2 ? Convert.ToInt32(splitData[2]) : 0;
                                questionBankDetail.Duration = new TimeSpan(hour, minutes, sec);
                                var masterlist = questionBankDetail.questionsDetailsViews.Where(x => !string.IsNullOrEmpty(x.MasterQuestion)).ToList();
                                questionBankDetail.questionsDetailsViews = questionBankDetail.questionsDetailsViews.Where(x => string.IsNullOrEmpty(x.MasterQuestion)).ToList();
                                foreach (var items in masterlist)
                                {
                                    for (var i = 0; i <= masterlist.Count - 1; i++)
                                    {
                                        if (items.MasterQuestion == masterlist[i].MasterQuestion)
                                        {
                                            items.MasterQuestionId = MasterQuestionId;
                                        }
                                    }
                                    MasterQuestionId++;
                                }

                                questionBankDetail.questionsDetailsViews.AddRange(masterlist);

                                if (questionBankDetail.questionsDetailsViews.Count > 0)
                                {
                                    client.BaseAddress = new Uri(apiUrl);
                                    var result = client.PostAsJsonAsync(apiUrl + "/QuestionBank/UploadQuestionBank", questionBankDetail).Result;
                                    if (result.IsSuccessStatusCode)
                                    {
                                        Result = result.Content.ReadAsStringAsync().Result;

                                        response      = JsonConvert.DeserializeObject <APIResponse>(Result);
                                        ResultMessage = "Question bank Uploaded Succesfully";
                                    }
                                }
                            }
                        }

                        response.Message = ResultMessage + AlertMessages;
                    }
                }
            }
            catch (Exception ex)
            {
                logger.WriteToLogFile("UploadQuestionBank - " + ex.ToString());
                if (ex.InnerException != null)
                {
                    logger.WriteToLogFile("UploadQuestionBank InnerException - " + ex.ToString());
                }
            }

            return(this.Json(new { data = response }));
        }