Difference between revisions of "The KISS principle: making sentences."

From WeBWorK_wiki
Jump to navigation Jump to search
(Created page with "We sometimes want students to give a longer response to a question. Unfortunately, many times the grader just starts searching for keywords and doesn't really read all the det...")
 
 
Line 7: Line 7:
 
These two go really well together because all the input is controlled and there is no possibilities for errors.
 
These two go really well together because all the input is controlled and there is no possibilities for errors.
   
<nowiki># Created by Nikola Kuzmanovski.
 
  +
<nowiki>
 
# In this problem we ask the student to make a sentence from predefined options.
 
# In this problem we ask the student to make a sentence from predefined options.
   

Latest revision as of 18:45, 7 May 2022

We sometimes want students to give a longer response to a question. Unfortunately, many times the grader just starts searching for keywords and doesn't really read all the details that the student wrote. Even if you assume the grader doesn't do this you still need to come up with a formal procedure on how to awards points. In many cases this is not easy. We try to give a way to test for such things with the next problem. This problem has less comments. Go read the other examples first if you struggle to understand the code.

We are going to use:

  1. "parserMultiAnswer.pl"
  2. parserPopUp.pl

These two go really well together because all the input is controlled and there is no possibilities for errors.

# In this problem we ask the student to make a sentence from predefined options.

########################################################################

DOCUMENT();      

loadMacros(
   "PGstandard.pl",     	# Standard macros for PG language
   "MathObjects.pl",		# Standard objects like real numbers, functions etc.
   "parserMultiAnswer.pl",	# Allows us to link multiple answer blanks into one.
   "parserPopUp.pl",
);

# Print problem number and point value (weight) for the problem.
TEXT(beginproblem());

# Show which answers are correct and which ones are incorrect.
$showPartialCorrectAnswers = 1;

##############################################################
#
#  Setup
#
#


Context("Numeric");	# Contains almost everything you need for real variable calculus.

$popupUpKelly = PopUp(["?", "Kelly Johnson", "George Washington", "Abraham Lincoln"], "Kelly Johnson");
$popupUpWashington = PopUp(["?", "Kelly Johnson", "George Washington", "Abraham Lincoln"], "George Washington");
$popupUpLincoln = PopUp(["?", "Kelly Johnson", "George Washington", "Abraham Lincoln"], "Abraham Lincoln");

$popupUpEngi = PopUp(["?", "a president", "an aircraft engineer"], "an aircraft engineer");
$popupUpPres = PopUp(["?", "a president", "an ircraft engineer"], "a president");
##############################################################
#
#  Text
#
#

Context()->texStrings;
BEGIN_TEXT

The KISS priciple it associated with \{$popupUpKelly->menu()\}, who was \{$popupUpEngi->menu()\}.


END_TEXT
Context()->normalStrings;

##############################################################
#
#  Answers
#
#

# Link the two answer blanks into one answer checker.
$multiAnsCheck = MultiAnswer($popupUpKelly, $popupUpEngi)->with(singleResult => 0, allowBlankAnswers => 0, checkTypes => 1,
	checker => sub {
		#Get the arrays of correct answers and student answers, and get the answer hash. 
		my ($correctAns, $studentAns, $ansHash) = @_;
	
		# Get the student answers from the array of student answers.
		my ($studentPerson, $studentRole) = @{$studentAns};
		
		# Array with student scores
		my @scores = (0.0, 0.0);
		
		if($popupUpKelly == $studentPerson){
			$scores[0] = 1.0;
			$ansHash->setMessage(1,"Yes, Kelly Johnson is usually cited at the originator for the KISS principle.");
		} else {
			$ansHash->setMessage(1,"He did other impressive things");
		}
		
		if($scores[0] == 1.0 && $popupUpEngi == $studentRole){
			$scores[1] = 1.0;
			$ansHash->setMessage(2,"Yes, Kelly was not a president");
		} elsif($scores[0] == 1.0 && $popupUpPres == $studentRole){
			$scores[1] = 0.0;
			$ansHash->setMessage(2,"Sorry, Kelly was not a president");
		} elsif($scores[0] == 0.0 && $popupUpEngi == $studentRole){
			$scores[1] = 0.0;
			$ansHash->setMessage(2,"He was not an aircraft engineer");
		} elsif($scores[0] == 0.0 && $popupUpPres == $studentRole){
			$scores[0] = 0.5;
			$scores[1] = 0.5;
			$ansHash->setMessage(2,"The KISS principle is not associted with him, but he was a president.");
		}
		
		return [ @scores ];
		}
);


ANS($multiAnsCheck->cmp());


ENDDOCUMENT();