Example #1
0
        public void Add(ExamTypesDataModel examTypesDataModel)
        {
            ExamTypes examTypes;

            examTypes = new ExamTypes
            {
                Id                = examTypesDataModel.Id,
                ExamTypeName      = examTypesDataModel.ExamTypeName,
                DifficultyLevelId = examTypesDataModel.DifficultyLevelId,
                NumberOfQuestions = examTypesDataModel.NumberOfQuestions
            };
            _contextGateWay.CreateDatabaseTransaction();

            _contextGateWay.ExamTypes.Add(examTypes);
            foreach (ExamTypesDetailsDataModel examTypesDetails in examTypesDataModel.examTypesDetails)
            {
                _contextGateWay.ExamTypesDetails.Add(
                    new ExamTypesDetails
                {
                    DifficultyLevelId = examTypesDetails.DifficultyLevelId,
                    NumberOfQuestions = examTypesDetails.NumberOfQuestions,
                    ExamTypeId        = examTypes.Id
                });
            }
            _contextGateWay.Commit();
        }
Example #2
0
        private void rbTestType_CheckedChanged(object sender, EventArgs e)
        {
            RadioButton rb = (RadioButton)sender;

            if (rb.Checked)
            {
                int iTemp = (int)Enum.Parse(typeof(ExamTypes), (string)rb.Tag);
                Properties.Settings.Default.LastTestType = iTemp;
                Properties.Settings.Default.Save();
                switch ((string)rb.Tag)
                {
                case "Regular":
                    enCurrentExamType         = ExamTypes.Regular;
                    txtNumberOfQuestions.Text = dicElementQamt[cmbElementNumber.Text].ToString();
                    break;

                case "Subelement":
                    enCurrentExamType         = ExamTypes.Subelement;
                    txtNumberOfQuestions.Text = GetSubelementQcount().ToString();
                    break;

                case "KeyTopic":
                    enCurrentExamType         = ExamTypes.KeyTopic;
                    txtNumberOfQuestions.Text = GetKeyTopicQcount().ToString();
                    break;

                default:
                    throw new Exception("Unknown test type in rbTestType_CheckedChanged");
                }
            }
        }
Example #3
0
        public async Task <IActionResult> ExamEdit(int id, [Bind("ExamType_Id,ExamType_Name")] ExamTypes examTypes)
        {
            if (id != examTypes.ExamType_Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(examTypes);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ExamTypesExists(examTypes.ExamType_Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(ExamIndex)));
            }
            return(View(examTypes));
        }
Example #4
0
        public async Task <IActionResult> CreateExam([Bind("ExamType_Id,ExamType_Name")] ExamTypes examTypes)
        {
            if (ModelState.IsValid)
            {
                _context.Add(examTypes);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(ExamIndex)));
            }
            return(View(examTypes));
        }
Example #5
0
        public ExamTypesDataModel Map(IRepository repository)
        {
            ExamTypes examTypes = (ExamTypes)repository;

            return(new ExamTypesDataModel
            {
                Id = examTypes.Id,
                ExamTypeName = examTypes.ExamTypeName,
                DifficultyLevelId = examTypes.DifficultyLevelId,
                NumberOfQuestions = examTypes.NumberOfQuestions
            });
        }
