/// <summary> /// Updates the info.json file for the quiz named quizName in questionCreator /// </summary> public void UpdateOverview() { overallQuizTime = 0f; questionCount = 0f; string path = gm.quizzesDir + "/" + quizName + "/Otázky/"; //calculate the overall quiz time and the quiz' question count try { IEnumerable <string> jsonFilePaths = Directory.EnumerateFiles(path, "*.json"); foreach (string filePath in jsonFilePaths) { //Debug.Log(filePath); st.LoadQuestion(filePath); overallQuizTime += st.otazka.cas; questionCount++; } } catch (Exception exc) { Debug.Log("there was an exception:" + exc.Message); } //Debug.Log("celkovy cas kvizu:" + overallQuizTime.ToString() + " pocet otazok: " + questionCount.ToString()); SetValuesIntoFields(); }
public void IncreaseIndex() { //TODO make it so that stuff gets saved only when a change occurred if (AreAllInputsFilledOut()) { //save the current input into the current question int currentIndex = int.Parse(questionNumberText.text); string questionName = currentIndex.ToString(); string path = gm.quizzesDir + "/" + quizName + "/Otázky/" + questionName + ".json"; PutFieldsIntoStorage(); st.SaveQuestion(path); //increment currentIndex and then create the string of the next question's path currentIndex++; questionName = currentIndex.ToString(); questionNumberText.text = questionName; string newPath = gm.quizzesDir + "/" + quizName + "/Otázky/" + questionName + ".json"; //if the next question exists - show it //else, blank all fields //string newPathNoExtension = newPath.Replace(".json", ""); Debug.Log(newPath); if (File.Exists(newPath)) { Debug.Log("found the file: " + newPath); st.LoadQuestion(newPath); PutStorageIntoFields(currentIndex); } else { Debug.Log("this file does not exist: " + newPath); BlankAllFields(); } } else { Debug.Log("not all inputs are filled out"); } }