Skip to content

Commit

Permalink
Merge pull request openwebwork#59 from openwebwork/master
Browse files Browse the repository at this point in the history
update freeze/thaw   to nfreeze/nthaw
  • Loading branch information
mgage committed Oct 10, 2012
2 parents 07eb0c2 + d5d6e41 commit 7c6c4d2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
10 changes: 5 additions & 5 deletions lib/WeBWorK/AchievementEvaluator.pm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use WeBWorK::CGI;
use WeBWorK::Utils qw(before after readFile sortAchievements);

use Safe;
use Storable qw(freeze thaw);
use Storable qw(nfreeze thaw);

sub checkForAchievements {

Expand Down Expand Up @@ -225,15 +225,15 @@ sub checkForAchievements {
$achievementPoints += $points;
}

#update counter, freeze localData and store
#update counter, nfreeze localData and store
$userAchievement->counter($counter);
$userAchievement->frozen_hash(freeze($localData));
$userAchievement->frozen_hash(nfreeze($localData));
$db->putUserAchievement($userAchievement);

} #end for loop

#freeze globalData and store
$globalUserAchievement->frozen_hash(freeze($globalData));
#nfreeze globalData and store
$globalUserAchievement->frozen_hash(nfreeze($globalData));
$db->putGlobalUserAchievement($globalUserAchievement);

return $cheevoMessage;
Expand Down
11 changes: 7 additions & 4 deletions lib/WeBWorK/ContentGenerator/GatewayQuiz.pm
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ sub attemptResults {
$resultsRows{$_} = "";
}

my $answerScore = 0;
my $numCorrect = 0;
my $numAns = 0;
foreach my $name (@answerNames) {
Expand All @@ -362,7 +363,7 @@ sub attemptResults {
? $self->previewAnswer($answerResult, $imgGen)
: "");
my $correctAnswer = $answerResult->{correct_ans};
my $answerScore = $answerResult->{score};
$answerScore = $answerResult->{score};
my $answerMessage = $showMessages ? $answerResult->{ans_message} : "";
#FIXME --Can we be sure that $answerScore is an integer-- could the problem give partial credit?
$numCorrect += $answerScore > 0;
Expand Down Expand Up @@ -407,10 +408,12 @@ sub attemptResults {
# . scalar @answerNames . " $numIncorrectNoun correct, for a score of $scorePercent.";

my $summary = "";
if (scalar @answerNames == 1) {
if ($numCorrect == scalar @answerNames) {
if (scalar @answerNames == 1) { #Here there is just one answer blank
if ($answerScore == 1) { #The student might be totally right
$summary .= CGI::div({class=>"gwCorrect"},"This answer is correct.");
} else {
} elsif ($answerScore && $answerScore < 1) { #The student might be partially right
$summary .= CGI::div({class=>"gwIncorrect"},"Part of this answer is NOT correct.");
} else { #The student might be completely wrong.
$summary .= CGI::div({class=>"gwIncorrect"},"This answer is NOT correct.");
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion lib/WeBWorK/Utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ sub encodeAnswers(\%\@) {
foreach my $key (@order) {
push @ordered_hash, $key, $hash{$key};
}
return Storable::freeze( \@ordered_hash);
return Storable::nfreeze( \@ordered_hash);

}

Expand Down

0 comments on commit 7c6c4d2

Please sign in to comment.