Skip to content

Commit 6cc3cf8

Browse files
authored
Merge pull request #2283 from drgrice1/problem-uuid-includes-source-hash
Include the problem source hash in the problemUUID passed to PG.
2 parents 2ed01cf + 2b6600a commit 6cc3cf8

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/WeBWorK/Utils/Rendering.pm

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ WeBWorK::Utils::Rendering - utilities for rendering problems.
2525
use Mojo::IOLoop;
2626
use Mojo::JSON qw(decode_json);
2727
use Data::Structure::Util qw(unbless);
28+
use Digest::MD5 qw(md5_hex);
29+
use Encode qw(encode_utf8);
2830

2931
use WeBWorK::Utils qw(formatDateTime);
3032

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

5362
$options{probNum} = $problem->problem_id;
5463
$options{questionNumber} = $options{probNum};

0 commit comments

Comments
 (0)