Skip to content

Commit cf5e970

Browse files
committed
Merge pull request #342 from cmhughes/cmhdevelop
showMeAnother button I've tested this feature both as a professor and as a student. The show me another button displays after the correct number of attempts (or is never shown at all), clicking it takes you to a new page with a different version of the problem. The options defined in the Course Configuration page all work. You can check and preview answers, and look at solutions and hints if the options are enabled and if they are there. I the system is usable and integrates well with the existing pages. Thanks for working with us for this (quite lengthy) pull process. I think this feature ended up being a really nice addition to WeBWorK. You might sign up for an account with the WeBWorK bug tracker (http://bugs.webwork.maa.org/) since its almost certain people will find bugs once more and more servers are using it. Cheers. Geoff.
2 parents 6ecd486 + a89bf51 commit cf5e970

File tree

15 files changed

+533
-72
lines changed

15 files changed

+533
-72
lines changed

conf/defaults.config

Lines changed: 64 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,23 @@ $editor{textTitle} = '';
155155
$editor{textEdition} = '';
156156
$editor{textAuthor} = '';
157157

158+
################################################################################
159+
# showMeAnother
160+
################################################################################
161+
# switch to enable showMeAnother button
162+
$pg{options}{enableShowMeAnother} = 0;
163+
# maximum number of times (per problem) the button can be used
164+
$pg{options}{showMeAnotherMaxReps} = 3;
165+
# maximum number of attempts to check if changing the problem seed
166+
# changes the problem
167+
$pg{options}{showMeAnotherGeneratesDifferentProblem} = 5;
168+
# showMeAnother options
169+
$pg{options}{showMeAnother}=[
170+
"SMAcheckAnswers",
171+
"SMAshowSolutions",
172+
"SMAshowCorrect",
173+
"SMAshowHints",
174+
];
158175
################################################################################
159176
# Language
160177
################################################################################
@@ -1067,6 +1084,12 @@ $problemDefaults{value} = 1;
10671084
# setting this to -1 gives students unlimited attempts.
10681085
$problemDefaults{max_attempts} = -1;
10691086

1087+
# The default showMeAnother for a problem to use when using the
1088+
# Library Browser, Problem Editor or Hmwk Sets Editor to add problems to a set
1089+
# or when this value is left blank in an imported set definition file. Note that
1090+
# setting this to -1 disables the showMeAnother button
1091+
$problemDefaults{showMeAnother} = -1;
1092+
10701093
##### Answer evaluatior defaults
10711094

