Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions conf/defaults.config
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ $authen{admin_module} = ['WeBWorK::Authen::Basic_TheLastOption'];
can_check_and_submit_answers => "ta",
can_use_show_me_another_early => "ta",
create_new_set_version_when_acting_as_student => undef,
print_path_to_problem => "professor", # see "Special" PG environment variables
print_path_to_problem => "professor",
always_show_hint => "professor",
always_show_solution => "professor",
record_set_version_answers_when_acting_as_student => undef,
Expand Down Expand Up @@ -1175,13 +1175,6 @@ $pg{URLs}{localHelpURL} = "$pg_htdocs_url/helpFiles";

##### "Special" PG environment variables. (Stuff that doesn't fit in anywhere else.)

# Users for whom to print the file name of the PG file being processed.
$pg{specialPGEnvironmentVars}{PRINT_FILE_NAMES_FOR} = [ "professor", ];

# File names are also printed for anyone with this permission or higher
$pg{specialPGEnvironmentVars}{PRINT_FILE_NAMES_PERMISSION_LEVEL} =
$userRoles{ $permissionLevels{print_path_to_problem} };

# whether to use javascript for rendering Live3D graphs
$pg{specialPGEnvironmentVars}{use_javascript_for_live3d} = 1;

Expand Down
6 changes: 0 additions & 6 deletions courses.dist/modelCourse/course.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@

# This file is used to override the global WeBWorK course environment for this course.

# Users for whom to label problems with the PG file name (global value typically "professor")
# For users in this list, PG will display the source file name when rendering a problem.
# defaults.config values:
# $pg{specialPGEnvironmentVars}{PRINT_FILE_NAMES_FOR} = ['professor'];
$pg{specialPGEnvironmentVars}{PRINT_FILE_NAMES_FOR} = ['admin'];

# The following hashes control which users are allowed to see students from which
# sections. This is typically used for large multi-section classes with many students, ta's and
# professors. When set users will only be allowed to see students from the appropriate section in the following:
Expand Down
15 changes: 1 addition & 14 deletions lib/WeBWorK/ContentGenerator/CourseAdmin.pm
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,6 @@ sub do_add_course ($c) {

my $ce2 = WeBWorK::CourseEnvironment->new({ courseName => $add_courseID });

my %courseOptions;

my @users;

# copy users from current (admin) course if desired
Expand Down Expand Up @@ -376,9 +374,6 @@ sub do_add_course ($c) {
}
}

push @{ $courseOptions{PRINT_FILE_NAMES_FOR} },
map { $_->[0]->user_id } grep { $_->[2]->permission >= $ce->{userRoles}{professor} } @users;

