public QuestionPaperViewModel GeneratorEngine(Worksheet worksheet) { QuestionPaper.PaperName = worksheet.WorksheetName; for (var i = 0; i < worksheet.QuestionPatterns.Count; i++) { QuestionPattern question = worksheet.QuestionPatterns.ElementAt(i); String QuestionName = question.Template.Name.ToString(); GetVariables(question); } return(QuestionPaper); }
public ActionResult Create(WorksheetViewModel worksheetView) { Worksheet worksheet = new Worksheet { WorksheetName = worksheetView.Worksheet.WorksheetName }; for (var i = 0; i < worksheetView.QuestionPatterns.Count; i++) { QuestionPattern question = new QuestionPattern(); question = worksheetView.QuestionPatterns[i]; worksheet.QuestionPatterns.Add(question); } db.Worksheets.Add(worksheet); db.SaveChanges(); return(RedirectToAction("Index", "Home")); }
public void GetVariables(QuestionPattern question) { var count = question.Template.Variables.Count(); var variables = question.Template.Variables.ToList(); string formula = question.Template.Formula.ToString(); //var ArrayOfVariables = Regex.Matches(formula, @"[^{\}]+(?=})").Cast<Match>().Select(m=>m.Value).ToList(); Regex operatorRegexPattern = new Regex(@"(\+|-|\*|\/)"); Match operatorInside = operatorRegexPattern.Match(formula); string[] result = Regex.Split(formula, operatorRegexPattern.ToString()); int noOfVariablesInFirstNumber = Regex.Matches(result[0].ToString(), @"[^{\}]+(?=})").Count; for (var i = 0; i < question.Frequency; i++) { GetNumbers(variables, noOfVariablesInFirstNumber, operatorInside.ToString(), question.Marks); } }