10721095
$pg{ansEvalDefaults} = {
@@ -1329,13 +1352,15 @@ $ConfigValues = [
13291352
type => 'popuplist'
13301353
},
13311354
{ var => 'pg{specialPGEnvironmentVars}{DragMath}',
1332-
doc => 'Use DragMath editor for answer entry',
1333-
doc2 => 'Set to true to display pencil DragMath equation editor next to each answer box',
1334-
type => 'boolean'},
1335-
{ var => 'pg{specialPGEnvironmentVars}{MathView}',
1336-
doc => 'Use MathView editor for answer entry',
1337-
doc2 => 'Set to true to display MathView equation editor icon next to each answer box',
1338-
type => 'boolean'},
1355+
doc => 'Use DragMath editor for answer entry',
1356+
doc2 => 'Set to true to display pencil DragMath equation editor next to each answer box',
1357+
type => 'boolean'
1358+
},
1359+
{ var => 'pg{specialPGEnvironmentVars}{MathView}',
1360+
doc => 'Use MathView editor for answer entry',
1361+
doc2 => 'Set to true to display MathView equation editor icon next to each answer box',
1362+
type => 'boolean'
1363+
},
13391364
{ var => 'pg{options}{showEvaluatedAnswers}',
13401365
doc => 'Display the evaluated student answer',
13411366
doc2 => 'Set to true to display the "Entered" column which automatically shows the evaluated student answer, e.g. 1 if student input is sin(pi/2). If this is set to false, e.g. to save space in the response area, the student can still see their evaluated answer by hovering the mouse pointer over the typeset version of their answer.',
@@ -1399,21 +1424,38 @@ $ConfigValues = [
13991424
values => [qw(1 0.95 0.9 0.85 0.8 0.75 0.7 0.65 0.6 0.55 0.5 0.45 0.4 0.35 0.3 0.25 0.2 0.15 0.1)],
14001425
type => 'popuplist'
14011426
},
1402-
{ var => 'pg{timeAssignDue}',
1403-
doc => 'Time that the Assignment is Due',
1404-
doc2 => 'The time of the day that the assignment is due. This can be changed on an individual basis, but WeBWorK will use this value for default when a date is set.',
1405-
type => 'text'
1406-
},
1407-
{ var => 'pg{assignOpenPriorToDue}',
1408-
doc => 'Amount of Time (in minutes) before Due Date that the Assignment is Open',
1409-
doc2 => 'The amount of time (in minutes) before the due date when the assignment is opened.',
1410-
type => 'number'
1411-
},
1412-
{ var => 'pg{answersOpenAfterDueDate}',
1413-
doc => 'Amount of Time (in minutes) after Due Date that Answers are Open',
1414-
doc2 => 'The amount of time (in minutes) after the due date that the Answers are available to student to view.',
1415-
type => 'number'
1416-
},
1427+
{ var => 'pg{timeAssignDue}',
1428+
doc => 'Time that the Assignment is Due',
1429+
doc2 => 'The time of the day that the assignment is due. This can be changed on an individual basis, but WeBWorK will use this value for default when a date is set.',
1430+
type => 'text'
1431+
},
1432+
{ var => 'pg{assignOpenPriorToDue}',
1433+
doc => 'Amount of Time (in minutes) before Due Date that the Assignment is Open',
1434+
doc2 => 'The amount of time (in minutes) before the due date when the assignment is opened.',
1435+
type => 'number'
1436+
},
1437+
{ var => 'pg{answersOpenAfterDueDate}',
1438+
doc => 'Amount of Time (in minutes) after Due Date that Answers are Open',
1439+
doc2 => 'The amount of time (in minutes) after the due date that the Answers are available to student to view.',
1440+
type => 'number'
1441+
},
1442+
{ var => 'pg{options}{enableShowMeAnother}',
1443+
doc => 'Enable Show Me Another button',
1444+
doc2 => 'Enables use of the Show Me Another button, which offers the student a newly-seeded version of the current problem, complete with solution (if it exists for that problem).',
1445+
type => 'boolean'
1446+
},
1447+
{ var => 'pg{options}{showMeAnotherMaxReps}',
1448+
doc => 'Maximum times Show me Another can be used per problem (-1 => unlimited)',
1449+
doc2 => 'The Maximum number of times Show me Another can be used per problem by a student. If set to -1 then there is no limit to the number of times that Show Me Another can be used.',
1450+
type => 'number'
1451+
},
1452+
{ var => 'pg{options}{showMeAnother}',
1453+
doc => 'List of options for Show Me Another button',
1454+
doc2 => '<ul><li><b>SMAcheckAnswers</b>: enables the Check Answers button <i>for the new problem</i> when Show Me Another is clicked</li> <li><b>SMAshowSolutions</b>: shows walk-through solution <i>for the new problem</i> when Show Me Another is clicked; a check is done first to make sure that a solution exists </li><li><b>SMAshowCorrect</b>: correct answers <i>for the new problem</i> can be viewed when Show Me Another is clicked; note that <b>SMAcheckAnswers</b> needs to be enabled at the same time</li><li><b>SMAshowHints</b>: show hints <i>for the new problem</i> (assuming they exist)</li></ul>Note: there is very little point enabling the button unless you check at least one of these options - the students would simply see a new version that they can not attempt or learn from.</p>',
1455+
min => 0,
1456+
values => ["SMAcheckAnswers", "SMAshowSolutions","SMAshowCorrect","SMAshowHints"],
1457+
type => 'checkboxlist'
1458+
}
14171459
],
14181460
['E-Mail',
14191461
{ var => 'mail{feedbackSubjectFormat}',

conf/localOverrides.conf.dist

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,12 @@ $problemDefaults{value} = 1;
228228

229229
$problemDefaults{max_attempts} = -1;
230230

231+
# The default showMeAnother for a problem to use when using the
232+
# Library Browser, Problem Editor or Hmwk Sets Editor to add problems to a set
233+
# or when this value is left blank in an imported set definition file. Note that
234+
# setting this to -1 disables the showMeAnother button
235+
$problemDefaults{showMeAnother} = -1;
236+
231237
################################################################################
232238
# "Special" PG environment variables. (Stuff that doesn't fit in anywhere else.)
233239
################################################################################

htdocs/themes/math4/math4.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ div.WarningMessage { background-color: #FF9494; padding: 3px 3px 3px 3px; }
364364
div.ResultsWithoutError { color: inherit; background-color: #8F8; } /* green */
365365
div.ResultsWithError { color: #FF9494; background-color: inherit; } /* error red, from http://www.colourlovers.com/color/FF9494/error_red*/
366366
div.ResultsAlert { color: #F60; background-color: inherit; } /* orange */
367+
div.showMeAnotherBox { background-color: #EDE275; border-radius: 5px; border: 2px solid #FDD017; padding: 3px 3px 3px 3px} /* bright gold border and harvest gold background*/
367368
label.WarningMessage { background-color: #FF9494; padding: 3px 3px 3px 3px; }
368369
label.ResultsWithoutError { color: inherit; background-color: #8F8; } /* green */
369370
label.ResultsWithError { color: #FF9494; background-color: inherit; } /* error red, from http://www.colourlovers.com/color/FF9494/error_red*/

lib/WeBWorK/ContentGenerator.pm

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,6 +1563,14 @@ method. The simplest way to to this is:
15631563
sub optionsMacro {
15641564
my ($self, %options) = @_;
15651565
my $r = $self->r;
1566+
my %showMeAnother;
1567+
my $problemSeed;
1568+
1569+
# check if showMeAnother is defined
1570+
if($self->{showMeAnother}){
1571+
%showMeAnother = %{ $self->{showMeAnother} };
1572+
$problemSeed = $self->{problem}->{problem_seed};
1573+
}
15661574

15671575
my @options_to_show = @{$options{options_to_show}} if exists $options{options_to_show};
15681576
@options_to_show = "displayMode" unless @options_to_show; #FIXME -- I don't understant this -- type seems wrong
@@ -1629,6 +1637,16 @@ sub optionsMacro {
16291637
$result .= CGI::br();
16301638
}
16311639

1640+
# hidden field for clicking Preview Answers and Check Answers from a Show Me Another screen
1641+
# it needs to send the seed from showMeAnother back to the screen
1642+
if($showMeAnother{active} or $showMeAnother{CheckAnswers} or $showMeAnother{Preview}){
1643+
$result .= CGI::hidden({name => "showMeAnotherCheckAnswers", id=>"showMeAnotherCheckAnswers_id", value => 1});
1644+
# output the problem seed from ShowMeAnother so that it can be recycled in the refreshed screen
1645+
$result .= CGI::hidden({name => "problemSeed", value => $problemSeed});
1646+
# tell showMeAnother that a display change has been made
1647+
$result .= CGI::hidden({name => "SMAdisplayChange", value => 1});
1648+
}
1649+
16321650
$result .= CGI::submit(-name=>"redisplay", -label=>$r->maketext("Apply Options"));
16331651
$result .= CGI::end_div();
16341652
$result .= CGI::end_form();

lib/WeBWorK/ContentGenerator/Instructor.pm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,9 @@ sub addProblemToSet {
520520
my $db = $self->r->db;
521521
my $value_default = $self->{ce}->{problemDefaults}->{value};
522522
my $max_attempts_default = $self->{ce}->{problemDefaults}->{max_attempts};
523+
my $showMeAnother_default = $self->{ce}->{problemDefaults}->{showMeAnother};
524+
# showMeAnotherCount is the number of times that showMeAnother has been clicked; initially 0
525+
my $showMeAnotherCount = 0;
523526

524527

525528
die "addProblemToSet called without specifying the set name." if $args{setName} eq "";
@@ -535,6 +538,7 @@ sub addProblemToSet {
535538
if (defined($args{value})){$value = $args{value};} # 0 is a valid value for $args{value}
536539

537540
my $maxAttempts = $args{maxAttempts} || $max_attempts_default;
541+
my $showMeAnother = $args{showMeAnother} || $showMeAnother_default;
538542
my $problemID = $args{problemID};
539543

540544
unless ($problemID) {
@@ -547,6 +551,8 @@ sub addProblemToSet {
547551
$problemRecord->source_file($sourceFile);
548552
$problemRecord->value($value);
549553
$problemRecord->max_attempts($maxAttempts);
554+
$problemRecord->showMeAnother($showMeAnother);
555+
$problemRecord->{showMeAnotherCount}=$showMeAnotherCount;
550556
$db->addGlobalProblem($problemRecord);
551557

552558
return $problemRecord;

lib/WeBWorK/ContentGenerator/Instructor/ProblemSetDetail.pm

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ use WeBWorK::Utils::DatePickerScripts;
4040

4141
# these constants determine which fields belong to what type of record
4242
use constant SET_FIELDS => [qw(set_header hardcopy_header open_date due_date answer_date visible description enable_reduced_scoring reduced_scoring_date restricted_release restricted_status restrict_ip relax_restrict_ip assignment_type attempts_per_version version_time_limit time_limit_cap versions_per_interval time_interval problem_randorder problems_per_page hide_score:hide_score_by_problem hide_work hide_hint)];
43-
use constant PROBLEM_FIELDS =>[qw(source_file value max_attempts)];
43+
use constant PROBLEM_FIELDS =>[qw(source_file value max_attempts showMeAnother)];
4444
use constant USER_PROBLEM_FIELDS => [qw(problem_seed status num_correct num_incorrect)];
4545

4646
# these constants determine what order those fields should be displayed in
4747
use constant HEADER_ORDER => [qw(set_header hardcopy_header)];
48-
use constant PROBLEM_FIELD_ORDER => [qw(problem_seed status value max_attempts attempted last_answer num_correct num_incorrect)];
48+
use constant PROBLEM_FIELD_ORDER => [qw(problem_seed status value max_attempts showMeAnother attempted last_answer num_correct num_incorrect)];
4949
# for gateway sets, we don't want to allow users to change max_attempts on a per
5050
# problem basis, as that's nothing but confusing.
5151
use constant GATEWAY_PROBLEM_FIELD_ORDER => [qw(problem_seed status value attempted last_answer num_correct num_incorrect)];
@@ -326,6 +326,16 @@ use constant FIELD_PROPERTIES => {
326326
"-1" => "unlimited",
327327
},
328328
},
329+
showMeAnother => {
330+
name => "Show me another",
331+
type => "edit",
332+
size => "6",
333+
override => "any",
334+
default=>"-1",
335+
labels => {
336+
"-1" => "Never",
337+
},
338+
},
329339
problem_seed => {
330340
name => "Seed",
331341
type => "edit",
@@ -428,6 +438,7 @@ sub FieldTable {
428438
($gwFields, $ipFields, $numLocations, $procFields) = $self->extraSetFields($userID, $setID, $globalRecord, $userRecord, $forUsers);
429439
}
430440

441+
431442
my $output = CGI::start_table({border => 0, cellpadding => 1});
432443
if ($forUsers) {
433444
$output .= CGI::Tr({},
@@ -477,6 +488,10 @@ sub FieldTable {
477488
next if ( $field eq 'problem_seed' &&
478489
( $isGWset && $forUsers && ! $setVersion ) );
479490

491+
# skip the Show Me Another value if SMA is not enabled
492+
next if ( $field eq 'showMeAnother' &&
493+
!$ce->{pg}->{options}->{enableShowMeAnother} );
494+
480495
unless ($properties{type} eq "hidden") {
481496
$output .= CGI::Tr({}, CGI::td({}, [$self->FieldHTML($userID, $setID, $problemID, $globalRecord, $userRecord, $field)])) . "\n";
482497
}

lib/WeBWorK/ContentGenerator/Instructor/ProblemSetList.pm

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,7 +1731,8 @@ sub importSetsFromDef {
17311731
sourceFile => $rh_problem->{source_file},
17321732
problemID => $freeProblemID++,
17331733
value => $rh_problem->{value},
1734-
maxAttempts => $rh_problem->{max_attempts});
1734+
maxAttempts => $rh_problem->{max_attempts},
1735+
showMeAnother => $rh_problem->{showMeAnother});
17351736
}
17361737

17371738

@@ -1753,6 +1754,7 @@ sub readSetDef {
17531754
my $filePath = "$templateDir/$fileName";
17541755
my $value_default = $self->{ce}->{problemDefaults}->{value};
17551756
my $max_attempts_default = $self->{ce}->{problemDefaults}->{max_attempts};
1757+
my $showMeAnother = $self->{ce}->{problemDefaults}->{showMeAnother};
17561758

17571759
my $setName = '';
17581760

@@ -1937,7 +1939,13 @@ sub readSetDef {
19371939
## anything left?
19381940
push(@line, $curr) if ( $curr );
19391941

1940-
($name, $value, $attemptLimit, $continueFlag) = @line;
1942+
# read the line and only look for $showMeAnother if it has the correct number of entries
1943+
# otherwise the default value will be used
1944+
if(scalar(@line)==4){
1945+
($name, $value, $attemptLimit, $showMeAnother, $continueFlag) = @line;
1946+
} else {
1947+
($name, $value, $attemptLimit, $continueFlag) = @line;
1948+
}
19411949
#####################
19421950
# clean up problem values
19431951
###########################
@@ -1953,6 +1961,7 @@ sub readSetDef {
19531961
push(@problemData, {source_file => $name,
19541962
value => $value,
19551963
max_attempts =>, $attemptLimit,
1964+
showMeAnother =>, $showMeAnother,
19561965
continuation => $continueFlag
19571966
});
19581967
}
@@ -2033,12 +2042,14 @@ SET: foreach my $set (keys %filenames) {
20332042
my $source_file = $problemRecord->source_file();
20342043
my $value = $problemRecord->value();
20352044
my $max_attempts = $problemRecord->max_attempts();
2045+
my $showMeAnother = $problemRecord->showMeAnother();
20362046

20372047
# backslash-escape commas in fields
20382048
$source_file =~ s/([,\\])/\\$1/g;
20392049
$value =~ s/([,\\])/\\$1/g;
20402050
$max_attempts =~ s/([,\\])/\\$1/g;
2041-
$problemList .= "$source_file, $value, $max_attempts \n";
2051+
$showMeAnother =~ s/([,\\])/\\$1/g;
2052+
$problemList .= "$source_file, $value, $max_attempts, $showMeAnother \n";
20422053
}
20432054

20442055
# gateway fields

lib/WeBWorK/ContentGenerator/Instructor/ProblemSetList2.pm

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,7 +1849,8 @@ sub importSetsFromDef {
18491849
sourceFile => $rh_problem->{source_file},
18501850
problemID => $freeProblemID++,
18511851
value => $rh_problem->{value},
1852-
maxAttempts => $rh_problem->{max_attempts});
1852+
maxAttempts => $rh_problem->{max_attempts},
1853+
showMeAnother => $rh_problem->{showMeAnother});
18531854
}
18541855

18551856

@@ -1886,6 +1887,7 @@ sub readSetDef {
18861887
my $filePath = "$templateDir/$fileName";
18871888
my $value_default = $self->{ce}->{problemDefaults}->{value};
18881889
my $max_attempts_default = $self->{ce}->{problemDefaults}->{max_attempts};
1890+
my $showMeAnother = $self->{ce}->{problemDefaults}->{showMeAnother};
18891891

18901892
my $setName = '';
18911893

@@ -2069,7 +2071,12 @@ sub readSetDef {
20692071
## anything left?
20702072
push(@line, $curr) if ( $curr );
20712073

2072-
($name, $value, $attemptLimit, $continueFlag) = @line;
2074+
# read the line and only look for $showMeAnother if it has the correct number of entries
2075+
if(scalar(@line)==4){
2076+
($name, $value, $attemptLimit, $showMeAnother, $continueFlag) = @line;
2077+
} else {
2078+
($name, $value, $attemptLimit, $continueFlag) = @line;
2079+
}
20732080
#####################
20742081
# clean up problem values
20752082
###########################
@@ -2085,6 +2092,7 @@ sub readSetDef {
20852092
push(@problemData, {source_file => $name,
20862093
value => $value,
20872094
max_attempts =>, $attemptLimit,
2095+
showMeAnother =>, $showMeAnother,
20882096
continuation => $continueFlag
20892097
});
20902098
}
@@ -2171,12 +2179,20 @@ SET: foreach my $set (keys %filenames) {
21712179
my $source_file = $problemRecord->source_file();
21722180
my $value = $problemRecord->value();
21732181
my $max_attempts = $problemRecord->max_attempts();
2182+
my $showMeAnother = $problemRecord->showMeAnother();
21742183

21752184
# backslash-escape commas in fields
21762185
$source_file =~ s/([,\\])/\\$1/g;
21772186
$value =~ s/([,\\])/\\$1/g;
21782187
$max_attempts =~ s/([,\\])/\\$1/g;
2179-
$problemList .= "$source_file, $value, $max_attempts \n";
2188+
$showMeAnother =~ s/([,\\])/\\$1/g;
2189+
2190+
# only include showMeAnother if it has been enabled in the course configuration
2191+
if($ce->{pg}->{options}{enableShowMeAnother}){
2192+
$problemList .= "$source_file, $value, $max_attempts, $showMeAnother \n";
2193+
} else {
2194+
$problemList .= "$source_file, $value, $max_attempts \n";
2195+
}
21802196
}
21812197

21822198
# gateway fields

0 commit comments

Comments
 (0)