# Include any optional arguments, including a template course and the course title and course institution.
my %optional_arguments;
if ($copy_from_course ne '') {
Expand All @@ -395,15 +390,7 @@ sub do_add_course ($c) {

my $output = $c->c;

eval {
addCourse(
courseID => $add_courseID,
ce => $ce2,
courseOptions => \%courseOptions,
users => \@users,
%optional_arguments,
);
};
eval { addCourse(courseID => $add_courseID, ce => $ce2, users => \@users, %optional_arguments,); };
if ($@) {
my $error = $@;
push(
Expand Down
5 changes: 1 addition & 4 deletions lib/WeBWorK/ContentGenerator/Hardcopy.pm
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,7 @@ async sub pre_header_initialize ($c) {
die 'Parameter "user" not defined -- this should never happen' unless defined $userID;

# Check to see if the user is authorized to view source file paths.
$c->{can_show_source_file} =
($db->getPermissionLevel($userID)->permission >=
$ce->{pg}{specialPGEnvironmentVars}{PRINT_FILE_NAMES_PERMISSION_LEVEL})
|| (grep { $_ eq $userID } @{ $ce->{pg}{specialPGEnvironmentVars}{PRINT_FILE_NAMES_FOR} });
$c->{can_show_source_file} = $authz->hasPermissions($userID, 'print_path_to_problem');

if ($generate_hardcopy) {
my $validation_failed = 0;
Expand Down
5 changes: 1 addition & 4 deletions lib/WeBWorK/ContentGenerator/Problem.pm
Original file line number Diff line number Diff line change
Expand Up @@ -906,10 +906,7 @@ sub page_title ($c) {

# This uses the permission level and user id of the user assigned to the problem.
my $problemUser = $problem->user_id;
my $inList = grep { $_ eq $problemUser } @{ $ce->{pg}{specialPGEnvironmentVars}{PRINT_FILE_NAMES_FOR} };
if ($db->getPermissionLevel($problemUser)->permission >=
$ce->{pg}{specialPGEnvironmentVars}{PRINT_FILE_NAMES_PERMISSION_LEVEL} || $inList)
{
if ($c->authz->hasPermissions($problemUser, 'print_path_to_problem')) {
$subheader .= ' ' . $problem->source_file;
}

Expand Down
5 changes: 1 addition & 4 deletions lib/WeBWorK/ContentGenerator/ShowMeAnother.pm
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,7 @@ sub page_title ($c) {

# This uses the permission level and user id of the user assigned to the problem.
my $problemUser = $problem->user_id;
if ($c->db->getPermissionLevel($problemUser)->permission >=
$ce->{pg}{specialPGEnvironmentVars}{PRINT_FILE_NAMES_PERMISSION_LEVEL}
|| grep { $_ eq $problemUser } @{ $ce->{pg}{specialPGEnvironmentVars}{PRINT_FILE_NAMES_FOR} })
{
if ($c->authz->hasPermissions($problemUser, 'print_path_to_problem')) {
$subheader .= ' ' . $problem->source_file;
}

Expand Down
53 changes: 12 additions & 41 deletions lib/WeBWorK/Utils/CourseManagement.pm
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,9 @@ sub listArchivedCourses {

%options must contain:

courseID => course ID for the new course,
ce => a course environment for the new course,
courseOptions => hash ref explained below
users => array ref explained below
courseID => course ID for the new course,
ce => a course environment for the new course,
users => array ref explained below

%options may contain:

Expand All @@ -150,12 +149,6 @@ Create a new course with ID $courseID.
$ce is a WeBWorK::CourseEnvironment object that describes the new course's
environment.

$courseOptions is a reference to a hash containing the following options:

PRINT_FILE_NAMES_FOR => $pg{specialPGEnvironmentVars}{PRINT_FILE_NAMES_FOR}

C<PRINT_FILE_NAMES_FOR> is a reference to an array.

$users is a list of arrayrefs, each containing a User, Password, and
PermissionLevel record for a single user:

Expand Down Expand Up @@ -187,11 +180,10 @@ sub addCourse {
debug("$key : $value");
}

my $courseID = $options{courseID};
my $sourceCourse = $options{copyFrom} // '';
my $ce = $options{ce};
my %courseOptions = %{ $options{courseOptions} // {} };
my @users = exists $options{users} ? @{ $options{users} } : ();
my $courseID = $options{courseID};
my $sourceCourse = $options{copyFrom} // '';
my $ce = $options{ce};
my @users = exists $options{users} ? @{ $options{users} } : ();

debug \@users;

Expand Down Expand Up @@ -432,7 +424,7 @@ sub addCourse {
my $courseEnvFile = $ce->{courseFiles}{environment};
open my $fh, ">:utf8", $courseEnvFile
or die "failed to open $courseEnvFile for writing.\n";
writeCourseConf($fh, $ce, %courseOptions);
writeCourseConf($fh);
close $fh;
}

Expand Down Expand Up @@ -1180,45 +1172,24 @@ sub protectQString {
return $string;
}

=item writeCourseConf($fh, $ce, %options)
=item writeCourseConf($fh)

Writes a course.conf file to $fh, a file handle, using defaults from the course
environment object $ce and overrides from %options. %options can contain any of
the pairs accepted in %courseOptions by addCourse(), above.
Writes an essentially empty course.conf file to $fh, a file handle. System
administrators can use this file to override global settings for a course.

=back

=cut

sub writeCourseConf {
my ($fh, $ce, %options) = @_;
my ($fh) = @_;

print $fh <<'EOF';
#!perl

# This file is used to override the global WeBWorK course environment for this course.

EOF

print $fh <<'EOF';
# Users for whom to label problems with the PG file name (global value typically "professor")
# For users in this list, PG will display the source file name when rendering a problem.
# defaults.config values:
EOF

if (defined $ce->{pg}{specialPGEnvironmentVars}{PRINT_FILE_NAMES_FOR}) {
print $fh "# \t", '$pg{specialPGEnvironmentVars}{PRINT_FILE_NAMES_FOR} = [',
join(", ",
map { "'" . protectQString($_) . "'" } @{ $ce->{pg}{specialPGEnvironmentVars}{PRINT_FILE_NAMES_FOR} }),
'];', "\n";
} else {
print $fh "# \t", '$pg{specialPGEnvironmentVars}{PRINT_FILE_NAMES_FOR} = [ ];', "\n";
}

if (defined $options{PRINT_FILE_NAMES_FOR}) {
print $fh '$pg{specialPGEnvironmentVars}{PRINT_FILE_NAMES_FOR} = [',
join(", ", map { "'" . protectQString($_) . "'" } @{ $options{PRINT_FILE_NAMES_FOR} }), '];', "\n";
}
}

sub get_SeedCE
Expand Down
9 changes: 1 addition & 8 deletions templates/ContentGenerator/GatewayQuiz.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -574,14 +574,7 @@
% }
%
% # This uses the permission level and user id of the user assigned to the set.
% if (
% $db->getPermissionLevel($effectiveUserID)->permission >=
% $ce->{pg}{specialPGEnvironmentVars}{PRINT_FILE_NAMES_PERMISSION_LEVEL}
% || (
% grep { $_ eq $effectiveUserID }
% @{ $ce->{pg}{specialPGEnvironmentVars}{PRINT_FILE_NAMES_FOR} }
% )
% )
% if ( $authz->hasPermissions($effectiveUserID, 'print_path_to_problem') )
% {
<%= $problems->[ $probOrder->[$i] ]->source_file %>
% }
Expand Down
Loading