Skip to content

Commit

Permalink
TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
drgrice1 committed Sep 19, 2023
1 parent 8cf57d3 commit bd464f2
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 50 deletions.
47 changes: 28 additions & 19 deletions lib/WeBWorK/ContentGenerator/Problem.pm
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ async sub pre_header_initialize ($c) {
{
$c->{submitAnswers} = 0;
$c->{resubmitDetected} = 1;
delete $formFields->{submitAnswers};
}

$c->{displayMode} = $displayMode;
Expand Down Expand Up @@ -581,6 +582,24 @@ async sub pre_header_initialize ($c) {
# Final values for options
my %will = map { $_ => $can{$_} && ($want{$_} || $must{$_}) } keys %must;

if ($prEnabled && $problem->{prCount} >= $rerandomizePeriod && !after($c->{set}->due_date, $c->submitTime)) {
$showMeAnother{active} = 0;
$must{requestNewSeed} = 1;
$can{requestNewSeed} = 1;
$want{requestNewSeed} = 1;
$will{requestNewSeed} = 1;
$c->{showCorrectOnRandomize} = $ce->{pg}{options}{showCorrectOnRandomize};
# If this happens, it means that the page was refreshed. So prevent the answers from
# being recorded and the number of attempts from being increased.
if ($problem->{prCount} > $rerandomizePeriod) {
$c->{resubmitDetected} = 1;
$must{recordAnswers} = 0;
$can{recordAnswers} = 0;
$want{recordAnswers} = 0;
$will{recordAnswers} = 0;
}
}

# Sticky answers
if (!($c->{submitAnswers} || $previewAnswers || $checkAnswers) && $will{showOldAnswers}) {
my %oldAnswers = decodeAnswers($problem->last_answer);
Expand Down Expand Up @@ -615,7 +634,15 @@ async sub pre_header_initialize ($c) {
useMathView => $will{useMathView},
forceScaffoldsOpen => 0,
isInstructor => $authz->hasPermissions($userID, 'view_answers'),
debuggingOptions => getTranslatorDebuggingOptions($authz, $userID)
debuggingOptions => getTranslatorDebuggingOptions($authz, $userID),
forceShowAttemptFeedback => $will{checkAnswers} || $will{showProblemGrader},
showAttemptAnswers => $ce->{pg}{options}{showEvaluatedAnswers},
showAttemptPreviews => 1,
showAttemptResults => 1,
showMessages => 1,
showCorrectAnswers => $c->{submitAnswers} ? ($c->{showCorrectOnRandomize} // $will{showCorrectAnswers})
: $will{checkAnswers} || $will{showProblemGrader} ? $will{showCorrectAnswers}
: 0
}
);

Expand All @@ -630,24 +657,6 @@ async sub pre_header_initialize ($c) {
id => 'num_attempts'
);

if ($prEnabled && $problem->{prCount} >= $rerandomizePeriod && !after($c->{set}->due_date, $c->submitTime)) {
$showMeAnother{active} = 0;
$must{requestNewSeed} = 1;
$can{requestNewSeed} = 1;
$want{requestNewSeed} = 1;
$will{requestNewSeed} = 1;
$c->{showCorrectOnRandomize} = $ce->{pg}{options}{showCorrectOnRandomize};
# If this happens, it means that the page was refreshed. So prevent the answers from
# being recorded and the number of attempts from being increased.
if ($problem->{prCount} > $rerandomizePeriod) {
$c->{resubmitDetected} = 1;
$must{recordAnswers} = 0;
$can{recordAnswers} = 0;
$want{recordAnswers} = 0;
$will{recordAnswers} = 0;
}
}

# Update and fix hint/solution options after PG processing
$can{showHints} &&= $pg->{flags}{hintExists};
$can{showSolutions} &&= $pg->{flags}{solutionExists};
Expand Down
62 changes: 31 additions & 31 deletions lib/WeBWorK/HTML/AttemptsTable.pm
Original file line number Diff line number Diff line change
Expand Up @@ -273,37 +273,37 @@ sub answerTemplate ($self) {

return '' unless $self->answersSubmitted; # Only print if there is at least one non-blank answer

my $tableRows = $c->c;

push(
@$tableRows,
$c->tag(
'tr',
$c->c(
$self->showAnswerNumbers ? $c->tag('th', '#') : '',
$self->showAttemptAnswers ? $c->tag('th', $c->maketext('Entered')) : '',
$self->showAttemptPreviews ? $c->tag('th', $c->maketext('Answer Preview')) : '',
$self->showAttemptResults ? $c->tag('th', $c->maketext('Result')) : '',
$self->showCorrectAnswers ? $c->tag('th', $c->maketext('Correct Answer')) : '',
$self->showMessages ? $c->tag('th', $c->maketext('Message')) : ''
)->join('')
)
);

my $answerNumber = 0;
for (@{ $self->answerOrder() }) {
push @$tableRows, $c->tag('tr', $self->formatAnswerRow($self->{answers}{$_}, $_, ++$answerNumber));
}
#my $tableRows = $c->c;

#push(
# @$tableRows,
# $c->tag(
# 'tr',
# $c->c(
# $self->showAnswerNumbers ? $c->tag('th', '#') : '',
# $self->showAttemptAnswers ? $c->tag('th', $c->maketext('Entered')) : '',
# $self->showAttemptPreviews ? $c->tag('th', $c->maketext('Answer Preview')) : '',
# $self->showAttemptResults ? $c->tag('th', $c->maketext('Result')) : '',
# $self->showCorrectAnswers ? $c->tag('th', $c->maketext('Correct Answer')) : '',
# $self->showMessages ? $c->tag('th', $c->maketext('Message')) : ''
# )->join('')
# )
#);

#my $answerNumber = 0;
#for (@{ $self->answerOrder() }) {
# push @$tableRows, $c->tag('tr', $self->formatAnswerRow($self->{answers}{$_}, $_, ++$answerNumber));
#}

return $c->c(
$self->showHeadline
? $c->tag('h2', class => 'attemptResultsHeader', $c->maketext('Results for this submission'))
: '',
$c->tag(
'div',
class => 'table-responsive',
$c->tag('table', class => 'attemptResults table table-sm table-bordered', $tableRows->join(''))
),
#$c->tag(
# 'div',
# class => 'table-responsive',
# $c->tag('table', class => 'attemptResults table table-sm table-bordered', $tableRows->join(''))
#),
$self->showSummary ? $self->createSummary : ''
)->join('');
}
Expand Down Expand Up @@ -372,7 +372,7 @@ sub createSummary ($self) {
$c->tag(
'div',
class => 'ResultsWithoutError mb-2',
$c->maketext('The answer above is correct.')
$c->maketext('The answer below is correct.')
)
);
} elsif ($self->{essayFlag}) {
Expand All @@ -383,7 +383,7 @@ sub createSummary ($self) {
$c->tag(
'div',
class => 'ResultsWithError mb-2',
$c->maketext('The answer above is NOT correct.')
$c->maketext('The answer below is NOT correct.')
)
);
}
Expand All @@ -395,7 +395,7 @@ sub createSummary ($self) {
$c->tag(
'div',
class => 'ResultsWithoutError mb-2',
$c->maketext('All of the gradeable answers above are correct.')
$c->maketext('All of the gradeable answers below are correct.')
)
);
} else {
Expand All @@ -404,7 +404,7 @@ sub createSummary ($self) {
$c->tag(
'div',
class => 'ResultsWithoutError mb-2',
$c->maketext('All of the answers above are correct.')
$c->maketext('All of the answers below are correct.')
)
);
}
Expand All @@ -414,7 +414,7 @@ sub createSummary ($self) {
$c->tag(
'div',
class => 'ResultsWithError mb-2',
$c->maketext('At least one of the answers above is NOT correct.')
$c->maketext('At least one of the answers below is NOT correct.')
)
);
}
Expand Down
8 changes: 8 additions & 0 deletions lib/WeBWorK/Utils/Rendering.pm
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,14 @@ sub constructPGOptions ($ce, $user, $set, $problem, $psvn, $formFields, $transla
$options{inputs_ref} = $formFields;
$options{processAnswers} = $translationOptions->{processAnswers};

# Attempt Results
$options{forceShowAttemptFeedback} = $translationOptions->{forceShowAttemptFeedback};
$options{showAttemptAnswers} = $translationOptions->{showAttemptAnswers};
$options{showAttemptPreviews} = $translationOptions->{showAttemptPreviews};
$options{showAttemptResults} = $translationOptions->{showAttemptResults};
$options{showMessages} = $translationOptions->{showMessages};
$options{showCorrectAnswers} = $translationOptions->{showCorrectAnswers};

# External Data
$options{external_data} = decode_json($set->{external_data} || '{}');

Expand Down

0 comments on commit bd464f2

Please sign in to comment.