Skip to content

Commit

Permalink
Remve the attempts table entirely.
Browse files Browse the repository at this point in the history
PG now also generates the results summary.
  • Loading branch information
drgrice1 committed Sep 27, 2023
1 parent a784d39 commit 702d2a8
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 325 deletions.
2 changes: 1 addition & 1 deletion htdocs/js/RenderProblem/renderproblem.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
send_pg_flags: 1,
extra_header_text:
'<style>' +
'html{overflow-y:hidden;}body{padding:1px;background:#f5f5f5;}.container-fluid{padding:0px;}' +
'html{overflow-y:auto;}body{padding:1px;background:#f5f5f5;}.container-fluid{padding:0px;}' +
'</style>',
...renderOptions
};
Expand Down
53 changes: 29 additions & 24 deletions lib/FormatRenderedProblem.pm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ use Digest::SHA qw(sha1_base64);
use Mojo::Util qw(xml_escape);
use Mojo::DOM;

use WeBWorK::HTML::AttemptsTable;
use WeBWorK::Utils qw(getAssetURL);
use WeBWorK::Utils::LanguageAndDirection;

Expand Down Expand Up @@ -145,23 +144,30 @@ sub formatRenderedProblem {
my $showCorrectMode = defined($ws->{inputs_ref}{WWcorrectAns}) || 0;
# A problemUUID should be added to the request as a parameter. It is used by PG to create a proper UUID for use in
# aliases for resources. It should be unique for a course, user, set, problem, and version.
my $problemUUID = $ws->{inputs_ref}{problemUUID} // '';
my $problemResult = $rh_result->{problem_result} // {};
my $showSummary = $ws->{inputs_ref}{showSummary} // 1;
my $showAnswerNumbers = $ws->{inputs_ref}{showAnswerNumbers} // 1;

# Attempts table
my $answerTemplate = '';

# Do not produce an AttemptsTable when we had a rendering error.
if (!$renderErrorOccurred && !$previewMode) {
$answerTemplate = WeBWorK::HTML::AttemptsTable->new(
$rh_result->{answers} // {}, $ws->c,
answersSubmitted => $ws->{inputs_ref}{answersSubmitted} // 0,
answerOrder => $rh_result->{flags}{ANSWER_ENTRY_ORDER} // [],
showSummary => (($showSummary && ($submitMode || $showCorrectMode)) // 0) ? 1 : 0,
summary => $problemResult->{summary} // '' # can be set by problem grader
)->answerTemplate;
my $problemUUID = $ws->{inputs_ref}{problemUUID} // '';
my $problemResult = $rh_result->{problem_result} // {};
my $showSummary = $ws->{inputs_ref}{showSummary} // 1;

# Result summary
my $resultSummary = '';

my $lh = WeBWorK::Localize::getLangHandle($formLanguage);

# Do not produce a result summary when we had a rendering error.
if (!$renderErrorOccurred
&& $showSummary
&& !$previewMode
&& ($submitMode || $showCorrectMode)
&& $problemResult->{summary})
{
$resultSummary = $ws->c->c(
$ws->c->tag(
'h2',
class => 'fs-3 mb-2',
$ws->c->maketext('Results for this submission')
)
. $ws->c->tag('div', role => 'alert', $ws->c->b($problemResult->{summary}))
)->join('');
}

# Answer hash in XML format used by the PTX format.
Expand Down Expand Up @@ -204,7 +210,7 @@ sub formatRenderedProblem {
$output->{input} = $ws->{input};

# The following could be constructed from the above, but this is a convenience
$output->{answerTemplate} = $answerTemplate->to_string if $answerTemplate;
$output->{resultSummary} = $resultSummary->to_string if $resultSummary;
$output->{lang} = $PROBLEM_LANG_AND_DIR{lang};
$output->{dir} = $PROBLEM_LANG_AND_DIR{dir};
$output->{extra_css_files} = \@extra_css_files;
Expand Down Expand Up @@ -232,7 +238,7 @@ sub formatRenderedProblem {
formatName => $formatName,
ws => $ws,
ce => $ce,
lh => WeBWorK::Localize::getLangHandle($ws->{inputs_ref}{language} // 'en'),
lh => $lh,
rh_result => $rh_result,
SITE_URL => $SITE_URL,
FORM_ACTION_URL => $SITE_URL . $ws->c->webwork_url . '/render_rpc',
Expand All @@ -253,7 +259,7 @@ sub formatRenderedProblem {
extra_js_files => \@extra_js_files,
problemText => $problemText,
extra_header_text => $ws->{inputs_ref}{extra_header_text} // '',
answerTemplate => $answerTemplate,
resultSummary => $resultSummary,
showScoreSummary => $submitMode && !$renderErrorOccurred && $problemResult,
answerhashXML => $answerhashXML,
LTIGradeMessage => $LTIGradeMessage,
Expand All @@ -265,9 +271,8 @@ sub formatRenderedProblem {
isInstructor => $ws->{inputs_ref}{isInstructor} // '',
forceScaffoldsOpen => $ws->{inputs_ref}{forceScaffoldsOpen} // '',
showSummary => $showSummary,
showHints => $ws->{inputs_ref}{showHints} // '',
showSolutions => $ws->{inputs_ref}{showSolutions} // '',
showAnswerNumbers => $showAnswerNumbers,
showHints => $ws->{inputs_ref}{showHints} // '',
showSolutions => $ws->{inputs_ref}{showSolutions} // '',
showPreviewButton => $ws->{inputs_ref}{showPreviewButton} // '',
showCheckAnswersButton => $ws->{inputs_ref}{showCheckAnswersButton} // '',
showCorrectAnswersButton => $ws->{inputs_ref}{showCorrectAnswersButton} // '',
Expand Down
16 changes: 4 additions & 12 deletions lib/WeBWorK/ContentGenerator/GatewayQuiz.pm
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ use WeBWorK::Utils::Tasks qw(fake_set fake_set_version fake_problem);
use WeBWorK::Debug;
use WeBWorK::Authen::LTIAdvanced::SubmitGrade;
use WeBWorK::Authen::LTIAdvantage::SubmitGrade;
use WeBWorK::HTML::AttemptsTable;
use PGrandom;
use Caliper::Sensor;
use Caliper::Entity;
Expand Down Expand Up @@ -238,17 +237,10 @@ sub can_useMathQuill ($c) {
}

# Output utility
sub attemptResults ($c, $pg, $showSummary) {
my $ce = $c->ce;

return WeBWorK::HTML::AttemptsTable->new(
$pg->{answers},
$c,
answersSubmitted => 1,
answerOrder => $pg->{flags}{ANSWER_ENTRY_ORDER},
showHeadline => 0,
showSummary => $showSummary,
)->answerTemplate;
sub attemptResults ($c, $pg) {
return ($c->{can}{showProblemScores} && $pg->{result}{summary})
? $c->tag('div', role => 'alert', $c->b($pg->{result}{summary}))
: '';
}

sub get_instructor_comment ($c, $problem) {
Expand Down
20 changes: 7 additions & 13 deletions lib/WeBWorK/ContentGenerator/Problem.pm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ use WeBWorK::Localize;
use WeBWorK::Utils::Tasks qw(fake_set fake_problem);
use WeBWorK::Utils::LanguageAndDirection qw(get_problem_lang_and_dir);
use WeBWorK::AchievementEvaluator;
use WeBWorK::HTML::AttemptsTable;

# GET/POST Parameters for this module
#
Expand Down Expand Up @@ -246,16 +245,11 @@ sub can_showMeAnother ($c, $user, $effectiveUser, $set, $problem, $submitAnswers
return 0;
}

sub attemptResults ($c, $pg, $showSummary) {
my $ce = $c->ce;

return WeBWorK::HTML::AttemptsTable->new(
$pg->{answers},
$c,
answersSubmitted => 1,
answerOrder => $pg->{flags}{ANSWER_ENTRY_ORDER},
showSummary => $showSummary,
)->answerTemplate;
sub attemptResults ($c, $pg) {
return $pg->{result}{summary}
? $c->c($c->tag('h2', class => 'fs-3 mb-2', $c->maketext('Results for this submission'))
. $c->tag('div', role => 'alert', $c->b($pg->{result}{summary})))->join('')
: '';
}

async sub pre_header_initialize ($c) {
Expand Down Expand Up @@ -1469,7 +1463,7 @@ sub output_summary ($c) {

# Attempt summary
if ($c->{submitAnswers}) {
push(@$output, $c->attemptResults($pg, 1));
push(@$output, $c->attemptResults($pg));
} elsif ($will{checkAnswers} || $c->{will}{showProblemGrader}) {
push(
@$output,
Expand All @@ -1478,7 +1472,7 @@ sub output_summary ($c) {
class => 'ResultsWithError d-inline-block mb-3',
$c->maketext('ANSWERS ONLY CHECKED -- ANSWERS NOT RECORDED')
),
$c->attemptResults($pg, 1)
$c->attemptResults($pg)
);
} elsif ($c->{previewAnswers}) {
push(
Expand Down
Loading

0 comments on commit 702d2a8

Please sign in to comment.