Skip to content

Commit

Permalink
Merge pull request openwebwork#2228 from drgrice1/attempts-table-remove
Browse files Browse the repository at this point in the history
Remove the attempts table.
  • Loading branch information
pstaabp authored Oct 30, 2023
2 parents 85ffa9a + 1a34fc3 commit 46f2fcf
Show file tree
Hide file tree
Showing 14 changed files with 155 additions and 707 deletions.
6 changes: 0 additions & 6 deletions conf/defaults.config
Original file line number Diff line number Diff line change
Expand Up @@ -1045,12 +1045,6 @@ $pg{options}{showEvaluatedAnswers} = 1;
# propogate to the main process. So this really should never be set to 0.
$pg{options}{catchWarnings} = 1;

# decorations for correct input blanks -- apparently you can't define and name attribute collections in a .css file
$pg{options}{correct_answer} = "{border-width:2;border-style:solid;border-color:#8F8}"; #matches resultsWithOutError class in math2.css

# decorations for incorrect input blanks
$pg{options}{incorrect_answer} = "{border-width:2;border-style:solid;border-color:#F55}"; #matches resultsWithError class in math2.css

##### Settings for various display modes

# "images" mode has several settings:
Expand Down
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
5 changes: 0 additions & 5 deletions htdocs/themes/math4/math4.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,6 @@
(el) => new bootstrap.Tooltip(el, {trigger: 'hover', fallbackPlacements: []})
);

// Set up popovers in the attemptResults table.
document.querySelectorAll('table.attemptResults td div.answer-preview').forEach((popover) => {
if (popover.dataset.bsContent) new bootstrap.Popover(popover, {trigger: 'click', html: true, sanitize: false});
});

// Sets up problems to rescale the image accoring to attr height width and not native height width.
const rescaleImage = (_index, element) => {
if (element.height != element.naturalHeight || element.width != element.naturalWidth) {
Expand Down
34 changes: 13 additions & 21 deletions htdocs/themes/math4/math4.scss
Original file line number Diff line number Diff line change
Expand Up @@ -687,14 +687,6 @@ ul.courses-list {
}
}

div.AuthorComment {
background-color: #00e0e0;
color: black;
padding: 0.25rem;
border: 1px solid transparent;
border-radius: 0.25rem;
}

/* Footer */
#footer {
font-size: 0.8em;
Expand Down Expand Up @@ -901,22 +893,22 @@ input.changed[type=text] { /* orange */
min-width: 2.5em;
text-align: center;
}
}

