public TestSegment GetTestSegment(string itsFormKey) { TestForm testForm = string.IsNullOrEmpty(itsFormKey) ? null: GetTestForm(itsFormKey); return(testForm == null ? new TestSegment(SegmentName, TestPosition, null, null, SelectionAlgorithmString, SelectionAlgorithm) : new TestSegment(SegmentName, TestPosition, testForm.FormID, testForm.ITSFormKey, SelectionAlgorithmString, SelectionAlgorithm)); }
public void AddTestForm(TestForm form) { if (_testForms.ContainsKey(form.ITSFormKey)) { _testForms[form.ITSFormKey] = form; } else { _testForms.Add(form.ITSFormKey, form); } }
/// <summary> /// Add an item to a form /// </summary> /// <param name="itemBank"></param> /// <param name="formName"></param> /// <param name="formKey"></param> /// <param name="startDate"></param> /// <param name="endDate"></param> /// <param name="position"></param> /// <param name="ti"></param> internal void AddFormItem(long itemBank, string formName, long formKey, DateTime startDate, DateTime endDate, int position, TestItem ti) { if (!HasForm(formName)) { _forms[formName] = new TestForm(itemBank, formName, formKey, startDate, endDate); } else { if (_forms[formName].StartDate != startDate) { throw new ScoringEngineException("Non-unique start date for form '" + formName + "', got both " + _forms[formName].StartDate.ToString() + " and " + startDate.ToString()); } if (_forms[formName].EndDate != endDate) { throw new ScoringEngineException("Non-unique end date for form '" + formName + "', got both " + _forms[formName].EndDate.ToString() + " and " + endDate.ToString()); } } _forms[formName].AddItem(formKey, position, ti); }
/// <summary> /// In case of a test with multiple segments and formNames being a dash separated list of segment form names, /// return the test form (as a concatenated list of all segment items). /// </summary> /// <param name="formName"></param> /// <returns></returns> public TestForm GetMultiSegmentForm(string formNames) { List <TestForm> forms = new List <TestForm>(); DateTime startDate = DateTime.MinValue; DateTime endDate = DateTime.MaxValue; while (formNames.Length > 0) { TestForm foundForm = null; foreach (string formName in _forms.Keys) { if (formNames == formName) { formNames = ""; foundForm = _forms[formName]; break; } else if (formNames.StartsWith(formName + "-")) { formNames = formNames.Substring(formName.Length + 1); foundForm = _forms[formName]; break; } } if (foundForm == null) { return(null); } else { forms.Add(foundForm); if (foundForm.StartDate > startDate) { startDate = foundForm.StartDate; } if (foundForm.EndDate < endDate) { endDate = foundForm.EndDate; } } } if (forms.Count == 0) { return(null); } if (forms.Count == 1) { return(forms[0]); } TestForm catForm = new TestForm(-1, formNames, -1, startDate, endDate); int position = 0; foreach (TestForm form in forms) { for (int i = 1; i <= form.Items.Count; i++) { position += 1; catForm.AddItem(-1, position, form.Items[i]); } } return(catForm); }