/gr;
+
+ my $assignmentType = $setRecord->assignment_type;
+ my $enableReducedScoring = $setRecord->enable_reduced_scoring ? 'Y' : 'N';
+ my $setHeader = $setRecord->set_header;
+ my $paperHeader = $setRecord->hardcopy_header;
+ my $emailInstructor = $setRecord->email_instructor;
+ my $restrictProbProgression = $setRecord->restrict_prob_progression;
+
+ my @problemList = $db->getGlobalProblemsWhere({ set_id => $set }, 'problem_id');
+
+ my $problemList = '';
+ for my $problemRecord (@problemList) {
+ my $problem_id = $problemRecord->problem_id();
+
+ $problem_id = join('.', jitar_id_to_seq($problem_id)) if ($setRecord->assignment_type eq 'jitar');
+
+ my $source_file = $problemRecord->source_file();
+ my $value = $problemRecord->value();
+ my $max_attempts = $problemRecord->max_attempts();
+ my $showMeAnother = $problemRecord->showMeAnother();
+ my $showHintsAfter = $problemRecord->showHintsAfter();
+ my $prPeriod = $problemRecord->prPeriod();
+ my $countsParentGrade = $problemRecord->counts_parent_grade();
+ my $attToOpenChildren = $problemRecord->att_to_open_children();
+
+ # backslash-escape commas in fields
+ $source_file =~ s/([,\\])/\\$1/g;
+ $value =~ s/([,\\])/\\$1/g;
+ $max_attempts =~ s/([,\\])/\\$1/g;
+ $showMeAnother =~ s/([,\\])/\\$1/g;
+ $showHintsAfter =~ s/([,\\])/\\$1/g;
+ $prPeriod =~ s/([,\\])/\\$1/g;
+
+ # This is the new way of saving problem information.
+ # The labelled list makes it easier to add variables and
+ # easier to tell when they are missing.
+ $problemList .= "problem_start\n";
+ $problemList .= "problem_id = $problem_id\n";
+ $problemList .= "source_file = $source_file\n";
+ $problemList .= "value = $value\n";
+ $problemList .= "max_attempts = $max_attempts\n";
+ $problemList .= "showMeAnother = $showMeAnother\n";
+ $problemList .= "showHintsAfter = $showHintsAfter\n";
+ $problemList .= "prPeriod = $prPeriod\n";
+ $problemList .= "counts_parent_grade = $countsParentGrade\n";
+ $problemList .= "att_to_open_children = $attToOpenChildren \n";
+ $problemList .= "problem_end\n";
+ }
+
+ # Gateway fields
+ my $gwFields = '';
+ if ($assignmentType =~ /gateway/) {
+ my $attemptsPerV = $setRecord->attempts_per_version;
+ my $timeInterval = $setRecord->time_interval;
+ my $vPerInterval = $setRecord->versions_per_interval;
+ my $vTimeLimit = $setRecord->version_time_limit;
+ my $probRandom = $setRecord->problem_randorder;
+ my $probPerPage = $setRecord->problems_per_page;
+ my $hideScore = $setRecord->hide_score;
+ my $hideScoreByProblem = $setRecord->hide_score_by_problem;
+ my $hideWork = $setRecord->hide_work;
+ my $timeCap = $setRecord->time_limit_cap;
+ $gwFields =
+ "attemptsPerVersion = $attemptsPerV\n"
+ . "timeInterval = $timeInterval\n"
+ . "versionsPerInterval = $vPerInterval\n"
+ . "versionTimeLimit = $vTimeLimit\n"
+ . "problemRandOrder = $probRandom\n"
+ . "problemsPerPage = $probPerPage\n"
+ . "hideScore = $hideScore\n"
+ . "hideScoreByProblem = $hideScoreByProblem\n"
+ . "hideWork = $hideWork\n"
+ . "capTimeLimit = $timeCap\n";
+ }
+
+ # IP restriction fields
+ my $restrictIP = $setRecord->restrict_ip;
+ my $restrictFields = '';
+ if ($restrictIP && $restrictIP ne 'No') {
+ # Only store the first location
+ my $restrictLoc = ($db->listGlobalSetLocations($setRecord->set_id))[0];
+ my $relaxRestrict = $setRecord->relax_restrict_ip;
+ $restrictLoc || ($restrictLoc = '');
+ $restrictFields =
+ "restrictIP = $restrictIP\n"
+ . "restrictLocation = $restrictLoc\n"
+ . "relaxRestrictIP = $relaxRestrict\n";
+ }
+
+ my $fileContents =
+ "assignmentType = $assignmentType\n"
+ . "openDate = $openDate\n"
+ . "reducedScoringDate = $reducedScoringDate\n"
+ . "dueDate = $dueDate\n"
+ . "answerDate = $answerDate\n"
+ . "enableReducedScoring = $enableReducedScoring\n"
+ . "paperHeaderFile = $paperHeader\n"
+ . "screenHeaderFile = $setHeader\n"
+ . $gwFields
+ . "description = $description\n"
+ . "restrictProbProgression = $restrictProbProgression\n"
+ . "emailInstructor = $emailInstructor\n"
+ . $restrictFields
+ . "\nproblemListV2\n"
+ . $problemList;
+
+ $filePath = WeBWorK::Utils::surePathToFile($ce->{courseDirs}->{templates}, $filePath);
+ if (open(my $setDefFH, '>', $filePath)) {
+ print $setDefFH $fileContents;
+ close $setDefFH;
+ push @exported, $set;
+ } else {
+ push @skipped, $set;
+ $reason{$set} = [ x('Failed to open [_1]'), $filePath ];
+ }
+ }
+
+ return \@exported, \@skipped, \%reason;
+}
+
+1;
diff --git a/templates/ContentGenerator/Instructor/ProblemSetList/import_form.html.ep b/templates/ContentGenerator/Instructor/ProblemSetList/import_form.html.ep
index c0a6ec31fb..a0d4408362 100644
--- a/templates/ContentGenerator/Instructor/ProblemSetList/import_form.html.ep
+++ b/templates/ContentGenerator/Instructor/ProblemSetList/import_form.html.ep
@@ -64,7 +64,7 @@
<%= select_field 'action.import.assign' => [
[ maketext('all current users') => 'all' ],
- [ maketext('only') . ' ' . param('user') => 'user', selected => undef ]
+ [ maketext('only') . ' ' . param('user') => param('user'), selected => undef ]
],
id => 'import_users_select', class => 'form-select form-select-sm' =%>