Commit e64fa0a4 authored by Jojo Boulix's avatar Jojo Boulix
Browse files

Keep the same codedigit convention from the layout detection to the scoring strategy extract.

This way extracting again the scoring strategy with a recent AMC won't break codes from an old
project.
parent 270021c2
Loading
Loading
Loading
Loading
+27 −11
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@ my $engine_topdf = '';
my $prefix          = '';
my $filter          = '';
my $filtered_source = '';
my $codedigit       = '';

my $debug        = '';
my $latex_stdout = '';
@@ -112,6 +113,7 @@ GetOptions(
    "n-copies=s"          => \$number_of_copies,
    "filter=s"            => \$filter,
    "filtered-source=s"   => \$filtered_source,
    "codedigit=s"         => \$codedigit,
    "epoch=s"             => \$epoch,
);

@@ -1006,21 +1008,35 @@ if ( $to_do{b} ) {

    my $delta = 0;

    # Opens a connection with the database

    my $data    = AMC::Data->new($data_dir);
    my $scoring = $data->module('scoring');
    my $capture = $data->module('capture');

    # Launches the LaTeX engine

    my @opts = (qw/ScoringExterne 1 NoHyperRef 1/);

    if ( !$codedigit ) {

        # if not explicitly given, uses the same codedigit convention
        # as recorded from the 'extract layout' phase
        my $layout = $data->module('layout');
        $codedigit = $layout->variable_transaction('build:codedigit');
        $codedigit = 'dot' if ( !$codedigit );    # old AMC versions
    }
    if ($codedigit) {
        push @opts, "codeDigitExterne", $codedigit;
    }

    execute(
        command_opts => [qw/ScoringExterne 1 NoHyperRef 1/],
        command_opts => [@opts],
        once         => 1
    );

    open( AMCLOG, "$jobname.amc" ) or die "Unable to open $jobname.amc : $!";

    # Opens a connection with the database

    my $data    = AMC::Data->new($data_dir);
    my $scoring = $data->module('scoring');
    my $capture = $data->module('capture');

    my $qs                    = {};
    my $qs0                   = {}; # memory for student 0 (when using AMCformS)
    my $current_q             = {};
@@ -1152,11 +1168,11 @@ if ( $to_do{b} ) {
                } else {

                    # associated to a question
                    $current_q->{strategy} =
                      (   $current_q->{strategy}
                    $current_q->{strategy} = (
                          $current_q->{strategy}
                        ? $current_q->{strategy} . ','
                        : '' )
                      . $1;
                        : ''
                    ) . $1;
                }
            } else {

+11 −1
Original line number Diff line number Diff line
@@ -3334,6 +3334,12 @@ Three digits and two letters:\insertgroup{mixed}.
\newcount\AMC@chiffres
\newdimen\AMCcodeHspace\AMCcodeHspace=.5em
\newdimen\AMCcodeVspace\AMCcodeVspace=.5em
\newcommand\AMCcodeID@squarebrackets[2]{#1[#2]}
\newcommand\AMCcodeID@dot[2]{#1.#2}
\newcommand\AMCcodeID@@[1]{%
  \expandafter\def\expandafter\AMCcodeID\expandafter{\csname AMCcodeID@#1\endcsname}%
}
\AMCcodeID@@{squarebrackets}
\ExplSyntaxOn

\clist_new:N \amc_code_descr_clist
@@ -3383,7 +3389,7 @@ Three digits and two letters:\insertgroup{mixed}.
  { \keys_set:nn { amccode } { #3 }
    \amc_code_init:N #2
    \clist_map_inline:Nn #2 { % iterates over 'digits'
      \begin{question}{#1[ \int_use:N \amc_code_digit_n_int ]}
      \begin{question}{\AMCcodeID{#1}{ \int_use:N \amc_code_digit_n_int }}
        \amc_code_digit_init:
        \seq_set_split:Nnn \amc_code_digits_seq {} { ##1 }
        \bool_if:NTF \amc_code_vertical_bool {
@@ -4699,6 +4705,7 @@ Three digits and two letters:\insertgroup{mixed}.
\newif\ifAMCneeds@storebox\AMCneeds@storeboxfalse
\DeclareOptionX{storebox}{\AMCneeds@storeboxtrue}
\DeclareOptionX{pdfform}{\AMC@pdfformtrue}
\DeclareOptionX{codedigit}{\AMCcodeID@@{#1}}
\ProcessOptionsX

\ifAMCneeds@storebox
@@ -4838,6 +4845,9 @@ pdflatex '\nonstopmode\def\SujetExterne{1}\def\NoWatermarkExterne{1}\input{mcq.t
\ifx\NoWatermarkExterne\undefined\else
\AMC@watermarkfalse
\fi
\ifx\codeDigitExterne\undefined\else
\AMCcodeID@@{\codeDigitExterne}
\fi
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}\end{macro}\end{macro}
%