public static IEnumerable <TextData> Test_ReadQuestionFiles(string directory, int limit = 0) { directory = zPath.Combine(XmlConfig.CurrentConfig.GetExplicit("CardDirectory"), directory); //TextDataReader textDataReader = new TextDataReader(QuestionsManager.GetScanFiles(directory, limit)); TextDataReader textDataReader = new TextDataReader(); textDataReader.SetRegexList(CreateQuestionRegexValuesList()); //return textDataReader.Read(QuestionsManager.GetScanFiles(zPath.Combine(directory, @"data\scan"), limit)); int pageNumber = 1; foreach (TextData textData in textDataReader.Read(QuestionsManager.GetScanFiles(zPath.Combine(directory, @"data\scan"), limit))) { yield return(textData); if (textData.Values.ContainsKey("pageNumber")) { pageNumber++; } if (textData.Values.ContainsKey("responses") && pageNumber > 1) { textDataReader.SetRegexList(CreateResponseRegexValuesList()); textDataReader.ContiguousSearch = true; } } }
public int StoreAnswer([FromBody] Answer answer) { if (answer == null) { return(0); } int assessmentId = Auth.AssessmentForUser(); string applicationMode = GetApplicationMode(assessmentId); if (answer.Is_Component) { QuestionsManager qm = new QuestionsManager(assessmentId); return(qm.StoreComponentAnswer(answer)); } if (answer.Is_Requirement) { RequirementsManager rm = new RequirementsManager(assessmentId); return(rm.StoreAnswer(answer)); } else { QuestionsManager qm = new QuestionsManager(assessmentId); return(qm.StoreAnswer(answer)); } }
public void TestGet() { var m = new QuestionsManager(); var r = m.Get(7); Assert.IsTrue(r.Success); }
public void HandleGuidTest() { using (CSET_Context db = new CSET_Context()) { var test = db.ASSESSMENT_DIAGRAM_COMPONENTS.Where(x => x.Component_Guid != null).FirstOrDefault(); if (test == null) { Assert.Fail("no data to test"); } try { QuestionsManager manager = new QuestionsManager(test.Assessment_Id); manager.HandleGuid(test.Component_Guid, true); var list = db.ANSWER.Where(x => x.Component_Guid == test.Component_Guid).ToList(); Assert.IsTrue(list.Count > 0); manager.HandleGuid(test.Component_Guid, false); list = db.ANSWER.Where(x => x.Component_Guid == test.Component_Guid).ToList(); Assert.IsTrue(list.Count == 0); } catch (Exception e) { throw e; } } }
public void SetMode([FromUri] string mode) { int assessmentId = Auth.AssessmentForUser(); QuestionsManager qm = new QuestionsManager(assessmentId); qm.SetApplicationMode(mode); }
private void Show() { Question question = QuestionsManager.GetCurrentQuestion(); questionText.text = question.QuestionText; if (question.Answers.Length == 2) { twoOptions.SetActive(true); int i = 0; foreach (Text text in twoOptions.GetComponentsInChildren <Text>()) { text.text = char.ConvertFromUtf32(65 + i) + ": " + question.Answers[i]; i++; } } else { fourOptions.SetActive(true); int i = 0; foreach (Text text in fourOptions.GetComponentsInChildren <Text>()) { text.text = char.ConvertFromUtf32(65 + i) + ": " + question.Answers[i]; i++; } } gameObject.SetActive(true); }
public DictionariesController(IHostingEnvironment hostingEnvironment, ILocalizationManager localizationManager, QuestionsManager questionsManager, PersonManager personManager) { _hostingEnvironment = hostingEnvironment; this.localizationManager = localizationManager; _questionsManager = questionsManager; _personManager = personManager; }
public QuestionResponse GetComponentOverridesList() { int assessmentId = Auth.AssessmentForUser(); QuestionsManager qm = new QuestionsManager(assessmentId); QuestionResponse resp = qm.GetOverrideListOnly(); return(resp); }
public QuestionDetailsContentViewModel GetDetails([FromUri] int QuestionId, string questionType) { int assessmentId = Auth.AssessmentForUser(); QuestionsManager qm = new QuestionsManager(assessmentId); return(qm.GetDetails(QuestionId, questionType)); }
public List <Answer_Components_Exploded_ForJSON> GetOverrideQuestions([FromUri] int question_id, int Component_Symbol_Id) { int assessmentId = Auth.AssessmentForUser(); QuestionsManager questionsManager = new QuestionsManager(assessmentId); return(questionsManager.GetOverrideQuestions(assessmentId, question_id, Component_Symbol_Id)); }
public QuestionDetailsContentViewModel GetDetails([FromUri] int QuestionId, bool IsComponent, bool IsMaturity) { int assessmentId = Auth.AssessmentForUser(); QuestionsManager qm = new QuestionsManager(assessmentId); return(qm.GetDetails(QuestionId, IsComponent, IsMaturity)); }
public void StoreSubcategoryAnswers([FromBody] SubCategoryAnswers subCatAnswers) { int assessmentId = Auth.AssessmentForUser(); QuestionsManager qm = new QuestionsManager(assessmentId); qm.StoreSubcategoryAnswers(subCatAnswers); }
public async Task <HttpResponseMessage> UploadToBlob() { string squestion_id = "questionId"; string sanswerId = "answerId"; string stitle = "title"; string bmaturity = "maturity"; int assessmentId = Auth.AssessmentForUser(); string fileHash; try { FileUploadStream fileUploader = new FileUploadStream(); Dictionary <string, string> formValues = new Dictionary <string, string>(); formValues.Add(squestion_id, null); formValues.Add(sanswerId, null); formValues.Add(stitle, null); formValues.Add(bmaturity, null); FileUploadStreamResult streamResult = await fileUploader.ProcessUploadStream(this.Request, formValues); // Find or create the Answer for the document to be associated with. // If they are attaching a document to a question that has not yet been answered, // the answerId will not be sent in the request. int questionId = int.Parse(streamResult.FormNameValues[squestion_id]); int answerId; bool isAnswerIdProvided = int.TryParse(streamResult.FormNameValues[sanswerId], out answerId); string title = streamResult.FormNameValues[stitle]; bool isMaturity = false; bool.TryParse(streamResult.FormNameValues[bmaturity], out isMaturity); if (!isAnswerIdProvided) { QuestionsManager qm = new QuestionsManager(assessmentId); Answer answer = new Answer(); answer.QuestionId = questionId; answer.AnswerText = "U"; answer.QuestionType = isMaturity ? "Maturity" : ""; answerId = qm.StoreAnswer(answer); } var dm = new DocumentManager(assessmentId); using (CSET_Context db = new CSET_Context()) { dm.AddDocument(title, answerId, streamResult); } // Return a current picture of this answer's documents return(Request.CreateResponse(dm.GetDocumentsForAnswer(answerId))); } catch (System.Exception e) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e)); } }
public QuestionDetailsContentViewModel GetDetails([FromUri] int QuestionId, bool IsComponent) { int assessmentId = Auth.AssessmentForUser(); string applicationMode = GetApplicationMode(assessmentId); QuestionsManager qm = new QuestionsManager(assessmentId); return(qm.GetDetails(QuestionId, assessmentId, IsComponent)); }
public void GenerateTestJSON() { FrameworkManager FM = new FrameworkManager(); AspectsManager AM = new AspectsManager(); AnswersManager ASWM = new AnswersManager(); QuestionsManager QM = new QuestionsManager(); NurseSelfAssessmentAnswersManager NSAM = new NurseSelfAssessmentAnswersManager(); //Get Aspects var aspect_Resul = AM.Get(); var aspects_List = (List <AspectEntity>)aspect_Resul.Entity; var aspects_Dict = aspects_List.ToDictionary(x => x.AspectId, x => x); //Get Answers var answers_result = ASWM.Get(); var answers_List = (List <AnswerEntity>)answers_result.Entity; var answers_Dict = answers_List.ToDictionary(x => (x.QuestionId, x.Value), x => x); //Get Questions var questions_result = QM.Get(); var questions_List = (List <QuestionEntity>)questions_result.Entity; var question_Dict = questions_List.ToDictionary(x => x.AspectId, x => x); var criteria = new Dictionary <int, AnswerEntity>(); var criteria_entity = new ListingCriteriaModel(); criteria_entity.EmmployerId = 1; criteria_entity.JobListingId = 3; decimal value = (decimal)0.66; for (int i = 1; i <= 30; i++) { var question = question_Dict[i]; var answer = new AnswerEntity(); if (answers_Dict.TryGetValue((question.QuestionId, value), out answer)) { criteria.Add(i, answer); } ; } criteria_entity.Answers = criteria; var json = JsonConvert.SerializeObject(criteria_entity); Console.WriteLine(json); Assert.IsTrue(true); }
public void SaveComponentOverride([FromUri] String guid, Boolean ShouldSave) { int assessmentId = Auth.AssessmentForUser(); string applicationMode = GetApplicationMode(assessmentId); QuestionsManager qm = new QuestionsManager(assessmentId); Guid g = new Guid(guid); qm.HandleGuid(g, ShouldSave); }
private void OnEnable() { if (_Instance == null) { _Instance = this; } else { Debug.LogError("ERROR: Instance Already Exists"); } }
private void LoadNextScene() { if (!QuestionsManager.WasLastQuestion()) { SceneManager.LoadScene(SceneManager.GetActiveScene().name); } else { SceneManager.LoadScene(1); } }
public void Start() { Hashtable props = new Hashtable { { InspiritVRQuizGame.PLAYER_LOADED_LEVEL, true } }; PhotonNetwork.LocalPlayer.SetCustomProperties(props); // Set the QuestionsManager reference _questionsManager = FindObjectOfType <QuestionsManager>(); }
//private Text levelEndTitle; //private Text levelEndSubtitle; public virtual void Awake() { gameObjectsHolder = gameObject.transform.GetChild(0).gameObject; gameObjectsHolder.SetActive(false); //Ensure holders are inactive at first uiManager = GameObject.Find("UI").GetComponent <UIManager>(); questionsManager = GameObject.Find("QuestionsManager").GetComponent <QuestionsManager>(); //TODO shouldn't all this live in UI manager? //levelEndTitle = GameObject.Find("ScoreSummaryUI").GetComponent<Text>(); //levelEndSubtitle = GameObject.Find("ScoreCommentUI").GetComponent<Text>(); foodPrompt = GameObject.Find("FoodPrompt").GetComponent <Text>(); }
public int StoreAnswer([FromBody] Answer answer) { if (answer == null) { return(0); } if (String.IsNullOrWhiteSpace(answer.QuestionType)) { if (answer.Is_Component) { answer.QuestionType = "Component"; } if (answer.Is_Maturity) { answer.QuestionType = "Maturity"; } if (answer.Is_Requirement) { answer.QuestionType = "Requirement"; } if (!answer.Is_Requirement && !answer.Is_Maturity && !answer.Is_Component) { answer.QuestionType = "Question"; } } int assessmentId = Auth.AssessmentForUser(); string applicationMode = GetApplicationMode(assessmentId); if (answer.Is_Component) { QuestionsManager qm = new QuestionsManager(assessmentId); return(qm.StoreComponentAnswer(answer)); } if (answer.Is_Requirement) { RequirementsManager rm = new RequirementsManager(assessmentId); return(rm.StoreAnswer(answer)); } if (answer.Is_Maturity) { MaturityManager mm = new MaturityManager(); return(mm.StoreAnswer(assessmentId, answer)); } QuestionsManager qm2 = new QuestionsManager(assessmentId); return(qm2.StoreAnswer(answer)); }
private void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); } SceneManager.sceneLoaded += SelectNextQuestion; }
//public static void CompareQuestionsFiles(string directory) public static void CompareJsonFiles(string directory, string jsonFile, IEnumerable <string> elementsToCompare = null, IEnumerable <string> documentReference = null) { string baseDirectory = XmlConfig.CurrentConfig.GetExplicit("CardDirectory"); int okCount = 0; int notOkCount = 0; int notFoundCount = 0; foreach (string questionDirectory in GetQuestionDirectories()) { if (!questionDirectory.StartsWith(baseDirectory)) { throw new PBException($"wrong directory \"{directory}\""); } string questionDirectory2 = questionDirectory.Substring(baseDirectory.Length + 1); // questions_01.json questions.json string file1 = zPath.Combine(questionDirectory, @"data\" + jsonFile); string lastFile1 = QuestionsManager.GetLastFileNumber(file1, startIndex: 1); if (lastFile1 == file1) { Trace.WriteLine($"question file not found \"{file1}\""); notFoundCount++; } else { // ".questions.json" string file2 = zPath.Combine(directory, questionDirectory2 + "." + jsonFile); Trace.WriteLine($"compare question files \"{lastFile1}\" \"{file2}\""); CompareDocumentsResult result = DocumentComparator.CompareBsonDocumentFiles(lastFile1, file2, comparatorOptions: DocumentComparatorOptions.ReturnNotEqualDocuments | DocumentComparatorOptions.ResultNotEqualElements, //elementsToCompare: new string[] { "Year", "Type", "Number", "QuestionText", "Choices", "SourceLine" }, elementsToCompare: elementsToCompare, //documentReference: new string[] { "document1.Year", "document1.Number", "document1.SourceFile", "document1.SourceLine", "document2.SourceFile", "document2.SourceLine" }); documentReference: documentReference); //.zGetResults().zSave(@"c:\pib\dev_data\exe\runsource\valentin\test\S2\compare.json", jsonIndent: true); if (result.Equal) { Trace.WriteLine(" ok"); okCount++; } else { Trace.WriteLine($" not ok"); string resultFile = zPath.Combine(directory, zPath.GetFileNameWithoutExtension(file2) + ".comp.json"); //Trace.WriteLine($" not ok, (\"{resultFile}\")"); result.GetResultDocuments().zSave(resultFile, jsonIndent: true); notOkCount++; } } } Trace.WriteLine($"{okCount} ok {notOkCount} not ok {notFoundCount} not found"); }
// Func<string, string, bool> testUnitReader, string extension private static void TestUnit_Reader(TestUnitOpe ope, IEnumerable <string> directories, string outputDirectory, bool traceUnknowValue, bool v2) { QuestionsManager questionsManager = QuestionRun.CreateQuestionsManager(v2: v2); questionsManager.TraceUnknowValue = traceUnknowValue; string baseDirectory = XmlConfig.CurrentConfig.GetExplicit("CardDirectory"); string extension = ope == TestUnitOpe.ReadQuestions ? ".questions.json" : ".responses.json"; int okCount = 0; int notOkCount = 0; int noOkCount = 0; int errorCount = 0; foreach (string directory in directories) { if (!directory.StartsWith(baseDirectory)) { throw new PBException($"wrong directory \"{directory}\""); } string directory2 = directory.Substring(baseDirectory.Length + 1); string file = zPath.Combine(outputDirectory, directory2 + extension); Trace.WriteLine($"create file \"{directory2 + extension}\""); if (ExecOpe(questionsManager, ope, directory, file, v2)) { string okFile = zPath.Combine(zPath.GetDirectoryName(file), "ok", zPath.GetFileName(file)); if (zFile.Exists(okFile)) { if (zfile.AreFileEqual(file, okFile)) { Trace.WriteLine(" ok"); okCount++; } else { Trace.WriteLine(" not ok"); notOkCount++; } } else { Trace.WriteLine(" ok file not found"); noOkCount++; } } else { errorCount++; } } Trace.WriteLine($"{okCount} ok {notOkCount} not ok {errorCount} error {noOkCount} ok not found"); }
public string GetMode() { int assessmentId = Auth.AssessmentForUser(); QuestionsManager qm = new QuestionsManager(assessmentId); string mode = GetApplicationMode(assessmentId).Trim().Substring(0, 1); if (String.IsNullOrEmpty(mode)) { mode = AssessmentModeData.DetermineDefaultApplicationModeAbbrev(); SetMode(mode); } return(mode); }
public void GetDetailsTest() { ANSWER newAnswer = new ANSWER() { Is_Requirement = false, Question_Or_Requirement_Id = 14, Answer_Text = AnswerEnum.UNANSWERED.GetStringAttribute(), Mark_For_Review = false, Is_Component = false }; //TODO a setup and teardown that creates the assessment and then destroys it QuestionsManager manager = new QuestionsManager(26); QuestionDetailsContentViewModel viewModel = manager.GetDetails(14, 26, false); }
// Use this for initialization void Start() { if (instance != null) { Destroy(gameObject); } else { DontDestroyOnLoad(gameObject); instance = this; } questionsManager = FindObjectOfType <QuestionsManager> (); }
public static IEnumerable <QuestionData> Test_ReadQuestionFilesAsQuestionData_v2(string directory, int limit = 0) { directory = zPath.Combine(XmlConfig.CurrentConfig.GetExplicit("CardDirectory"), directory); //TextDataReader textDataReader = new TextDataReader(QuestionsManager.GetScanFiles(directory, limit)); TextDataReader textDataReader = new TextDataReader(); textDataReader.SetRegexList(CreateQuestionRegexValuesList()); foreach (QuestionData value in textDataReader.Read(QuestionsManager.GetScanFiles(zPath.Combine(directory, @"data\scan"), limit)).Select(textData => QuestionData.CreateQuestionData(textData))) { if (value.Type == QuestionDataType.Responses) { //Trace.WriteLine("read responses"); textDataReader.SetRegexList(CreateResponseRegexValuesList()); textDataReader.ContiguousSearch = true; } yield return(value); } }
public QuestionResponse GetList([FromBody] string group) { int assessmentId = Auth.AssessmentForUser(); string applicationMode = GetApplicationMode(assessmentId); if (applicationMode.ToLower().StartsWith("questions")) { QuestionsManager qm = new QuestionsManager(assessmentId); QuestionResponse resp = qm.GetQuestionList(group); return(resp); } else { RequirementsManager rm = new RequirementsManager(assessmentId); QuestionResponse resp = rm.GetRequirementsList(); return(resp); } }
public Finding GetFinding([FromUri] int Answer_Id, int Finding_id, int Question_Id) { int assessmentId = Auth.AssessmentForUser(); using (CSET_Context context = new CSET_Context()) { if (Answer_Id == 0) { QuestionsManager questions = new QuestionsManager(assessmentId); Answer_Id = questions.StoreAnswer(new Answer() { QuestionId = Question_Id, MarkForReview = false }); } FindingsViewModel fm = new FindingsViewModel(context, assessmentId, Answer_Id); return(fm.GetFinding(Finding_id)); } }
public void SaveQuestionRating(long questionID, int selectedRating) { //int selcetedRating = int.Parse(rdoRating.SelectedValue); QuestionsManager questionManager = new QuestionsManager(); Questions question = questionManager.Get(questionID); if (question != null) { question.RateTotal += selectedRating; question.RateCount++; question.Rating = (float)question.RateTotal / (float)question.RateCount; questionManager.SaveOrUpdate(question); } }