/// <summary> /// Gets the query multiple choice options. /// </summary> /// <param name="multipleChoiceOptions">The multiple choice options.</param> /// <remarks>Documented by Dev02, 2008-01-11</remarks> public void GetQueryMultipleChoiceOptions(ref IQueryMultipleChoiceOptions multipleChoiceOptions) { multipleChoiceOptions.AllowRandomDistractors = checkBoxAllowRandomDistractors.Checked; multipleChoiceOptions.AllowMultipleCorrectAnswers = checkBoxAllowMultipleCorrectAnswers.Checked; multipleChoiceOptions.NumberOfChoices = Convert.ToInt32(numericUpDownNumberOfChoices.Value); multipleChoiceOptions.MaxNumberOfCorrectAnswers = Convert.ToInt32(numericUpDownMaxNumberOfCorrectAnswers.Value); }
internal XmlQueryOptions(XmlDictionary dictionary, ParentClass parentClass) { parent = parentClass; m_dictionary = dictionary.Dictionary; m_userSettings = (XmlElement)m_dictionary.SelectSingleNode(m_basePath); m_MultipleChoiceOptions = new XmlQueryMultipleChoiceOptions(dictionary, Parent.GetChildParentClass(this)); }
/// <summary> /// Sets the query multiple choice options. /// </summary> /// <param name="multipleChoiceOptions">The multiple choice options.</param> /// <remarks>Documented by Dev02, 2008-01-11</remarks> public void SetQueryMultipleChoiceOptions(IQueryMultipleChoiceOptions multipleChoiceOptions) { if (checkBoxAllowRandomDistractors.Enabled) { checkBoxAllowRandomDistractors.Checked = multipleChoiceOptions.AllowRandomDistractors.GetValueOrDefault(); } if (checkBoxAllowMultipleCorrectAnswers.Enabled) { checkBoxAllowMultipleCorrectAnswers.Checked = multipleChoiceOptions.AllowMultipleCorrectAnswers.GetValueOrDefault(); } if (numericUpDownNumberOfChoices.Enabled && multipleChoiceOptions.NumberOfChoices > 0) { numericUpDownNumberOfChoices.Value = multipleChoiceOptions.NumberOfChoices.GetValueOrDefault(); } if (numericUpDownMaxNumberOfCorrectAnswers.Enabled && multipleChoiceOptions.MaxNumberOfCorrectAnswers > 0) { numericUpDownMaxNumberOfCorrectAnswers.Value = multipleChoiceOptions.MaxNumberOfCorrectAnswers.GetValueOrDefault(); } }
/// <summary> /// Initializes a new instance of the <see cref="QueryMultipleChoiceOptions"/> class. /// </summary> /// <param name="defaultSettings">The default settings.</param> /// <param name="userSettings">The user settings.</param> /// <remarks>Documented by Dev08, 2009-04-10</remarks> public QueryMultipleChoiceOptions(IQueryMultipleChoiceOptions defaultSettings, IQueryMultipleChoiceOptions userSettings) { this.defaultSettings = defaultSettings; this.userSettings = userSettings; }
/// <summary> /// Sets the multiple choice options. /// </summary> /// <param name="id">The id.</param> /// <param name="MultipleChoiceOptions">The multiple choice options.</param> /// <remarks>Documented by Dev11, 2008-08-14</remarks> public void SetMultipleChoiceOptions(int id, IQueryMultipleChoiceOptions MultipleChoiceOptions) { using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "SELECT multiple_choice_options FROM \"Settings\" WHERE id=:id"; cmd.Parameters.Add("id", id); int mcoid = Convert.ToInt32(PostgreSQLConn.ExecuteScalar(cmd, Parent.CurrentUser)); if (mcoid > 0) { using (NpgsqlCommand cmd2 = con.CreateCommand()) { cmd2.CommandText = "UPDATE \"MultipleChoiceOptions\" SET " + "allow_multiple_correct_answers=:a_m_c_a, allow_random_distractors=:r_d, max_correct_answers=:m_c_a, number_of_choices=:n_o_c WHERE id=:id"; cmd2.Parameters.Add("id", mcoid); cmd2.Parameters.Add("a_m_c_a", MultipleChoiceOptions.AllowMultipleCorrectAnswers); cmd2.Parameters.Add("r_d", MultipleChoiceOptions.AllowRandomDistractors); cmd2.Parameters.Add("m_c_a", MultipleChoiceOptions.MaxNumberOfCorrectAnswers); cmd2.Parameters.Add("n_o_c", MultipleChoiceOptions.NumberOfChoices); PostgreSQLConn.ExecuteNonQuery(cmd2, Parent.CurrentUser); //Save to Cache Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsMultipleChoiceOptionsFk, id, Cache.DefaultSettingsValidationTime)] = mcoid; Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsMultipleChoiceOptionsAllowMultipleCorrectAnswers, mcoid, Cache.DefaultSettingsValidationTime)] = MultipleChoiceOptions.AllowMultipleCorrectAnswers; Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsMultipleChoiceOptionsAllowRandomDistractors, mcoid, Cache.DefaultSettingsValidationTime)] = MultipleChoiceOptions.AllowRandomDistractors; Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsMultipleChoiceOptionsMaxCorrectAnswers, mcoid, Cache.DefaultSettingsValidationTime)] = MultipleChoiceOptions.MaxNumberOfCorrectAnswers; Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsMultipleChoiceOptionsNumberOfChoices, mcoid, Cache.DefaultSettingsValidationTime)] = MultipleChoiceOptions.NumberOfChoices; } } else { using (NpgsqlCommand cmd3 = con.CreateCommand()) { cmd3.CommandText = "INSERT INTO \"MultipleChoiceOptions\" " + "(allow_multiple_correct_answers, allow_random_distractors, max_correct_answers, number_of_choices) VALUES " + "(:a_m_c_a, :r_d, :m_c_a, :n_o_c); UPDATE \"Settings\" SET multiple_choice_options=currval('\"MultipleChoiceOptions_id_seq\"') WHERE id=:id; " + "SELECT multiple_choice_options FROM \"Settings\" WHERE id=:id"; cmd3.Parameters.Add("id", id); cmd3.Parameters.Add("a_m_c_a", MultipleChoiceOptions.AllowMultipleCorrectAnswers); cmd3.Parameters.Add("r_d", MultipleChoiceOptions.AllowRandomDistractors); cmd3.Parameters.Add("m_c_a", MultipleChoiceOptions.MaxNumberOfCorrectAnswers); cmd3.Parameters.Add("n_o_c", MultipleChoiceOptions.NumberOfChoices); int? multipleChoiceOptionsId = PostgreSQLConn.ExecuteScalar<int>(cmd3, Parent.CurrentUser); //Save to Cache Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsMultipleChoiceOptionsFk, id, Cache.DefaultSettingsValidationTime)] = multipleChoiceOptionsId; Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsMultipleChoiceOptionsAllowMultipleCorrectAnswers, multipleChoiceOptionsId.Value, Cache.DefaultSettingsValidationTime)] = MultipleChoiceOptions.AllowMultipleCorrectAnswers; Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsMultipleChoiceOptionsAllowRandomDistractors, multipleChoiceOptionsId.Value, Cache.DefaultSettingsValidationTime)] = MultipleChoiceOptions.AllowRandomDistractors; Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsMultipleChoiceOptionsMaxCorrectAnswers, multipleChoiceOptionsId.Value, Cache.DefaultSettingsValidationTime)] = MultipleChoiceOptions.MaxNumberOfCorrectAnswers; Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsMultipleChoiceOptionsNumberOfChoices, multipleChoiceOptionsId.Value, Cache.DefaultSettingsValidationTime)] = MultipleChoiceOptions.NumberOfChoices; } } } } }
/// <summary> /// Sets the query multiple choice options. /// </summary> /// <param name="multipleChoiceOptions">The multiple choice options.</param> /// <remarks>Documented by Dev02, 2008-01-11</remarks> public void SetQueryMultipleChoiceOptions(IQueryMultipleChoiceOptions multipleChoiceOptions) { if (checkBoxAllowRandomDistractors.Enabled) checkBoxAllowRandomDistractors.Checked = multipleChoiceOptions.AllowRandomDistractors.GetValueOrDefault(); if (checkBoxAllowMultipleCorrectAnswers.Enabled) checkBoxAllowMultipleCorrectAnswers.Checked = multipleChoiceOptions.AllowMultipleCorrectAnswers.GetValueOrDefault(); if (numericUpDownNumberOfChoices.Enabled && multipleChoiceOptions.NumberOfChoices > 0) numericUpDownNumberOfChoices.Value = multipleChoiceOptions.NumberOfChoices.GetValueOrDefault(); if (numericUpDownMaxNumberOfCorrectAnswers.Enabled && multipleChoiceOptions.MaxNumberOfCorrectAnswers > 0) numericUpDownMaxNumberOfCorrectAnswers.Value = multipleChoiceOptions.MaxNumberOfCorrectAnswers.GetValueOrDefault(); }
internal XmlSettings(XmlDictionary dictionary, ParentClass parent) { this.parent = parent; this.dictionary = dictionary; m_dictionary = dictionary.Dictionary; m_Settings = (XmlElement)m_dictionary.SelectSingleNode(m_basePath); m_MultipleChoiceOptions = new XmlQueryMultipleChoiceOptions(dictionary, Parent.GetChildParentClass(this)); m_generalSettings = (XmlElement)m_dictionary.SelectSingleNode(m_xpathGenSet); m_userSettings = (XmlElement)m_dictionary.SelectSingleNode(m_xpathUsrSet); XPathNavigator navigator; XPathExpression expression; XPathNodeIterator nodeIterator; //read commentsound m_audioComments = new List<string>(); navigator = m_generalSettings.CreateNavigator(); expression = navigator.Compile(m_xpathCommentSound); expression.AddSort(m_xpathAttributeId, XmlSortOrder.Ascending, XmlCaseOrder.None, String.Empty, XmlDataType.Number); nodeIterator = navigator.Select(expression); while (nodeIterator.MoveNext()) m_audioComments.Add(nodeIterator.Current.Value); }
/// <summary> /// Cards the search filter MC options. /// </summary> /// <param name="settings">The settings.</param> /// <returns></returns> /// <remarks>Documented by Dev08, 2009-07-16</remarks> private bool CardSearchFilterMCOptions(IQueryMultipleChoiceOptions mcOptions) { //If all checkboxes are unchecked, return true; if (!toggleButtonAllowMultipleAnswers.IsChecked.Value && !toggleButtonAllowRandDistractors.IsChecked.Value && !toggleButtonMaxNumber.IsChecked.Value && !toggleButtonNumberChoices.IsChecked.Value) { return(true); } if (toggleButtonAllowMultipleAnswers.IsChecked.Value) { if (!mcOptions.AllowMultipleCorrectAnswers.HasValue) { return(false); } if (checkBoxFilterAllowMultipleCorrectAnswers.IsChecked.Value != mcOptions.AllowMultipleCorrectAnswers.Value) { return(false); } } if (toggleButtonAllowRandDistractors.IsChecked.Value) { if (!mcOptions.AllowRandomDistractors.HasValue) { return(false); } if (checkboxFilterAllowRandomDistractors.IsChecked.Value != mcOptions.AllowRandomDistractors.Value) { return(false); } } if (toggleButtonMaxNumber.IsChecked.Value) { if (!mcOptions.MaxNumberOfCorrectAnswers.HasValue) { return(false); } if (numericUpDownMaxNumberCorrectAnswers.Value != mcOptions.MaxNumberOfCorrectAnswers.Value) { return(false); } } if (toggleButtonNumberChoices.IsChecked.Value) { if (!mcOptions.NumberOfChoices.HasValue) { return(false); } if (numericUpDownNumberOfChoices.Value != mcOptions.NumberOfChoices.Value) { return(false); } } return(true); }
/// <summary> /// Sets the multiple choice options. /// </summary> /// <param name="id">The id.</param> /// <param name="MultipleChoiceOptions">The multiple choice options.</param> /// <remarks>Documented by Dev05, 2009-01-15</remarks> public void SetMultipleChoiceOptions(int id, IQueryMultipleChoiceOptions MultipleChoiceOptions) { SqlCeCommand cmd = MSSQLCEConn.CreateCommand(Parent.CurrentUser); cmd.CommandText = "SELECT multiple_choice_options FROM \"Settings\" WHERE id=@id"; cmd.Parameters.Add("@id", id); int mcoid = Convert.ToInt32(MSSQLCEConn.ExecuteScalar(cmd)); if (mcoid > 0) { SqlCeCommand cmd2 = MSSQLCEConn.CreateCommand(Parent.CurrentUser); cmd2.CommandText = "UPDATE \"MultipleChoiceOptions\" SET " + "allow_multiple_correct_answers=@a_m_c_a, allow_random_distractors=@r_d, max_correct_answers=@m_c_a, number_of_choices=@n_o_c WHERE id=@id"; cmd2.Parameters.Add("@id", mcoid); cmd2.Parameters.Add("@a_m_c_a", MultipleChoiceOptions.AllowMultipleCorrectAnswers); cmd2.Parameters.Add("@r_d", MultipleChoiceOptions.AllowRandomDistractors); cmd2.Parameters.Add("@m_c_a", MultipleChoiceOptions.MaxNumberOfCorrectAnswers); cmd2.Parameters.Add("@n_o_c", MultipleChoiceOptions.NumberOfChoices); MSSQLCEConn.ExecuteNonQuery(cmd2); //Save to Cache Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsMultipleChoiceOptionsFk, id, Cache.DefaultSettingsValidationTime)] = mcoid; Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsMultipleChoiceOptionsAllowMultipleCorrectAnswers, mcoid, Cache.DefaultSettingsValidationTime)] = MultipleChoiceOptions.AllowMultipleCorrectAnswers; Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsMultipleChoiceOptionsAllowRandomDistractors, mcoid, Cache.DefaultSettingsValidationTime)] = MultipleChoiceOptions.AllowRandomDistractors; Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsMultipleChoiceOptionsMaxCorrectAnswers, mcoid, Cache.DefaultSettingsValidationTime)] = MultipleChoiceOptions.MaxNumberOfCorrectAnswers; Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsMultipleChoiceOptionsNumberOfChoices, mcoid, Cache.DefaultSettingsValidationTime)] = MultipleChoiceOptions.NumberOfChoices; } else { SqlCeCommand cmd3 = MSSQLCEConn.CreateCommand(Parent.CurrentUser); cmd3.CommandText = "INSERT INTO \"MultipleChoiceOptions\" " + "(allow_multiple_correct_answers, allow_random_distractors, max_correct_answers, number_of_choices) VALUES " + "(@a_m_c_a, @r_d, @m_c_a, @n_o_c); UPDATE \"Settings\" SET multiple_choice_options=@@IDENTITY WHERE id=@id; " + "SELECT multiple_choice_options FROM \"Settings\" WHERE id=@id"; cmd3.Parameters.Add("@id", id); cmd3.Parameters.Add("@a_m_c_a", MultipleChoiceOptions.AllowMultipleCorrectAnswers); cmd3.Parameters.Add("@r_d", MultipleChoiceOptions.AllowRandomDistractors); cmd3.Parameters.Add("@m_c_a", MultipleChoiceOptions.MaxNumberOfCorrectAnswers); cmd3.Parameters.Add("@n_o_c", MultipleChoiceOptions.NumberOfChoices); int? multipleChoiceOptionsId = MSSQLCEConn.ExecuteScalar<int>(cmd3); //Save to Cache Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsMultipleChoiceOptionsFk, id, Cache.DefaultSettingsValidationTime)] = multipleChoiceOptionsId; Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsMultipleChoiceOptionsAllowMultipleCorrectAnswers, multipleChoiceOptionsId.Value, Cache.DefaultSettingsValidationTime)] = MultipleChoiceOptions.AllowMultipleCorrectAnswers; Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsMultipleChoiceOptionsAllowRandomDistractors, multipleChoiceOptionsId.Value, Cache.DefaultSettingsValidationTime)] = MultipleChoiceOptions.AllowRandomDistractors; Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsMultipleChoiceOptionsMaxCorrectAnswers, multipleChoiceOptionsId.Value, Cache.DefaultSettingsValidationTime)] = MultipleChoiceOptions.MaxNumberOfCorrectAnswers; Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.SettingsMultipleChoiceOptionsNumberOfChoices, multipleChoiceOptionsId.Value, Cache.DefaultSettingsValidationTime)] = MultipleChoiceOptions.NumberOfChoices; } }
/// <summary> /// Cards the search filter MC options. /// </summary> /// <param name="settings">The settings.</param> /// <returns></returns> /// <remarks>Documented by Dev08, 2009-07-16</remarks> private bool CardSearchFilterMCOptions(IQueryMultipleChoiceOptions mcOptions) { //If all checkboxes are unchecked, return true; if (!toggleButtonAllowMultipleAnswers.IsChecked.Value && !toggleButtonAllowRandDistractors.IsChecked.Value && !toggleButtonMaxNumber.IsChecked.Value && !toggleButtonNumberChoices.IsChecked.Value) return true; if (toggleButtonAllowMultipleAnswers.IsChecked.Value) { if (!mcOptions.AllowMultipleCorrectAnswers.HasValue) return false; if (checkBoxFilterAllowMultipleCorrectAnswers.IsChecked.Value != mcOptions.AllowMultipleCorrectAnswers.Value) return false; } if (toggleButtonAllowRandDistractors.IsChecked.Value) { if (!mcOptions.AllowRandomDistractors.HasValue) return false; if (checkboxFilterAllowRandomDistractors.IsChecked.Value != mcOptions.AllowRandomDistractors.Value) return false; } if (toggleButtonMaxNumber.IsChecked.Value) { if (!mcOptions.MaxNumberOfCorrectAnswers.HasValue) return false; if (numericUpDownMaxNumberCorrectAnswers.Value != mcOptions.MaxNumberOfCorrectAnswers.Value) return false; } if (toggleButtonNumberChoices.IsChecked.Value) { if (!mcOptions.NumberOfChoices.HasValue) return false; if (numericUpDownNumberOfChoices.Value != mcOptions.NumberOfChoices.Value) return false; } return true; }