NAME

AttemptsTable

SYNPOSIS

my $tbl = WeBWorK::HTML::AttemptsTable->new(
        $answers,
        answersSubmitted       => 1,
        answerOrder            => $pg->{flags}{ANSWER_ENTRY_ORDER},
        displayMode            => 'MathJax',
        showAnswerNumbers      => 0,
        showAttemptAnswers     => $showAttemptAnswers && $showEvaluatedAnswers,
        showAttemptPreviews    => $showAttemptPreview,
        showAttemptResults     => $showAttemptResults,
        showCorrectAnswers     => $showCorrectAnswers,
        showMessages           => $showAttemptAnswers, # internally checks for messages
        showSummary            => $showSummary,
        imgGen                 => $imgGen, # not needed if ce is present ,
        ce                     => '',      # not needed if $imgGen is present
        maketext               => WeBWorK::Localize::getLoc("en"),
);
$tbl->{imgGen}->render(refresh => 1) if $tbl->displayMode eq 'images';
my $answerTemplate = $tbl->answerTemplate;

DESCRIPTION

This module handles the formatting of the table which presents the results of analyzing a student's answer to a WeBWorK problem. It is used in Problem.pm, OpaqueServer.pm, standAlonePGproblemRender

new

my $tbl = WeBWorK::HTML::AttemptsTable->new(
        $answers,
        answersSubmitted       => 1,
        answerOrder            => $pg->{flags}{ANSWER_ENTRY_ORDER},
        displayMode            => 'MathJax',
        showHeadline           => 1,
        showAnswerNumbers      => 0,
        showAttemptAnswers     => $showAttemptAnswers && $showEvaluatedAnswers,
        showAttemptPreviews    => $showAttemptPreview,
        showAttemptResults     => $showAttemptResults,
        showCorrectAnswers     => $showCorrectAnswers,
        showMessages           => $showAttemptAnswers, # internally checks for messages
        showSummary            => $showSummary,
        imgGen                 => $imgGen, # not needed if ce is present ,
        ce                     => '',      # not needed if $imgGen is present
        maketext               => WeBWorK::Localize::getLoc("en"),
        summary                =>'',
);

$answers -- a hash of student answers e.g. $pg->{answers}
answersSubmitted     if 0 then then the attemptsTable is not displayed (???)
answerOrder       -- an array indicating the order the answers appear on the page.
displayMode       'MathJax' and 'images' are the most common

showHeadline       Show the header line 'Results for this submission'

showAnswerNumbers, showAttemptAnswers, showAttemptPreviews,showAttemptResults,
showCorrectAnswers and showMessages control the display of each column in the table.

attemptAnswers     the student's typed in answer (possibly simplified numerically)
attemptPreview     the student's answer after typesetting
attemptResults     "correct", "_% correct",  "incorrect" or "ungraded"- links to the answer blank
correctAnswers     typeset version (untypeset versions are available via popups)
messages           warns of formatting typos in the answer, or
                    more detailed messages about a wrong answer
summary            is obtained from $pg->{result}{summary}.
                   If this is empty then a (localized)
                   version of "all answers are correct"
                   or "at least one answer is not coorrect"
imgGen             points to a prebuilt image generator objectfor "images" mode
ce                 points to the CourseEnvironment -- it is needed if AttemptsTable
                    is required to build its own imgGen object
maketext           points to a localization subroutine

Methods

answerTemplate

Returns HTML which formats the analysis of the student's answers to the problem.

Read/Write Properties

showMessages,

This can be switched on or off before exporting the answerTemplate, perhaps under instructions from the PG problem.

summary

The contents of the summary can be defined when the attemptsTable object is created.

The summary can be defined by the PG problem grader usually returned as $pg->{result}{summary}.

If the summary is not explicitly defined then (localized) versions of the default summaries are created:

"The answer above is correct.",
"Some answers will be graded later.",
"All of the [gradeable] answers above are correct.",
"[N] of the questions remain unanswered.",
"At least one of the answers above is NOT [fully] correct.',

Note that if this is set after initialization, you must ensure that it is a Mojo::ByteStream object if it contains html or characters that need escaping.