Example #6
0
        private void LoadSettings()
        {
            sDBfilepath    = Properties.Settings.Default.DataFilePath;
            txtDBpath.Text = sDBfilepath;             //.Substring(sDBfilepath.LastIndexOf("\\") + 1);

            dicElementQamt.Clear();
            char[] splitVal = new char[] { ',' };
            foreach (string s in Properties.Settings.Default.QsPerElement)
            {
                string[] splitArray = s.Split(splitVal);
                dicElementQamt.Add(splitArray[0], int.Parse(splitArray[1]));
            }
            if (Properties.Settings.Default.LastOutputFolder != "")
            {
                OutputFileForm.txtOutputFolder.Text = Properties.Settings.Default.LastOutputFolder;
            }
            if (Properties.Settings.Default.LastOutputFile != "")
            {
                OutputFileForm.txtOutputFileName.Text = Properties.Settings.Default.LastOutputFile;
            }
            chkRandomDist.Checked = Properties.Settings.Default.RandomDistrubtion;
            cmbElementNumber.Text = Properties.Settings.Default.LastExamElement.ToString();
            cmbSubelements.Text   = Properties.Settings.Default.LastSubElement;
            cmbKeyTopic.Text      = Properties.Settings.Default.LastKeyTopic;
            int iLastTest = Properties.Settings.Default.LastTestType;

            switch (iLastTest)
            {
            case (int)ExamTypes.Regular:
                enCurrentExamType     = ExamTypes.Regular;
                rbRegularTest.Checked = true;
                break;

            case (int)ExamTypes.Subelement:
                enCurrentExamType        = ExamTypes.Subelement;
                rbSubelementTest.Checked = true;
                break;

            case (int)ExamTypes.KeyTopic:
                enCurrentExamType      = ExamTypes.KeyTopic;
                rbKeyTopicTest.Checked = true;
                break;

            default:
                throw new Exception("Unknown exam type! LoadSettings()");
            }
            chkRandomAnswers.Checked = Properties.Settings.Default.RandomizeAnswers;
            chkLearnMode.Checked     = Properties.Settings.Default.LearnModeOn;
        }
        /// <summary>
        /// Call Web API and get all Exams Data
        /// </summary>
        public void LoadData()
        {
            // setting
            //string WebApiUrl = Settings.Default.WebAPIURL;
            string WebApiUrl = ConfigurationManager.AppSettings["WebApiURL"].ToString();

            // Code to call API
            // First need to install a Nudget Package if is not exists: "Microsoft.AspNet.WebApi.Client"

            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri(WebApiUrl);
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            ResourceDictionary rd = this.Resources.MergedDictionaries[0];

            try
            {
                HttpResponseMessage response = client.GetAsync("/api/ExamTypes").Result;
                if (response.IsSuccessStatusCode)
                {
                    var items = response.Content.ReadAsAsync <IEnumerable <ExamTypes> >().Result;

                    List <ExamTypes> listExamTypes = new List <ExamTypes>();
                    foreach (var i in items)
                    {
                        ExamTypes ex = new ExamTypes();
                        ex.Id   = i.Id;
                        ex.Exam = i.Exam;
                        listExamTypes.Add(ex);
                    }

                    this.ExamsListBox.ItemsSource = listExamTypes;
                }
                else
                {
                    MessageBox.Show("Error Code " + response.StatusCode + ": Message - " + response.ReasonPhrase);
                }

                this.TotalSelectedExamsText.Text = 0 + " " + rd["InsertNewExam.TotalSelectedExams"];
            }
            catch (Exception)
            {
                MessageBox.Show(rd["Error.WebAPINotFoundText"].ToString(), rd["Error.WebAPINotFoundTitle"].ToString());
            }
        }
Example #8
0
        /// <summary>
        /// Get all Exam Types
        /// </summary>
        /// <exception cref="NotImplementedException"></exception>
        /// <returns>The Exam Types(s)</returns>
        public async Task <Exam[]> GetExamTypes()
        {
            //Get the JSON
            ExamTypes requestExams = new ExamTypes();

            //Send and receive JSON from WebUntis
            string requestJson  = JsonConvert.SerializeObject(requestExams);
            string responseJson = await SendJsonAndWait(requestJson, _url, SessionId);

            //Parse JSON to Class
            ExamResult result = JsonConvert.DeserializeObject <ExamResult>(responseJson);

            string errorMsg = wus.LastError.Message;

            if (!SuppressErrors && errorMsg != null)
            {
                Logger.Append(Logger.LogLevel.Error, errorMsg);
                throw new WebUntisException(errorMsg);
            }

            //Return the Exams Types(s)
            return(result.result);
        }