--- loncom/interface/lonparmset.pm 2009/05/16 22:18:20 1.449
+++ loncom/interface/lonparmset.pm 2009/05/17 01:02:10 1.450
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.449 2009/05/16 22:18:20 neumanie Exp $
+# $Id: lonparmset.pm,v 1.450 2009/05/17 01:02:10 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -214,19 +214,6 @@ Variables used (guessed by Jeremy):
When storing information, store as part 0
When requesting information, request from full part
-=item crsenv()
-
-Show and set course data and parameters. This is a large routine that should
-be simplified and shortened... someday.
-
-Inputs: $r
-
-Returns: nothing
-
-=item can_modify_catsettings()
-
-=item assign_course_categories()
-
=item tablestart()
=item tableend()
@@ -322,7 +309,7 @@ Set portfolio metadata
=item handler() :
-Main handler. Calls &assessparms and &crsenv subroutines.
+Main handler. Calls &assessparms subroutine.
=back
@@ -2304,806 +2291,6 @@ ENDMAPONE
$r->print(''.&Apache::loncommon::end_page());
} # end sub assessparms
-
-
-sub crsenv {
- my $r=shift;
- my $setoutput='';
-
- &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=crsenv',
- text=>"Course Environment"});
- my $breadcrumbs =
- &Apache::lonhtmlcommon::breadcrumbs('Edit Course Environment');
- my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
- my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
-
- my (%crsinfo,$chome);
- my $crstype = &Apache::loncommon::course_type();
-
- #
- # Go through list of changes
- foreach (keys %env) {
- next if ($_!~/^form\.(.+)\_setparmval$/);
- my $name = $1;
- my $value = $env{'form.'.$name.'_value'};
- if ($name eq 'newp') {
- $name = $env{'form.newp_name'};
- }
- if ($name =~ /^rolenames_([^_]+)$/) {
- $name = $1.'.plaintext';
- my $standardtitle =
- &Apache::lonnet::plaintext($1,$crstype,$env{'request.course.id'},1);
- my %adv_roles =
- &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
- if ($value ne '') {
- foreach my $role (keys(%adv_roles)) {
- if ($role =~ m{^cr/$match_domain/$match_name/\Q$value\E$}) {
- $setoutput.= ''.
- &mt('Requested replacement title for [_1] role is already used as the name of a custom role ([_2]).',$standardtitle,$value).
- ' ';
- undef($value);
- }
- }
- }
- }
- if ($name eq 'url') {
- $value=~s/^\/res\///;
- my $bkuptime=time;
- my @tmp = &Apache::lonnet::get
- ('environment',['url'],$dom,$crs);
- $setoutput.=&mt('Backing up previous URL').': '.
- &Apache::lonnet::put
- ('environment',
- {'top level map backup '.$bkuptime => $tmp[1] },
- $dom,$crs).
- ' ';
- }
- #
- # Deal with modified default spreadsheets
- if ($name =~ /^spreadsheet_default_(classcalc|
- studentcalc|
- assesscalc)$/x) {
- my $sheettype = $1;
- if ($sheettype eq 'classcalc') {
- # no need to do anything since viewing the sheet will
- # cause it to be updated.
- } elsif ($sheettype eq 'studentcalc') {
- # expire all the student spreadsheets
- &Apache::lonnet::expirespread('','','studentcalc');
- } else {
- # expire all the assessment spreadsheets
- # this includes non-default spreadsheets, but better to
- # be safe than sorry.
- &Apache::lonnet::expirespread('','','assesscalc');
- # expire all the student spreadsheets
- &Apache::lonnet::expirespread('','','studentcalc');
- }
- }
- #
- # Deal with the enrollment dates
- 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 e-mail 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 e-mail address specified, user [_1] is unknown.",$name).
- '';
- undef($value);
- }
- }
- }
- # Get existing cloners
- my @oldcloner = ();
- if ($name eq 'cloners') {
- my %clonenames=&Apache::lonnet::dump('environment',$dom,$crs,'cloners');
- if ($clonenames{'cloners'} =~ /,/) {
- @oldcloner = split/,/,$clonenames{'cloners'};
- } else {
- $oldcloner[0] = $clonenames{'cloners'};
- }
- }
- #
- # Let the user know we made the changes
- if ($name && defined($value)) {
- 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);
- }
- my $put_result = &Apache::lonnet::put('environment',
- {$name=>$value},$dom,$crs);
- if ($put_result eq 'ok') {
- $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);
- }
- # 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::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') && (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).'. ';
- }
- }
- }
-
-# ------------------------- Re-init course environment entries for this session
-
- &Apache::lonnet::coursedescription($env{'request.course.id'},
- {'freshen_cache' => 1});
-
-# -------------------------------------------------------- Get parameters again
-
- my %values=&Apache::lonnet::dump('environment',$dom,$crs);
- my $SelectStyleFile=&mt('Select Style File');
- my $SelectSpreadsheetFile=&mt('Select Spreadsheet File');
- my $output='';
- my $output_SB = ''; # will be replaced by "$output" when all changes are done
- my $can_categorize;
- my %lt=&Apache::lonlocal::texthash(
- 'par' => 'Parameter',
- 'val' => 'Value',
- 'set' => 'Set?',
- 'sav' => 'Save',
- );
- if (! exists($values{'con_lost'})) {
- my %descriptions=
- ('url' => ''.&mt('Top Level Map').' '.
- '".
- &mt('Select Map').' '.
- &mt('Modification may make assessment data inaccessible!').
- '',
- 'description' => ''.&mt('Course Title').'',
- 'courseid' => ''.&mt('Course ID or number').
- ' '.
- '('.&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').' '.
- &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').' '
- .'("'.&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 chat room 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 chat room use for Users').' '.
- '("'.&mt('user:domain,user:domain,...').'")',
-
- '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').' '.
- '("'.&mt('user:domain,user:domain,...').'")',
- 'spreadsheet_default_classcalc'
- => ''.&mt('Default Course Spreadsheet').' '.
- '$SelectSpreadsheetFile ",
- 'spreadsheet_default_studentcalc'
- => ''.&mt('Default Student Spreadsheet').' '.
- '$SelectSpreadsheetFile ",
- 'spreadsheet_default_assesscalc'
- => ''.&mt('Default Assessment Spreadsheet').' '.
- '$SelectSpreadsheetFile ",
- 'allow_limited_html_in_feedback'
- => ''.&mt('Allow limited HTML in discussion posts').' '.
- '('.&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').' '
- .'('.&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 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"').')',
- 'problem_stream_switch'
- => ''.&mt('Allow problems to be split over pages').' '.
- ' ('.&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'
- => ' '.&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').' '
- .'("'.&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').' ('.&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').')',
- 'disableexampointprint'
- => ''.&mt('Disable automatically printing point values onto exams.').' '.
- ' ('.&mt('"[_1]" to disable, anything else if not','yes').')',
- 'externalsyllabus'
- => ''.&mt('URL of Syllabus (not using internal handler)').'',
- 'tthoptions'
- => ''.&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').'',
- 'datelocale'
- => ''.&mt('Locale used for course calendar').'',
- 'rolenames'
- => ''.&mt('Replacement titles for standard course roles').' '.
- '('.&mt('To replace the standard title for a course role, enter the title you wish to use, otherwise leave blank.').')',
- );
-
-
-# ----------------------------------------------------------------
-# Begin: New Version with Parameter Categories
-
- sub parameter_row {
- # Create parameter row for course environment screen
-
- my ($parameter, $description) = @_;
-
- # Start Parameter Row
- my $output = &Apache::loncommon::start_data_table_row();
-
- # Column 1/3: Descriptive text of current parameter
- $output .= '
'.$description.'
';
-
- # Column 2/3: Input field (Sometimes special field(s), depending on parameter)
-
- # onchange is javascript to automatically check the 'Set' button.
- my $onchange = 'onFocus="javascript:window.document.forms'
- ."['envform'].elements['".$parameter."_setparmval']"
- .'.checked=true;"';
- if ($parameter =~ /^default_enrollment_(start|end)_date$/) {
- $output .= '
'
- .&Apache::loncommon::end_data_table_row();
- }
- # Add buttons row at end of each category
- $output_SB .= &Apache::loncommon::start_data_table_empty_row()
- .'
'
- .$buttons
- .'
'
- .&Apache::loncommon::end_data_table_empty_row;
-
- $output_SB .= &Apache::loncommon::end_data_table()
- . ' ';
-}
-
-# End: New Version with Parameter Categories
-# ----------------------------------------------------------------
-
-
- }
-
- 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',
- $jscript);
- my $end_page =
- &Apache::loncommon::end_page();
- $r->print(<
-$setoutput
-$output_SB
-
-$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) {
- unescapedcats = 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.').'