//------------------------------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// theory functions /// </summary> /// <param name="theoryQuestion"></param> public void Add_theory_q(BE.TheoryQuestion theoryQuestion) { if (theoryQuestion.Question == null) { throw new Exception("שגיאה בהוספת שאלה: השאלה לא יכולה להיות ריקה. "); } Dal.Add_theory_q(theoryQuestion); }
public void Remove_theory_q(BE.TheoryQuestion theoryQuestion) { try { TheoryRoot = XElement.Load(TheoryPath); XElement TheoryElement = (from item in TheoryRoot.Elements() where item.Element("Question").Value == theoryQuestion.Question select item).FirstOrDefault(); TheoryElement.Remove(); TheoryRoot.Save(TheoryPath); } catch { throw new Exception("שגיאה במחיקת השאלה: לא ניתן למצוא את השאלה"); } }
/// <summary> /// /// </summary> /// <param name="question"></param> /// <param name="rand"></param> public string[] GetOptions(BE.TheoryQuestion question, Random rand) { List <string> options = new List <string>(question.Wrong); options.Add(question.Answer); string[] random_options = new string[4]; for (int i = 0; i < random_options.Length; i++) // getting a random options without repeat { int index = rand.Next(0, options.Count); random_options[i] = options[index]; options.RemoveAt(index); } return(random_options); }
/// <summary> /// /// </summary> public BE.TheoryQuestion[] GetTheoryTest() { List <BE.TheoryQuestion> tq = Dal.GetTQ(); BE.TheoryQuestion[] return_test = new BE.TheoryQuestion[BE.Configuration.Amount_questions]; Random rand = new Random(); for (int i = 0; i < return_test.Length; i++) // getting a random question without repeat { int index = rand.Next(0, tq.Count); return_test[i] = tq[index]; return_test[i].Student_answer = "לא ענית תשובה"; tq.RemoveAt(index); } return(return_test); }
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// theory functions /// </summary> /// <param name="theoryQuestion"></param> public void Add_theory_q(BE.TheoryQuestion theoryQuestion) { try { TheoryRoot = XElement.Load(TheoryPath); XElement Question = new XElement("Question", theoryQuestion.Question); XElement Answer = new XElement("Answer", theoryQuestion.Answer); XElement Wrong = WrongToSXElement(theoryQuestion.Wrong); XElement Image_code = new XElement("Image_code", theoryQuestion.Image_code); TheoryRoot.Add(new XElement("TheoryQuestion", Question, Answer, Wrong, Image_code)); TheoryRoot.Save(TheoryPath); } catch { throw new Exception("שגיאה בשמירת מבחן: קרתה תקלה בגישה אל קובץ הנתונים, אנא נסה שוב"); } }
public TheoryQuestionUserControl(BE.TheoryQuestion tq, CheckBox cb, int index, Random rand) { InitializeComponent(); theory_question = tq; check_box = cb; options = new RadioButton[] { option1, option2, option3, option4 }; questin.Text = "שאלה " + (index + 1) + ": " + theory_question.Question; string[] QandA = iBL_Imp.GetOptions(theory_question, rand); for (int i = 0; i < options.Length; i++) { options[i].Content = QandA[i]; options[i].Checked += Option_Checked; } if (theory_question.Image_code != null) { question_image.Source = iBL_Imp.StringToBitmap(theory_question.Image_code); question_image.Visibility = Visibility.Visible; } }
public void Remove_theory_q(BE.TheoryQuestion theoryQuestion) { }
//-------------------------------------------------------------- public void Add_theory_q(BE.TheoryQuestion theoryQuestion) { }
public void Remove_theory_q(BE.TheoryQuestion theoryQuestion) { Dal.Remove_theory_q(theoryQuestion); }