private string GetAfterEntry(string var, QuestionRouting qr, List <SurveyQuestion> questionList) { bool startListing = false; string afterEntry = ""; List <string> conds = new List <string>(); List <string> actions = new List <string>(); foreach (RoutingVar v in qr.RoutingVars) { for (int i = 0; i < v.ResponseCodes.Count; i++) { conds.Add("(" + var + " = " + Convert.ToString(v.ResponseCodes[i]) + ")"); } actions.Add(" GOTO " + v.Varname.Replace("go to ", "")); foreach (SurveyQuestion sq in questionList) { if (sq.ScriptOnly) { continue; } if (sq.VarName.Equals(var)) { startListing = true; continue; } if (v.Varname.Contains(sq.VarName.RefVarName)) { startListing = false; break; } if (startListing) { if (sq.VarType == "string") { actions.Add(" " + sq.VarName + "=\"NA\""); } else { actions.Add(" " + sq.VarName + "=" + new string('7', sq.NumCol)); } } } afterEntry += " IF" + String.Join(" OR ", conds) + " THEN"; afterEntry += "\r\n"; afterEntry += String.Join("\r\n", actions); afterEntry += "\r\n ENDIF"; conds.Clear(); actions.Clear(); } return(afterEntry); }
/// <summary> /// /// </summary> /// <param name="sq"></param> public void FormatRouting(SurveyQuestion sq) { QuestionRouting qr; // format the response options qr = new QuestionRouting(sq.PstP, sq.RespOptions); sq.RespOptions = qr.ToString(); // format the non-response options qr = new QuestionRouting(sq.PstP, sq.NRCodes); sq.NRCodes = qr.ToString(); // format the PstP sq.PstP = string.Join("\r\n", qr.RoutingText); }