Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit MitosisQuestionsUnit;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls,
- Vcl.Imaging.GIFImg;
- type
- TfrmMitosisQuestions = class(TForm)
- rgrpQuestion1: TRadioGroup;
- rgrpQuestion2: TRadioGroup;
- rgrpQuestion3: TRadioGroup;
- rgrpQuestion4: TRadioGroup;
- imgMetaphase: TImage;
- btnSubmit: TButton;
- procedure btnSubmitClick(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- frmMitosisQuestions: TfrmMitosisQuestions;
- implementation
- {$R *.dfm}
- Uses
- LoginUnit;
- procedure TfrmMitosisQuestions.btnSubmitClick(Sender: TObject);
- Var
- CorrectAnswers : Integer;
- FinalScore : String;
- ResultsFile : Textfile;
- Today : TDateTime;
- begin
- CorrectAnswers := 0;
- if rgrpQuestion1.ItemIndex = 1 then //if answer is correct for question 1
- CorrectAnswers := CorrectAnswers + 1;
- if rgrpQuestion2.ItemIndex = 0 then //if answer is correct for question 2
- CorrectAnswers := CorrectAnswers + 1;
- if rgrpQuestion3.ItemIndex = 3 then //if answer is correct for question 3
- CorrectAnswers := CorrectAnswers + 1;
- if rgrpQuestion4.ItemIndex = 1 then //if answer is correct for question 4
- CorrectAnswers := CorrectAnswers + 1;
- //Display total mark to user
- FinalScore := ('You scored: ' + IntToStr(CorrectAnswers) + ' out of 4');
- ShowMessage(FinalScore);
- //CorrectAnswers needed to be converted to str - Show in developmental testing
- //done
- {if CorrectAnswers = 4 then
- ShowMessage('Well Done you got full marks');
- if CorrectAnswers = 0 then
- ShowMessage('You need more revision');}
- //put the above in prototype 2 - for 'usability features'
- Today := Now; //assigns the current date and time to the variable 'Today'
- //Writing results to file accessed by teacher:
- AssignFile(ResultsFile , 'StudentScores.txt');
- Append(ResultsFile);
- writeln(ResultsFile , '');
- writeln(ResultsFile , ('Mitosis Multiple Choice Questions: ' //write name of test
- + IntToStr(CorrectAnswers) + '/4')); //write mark
- writeln(ResultsFile , frmLogin.ledtUsername.Text); //write username to file
- writeln(ResultsFile , ('On: ' + DateToStr(Today) + ' At: ' + TimeToStr(Today)));
- CloseFile(ResultsFile);
- end;
- end.
- unit MitosisQuestionsUnit;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls,
- Vcl.Imaging.GIFImg;
- type
- TfrmMitosisQuestions = class(TForm)
- rgrpQuestion1: TRadioGroup;
- rgrpQuestion2: TRadioGroup;
- rgrpQuestion3: TRadioGroup;
- rgrpQuestion4: TRadioGroup;
- imgQuestion4: TImage;
- btnSubmit: TButton;
- btnExit: TButton;
- lblAnswer1: TLabel;
- lblAnswer2: TLabel;
- lblAnswer3: TLabel;
- lblAnswer4: TLabel;
- procedure btnSubmitClick(Sender: TObject);
- procedure btnExitClick(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- frmMitosisQuestions: TfrmMitosisQuestions;
- implementation
- {$R *.dfm}
- Uses
- LoginUnit , ASTopicSelectionUnit;
- procedure TfrmMitosisQuestions.btnSubmitClick(Sender: TObject);
- Var
- CorrectAns : Integer;
- FinalScore : String;
- ResultsFile : Textfile;
- Today : TDateTime;
- begin
- btnSubmit.Enabled := False; //disables submit button
- CorrectAns := 0;
- if rgrpQuestion1.ItemIndex = 1 then //if answer is correct for question 1
- CorrectAns := CorrectAns + 1
- Else
- lblAnswer1.Visible := True; //show correct answer for question 1
- if rgrpQuestion2.ItemIndex = 0 then //if answer is correct for question 2
- CorrectAns := CorrectAns + 1
- Else
- lblAnswer2.Visible := True; //show correct answer for question 2
- if rgrpQuestion3.ItemIndex = 3 then //if answer is correct for question 3
- CorrectAns := CorrectAns + 1
- Else //show correct answer for question 3
- lblAnswer3.Visible := True;
- if rgrpQuestion4.ItemIndex = 1 then //if answer is correct for question 4
- CorrectAns := CorrectAns + 1
- Else
- lblAnswer4.Visible := True; //show correct answer for question 4
- //Display total mark to user
- FinalScore := ('You scored: ' + IntToStr(CorrectAns) + ' out of 4');
- ShowMessage(FinalScore);
- {if CorrectAnswers = 4 then
- ShowMessage('Well Done you got full marks');
- if CorrectAnswers = 0 then
- ShowMessage('You need more revision');}
- //put the above in prototype 3 - for 'usability features'
- Today := Now; //assigns the current date and time to the variable 'Today'
- //Writing results to student's report file:
- AssignFile(ResultsFile , frmLogin.ledtUsername.Text + '.txt');
- Append(ResultsFile);
- writeln(ResultsFile , '');
- writeln(ResultsFile , ('Mitosis Multiple Choice Questions: ' //write name of test
- + IntToStr(CorrectAns) + '/4')); //write mark
- writeln(ResultsFile , ('On: ' + DateToStr(Today) + ' At: ' + TimeToStr(Today)));
- CloseFile(ResultsFile);
- end;
- procedure TfrmMitosisQuestions.FormCreate(Sender: TObject);
- begin
- //disables close button (top-right corner):
- EnableMenuItem( GetSystemMenu( handle, False ),SC_CLOSE, MF_BYCOMMAND or MF_GRAYED );
- end;
- //Close the form - goes back to AS Topic Selection:
- procedure TfrmMitosisQuestions.btnExitClick(Sender: TObject);
- begin
- frmMitosisQuestions.Close;
- frmASTopicSelect.Show;
- end;
- end.
- unit MitosisQuestions1Unit;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls,
- Vcl.Imaging.GIFImg;
- type
- TfrmMitosisQuestions = class(TForm)
- rgrpQuestion1: TRadioGroup;
- rgrpQuestion2: TRadioGroup;
- rgrpQuestion3: TRadioGroup;
- rgrpQuestion4: TRadioGroup;
- imgQuestion4: TImage;
- btnExit: TButton;
- lblAnswer1: TLabel;
- lblAnswer2: TLabel;
- lblAnswer3: TLabel;
- lblAnswer4: TLabel;
- lblTitle: TLabel;
- rgrpQuestion5: TRadioGroup;
- lblAnswer5: TLabel;
- btnNextPage: TButton;
- procedure btnExitClick(Sender: TObject);
- procedure btnNextPageClick(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- frmMitosisQuestions: TfrmMitosisQuestions;
- implementation
- {$R *.dfm}
- Uses
- LoginUnit , ASTopicSelectionUnit , MitosisQuestions2Unit;
- //show the next page of questions
- procedure TfrmMitosisQuestions.btnNextPageClick(Sender: TObject);
- begin
- frmMitosisQuestionsII.Show;
- end;
- //Close both question forms - goes back to AS Topic Selection:
- procedure TfrmMitosisQuestions.btnExitClick(Sender: TObject);
- begin
- frmMitosisQuestions.Close;
- frmMitosisQuestionsII.Close;
- frmASTopicSelect.Show;
- end;
- end.
- unit MitosisQuestions2Unit;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls;
- type
- TfrmMitosisQuestionsII = class(TForm)
- rgrpQuestion6: TRadioGroup;
- rgrpQuestion7: TRadioGroup;
- rgrpQuestion8: TRadioGroup;
- rgrpQuestion9: TRadioGroup;
- rgrpQuestion10: TRadioGroup;
- lblAnswer6: TLabel;
- lblAnswer7: TLabel;
- lblAnswer8: TLabel;
- lblAnswer9: TLabel;
- lblAnswer10: TLabel;
- btnSubmit: TButton;
- btnExit: TButton;
- procedure btnSubmitClick(Sender: TObject);
- procedure btnExitClick(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- frmMitosisQuestionsII: TfrmMitosisQuestionsII;
- implementation
- {$R *.dfm}
- Uses
- MitosisQuestions1Unit , LoginUnit , ASTopicSelectionUnit;
- //Close both question forms - goes back to AS Topic Selection:
- procedure TfrmMitosisQuestionsII.btnExitClick(Sender: TObject);
- begin
- frmMitosisQuestions.Close;
- frmMitosisQuestionsII.Close;
- frmASTopicSelect.Show;
- end;
- procedure TfrmMitosisQuestionsII.btnSubmitClick(Sender: TObject);
- Var
- FinalScore : String;
- Today : TDateTime;
- ResultsFile : TextFile;
- CorrectAns : Integer;
- PresenceCheck : Bool;
- begin
- presencecheck := True;
- //presence check for each question:
- if frmMitosisQuestions.rgrpQuestion1.ItemIndex = -1 then
- presencecheck := False
- Else if frmMitosisQuestions.rgrpQuestion2.ItemIndex = -1 then
- presencecheck := False
- Else if frmMitosisQuestions.rgrpQuestion3.ItemIndex = -1 then
- presencecheck := False
- Else if frmMitosisQuestions.rgrpQuestion4.ItemIndex = -1 then
- presencecheck := False
- Else if frmMitosisQuestions.rgrpQuestion5.ItemIndex = -1 then
- presencecheck := False
- Else if rgrpQuestion6.ItemIndex = -1 then
- presencecheck := False
- Else if rgrpQuestion7.ItemIndex = -1 then
- presencecheck := False
- Else if rgrpQuestion8.ItemIndex = -1 then
- presencecheck := False
- Else if rgrpQuestion9.ItemIndex = -1 then
- presencecheck := False
- Else if rgrpQuestion10.ItemIndex = -1 then
- presencecheck := False;
- if presencecheck = False then
- ShowMessage('You have not completed all the questions')
- Else
- Begin
- CorrectAns := 0;
- if frmMitosisQuestions.rgrpQuestion1.ItemIndex = 1 then //if answer is correct for question 1
- CorrectAns := CorrectAns + 1
- Else
- frmMitosisQuestions.lblAnswer1.Visible := True; //show correct answer for question 1
- if frmMitosisQuestions.rgrpQuestion2.ItemIndex = 0 then //if answer is correct for question 2
- CorrectAns := CorrectAns + 1
- Else
- frmMitosisQuestions.lblAnswer2.Visible := True; //show correct answer for question 2
- if frmMitosisQuestions.rgrpQuestion3.ItemIndex = 3 then //if answer is correct for question 3
- CorrectAns := CorrectAns + 1
- Else
- frmMitosisQuestions.lblAnswer3.Visible := True; //show correct answer for question 3
- if frmMitosisQuestions.rgrpQuestion4.ItemIndex = 1 then //if answer is correct for question 4
- CorrectAns := CorrectAns + 1
- Else
- frmMitosisQuestions.lblAnswer4.Visible := True; //show correct answer for question 4
- if frmMitosisQuestions.rgrpQuestion5.ItemIndex = 2 then //if answer is correct for question 5
- CorrectAns := CorrectAns + 1
- Else
- frmMitosisQuestions.lblAnswer5.Visible := True; //show correct answer for question 5
- if rgrpQuestion6.ItemIndex = 0 then //if answer is correct for question 6
- CorrectAns := CorrectAns + 1
- Else
- lblAnswer6.visible := True; //show correct answer for question 6
- if rgrpQuestion7.ItemIndex = 3 then //if answer is correct for question 7
- CorrectAns := CorrectAns + 1
- Else
- lblAnswer7.visible := True; //show correct answer for question 7
- if rgrpQuestion8.ItemIndex = 1 then //if answer is correct for question 8
- CorrectAns := CorrectAns + 1
- Else
- lblAnswer8.visible := True; //show correct answer for question 8
- if rgrpQuestion9.ItemIndex = 0 then //if answer is correct for question 9
- CorrectAns := CorrectAns + 1
- Else
- lblAnswer9.visible := True; //show correct answer for question 9
- if rgrpQuestion10.ItemIndex = 1 then //if answer is correct for question 10
- CorrectAns := CorrectAns + 1
- Else
- lblAnswer10.visible := True; //show correct answer for question 10
- btnSubmit.Enabled := False; //disables submit button
- //Display total mark to user
- FinalScore := ('You scored: ' + IntToStr(CorrectAns) + ' out of 10');
- ShowMessage(FinalScore);
- //display feedback based on results:
- if CorrectAns = 10 then
- ShowMessage ('Well Done! You got full marks.');
- if CorrectAns < 5 then
- ShowMessage('You need more revision on this topic.');
- if CorrectAns > 6 then
- ShowMessage('You''re on track for this topic - but there are still areas to improve!');
- Today := Now; //assigns the current date and time to the variable 'Today'
- //Writing results to student's report file:
- AssignFile(ResultsFile , frmLogin.ledtUsername.Text + '.txt');
- Append(ResultsFile);
- writeln(ResultsFile , '');
- writeln(ResultsFile , ('Mitosis Multiple Choice Questions: ' //write name of test
- + IntToStr(CorrectAns) + '/10')); //write mark
- writeln(ResultsFile , ('On: ' + DateToStr(Today) + ' At: ' + TimeToStr(Today)));
- CloseFile(ResultsFile);
- End;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement