Skip to content

Commit

Permalink
Merge pull request #2283 from drgrice1/problem-uuid-includes-source-hash
Browse files Browse the repository at this point in the history
Include the problem source hash in the problemUUID passed to PG.
  • Loading branch information
pstaabp authored Jan 24, 2024
2 parents 2ed01cf + 2b6600a commit 6cc3cf8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/WeBWorK/Utils/Rendering.pm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ WeBWorK::Utils::Rendering - utilities for rendering problems.
use Mojo::IOLoop;
use Mojo::JSON qw(decode_json);
use Data::Structure::Util qw(unbless);
use Digest::MD5 qw(md5_hex);
use Encode qw(encode_utf8);

use WeBWorK::Utils qw(formatDateTime);

Expand All @@ -48,7 +50,14 @@ sub constructPGOptions ($ce, $user, $set, $problem, $psvn, $formFields, $transla
# If a problemUUID is provided in the form fields, then that is used. Otherwise we create one that depends on
# the course, user, set, and problem. Note that it is not a true UUID, but will be converted into one by PG.
$options{problemUUID} = $formFields->{problemUUID}
|| join('-', $user->user_id, $ce->{courseName}, 'set' . $set->set_id, 'prob' . $problem->problem_id);
|| join('-',
$user->user_id,
$ce->{courseName},
'set' . $set->set_id,
'prob' . $problem->problem_id,
defined $translationOptions->{r_source} && ${ $translationOptions->{r_source} }
? 'sourcehash' . md5_hex(encode_utf8(${ $translationOptions->{r_source} }))
: ());

$options{probNum} = $problem->problem_id;
$options{questionNumber} = $options{probNum};
Expand Down

0 comments on commit 6cc3cf8

Please sign in to comment.