span {
&.correct {
color: inherit; /* green */
background-color: #8f8;
}
span {
&.correct {
color: inherit;
background-color: #8f8;
}

&.incorrect {
color: #bf5454; /* red */
background-color: inherit;
}
&.incorrect {
color: #bf5454; /* red */
background-color: inherit;
}

&.unattempted {
color: inherit;
background-color: #88ecff;
&.unattempted {
color: inherit;
background-color: #88ecff;
}
}
}

Expand Down
63 changes: 29 additions & 34 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,33 +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) {
my $tbl = WeBWorK::HTML::AttemptsTable->new(
$rh_result->{answers} // {}, $ws->c,
answersSubmitted => $ws->{inputs_ref}{answersSubmitted} // 0,
answerOrder => $rh_result->{flags}{ANSWER_ENTRY_ORDER} // [],
displayMode => $displayMode,
showAnswerNumbers => $showAnswerNumbers,
ce => $ce,
showAttemptPreviews => $previewMode || $submitMode || $showCorrectMode,
showAttemptResults => $submitMode || $showCorrectMode,
showCorrectAnswers => $showCorrectMode,
showMessages => $previewMode || $submitMode || $showCorrectMode,
showSummary => (($showSummary && ($submitMode || $showCorrectMode)) // 0) ? 1 : 0,
maketext => WeBWorK::Localize::getLoc($formLanguage),
summary => $problemResult->{summary} // '', # can be set by problem grader
);
$answerTemplate = $tbl->answerTemplate;
$tbl->imgGen->render(refresh => 1) if $tbl->displayMode eq 'images';
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 @@ -214,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 @@ -242,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 @@ -263,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 @@ -275,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
86 changes: 25 additions & 61 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,42 +237,10 @@ sub can_useMathQuill ($c) {
}

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

# Create AttemptsTable object
my $tbl = WeBWorK::HTML::AttemptsTable->new(
$pg->{answers},
$c,
answersSubmitted => 1,
answerOrder => $pg->{flags}{ANSWER_ENTRY_ORDER},
displayMode => $c->{displayMode},
showHeadline => 0,
showAnswerNumbers => 0,
showAttemptAnswers => $ce->{pg}{options}{showEvaluatedAnswers},
showAttemptPreviews => 1,
showAttemptResults => $showAttemptResults,
showCorrectAnswers => $showCorrectAnswers,
showMessages => 1,
showSummary => $showSummary,
imgGen => WeBWorK::PG::ImageGenerator->new(
tempDir => $ce->{webworkDirs}{tmp},
latex => $ce->{externalPrograms}{latex},
dvipng => $ce->{externalPrograms}{dvipng},
useCache => 1,
cacheDir => $ce->{webworkDirs}{equationCache},
cacheURL => $ce->{webworkURLs}{equationCache},
cacheDB => $ce->{webworkFiles}{equationCacheDB},
useMarkers => 1,
dvipng_align => $ce->{pg}{displayModeOptions}{images}{dvipng_align},
dvipng_depth_db => $ce->{pg}{displayModeOptions}{images}{dvipng_depth_db},
),
);

my $answerTemplate = $tbl->answerTemplate;
$tbl->imgGen->render(body_text => $answerTemplate) if $tbl->displayMode eq 'images';

return $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 Expand Up @@ -1482,18 +1449,6 @@ sub warningMessage ($c) {
# hash of parameters from the input form that need to be passed to the translator, and $mergedProblem
# is what we'd expect.
async sub getProblemHTML ($c, $effectiveUser, $set, $formFields, $mergedProblem) {
my $setID = $set->set_id;
my $setVersionNumber = $set->version_id;

# Figure out solutions are allowed and call renderPG accordingly.
my $showCorrectAnswers = $c->{will}{showCorrectAnswers};
my $showHints = $c->{will}{showHints};
my $showSolutions = $c->{will}{showSolutions};
my $processAnswers = $c->{will}{checkAnswers};

# FIXME: I'm not sure that problem_id is what we want here.
my $problemNumber = $mergedProblem->problem_id;

my $pg = await renderPG(
$c,
$effectiveUser,
Expand All @@ -1502,17 +1457,26 @@ async sub getProblemHTML ($c, $effectiveUser, $set, $formFields, $mergedProblem)
$set->psvn,
$formFields,
{
displayMode => $c->{displayMode},
showHints => $showHints,
showSolutions => $showSolutions,
refreshMath2img => $showHints || $showSolutions,
processAnswers => 1,
QUIZ_PREFIX => 'Q' . sprintf('%04d', $problemNumber) . '_',
useMathQuill => $c->{will}{useMathQuill},
useMathView => $c->{will}{useMathView},
forceScaffoldsOpen => 1,
isInstructor => $c->authz->hasPermissions($c->{userID}, 'view_answers'),
debuggingOptions => getTranslatorDebuggingOptions($c->authz, $c->{userID})
displayMode => $c->{displayMode},
showHints => $c->{will}{showHints},
showSolutions => $c->{will}{showSolutions},
refreshMath2img => $c->{will}{showHints} || $c->{will}{showSolutions},
processAnswers => 1,
QUIZ_PREFIX => 'Q' . sprintf('%04d', $mergedProblem->problem_id) . '_',
useMathQuill => $c->{will}{useMathQuill},
useMathView => $c->{will}{useMathView},
forceScaffoldsOpen => 1,
isInstructor => $c->authz->hasPermissions($c->{userID}, 'view_answers'),
showFeedback => $c->{submitAnswers} || $c->{previewAnswers} || $c->{will}{checkAnswers},
showAttemptAnswers => $c->ce->{pg}{options}{showEvaluatedAnswers},
showAttemptPreviews => 1,
showAttemptResults => !$c->{previewAnswers} && $c->{can}{showProblemScores},
forceShowAttemptResults => $c->{will}{showProblemGrader},
showMessages => 1,
showCorrectAnswers => ($c->{submitAnswers} || $c->{will}{checkAnswers} || $c->{will}{showProblemGrader})
? $c->{will}{showCorrectAnswers}
: 0,
debuggingOptions => getTranslatorDebuggingOptions($c->authz, $c->{userID})
},
);

Expand All @@ -1523,7 +1487,7 @@ async sub getProblemHTML ($c, $effectiveUser, $set, $formFields, $mergedProblem)
if ($pg->{flags}{error_flag}) {
push @{ $c->{errors} },
{
set => "$setID,v$setVersionNumber",
set => $set->set_id . ',v' . $set->version_id,
problem => $mergedProblem->problem_id,
message => $pg->{errors},
context => $pg->{body_text},
Expand Down
Loading

0 comments on commit 46f2fcf

Please sign in to comment.