Skip to content

Commit

Permalink
Merge pull request #2254 from drgrice1/bugfix/set-def-import-correct-…
Browse files Browse the repository at this point in the history
…problem-ids

Correct the problem numbers when a set definition file is imported.
  • Loading branch information
drdrew42 authored Nov 27, 2023
2 parents 98252a5 + fa9ea06 commit 1c7df28
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/WeBWorK/File/SetDef.pm
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,13 @@ sub importSetsFromDef ($ce, $db, $setDefFiles, $existingSets = undef, $assign =

debug("$set_definition_file: adding problems to database");
# Add problems
my $freeProblemID = WeBWorK::Utils::max($db->listGlobalProblems($setData->{setID})) + 1;
my $freeProblemID = WeBWorK::Utils::max(grep {$_} map { $_->{problem_id} } @{ $setData->{problemData} }) + 1;
for my $rh_problem (@{ $setData->{problemData} }) {
addProblemToSet(
$db, $ce->{problemDefaults},
setName => $setData->{setID},
sourceFile => $rh_problem->{source_file},
problemID => $rh_problem->{problemID} ? $rh_problem->{problemID} : $freeProblemID++,
problemID => $rh_problem->{problem_id} || $freeProblemID++,
value => $rh_problem->{value},
maxAttempts => $rh_problem->{max_attempts},
showMeAnother => $rh_problem->{showMeAnother},
Expand Down

0 comments on commit 1c7df28

Please sign in to comment.