-Set Defaults for All Resources in $foldermap
-$showtitle
-Specifically for
-ENDMAPONE
+ my $tmp="";
if ($uname) {
my $person=&Apache::loncommon::plainname($uname,$udom);
- $r->print(&mt("User")." $uname \($person\) ".
- &mt('in')." \n");
+ $tmp.=&mt("User")." $uname \($person\) ".
+ &mt('in')." \n";
} else {
- $r->print("".&mt('all').' '.&mt('users in')." \n");
+ $tmp.="".&mt('all').' '.&mt('users in')." \n";
}
if ($cgroup) {
- $r->print(&mt("Group")." $cgroup".
- " ".&mt('of')." \n");
+ $tmp.=&mt("Group")." $cgroup".
+ " ".&mt('of')." \n";
$csec = '';
} elsif ($csec) {
- $r->print(&mt("Section")." $csec".
- " ".&mt('of')." \n");
+ $tmp.=&mt("Section")." $csec".
+ " ".&mt('of')." \n";
}
- $r->print("$coursename
");
- $r->print("
\n");
+ $r->print(''
+ .&mt('Set Defaults for All Resources in [_1]Specifically for [_2][_3]'
+ ,$foldermap.'
'.$showtitle.'
'
+ ,$tmp
+ ,''.$coursename.''
+ )
+ ."
\n"
+ );
#---------------------------------------------------------------- print table
$r->print('
');
$r->print(''.&mt('Parameter Name').' | ');
@@ -1876,7 +1917,7 @@ ENDMAPONE
\%type,\%display,$defbgone,$defbgtwo,$defbgthree,
$parmlev,$uname,$udom,$csec,$cgroup);
}
- $r->print("
---|
");
+ $r->print("
");
} # end each map
} # end of $parmlev eq map
#--------------------------------- Entry for parm level general (Course level)
@@ -1986,6 +2027,8 @@ sub crsenv {
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my (%crsinfo,$chome);
+
#
# Go through list of changes
foreach (keys %env) {
@@ -2033,6 +2076,29 @@ sub crsenv {
if ($name =~ /^default_enrollment_(start|end)_date$/) {
$value=&Apache::lonhtmlcommon::get_date_from_form($name.'_value');
}
+ #
+ # Deal with the emails
+ if ($name =~ /\.email$/) {
+ foreach my $specifier (split(',',$value)) {
+ my ($user,$sections_or_groups)=
+ ($specifier=~/^([^\(]+)\(([^\)]+)\)/);
+ if (!$sections_or_groups) {
+ $user = $specifier;
+ }
+ my ($name,$domain) = split(':',$user);
+ if (!defined($user) || !defined($domain)) {
+ $setoutput.= '
'.
+ &mt("Invalid email address specified, address must be of the form username:domain what was specified was ([_1])",$user).
+ '';
+ undef($value);
+ } elsif (&Apache::lonnet::homeserver($user,$domain) eq 'no_host') {
+ $setoutput.= '
'.
+ &mt("Invalid email address specified, user [_1] is unknown.",$name).
+ '';
+ undef($value);
+ }
+ }
+ }
# Get existing cloners
my @oldcloner = ();
if ($name eq 'cloners') {
@@ -2046,40 +2112,89 @@ sub crsenv {
#
# Let the user know we made the changes
if ($name && defined($value)) {
- my $failed_cloners;
+ my %failed_cloners;
if ($name eq 'cloners') {
$value =~ s/\s//g;
$value =~ s/^,//;
$value =~ s/,$//;
# check requested clones are valid users.
- $failed_cloners = &check_cloners(\$value,\@oldcloner);
+ %failed_cloners = &check_cloners(\$value,\@oldcloner);
}
my $put_result = &Apache::lonnet::put('environment',
{$name=>$value},$dom,$crs);
if ($put_result eq 'ok') {
- $setoutput.=&mt('Set').' '.$name.' '.&mt('to').' '.$value.'.
';
+ $setoutput.=&mt('Set').' '.$name.' '.&mt('to').' ';
+ if ($name =~ /^default_enrollment_(start|end)_date$/) {
+ $setoutput .= &Apache::lonlocal::locallocaltime($value);
+ } elsif ($name eq 'categories') {
+ $setoutput .= $env{'form.categories_display'};
+ } else {
+ $setoutput .= $value;
+ }
+ $setoutput .= '.
';
if ($name eq 'cloners') {
&change_clone($value,\@oldcloner);
}
- # Flush the course logs so course description is immediately updated
+ # Update environment and nohist_courseids.db
+ if (($name eq 'description') || ($name eq 'cloners') ||
+ ($name eq 'hidefromcat') || ($name eq 'categories')) {
+ if ($chome eq '') {
+ %crsinfo =
+ &Apache::lonnet::courseiddump($dom,'.',1,'.','.',
+ $crs,undef,undef,'.');
+ $chome = &Apache::lonnet::homeserver($crs,$dom);
+ }
+ }
if ($name eq 'description' && defined($value)) {
- &Apache::lonnet::flushcourselogs();
+ &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.description' => $value});
+ if (ref($crsinfo{$env{'request.course.id'}}) eq 'HASH') {
+ $crsinfo{$env{'request.course.id'}}{'description'} = $value;
+ my $putresult =
+ &Apache::lonnet::courseidput($dom,\%crsinfo,
+ $chome,'notime');
+ }
+ }
+ if (($name eq 'cloners') || ($name eq 'hidefromcat') || ($name eq 'categories')) {
+ if (ref($crsinfo{$env{'request.course.id'}}) eq 'HASH') {
+ &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.'.$name => $value});
+ $crsinfo{$env{'request.course.id'}}{$name} = $value;
+ my $putresult =
+ &Apache::lonnet::courseidput($dom,\%crsinfo,
+ $chome,'notime');
+ }
}
} else {
$setoutput.=&mt('Unable to set').' '.$name.' '.&mt('to').
' '.$value.' '.&mt('due to').' '.$put_result.'.
';
}
- if (($name eq 'cloners') && ($failed_cloners)) {
- $setoutput.= &mt('Unable to include').' - '.$failed_cloners.', '.
- &mt('reason').' - '.&mt('LON-CAPA user(s) do(es) not exist').
- '.
'.&mt('Please ').
- ' '.
- &mt('add the user(s)').', '.
- &mt('and then return to the ').
- ''.
- &mt('Course Parameters page').' '.
- &mt('to add the new user(s) to the list of possible cloners').
- '.
';
+ if (($name eq 'cloners') && (keys(%failed_cloners) > 0)) {
+ $setoutput.= &mt('Unable to include').': ';
+ my @fails;
+ my $num = 0;
+ if (defined($failed_cloners{'format'})) {
+ $fails[$num] .= ''.$failed_cloners{'format'}.
+ ', '.&mt('reason').' - '.
+ &mt('Invalid format');
+ $num ++;
+ }
+ if (defined($failed_cloners{'domain'})) {
+ $fails[$num] .= ''.$failed_cloners{'domain'}.
+ ', '.&mt('reason').' - '.
+ &mt('Domain does not exist');
+ $num ++;
+ }
+ if (defined($failed_cloners{'newuser'})) {
+ $fails[$num] .= ''.$failed_cloners{'newuser'}. ', '.&mt('reason').' - '.
+ &mt('LON-CAPA user(s) do(es) not exist.').
+ '.
'.&mt('Please ').
+ ' '.
+ &mt('add the user(s)').', '.
+ &mt('and then return to the ').
+ ''.
+ &mt('Course Parameters page').' '.
+ &mt('to add the new user(s) to the list of possible cloners');
+ }
+ $setoutput .= join('; ',@fails).'.
';
}
}
}
@@ -2098,65 +2213,75 @@ sub crsenv {
my $SelectStyleFile=&mt('Select Style File');
my $SelectSpreadsheetFile=&mt('Select Spreadsheet File');
my $output='';
+ my $can_categorize;
if (! exists($values{'con_lost'})) {
my %descriptions=
- ('url' => ''.&mt('Top Level Map').' '.
+ ('url' => ''.&mt('Top Level Map').'
'.
'".
&mt('Select Map').'
'.
- &mt('Modification may make assessment data inaccessible').
+ &mt('Modification may make assessment data inaccessible!').
'',
'description' => ''.&mt('Course Description').'',
'courseid' => ''.&mt('Course ID or number').
'
'.
- '('.&mt('internal').', '.&mt('optional').')',
- 'cloners' => ''.&mt('Users allowed to clone course').'
(user:domain,user:domain)
'.&mt('Users with active Course Coordinator role in the course automatically have the right to clone it, and can be omitted from list.'),
+ '('.&mt('internal, optional').')',
+ 'cloners' => ''.&mt('Users allowed to clone course').'
'
+ .'("'.&mt('user:domain,user:domain,*:domain').'")
'
+ .&mt('Users with active Course Coordinator role in this course are permitted to clone and need not be included.').'
'
+ .&mt('Use [_1] to allow course to be cloned by anyone in the specified domain.','"*:domain"').'
'
+ .&mt('Use [_1] to allow unrestricted cloning in all domains.','"*"'),
'grading' => ''.&mt('Grading').'
'.
- '"standard", "external", or "spreadsheet" '.&Apache::loncommon::help_open_topic('GradingOptions'),
- 'default_xml_style' => ''.&mt('Default XML Style File').' '.
+ &mt('[_1], [_2], or [_3]','"standard"','"external"','"spreadsheet"').&Apache::loncommon::help_open_topic('GradingOptions'),
+ 'task_grading' => ''.&mt('Bridge Task Grading').'
'
+ .&mt('Instructors and TAs in sections, when grading bridge tasks, should be allowed to grade other sections.').'
'
+ .'('.&mt('[_1]: they are allowed (this is the default). [_2]: no, they can only grade their own section.','"any"','"section"').')',
+ 'default_xml_style' => ''.&mt('Default XML Style File').'
'.
'$SelectStyleFile
",
- 'question.email' => ''.&mt('Feedback Addresses for Resource Content Question').
- '
(user:domain,'.
- 'user:domain(section;section;...;*;...),...)',
- 'comment.email' => ''.&mt('Feedback Addresses for Course Content Comments').'
'.
- '(user:domain,user:domain(section;section;...;*;...),...)',
- 'policy.email' => ''.&mt('Feedback Addresses for Course Policy').''.
- '
(user:domain,user:domain(section;section;...;*;...),...)',
- 'hideemptyrows' => ''.&mt('Hide Empty Rows in Spreadsheets').'
'.
- '('.&mt('"[_1]" for default hiding','yes').')',
- 'pageseparators' => ''.&mt('Visibly Separate Items on Pages').'
'.
- '('.&mt('"[_1]" for visible separation','yes').', '.
- &mt('changes will not show until next login').')',
- 'student_classlist_view' => ''.&mt('Allow students to view classlist.').''.&mt('("all":students can view all sections,"section":students can only view their own section.blank or "disabled" prevents student view.'),
-
- 'plc.roles.denied'=> ''.&mt('Disallow live chatroom use for Roles').
- '
"st": '.
- &mt('student').', "ta": '.
- 'TA, "in": '.
- &mt('instructor').';
'.&mt('role,role,...').') '.
- Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
+ 'question.email' => ''.&mt('Feedback Addresses for Resource Content Question').'
'
+ .'("'.&mt('user:domain,user:domain(section;section;...;*;...),...').'")',
+ 'question.email.text' => ''.&mt('Custom Text for Resource Content Question Option in Feedback').'',
+ 'comment.email' => ''.&mt('Feedback Addresses for Course Content Comments').'
'
+ .'("'.&mt('user:domain,user:domain(section;section;...;*;...),...').'")',
+ 'comment.email.text' => ''.&mt('Custom Text for Course Content Option in Feedback').'',
+ 'policy.email' => ''.&mt('Feedback Addresses for Course Policy').'
'
+ .'("'.&mt('user:domain,user:domain(section;section;...;*;...),...').'")',
+ 'policy.email.text' => ''.&mt('Custom Text for Course Policy Option in Feedback').'',
+ 'hideemptyrows' => ''.&mt('Hide Empty Rows in Spreadsheets').'
'
+ .'('.&mt('[_1] for default hiding','"yes"').')',
+ 'pageseparators' => ''.&mt('Visibly Separate Items on Pages').'
'
+ .'('.&mt('[_1] for visible separation.','"yes"').' '
+ .&mt('Changes will not show until next login.').')',
+ 'student_classlist_view' => ''.&mt('Allow students to view classlist.').'
'
+ .'('.&mt('[_1]: students can view all sections. [_2]: students can only view their own section. blank or [_3] prevents student view.','"all"','"section"','"disabled"').')',
+ 'student_classlist_portfiles' => ''.&mt('Include link to accessible portfolio files').'
'
+ .'('.&mt('[_1] for link to each a listing of each student\'s files.','"yes"').')',
+ 'student_classlist_opt_in' => ''.&mt("Student's agreement needed for listing in student-viewable roster").'
'
+ .'('.&mt('[_1] to require students to opt-in to listing in the roster (on the roster page).','"yes"').')',
+ 'plc.roles.denied'=> ''.&mt('Disallow live chatroom use for Roles').'
'
+ .'('.&mt('[_1]: student, [_2]: TA, [_3]: instructor','"st"','"ta"','"in"').')
'
+ .'("'.&mt('role,role,...').'") '
+ .Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
'plc.users.denied' =>
''.&mt('Disallow live chatroom use for Users').'
'.
- '(user:domain,user:domain,...)',
+ '("'.&mt('user:domain,user:domain,...').'")',
- 'pch.roles.denied'=> ''.&mt('Disallow Resource Discussion for Roles').
- '
"st": '.
- 'student, "ta": '.
- 'TA, "in": '.
- 'instructor;
role,role,...) '.
- Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
+ 'pch.roles.denied'=> ''.&mt('Disallow Resource Discussion for Roles').'
'
+ .'('.&mt('[_1]: student, [_2]: TA, [_3]: instructor','"st"','"ta"','"in"')
+ .'("'.&mt('role,role,...').'") '
+ .Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
'pch.users.denied' =>
''.&mt('Disallow Resource Discussion for Users').'
'.
- '(user:domain,user:domain,...)',
+ '("'.&mt('user:domain,user:domain,...').'")',
'spreadsheet_default_classcalc'
=> ''.&mt('Default Course Spreadsheet').' '.
'$SelectSpreadsheetFile
",
'spreadsheet_default_studentcalc'
- => ''.&mt('Default Student Spreadsheet').' '.
+ => ''.&mt('Default Student Spreadsheet').'
'.
'$SelectSpreadsheetFile
",
@@ -2167,46 +2292,45 @@ sub crsenv {
",'spreadsheet')\">$SelectSpreadsheetFile
",
'allow_limited_html_in_feedback'
=> ''.&mt('Allow limited HTML in discussion posts').'
'.
- '('.&mt('Set value to "[_1]" to allow',"yes").')',
+ '('.&mt('Set value to [_1] to allow.','"yes"').')',
'allow_discussion_post_editing'
- => ''.&mt('Allow users with specified roles to edit/delete their own discussion posts').'
"st": '.
- &mt('student').', "ta": '.
- 'TA, "in": '.
- &mt('instructor').'; ('.&mt('role:section,role:section,..., e.g., st:001,st:002,in,cc would permit students in sections 001 and 002 and instructors in any section, and course coordinators to edit their own posts.').')
'.
- '('.&mt('or set value to "[_1]" to allow all roles',"yes").')',
+ => ''.&mt('Allow users with specified roles to edit/delete their own discussion posts').'
'
+ .'('.&mt('[_1]: student, [_2]: TA, [_3]: instructor','"st"','"ta"','"in"').')
'
+ .'('.&mt('Set value to [_1] to allow all roles.','"yes"').')'
+ .'("'.&mt('role:section,role:section,...').'")
'
+ .'('.&mt('Example: "st:001,st:002,in,cc" would permit students in sections 001 and 002 and instructors in any section, and course coordinators to edit their own posts.').')',
'rndseed'
- => ''.&mt('Randomization algorithm used').'
'.
- ''.&mt('Modifying this will make problems').' '.
- &mt('have different numbers and answers').'',
+ => ''.&mt('Randomization algorithm used').'
'
+ .''
+ .&mt('Modifying this will make problems have different numbers and answers!')
+ .'',
'receiptalg'
=> ''.&mt('Receipt algorithm used').'
'.
&mt('This controls how receipt numbers are generated.'),
'suppress_tries'
=> ''.&mt('Suppress number of tries in printing').'
'.
- ' ('.&mt('"[_1]" to suppress, anything else to not suppress','yes').')',
+ ' ('.&mt('[_1] to suppress, anything else to not suppress','"yes"').')',
'problem_stream_switch'
=> ''.&mt('Allow problems to be split over pages').'
'.
- ' ('.&mt('"[_1]" if allowed, anything else if not','yes').')',
+ ' ('.&mt('[_1] if allowed, anything else if not','"yes"').')',
'default_paper_size'
=> ''.&mt('Default paper type').'
'.
' ('.&mt('supported types').': Letter [8 1/2x11 in], Legal [8 1/2x14 in],'.
' Tabloid [11x17 in], Executive [7 1/2x10 in], A2 [420x594 mm],'.
' A3 [297x420 mm], A4 [210x297 mm], A5 [148x210 mm], A6 [105x148 mm])',
'print_header_format'
- => 'Print header format; substitutions: %n student name %c course id %a assignment note, numbers after the % limit the field size',
- 'anonymous_quiz'
- => ''.&mt('Anonymous quiz/exam').'
'.
- ' ('.&mt('yes').' '.&mt('to avoid print students names').' )',
+ => ' '.&mt('Print header format').'
'
+ .&mt('Substitutions:
[_1]: student name, [_2]: course id, [_3]: assignment note. Numbers after the % limit the field size.','"%n"','"%c"','"%a"'),
'default_enrollment_start_date' => ''.&mt('Default beginning date for student access.').'',
'default_enrollment_end_date' => ''.&mt('Default ending date for student access.').'',
- 'nothideprivileged' => ''.&mt('Privileged users that should not be hidden on staff listings').''.
- '
(user:domain,user:domain,...)',
+ 'nothideprivileged' => ''.&mt('Privileged users that should not be hidden on staff listings').'
'
+ .'("'.&mt('user:domain,user:domain,*:domain').'")',
'languages' => ''.&mt('Languages used').'',
'disable_receipt_display'
=> ''.&mt('Disable display of problem receipts').'
'.
' ('.&mt('"[_1]" to disable, anything else if not','yes').')',
'task_messages'
- => ''.&mt('Send message to student when clicking Done on Tasks. [_1] to send a message only to student, [_2] to send message to student and add record to user information page for instructors. Leave blank to disable.','only_student','student_and_user_notes_screen').'',
+ => ''.&mt('Send message to student when clicking Done on Tasks').'
('.&mt('[_1] to send a message only to student, [_2] to send message to student and add record to user information page for instructors. Leave blank to disable.','"only_student"','"student_and_user_notes_screen"').')',
'disablesigfigs'
=> ''.&mt('Disable checking of Significant Figures').'
'.
' ('.&mt('"[_1]" to disable, anything else if not','yes').')',
@@ -2216,23 +2340,52 @@ sub crsenv {
'externalsyllabus'
=> ''.&mt('URL of Syllabus (not using internal handler)').'',
'tthoptions'
- => ''.&mt('Default set of options to pass to tth/m when converting tex').''
- );
- my @Display_Order = ('url','description','courseid','cloners','grading',
+ => ''.&mt('Default set of options to pass to tth/m when converting tex').'',
+
+ 'texengine'
+ => ''.&mt('Force all students in the course to use a specific math rendering engine.').'
'
+ .'('.&mt('[_1], [_2] (Convert to Images), [_3] (TeX to HTML), or blank for student\'s preference','"jsMath"','"mimetex"','"tth"').')',
+ 'timezone'
+ => ''.&mt('Timezone in which the course takes place').'',
+
+ 'suppress_embed_prompt'
+ => ''.&mt('Suppress prompt to upload items referenced in a web page being uploaded to portfolio, when current role is student.').'
'.
+ ' ('.&mt('[_1] to suppress, anything else to not suppress','"yes"').')',
+ 'hidefromcat'
+ => ''.&mt('Exclude from course catalog').'
'.
+ ' ('.&mt('[_1] to exclude, anything else to include - included if assigned an institutional code, or manually catagorized','"yes"').')',
+ 'categories'
+ => ''.&mt('Categorize course').' '.
+ &mt('Display Categories').'',
+ );
+ my @Display_Order = ('url','description','courseid','cloners');
+ (my $can_toggle_cat,$can_categorize) = &can_modify_catsettings($dom);
+ if ($can_toggle_cat) {
+ push(@Display_Order,'hidefromcat');
+ }
+ if ($can_categorize) {
+ push(@Display_Order,'categories');
+ }
+ push (@Display_Order,('grading',
'externalsyllabus',
'default_xml_style','pageseparators',
- 'question.email','comment.email','policy.email',
+ 'question.email','question.email.text','comment.email',
+ 'comment.email.text','policy.email','policy.email.text',
'student_classlist_view',
+ 'student_classlist_opt_in',
+ 'student_classlist_portfiles',
'plc.roles.denied','plc.users.denied',
'pch.roles.denied','pch.users.denied',
'allow_limited_html_in_feedback',
'allow_discussion_post_editing',
'languages',
+ 'timezone',
'nothideprivileged',
'rndseed',
'receiptalg',
'problem_stream_switch',
'suppress_tries',
+ 'suppress_embed_prompt',
'default_paper_size',
'print_header_format',
'disable_receipt_display',
@@ -2243,12 +2396,14 @@ sub crsenv {
'default_enrollment_start_date',
'default_enrollment_end_date',
'tthoptions',
+ 'texengine',
'disablesigfigs',
'disableexampointprint',
- 'task_messages'
- );
+ 'task_messages','task_grading'));
foreach my $parameter (sort(keys(%values))) {
- unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./)) {
+ unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./) ||
+ ($parameter =~ m/^selfenroll_/) || ($parameter =~ /_selfenroll$/)
+ || ($parameter eq 'type')) {
if (! $descriptions{$parameter}) {
$descriptions{$parameter}=$parameter;
push(@Display_Order,$parameter);
@@ -2271,6 +2426,28 @@ sub crsenv {
$values{$parameter},
$onchange).
'';
+ } elsif ($parameter eq 'timezone') {
+ my $includeempty = 1;
+ my $timezone = &Apache::lonlocal::gettimezone();
+ $output .= ''.
+ &Apache::loncommon::select_timezone($parameter.'_value',
+ $timezone,
+ $onchange,$includeempty).' | ';
+ } elsif ($parameter eq 'categories') {
+ my $catdisplay;
+ if ($values{'categories'} ne '') {
+ my @curritems = split(/\&/,$values{'categories'});
+ foreach my $item (@curritems) {
+ my ($name,$parent,$pos) = split(/:/,$item);
+ $catdisplay .= &unescape($name).'&';
+ }
+ $catdisplay =~ s/\&$//;
+ }
+ $output .= ''.
+ ''.
+ ' | ';
} else {
$output .= ''.
&Apache::lonhtmlcommon::textbox($parameter.'_value',
@@ -2297,21 +2474,33 @@ sub crsenv {
my %lt=&Apache::lonlocal::texthash(
'par' => 'Parameter',
'val' => 'Value',
- 'set' => 'Set',
- 'sce' => 'Set Course Environment'
+ 'set' => 'Set?',
+ 'sav' => 'Save'
);
my $Parameter=&mt('Parameter');
my $Value=&mt('Value');
my $Set=&mt('Set');
- my $browse_js=
- '';
-
+ my ($jscript,$categorize_js);
+ my $browse_js = &Apache::loncommon::browser_and_searcher_javascript('parmset');
+ if ($can_categorize) {
+ $categorize_js = <'."\n".
+ $browse_js."\n".$categorize_js."\n".'';
my $start_page =
&Apache::loncommon::start_page('Set Course Environment',
- $browse_js);
+ $jscript);
my $end_page =
&Apache::loncommon::end_page();
my $end_table=&Apache::loncommon::end_data_table();
@@ -2320,17 +2509,110 @@ $start_page
$breadcrumbs
$end_page
ENDENV
}
+
+sub can_modify_catsettings {
+ my ($dom) = @_;
+ my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
+ my ($can_toggle_cat,$can_categorize);
+ if (ref($domconf{'coursecategories'}) eq 'HASH') {
+ if ($domconf{'coursecategories'}{'togglecats'} eq 'crs') {
+ $can_toggle_cat = 1;
+ }
+ if ($domconf{'coursecategories'}{'categorize'} eq 'crs') {
+ $can_categorize = 1;
+ }
+ }
+ return ($can_toggle_cat,$can_categorize);
+}
+
+sub assign_course_categories {
+ my ($r) = @_;
+ my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my $hascats = 0;
+ my $cathash;
+ my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
+ if (ref($domconf{'coursecategories'}) eq 'HASH') {
+ $cathash = $domconf{'coursecategories'}{'cats'};
+ if (ref($cathash) eq 'HASH') {
+ $hascats = 1;
+ }
+ }
+ my $catwin_js;
+ if ($hascats) {
+ my $alert = &mt('Use \"Save\" in the main window to save course categories');
+ $catwin_js = <
+
+function updateCategories() {
+ var newcategories = '';
+ var unescapedcats = '';
+ if (document.chgcats.usecategory.length) {
+ for (var i=0; i 0) {
+ newcategories = newcategories.slice(0,-1);
+ }
+ if (unescapedcats.length > 0) {
+ usescapedcats = unescapedcats.slice(0,-3);
+ }
+ } else {
+ if (document.chgcats.usecategory.checked == true) {
+ newcategories = document.chgcats.usecategory.value;
+ unescapedcats = document.chgcats.catname.value;
+ }
+ }
+ opener.document.envform.categories_value.value = newcategories;
+ opener.document.envform.categories_display.value = unescapedcats;
+ opener.document.envform.categories_setparmval.checked = true;
+ alert("$alert");
+ self.close();
+ return;
+}
+
+
+ENDSCRIPT
+ } else {
+ my $onload;
+ }
+ my $start_page =
+ &Apache::loncommon::start_page('Course Categories',$catwin_js,
+ {'only_body' => 1,});
+ my $end_page = &Apache::loncommon::end_page();
+ my $categoriesform = ''.&mt('Categorize Course').'';
+ if ($hascats) {
+ my %currsettings =
+ &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
+ $categoriesform .= &mt('Assign one or more categories to this course.').'
'.
+ ' ';
+ } else {
+ $categoriesform .= &mt('No categories defined for this domain');
+ }
+ $r->print($start_page.$categoriesform.$end_page);
+ return;
+}
+
##################################################
# Overview mode
##################################################
@@ -2363,8 +2645,7 @@ sub readdata {
my $classlist=&Apache::loncoursedata::get_classlist();
foreach (keys %$classlist) {
- # the following undefs are for 'domain', and 'username' respectively.
- if ($_=~/^(\w+)\:(\w+)$/) {
+ if ($_=~/^($match_username)\:($match_domain)$/) {
my ($tuname,$tudom)=($1,$2);
my $useropt=&Apache::lonnet::get_userresdata($tuname,$tudom);
foreach my $userkey (keys %{$useropt}) {
@@ -2400,20 +2681,32 @@ sub storedata {
if ($tuname) {
$tkey=~s/\.\[useropt\:$tuname\:$tudom\]\./\./;
}
- if ($cmd eq 'set') {
- my $data=$env{$_};
- my $typeof=$env{'form.typeof_'.$thiskey};
- if ($$olddata{$thiskey} ne $data) {
+ if ($cmd eq 'set' || $cmd eq 'datepointer' || $cmd eq 'dateinterval') {
+ my ($data, $typeof, $text);
+ if ($cmd eq 'set') {
+ $data=$env{$_};
+ $typeof=$env{'form.typeof_'.$thiskey};
+ $text = &mt('Saved modified parameter for');
+ } elsif ($cmd eq 'datepointer') {
+ $data=&Apache::lonhtmlcommon::get_date_from_form($env{$_});
+ $typeof=$env{'form.typeof_'.$thiskey};
+ $text = &mt('Saved modified date for');
+ } elsif ($cmd eq 'dateinterval') {
+ $data=&get_date_interval_from_form($thiskey);
+ $typeof=$env{'form.typeof_'.$thiskey};
+ $text = &mt('Saved modified date for');
+ }
+ if (defined($data) and $$olddata{$thiskey} ne $data) {
if ($tuname) {
if (&Apache::lonnet::put('resourcedata',{$tkey=>$data,
$tkey.'.type' => $typeof},
$tudom,$tuname) eq 'ok') {
&log_parmset({$tkey=>$data,$tkey.'.type' => $typeof},0,$tuname,$tudom);
- $r->print(' '.&mt('Stored modified parameter for').' '.
+ $r->print(' '.$text.' '.
&Apache::loncommon::plainname($tuname,$tudom));
} else {
$r->print(''.
- &mt('Error storing parameters').' ');
+ &mt('Error saving parameters').'');
}
&Apache::lonnet::devalidateuserresdata($tuname,$tudom);
} else {
@@ -2434,26 +2727,6 @@ sub storedata {
} else {
push (@deldata,$thiskey,$thiskey.'.type');
}
- } elsif ($cmd eq 'datepointer') {
- my $data=&Apache::lonhtmlcommon::get_date_from_form($env{$_});
- my $typeof=$env{'form.typeof_'.$thiskey};
- if (defined($data) and $$olddata{$thiskey} ne $data) {
- if ($tuname) {
- if (&Apache::lonnet::put('resourcedata',{$tkey=>$data,
- $tkey.'.type' => $typeof},
- $tudom,$tuname) eq 'ok') {
- &log_parmset({$tkey=>$data,$tkey.'.type' => $typeof},0,$tuname,$tudom);
- $r->print(' '.&mt('Stored modified date for').' '.&Apache::loncommon::plainname($tuname,$tudom));
- } else {
- $r->print(''.
- &mt('Error storing parameters').' ');
- }
- &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
- } else {
- $newdata{$thiskey}=$data;
- $newdata{$thiskey.'.type'}=$typeof;
- }
- }
}
}
}
@@ -2475,10 +2748,10 @@ sub storedata {
if ($putentries) {
if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') {
&log_parmset(\%newdata,0);
- $r->print(''.&mt('Stored [_1] parameter(s)',$putentries/2).'');
+ $r->print(''.&mt('Saved [_1] parameter(s)',$putentries/2).'');
} else {
$r->print(''.
- &mt('Error storing parameters').' ');
+ &mt('Error saving parameters').'');
}
&Apache::lonnet::devalidatecourseresdata($crs,$dom);
}
@@ -2486,7 +2759,27 @@ sub storedata {
sub extractuser {
my $key=shift;
- return ($key=~/^$env{'request.course.id'}.\[useropt\:(\w+)\:(\w+)\]\./);
+ return ($key=~/^$env{'request.course.id'}.\[useropt\:($match_username)\:($match_domain)\]\./);
+}
+
+sub parse_listdata_key {
+ my ($key,$listdata) = @_;
+ # split into student/section affected, and
+ # the realm (folder/resource part and parameter
+ my ($student,$realm) =
+ ($key=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)$/);
+ # if course wide student would be undefined
+ if (!defined($student)) {
+ ($realm)=($key=~/^\Q$env{'request.course.id'}\E\.(.+)$/);
+ }
+ # strip off the .type if it's not the Question type parameter
+ if ($realm=~/\.type$/ && !exists($listdata->{$key.'.type'})) {
+ $realm=~s/\.type//;
+ }
+ # split into resource+part and parameter name
+ my ($res, $parm) = ($realm=~/^(.*)\.(.*)$/);
+ ($res, my $part) = ($res =~/^(.*)\.(.*)$/);
+ return ($student,$res,$part,$parm);
}
sub listdata {
@@ -2500,40 +2793,48 @@ sub listdata {
$tableopen=0;
my $foundkeys=0;
my %keyorder=&standardkeyorder();
+
foreach my $thiskey (sort {
+ my ($astudent,$ares,$apart,$aparm) = &parse_listdata_key($a,$listdata);
+ my ($bstudent,$bres,$bpart,$bparm) = &parse_listdata_key($b,$listdata);
+
+ # get the numerical order for the param
+ $aparm=$keyorder{'parameter_0_'.$aparm};
+ $bparm=$keyorder{'parameter_0_'.$bparm};
+
+ my $result=0;
+
if ($sortorder eq 'realmstudent') {
- my ($astudent,$arealm)=($a=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)\.[^\.]+$/);
- my ($bstudent,$brealm)=($b=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)\.[^\.]+$/);
- if (!defined($astudent)) {
- ($arealm)=($a=~/^\Q$env{'request.course.id'}\E\.(.+)$/);
- }
- if (!defined($bstudent)) {
- ($brealm)=($b=~/^\Q$env{'request.course.id'}\E\.(.+)$/);
- }
- $arealm=~s/\.type//;
- my ($ares, $aparm) = ($arealm=~/^(.*)\.(.*)$/);
- $aparm=$keyorder{'parameter_0_'.$aparm};
- $brealm=~s/\.type//;
- my ($bres, $bparm) = ($brealm=~/^(.*)\.(.*)$/);
- $bparm=$keyorder{'parameter_0_'.$bparm};
- if ($ares eq $bres) {
- if (defined($aparm) && defined($bparm)) {
- ($aparm <=> $bparm);
- } elsif (defined($aparm)) {
- -1;
- } elsif (defined($bparm)) {
- 1;
- } else {
- ($arealm cmp $brealm) || ($astudent cmp $bstudent);
- }
- } else {
- ($arealm cmp $brealm) || ($astudent cmp $bstudent);
+ if ($ares ne $bres ) {
+ $result = ($ares cmp $bres);
+ } elsif ($astudent ne $bstudent) {
+ $result = ($astudent cmp $bstudent);
+ } elsif ($apart ne $bpart ) {
+ $result = ($apart cmp $bpart);
}
} else {
- $a cmp $b;
+ if ($astudent ne $bstudent) {
+ $result = ($astudent cmp $bstudent);
+ } elsif ($ares ne $bres ) {
+ $result = ($ares cmp $bres);
+ } elsif ($apart ne $bpart ) {
+ $result = ($apart cmp $bpart);
+ }
}
+
+ if (!$result) {
+ if (defined($aparm) && defined($bparm)) {
+ $result = ($aparm <=> $bparm);
+ } elsif (defined($aparm)) {
+ $result = -1;
+ } elsif (defined($bparm)) {
+ $result = 1;
+ }
+ }
+
+ $result;
} keys %{$listdata}) {
-
+
if ($$listdata{$thiskey.'.type'}) {
my $thistype=$$listdata{$thiskey.'.type'};
if ($$resourcedata{$thiskey.'.type'}) {
@@ -2544,7 +2845,7 @@ sub listdata {
my $section=&mt('All Students');
if ($middle=~/^\[(.*)\]/) {
my $issection=$1;
- if ($issection=~/^useropt\:(\w+)\:(\w+)/) {
+ if ($issection=~/^useropt\:($match_username)\:($match_domain)/) {
$section=&mt('User').": ".&Apache::loncommon::plainname($1,$2);
} else {
$section=&mt('Group/Section').': '.$issection;
@@ -2606,32 +2907,18 @@ sub listdata {
$$resourcedata{$thiskey},
'',1,'','').
''.
+(($$resourcedata{$thiskey}!=0)?''.
+&mt('Shift all dates based on this date').'':'').
&date_sanity_info($$resourcedata{$thiskey})
);
- } elsif ($thistype eq 'string_yesno') {
- my $showval;
- if (defined($$resourcedata{$thiskey})) {
- $showval=$$resourcedata{$thiskey};
- }
- $r->print(' ');
- $r->print('');
+ } elsif ($thistype eq 'date_interval') {
+ $r->print(&date_interval_selector($thiskey,
+ $$resourcedata{$thiskey}));
+ } elsif ($thistype =~ m/^string/) {
+ $r->print(&string_selector($thistype,$thiskey,
+ $$resourcedata{$thiskey}));
} else {
- my $showval;
- if (defined($$resourcedata{$thiskey})) {
- $showval=$$resourcedata{$thiskey};
- }
- $r->print('');
+ $r->print(&default_selector($thiskey,$$resourcedata{$thiskey}));
}
$r->print('');
@@ -2641,6 +2928,117 @@ sub listdata {
return $foundkeys;
}
+
+sub date_interval_selector {
+ my ($thiskey, $showval) = @_;
+ my $result;
+ foreach my $which (['days', 86400, 31],
+ ['hours', 3600, 23],
+ ['minutes', 60, 59],
+ ['seconds', 1, 59]) {
+ my ($name, $factor, $max) = @{ $which };
+ my $amount = int($showval/$factor);
+ $showval %= $factor;
+ my %select = ((map {$_ => $_} (0..$max)),
+ 'select_form_order' => [0..$max]);
+ $result .= &Apache::loncommon::select_form($amount,$name.'_'.$thiskey,
+ %select);
+ $result .= ' '.&mt($name);
+ }
+ $result .= '';
+ return $result;
+
+}
+
+sub get_date_interval_from_form {
+ my ($key) = @_;
+ my $seconds = 0;
+ foreach my $which (['days', 86400],
+ ['hours', 3600],
+ ['minutes', 60],
+ ['seconds', 1]) {
+ my ($name, $factor) = @{ $which };
+ if (defined($env{'form.'.$name.'_'.$key})) {
+ $seconds += $env{'form.'.$name.'_'.$key} * $factor;
+ }
+ }
+ return $seconds;
+}
+
+
+sub default_selector {
+ my ($thiskey, $showval) = @_;
+ return '';
+}
+
+my %strings =
+ (
+ 'string_yesno'
+ => [[ 'yes', 'Yes' ],
+ [ 'no', 'No' ]],
+ 'string_problemstatus'
+ => [[ 'yes', 'Yes' ],
+ [ 'answer', 'Yes, and show correct answer if they exceed the maximum number of tries.' ],
+ [ 'no', 'No, don\'t show correct/incorrect feedback.' ],
+ [ 'no_feedback_ever', 'No, show no feedback at all.' ]],
+ );
+
+
+sub string_selector {
+ my ($thistype, $thiskey, $showval) = @_;
+
+ if (!exists($strings{$thistype})) {
+ return &default_selector($thiskey,$showval);
+ }
+
+ my $result;
+ foreach my $possibilities (@{ $strings{$thistype} }) {
+ my ($name, $description) = @{ $possibilities };
+ $result .= ' | '.&Apache::loncommon::end_data_table_row();
}
- $r->print(''.$time.' |
+ if ($env{'form.displayfilter'} eq 'containing') {
+ my $wholeentry=$about_me_link.':'.
+ $parmlog{$id}{'exe_uname'}.':'.$parmlog{$id}{'exe_udom'}.':'.
+ $output;
+ if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
+ }
+ if ($count) {
+ $r->print($row_start.''.$time.' |
'.$about_me_link.
' '.$parmlog{$id}{'exe_uname'}.
':'.$parmlog{$id}{'exe_udom'}.''.
$send_msg_link.' | '.$output);
-
- $shown++;
+ $shown++;
+ }
if (!($env{'form.show'} eq &mt('all')
|| $shown<=$env{'form.show'})) { last; }
}
@@ -3824,6 +4351,12 @@ sub parm_change_log {
$r->print(&Apache::loncommon::end_page());
}
+sub check_for_course_info {
+ my $navmap = Apache::lonnavmaps::navmap->new();
+ return 1 if ($navmap);
+ return 0;
+}
+
##################################################
##################################################
@@ -3834,14 +4367,15 @@ sub parm_change_log {
Main handler. Calls &assessparms and &crsenv subroutines.
=cut
+
##################################################
##################################################
-# use Data::Dumper;
-
sub handler {
my $r=shift;
+ &reset_caches();
+
if ($r->header_only) {
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
@@ -3852,7 +4386,7 @@ sub handler {
'pres_marker',
'pres_value',
'pres_type',
- 'udom','uname','symb','serial']);
+ 'udom','uname','symb','serial','timebase']);
&Apache::lonhtmlcommon::clear_breadcrumbs();
@@ -3867,17 +4401,15 @@ sub handler {
(&Apache::lonnet::allowed('opa',$env{'request.course.id'}) ||
&Apache::lonnet::allowed('opa',$env{'request.course.id'}.'/'.
$env{'request.course.sec'}));
- if ($env{'request.course.id'} && $parm_permission) {
+ my $exists = &check_for_course_info();
+
+ if ($env{'request.course.id'} && $parm_permission && $exists) {
# Start Page
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
- # id numbers can change on re-ordering of folders
-
- &resetsymbcache();
-
#
# Main switch on form.action and form.state, as appropriate
#
@@ -3934,13 +4466,30 @@ sub handler {
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=cleanparameters',
text=>"Clean Parameters"});
&clean_parameters($r);
- }
+ } elsif ($env{'form.action'} eq 'dateshift1' && $parm_permission) {
+ &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
+ text=>"Shifting Dates"});
+ &date_shift_one($r);
+ } elsif ($env{'form.action'} eq 'dateshift2' && $parm_permission) {
+ &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
+ text=>"Shifting Dates"});
+ &date_shift_two($r);
+ } elsif ($env{'form.action'} eq 'categorizecourse' && $parm_permission) {
+ &assign_course_categories($r);
+ }
} else {
# ----------------------------- Not in a course, or not allowed to modify parms
- $env{'user.error.msg'}=
- "/adm/parmset:opa:0:0:Cannot modify assessment parameters";
+ if ($exists) {
+ $env{'user.error.msg'}=
+ "/adm/parmset:opa:0:0:Cannot modify assessment parameters";
+ } else {
+ $env{'user.error.msg'}=
+ "/adm/parmset::0:1:Course environment gone, reinitialize the course";
+ }
return HTTP_NOT_ACCEPTABLE;
}
+ &reset_caches();
+
return OK;
}
500 Internal Server Error
Internal Server Error
The server encountered an internal error or
misconfiguration and was unable to complete
your request.
Please contact the server administrator at
root@localhost to inform them of the time this error occurred,
and the actions you performed just before this error.
More information about this error may be available
in the server error log.