Procedure

TfrmMHTest.btnOKClick

Module

fMHTest

Last Modified

7/15/2014 3:26:38 PM

Visibility

Public/Published

Owner

TfrmMHTest

Declaration

procedure btnOKClick(Sender: TObject);

Calls Hierarchy


TfrmMHTest.btnOKClick
 ├VerifyMentalHealthTestComplete
 └TfrmMHTest.GotoQ

Calls

Name Declaration Comments
TfrmMHTest.GotoQ procedure GotoQ(x: integer); -
VerifyMentalHealthTestComplete function VerifyMentalHealthTestComplete(TestName, Answers: string): String; -


Source

1110  procedure TfrmMHTest.btnOKClick(Sender: TObject);
1111  var
1112    i, XCnt, First: integer;
1113    msg, ans, TestStatus: string;
1114  
1115  begin
1116    msg := '';
1117    ans := '';
1118    XCnt := 0;
1119    First := -1;
1120    TestStatus := '2';
1121    MHTestComp := '2';
1122    for i := 0 to FObjs.Count-1 do
1123    begin
1124      ans := ans + TMHQuestion(Fobjs[i]).FAnswer;
1125      if(TMHQuestion(FObjs[i]).FAnswer = Skipped) then
1126      begin
1127        if(First < 0) then First := i;
1128        inc(XCnt);
1129        if(msg <> '') then
1130          msg := msg + ', ';
1131        msg := msg + IntToStr(i+1);
1132      end;
1133    end;
1134    if(XCnt = FObjs.Count) then ModalResult := mrOK;
1135    TestStatus := VerifyMentalHealthTestComplete(Self.Caption, ans);
1136    if Piece(TestStatus,U,1) <> '2' then
1137      begin
1138        if Piece(TestStatus,U,1)='1' then
1139          begin
1140            ModalResult := mrOK;
1141            MHTestComp := '1';
1142            EXIT;
1143          end;
1144        if Piece(TestStatus,U,1)='0' then
1145          begin
1146            MHTestComp := '0';
1147            msg := Piece(TestStatus,u,2);
1148            msg := 'The following questions have not been answered:' + CRLF + CRLF + '    ' + msg;
1149            if(InfoBox(msg + CRLF + CRLF + 'Answer skipped questions?', 'Skipped Questions',
1150             MB_YESNO or MB_ICONQUESTION) = IDYES) then GotoQ(First)
1151            else
1152              ModalResult := mrOK;
1153              EXIT;
1154          end;
1155      end;
1156    if(XCnt = 0) then
1157      ModalResult := mrOK
1158    else
1159    begin
1160      if(XCnt = FObjs.Count) then
1161        ModalResult := mrOK
1162      else
1163      begin
1164        msg := 'The following questions have not been answered:' + CRLF + CRLF + '    ' + msg;
1165        if(InfoBox(msg + CRLF + CRLF + 'Answer skipped questions?', 'Skipped Questions',
1166           MB_YESNO or MB_ICONQUESTION) = IDYES) then
1167          GotoQ(First)
1168        else
1169          ModalResult := mrOK;
1170      end;
1171    end;
1172  end;