I am going to take my first crack at asking questions here. My question deals with general formulae for sequences a_n questions. Particularly in the case where you have an alternating sequence -1,1,-1,1, . . . students can write this as a_n = cos(pi*n) or (-1)^n. I wanted to make sure to include all possibilities. So I used test_points operator and tested the first 10 points. This worked fabulous (I don't think students will find a formula which breaks down at n=11). But my problem comes in here. I gave the students the formula 1,3,1,3, . . ., and some students wrote a list, prompting a "pink screen of death" error. They immediately respond back to me. I fixed this error in a way that any sane person might do, undefining "," as an operator. Now, some student wrote "None," and got a similar error. Is there anything I can do to correct this once and for all? It seems that lists cause the error.

Here is my code for a sample problem:

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

DOCUMENT(); # This should be the first executable line in the problem.

loadMacros(

"PGstandard.pl",

"MathObjects.pl",

"PGcourse.pl",

);

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

$showPartialCorrectAnswers = 1;

TEXT(beginproblem());

Context("Numeric");

Context()->variables->add(n =>'Real');

Context()->operators->undefine(",");

$a = random(1,12,1);

$b = Compute("$a+4");

$ans = Formula("($a+2)+2(-1)^n")->reduce;

$ans->{test_points} = [[2,0],[3,0],[4,0],[5,0],[6,0],[7,0],[8,0],[9,0],[10,0]];

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

Context()->texStrings;

BEGIN_TEXT

Find a formula for the general term \(a_n\) of the sequence:

\[

\lbrace$a,$b,$a,$b, \ldots\rbrace.

\]

$HR

\(a_n =\) \{ans_rule(20)\} $PAR

END_TEXT

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

ANS(($ans)->cmp());

ENDDOCUMENT(); # This should be the last executable line in the problem.

### General Sequence problems

by Justin Sukiennik -
In reply to Justin Sukiennik
Sunday, 11 April 2010, 3:16 PM

### Re: General Sequence problems

by Paul Pearson -
Dear Justin,

It's good to see that you're writing some webwork questions. The short answer to your question is to remove the string NONE from the context. Also, I would recommend making the following modifications, which I made in the PG code below:

1. In the text of the problem, specify the type of answer you're expecting from students (a closed formula instead of just a formula).

2. In the text of the problem, specify where the indexing starts so that students are clear that it starts with a_1 and not a_0.

3. Make the question a bit more randomized by allowing the "radius" to be randomized rather than always fixed at 2.

4. Modify the context using variables->are(n=>"Real") so that the only variable in the context is n. Using variables->add(n=>"Real") retains the variable x in the context so that both n and x are in the context. Accordingly, using variables->are(n=>"Real"), you can now shorten your test points from pairs of numbers to singletons. In this particular question, having two variables in the context is probably not going to confuse students. Other times, though, it can. For example, if you add the variable t to the context, students may instinctively use x and will not figure out why their answer is incorrect. However, if you declare that the only variable is t using variables->are(t=>"Real"), students who enter an answer in terms of x will get an error message, realize their mistake, and correct it without needing to ask for help.

5. Don't forget to change back to normalStrings after END_TEXT.

Good luck!

Paul Pearson

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

# Initialization

DOCUMENT();

loadMacros(

"PGstandard.pl",

"MathObjects.pl",

"PGcourse.pl",

);

TEXT(beginproblem());

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

# Setup

Context("Numeric");

Context()->variables->are(n=>'Real');

Context()->operators->undefine(",");

Context()->strings->remove("NONE");

$a = random(1,12,1);

$b = random(2,5,1);

$apb = $a + $b;

$c = $a+2*$b;

$ans = Formula("$apb + $b * (-1)^n");

$ans->{test_points} = [[2],[3],[4],[5],[6],[7],[8],[9],[10]];

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

# Main text

Context()->texStrings;

BEGIN_TEXT

Find a closed formula for the general term

\(a_n\) of the sequence \( \lbrace$a,$c,$a,$c, \ldots\rbrace \),

assuming that the first term is \( a_1 \).

$BR

$BR

\(a_n =\) \{ans_rule(20)\}

END_TEXT

Context()->normalStrings;

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

# Answer evaluation

$showPartialCorrectAnswers = 1;

ANS( $ans->cmp() );

ENDDOCUMENT();

It's good to see that you're writing some webwork questions. The short answer to your question is to remove the string NONE from the context. Also, I would recommend making the following modifications, which I made in the PG code below:

1. In the text of the problem, specify the type of answer you're expecting from students (a closed formula instead of just a formula).

2. In the text of the problem, specify where the indexing starts so that students are clear that it starts with a_1 and not a_0.

3. Make the question a bit more randomized by allowing the "radius" to be randomized rather than always fixed at 2.

4. Modify the context using variables->are(n=>"Real") so that the only variable in the context is n. Using variables->add(n=>"Real") retains the variable x in the context so that both n and x are in the context. Accordingly, using variables->are(n=>"Real"), you can now shorten your test points from pairs of numbers to singletons. In this particular question, having two variables in the context is probably not going to confuse students. Other times, though, it can. For example, if you add the variable t to the context, students may instinctively use x and will not figure out why their answer is incorrect. However, if you declare that the only variable is t using variables->are(t=>"Real"), students who enter an answer in terms of x will get an error message, realize their mistake, and correct it without needing to ask for help.

5. Don't forget to change back to normalStrings after END_TEXT.

Good luck!

Paul Pearson

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

# Initialization

DOCUMENT();

loadMacros(

"PGstandard.pl",

"MathObjects.pl",

"PGcourse.pl",

);

TEXT(beginproblem());

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

# Setup

Context("Numeric");

Context()->variables->are(n=>'Real');

Context()->operators->undefine(",");

Context()->strings->remove("NONE");

$a = random(1,12,1);

$b = random(2,5,1);

$apb = $a + $b;

$c = $a+2*$b;

$ans = Formula("$apb + $b * (-1)^n");

$ans->{test_points} = [[2],[3],[4],[5],[6],[7],[8],[9],[10]];

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

# Main text

Context()->texStrings;

BEGIN_TEXT

Find a closed formula for the general term

\(a_n\) of the sequence \( \lbrace$a,$c,$a,$c, \ldots\rbrace \),

assuming that the first term is \( a_1 \).

$BR

$BR

\(a_n =\) \{ans_rule(20)\}

END_TEXT

Context()->normalStrings;

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

# Answer evaluation

$showPartialCorrectAnswers = 1;

ANS( $ans->cmp() );

ENDDOCUMENT();

In reply to Paul Pearson
Sunday, 11 April 2010, 8:53 PM

### Re: General Sequence problems

by Justin Sukiennik -
Thank you Paul! I hope you are well in Colorado.

In reply to Justin Sukiennik
Monday, 12 April 2010, 7:20 AM

### Re: General Sequence problems

by Davide Cervone -
Neither the list not the word "none" should produce a pink screen error, and I am not able to reproduce that here. So something is wrong. You should not need to disable the comma nor the answer "none". A student who answers a list should receive the message "Your answer isn't a formula that returns a number (it looks like a list of numbers)", and the answer "none" should give "incorrect" with no other message. All that works properly for me.

Can you send the actual error message that occurs on your pink screen? Thanks.

Davide

Can you send the actual error message that occurs on your pink screen? Thanks.

Davide

In reply to Davide Cervone
Monday, 12 April 2010, 9:33 AM

### Re: General Sequence problems

by Justin Sukiennik -
The warning messages for typing "None" are as follows

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

DOCUMENT(); # This should be the first executable line in the problem.

loadMacros(

"PGstandard.pl",

"MathObjects.pl",

"PGcourse.pl",

);

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

$showPartialCorrectAnswers = 1;

TEXT(beginproblem());

Context("Numeric");

Context()->variables->are(n =>'Real');

$a = random(1,12,1);

$b = Compute("$a+4");

$ans = Formula("($a+2)+2(-1)^n")->reduce;

$ans->{test_points} = [[2],[3],[4],[5],[6],[7],[8],[9],[10]];

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

Context()->texStrings;

BEGIN_TEXT

Find a formula for the general term \(a_n\) of the sequence (starting with \(a_1\)):

\[

\lbrace$a,$b,$a,$b, \ldots\rbrace.

\]

$HR

\(a_n =\) \{ans_rule(20)\} $PAR

END_TEXT

Context()->normalStrings;

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

ANS(($ans)->cmp());

ENDDOCUMENT(); # This should be the last executable line in the problem.

Thank you.

`Error in Translator.pm::process_answers: Answer AnSwEr1: |None|`

`Can't generate enough valid points for comparison at line 562 of [PG]/lib/AnswerHash.pm`

Died within AnswerEvaluator::evaluate called at line 1 of (eval 5653)`Error in Translator.pm::process_answers: Answer AnSwEr1:`

`Answer evaluators must return a hash or an AnswerHash type, not type || at /opt/webwork/pg/lib/WeBWorK/PG/Translator.pm line 1174`

`Use of uninitialized value $answerScore in numeric ge (>=) at /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm line 249.`

`Use of uninitialized value $studentAnswer in pattern match (m//) at /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm line 250.`

`Use of uninitialized value $answerScore in numeric ge (>=) at /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm line 250.`

`Use of uninitialized value $answerScore in numeric ge (>=) at /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm line 251.`

`Use of uninitialized value $answerScore in numeric gt (>) at /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm line 251.`

`Use of uninitialized value $answerScore in numeric gt (>) at /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm line 254.`

`Error in Translator.pm::process_answers: Answer AnSwEr1: |3,7|`

`Can't generate enough valid points for comparison at line 562 of [PG]/lib/AnswerHash.pm`

Died within AnswerEvaluator::evaluate called at line 1 of (eval 6631)`Error in Translator.pm::process_answers: Answer AnSwEr1:`

`Answer evaluators must return a hash or an AnswerHash type, not type || at /opt/webwork/pg/lib/WeBWorK/PG/Translator.pm line 1174`

`Use of uninitialized value $answerScore in numeric ge (>=) at /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm line 249.`

`Use of uninitialized value $studentAnswer in pattern match (m//) at /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm line 250.`

`Use of uninitialized value $answerScore in numeric ge (>=) at /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm line 250.`

`Use of uninitialized value $answerScore in numeric ge (>=) at /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm line 251.`

`Use of uninitialized value $answerScore in numeric gt (>) at /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm line 251.`

`Use of uninitialized value $answerScore in numeric gt (>) at /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm line 254.`

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

DOCUMENT(); # This should be the first executable line in the problem.

loadMacros(

"PGstandard.pl",

"MathObjects.pl",

"PGcourse.pl",

);

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

$showPartialCorrectAnswers = 1;

TEXT(beginproblem());

Context("Numeric");

Context()->variables->are(n =>'Real');

$a = random(1,12,1);

$b = Compute("$a+4");

$ans = Formula("($a+2)+2(-1)^n")->reduce;

$ans->{test_points} = [[2],[3],[4],[5],[6],[7],[8],[9],[10]];

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

Context()->texStrings;

BEGIN_TEXT

Find a formula for the general term \(a_n\) of the sequence (starting with \(a_1\)):

\[

\lbrace$a,$b,$a,$b, \ldots\rbrace.

\]

$HR

\(a_n =\) \{ans_rule(20)\} $PAR

END_TEXT

Context()->normalStrings;

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

ANS(($ans)->cmp());

ENDDOCUMENT(); # This should be the last executable line in the problem.

Thank you.

In reply to Justin Sukiennik
Monday, 12 April 2010, 11:27 AM

### Re: General Sequence problems

by Davide Cervone -
I'm still not able to reproduce these error messages. Everything works fine for me. The errors suggest that the type-checking that occurs before the formulas are compared is not working, which is very strange. The answer checker should never get as far as trying to compare the two answers, which is where it is when the error actually occurs.

What version of pg are you using? Have any custom modifications been made? Are there any files in your course templates/macros folder? Are correct answers graded correctly? And are incorrect formulas graded correctly?

Davide

What version of pg are you using? Have any custom modifications been made? Are there any files in your course templates/macros folder? Are correct answers graded correctly? And are incorrect formulas graded correctly?

Davide

In reply to Davide Cervone
Monday, 12 April 2010, 1:33 PM

### Re: General Sequence problems

by Jonathan Rogness -
Hi Davide,

We're running a vanilla installation of the Live DVD -- 2.4.7, if I recall correctly. We've been upgrading the OS and apache software in the background, but haven't made any changes or customizations to webwork yet. There's nothing in the templates/macros directory, either.

Justin would have a better sense for whether the answers have been graded appropriately, but I haven't noticed any problems.

Jon

We're running a vanilla installation of the Live DVD -- 2.4.7, if I recall correctly. We've been upgrading the OS and apache software in the background, but haven't made any changes or customizations to webwork yet. There's nothing in the templates/macros directory, either.

Justin would have a better sense for whether the answers have been graded appropriately, but I haven't noticed any problems.

Jon

In reply to Davide Cervone
Monday, 12 April 2010, 3:04 PM

### Re: General Sequence problems

by Justin Sukiennik -
I have not seen any issues with correctness. I did check it out in several different ways, and it seemed to me that the answers were counted as right or wrong correctly.