Modifying Exercise:(Computer-Assisted Instruction: Reducing Student Fatigue) One
ID: 3882154 • Letter: M
Question
Modifying Exercise:(Computer-Assisted Instruction: Reducing Student Fatigue) One problem in CAI environments is student fatigue. This can be reduced by varying the computer’s responses to hold the student’s attention, so that various comments are displayed for each answer as follows: Possible responses to a correct answer: Very good!
Excellent!
Nice work!
Keep up the good work!
Possible responses to an incorrect answer: No. Please try again. Wrong. Try once more. Don't give up! No. Keep trying. Use random-number generation to choose a number from 1 to 4 that will be used to select one of the four appropriate responses to each correct or incorrect answer. Use a switch or if statement to issue the responses.
Program is PERL SCRIPTING
Please make the program Simple..
Explanation / Answer
use strict;
use warnings;
# get a questionare of 5 questions
# for each question find if answer is correct or inncorect
# if in correct any one of correct response
# if in correct any one of incorrect response
sub question_source{
my $source = shift;
if($source == 1){
print "what is the result of 5 +3 ?"
}
if($source == 2){
print "what is the result of 5 - 3 ?"
}
if($source == 3){
print "what is the result of 5 * 3 ?"
}
if($source == 4){
print "what is the result of 5 - 5 ?"
}
if($source == 5){
print "what is the result of 5 + 5 ?"
}
my $user_answer = <STDIN>;
chomp $user_answer;
return $user_answer;
}
sub get_random_number{
# generate a random number in perl in the range 1-4
my $lower_limit = 1;
my $upper_limit = 5;
my $random_number = int(rand($upper_limit-$lower_limit)) + $lower_limit;
return $random_number;
}
sub check_answer{
my $user_answer = shift;
my $question = shift;
my @answerArray = ("first_index", "8", "2", "15", "0" , "10");
my $returnvalue = ( $user_answer == $answerArray[$question] ) ? 1 : 0;
return $returnvalue;
}
my @correct_answer_response =( "dummy not used",
"Very good!",
"Excellent!",
"Nice work! ",
"Keep up the good work!"
);
my @incorrect_answer_response =( "dummy not used",
"No. Please try again.",
"Wrong. Try once more. ",
"Don't give up! ",
"No. Keep trying."
);
my $no_of_questions = 5;
for my $question ( 1.. $no_of_questions){
my $user_answer1 = question_source($question);
my $answer = check_answer($user_answer1, $question);
my $random_number = get_random_number();
if($answer == 1){
# print "The Answer is correct "
print $correct_answer_response[$random_number] . " "
}
else{
#print "The Answer is incorrect "
print $incorrect_answer_response[$random_number] . " "
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.