| … | |
… | |
| 251 | nextStyle => "Checkbox", # or "Button", "Forced", or "HTML" |
251 | nextStyle => "Checkbox", # or "Button", "Forced", or "HTML" |
| 252 | nextLabel => undef, # Checkbox text or button name or HTML |
252 | nextLabel => undef, # Checkbox text or button name or HTML |
| 253 | nextNoChange => 1, # true if answer can't change for new part |
253 | nextNoChange => 1, # true if answer can't change for new part |
| 254 | allowReset => 0, # true to show "back to part 1" button |
254 | allowReset => 0, # true to show "back to part 1" button |
| 255 | resetLabel => undef, # label for reset button |
255 | resetLabel => undef, # label for reset button |
| 256 | grader => $main::PG_FLAGS{PROBLEM_GRADER_TO_USE} || \&main::avg_problem_grader, |
256 | grader => $main::PG->{flags}->{PROBLEM_GRADER_TO_USE} || \&main::avg_problem_grader, |
| 257 | @_, |
257 | @_, |
| 258 | status => $defaultStatus, |
258 | status => $defaultStatus, |
| 259 | }, $class; |
259 | }, $class; |
| 260 | die "You must provide either the totalAnswers or weights" |
260 | die "You must provide either the totalAnswers or weights" |
| 261 | unless $cp->{totalAnswers} || $cp->{weights}; |
261 | unless $cp->{totalAnswers} || $cp->{weights}; |
| … | |
… | |
| 305 | my $self = shift; |
305 | my $self = shift; |
| 306 | $main::ans_rule_count = $self->{status}{ans_rule_count}; |
306 | $main::ans_rule_count = $self->{status}{ans_rule_count}; |
| 307 | $main::images_created{$self->{status}{imageName}} = $self->{status}{images_created} |
307 | $main::images_created{$self->{status}{imageName}} = $self->{status}{images_created} |
| 308 | if $self->{status}{imageName}; |
308 | if $self->{status}{imageName}; |
| 309 | main::install_problem_grader(\&compoundProblem::grader); |
309 | main::install_problem_grader(\&compoundProblem::grader); |
| 310 | $main::PG_FLAGS{compoundProblem} = $self; |
310 | $main::PG->{flags}->{compoundProblem} = $self; |
| 311 | $self->initAnswers($self->{status}{answers}); |
311 | $self->initAnswers($self->{status}{answers}); |
| 312 | } |
312 | } |
| 313 | |
313 | |
| 314 | # |
314 | # |
| 315 | # Look through the list of answer labels and set |
315 | # Look through the list of answer labels and set |
| … | |
… | |
| 550 | # |
550 | # |
| 551 | # The custom grader that does the work of computing the scores |
551 | # The custom grader that does the work of computing the scores |
| 552 | # and saving the data. |
552 | # and saving the data. |
| 553 | # |
553 | # |
| 554 | sub grader { |
554 | sub grader { |
| 555 | my $self = $main::PG_FLAGS{compoundProblem}; |
555 | my $self = $main::PG->{flags}->{compoundProblem}; |
| 556 | |
|
|
| 557 | # |
556 | # |
| 558 | # Get the answer names and the weight for the current part. |
557 | # Get the answer names and the weight for the current part. |
| 559 | # |
558 | # |
| 560 | my @answers = keys(%{$_[0]}); |
559 | my @answers = keys(%{$_[0]}); |
| 561 | my $weight = scalar(@answers)/$self->{totalAnswers}; |
560 | my $weight = scalar(@answers)/$self->{totalAnswers}; |