--- loncom/interface/courseprefs.pm 2009/10/29 14:57:18 1.9 +++ loncom/interface/courseprefs.pm 2010/01/08 21:07:49 1.20 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set configuration settings for a course # -# $Id: courseprefs.pm,v 1.9 2009/10/29 14:57:18 raeburn Exp $ +# $Id: courseprefs.pm,v 1.20 2010/01/08 21:07:49 faziophi Exp $ # # Copyright Michigan State University Board of Trustees # @@ -101,7 +101,7 @@ sub handler { date => 'Locale used for community calendar', coco => 'Community Content', copo => 'Community Policy', - priv => 'Domain Coodinators in community', + priv => 'Domain Coordinators in community', defd => 'Default dates for member access', stuv => 'Member-viewable membership list options', stul => 'Member agreement needed to be listed', @@ -126,7 +126,7 @@ sub handler { date => 'Locale used for course calendar', coco => 'Course Content', copo => 'Course Policy', - priv => 'Domain Coodinators in course', + priv => 'Domain Coordinators in course', defd => 'Default dates for student access', stuv => 'Student-viewable classlist options', stul => 'Student agreement needed to be listed', @@ -161,11 +161,9 @@ sub handler { 'courseinfo' => { text => $lt{'gens'}, help => 'Course_Environment', - header => [{col1 => 'Setting', - col2 => 'Value'}], ordered => ['description','courseid','categories', - 'hidefromcat','cloners','externalsyllabus', - 'url','rolenames'], + 'hidefromcat','externalsyllabus', + 'cloners','url','rolenames'], itemtext => { description => $lt{'desc'}, courseid => $lt{'idnu'}, @@ -178,10 +176,8 @@ sub handler { }, }, 'localization' => - { text => 'Language/TimeZone/Locale', + { text => 'Language & Time Localization', help => 'Course_Environment', - header => [{col1 => 'Setting', - col2 => 'Value',}], ordered => ['languages','timezone','datelocale'], itemtext => { languages => 'Languages used', @@ -193,9 +189,7 @@ sub handler { { text => 'Feedback messages', help => 'Course_Environment', header => [{col1 => 'Questions about:', - col2 => 'Recipients'}, - {col1 => 'Questions about:', - col2 => 'Custom Text'}], + col2 => 'Recipients'}], ordered => ['question.email','comment.email','policy.email'], itemtext => { 'question.email' => 'Resource Content', @@ -206,8 +200,6 @@ sub handler { 'discussion' => { text => 'Discussion and Chat', help => 'Course_Environment', - header => [{col1 => 'Setting', - col2 => 'Value',}], ordered => ['plc.roles.denied','plc.users.denied', 'pch.roles.denied','pch.users.denied', 'allow_limited_html_in_feedback', @@ -217,7 +209,7 @@ sub handler { 'plc.users.denied' => 'No Resource Discussion', 'pch.roles.denied' => 'No Chat room use', 'pch.users.denied' => 'No Chat room use', - allow_limited_html_in_feedback => 'Allow limited HTML in discussion posts', + allow_limited_html_in_feedback => 'Allow limited HTML in discussion', allow_discussion_post_editing => 'Users can edit/delete own discussion posts', }, }, @@ -246,13 +238,11 @@ sub handler { 'appearance' => { text => 'Display of resources ', help => 'Course_Environment', - header => [{col1 => 'Setting', - col2 => 'Value'}], ordered => ['default_xml_style','pageseparators', 'disable_receipt_display','texengine', 'tthoptions'], itemtext => { - default_xml_style => 'Default XML Style File', + default_xml_style => 'Default XML style file', pageseparators => 'Visibly Separate Items on Pages', disable_receipt_display => 'Disable display of problem receipts', texengine => 'Force use of a specific math rendering engine', @@ -262,8 +252,6 @@ sub handler { 'grading' => { text => 'Grading', help => 'Course_Environment', - header => [{col1 => 'Setting', - col2 => 'Value',}], ordered => ['grading','rndseed', 'receiptalg','disablesigfigs'], itemtext => { @@ -277,24 +265,21 @@ sub handler { 'printouts' => { text => 'Printout generation', help => 'Course_Environment', - header => [{col1 => 'Setting', - col2 => 'Value',}], ordered => ['problem_stream_switch','suppress_tries', 'default_paper_size','print_header_format', - 'disableexampointprint'], + 'disableexampointprint','canuse_pdfforms'], itemtext => { problem_stream_switch => 'Allow problems to be split over pages', suppress_tries => 'Suppress number of tries in printing', default_paper_size => 'Default paper type', print_header_format => 'Print header format', disableexampointprint => 'Disable automatically printing point values on exams', + canuse_pdfforms => 'Users can print problems as PDF forms and upload later for grading', }, }, 'spreadsheet' => { text => 'Spreadsheets', help => 'Course_Environment', - header => [{col1 => 'Setting', - col2 => 'Value'}], ordered => ['spreadsheet_default_classcalc', 'spreadsheet_default_studentcalc', 'spreadsheet_default_assesscalc','hideemptyrows'], @@ -308,8 +293,6 @@ sub handler { 'bridgetasks' => { text => 'Bridge tasks', help => 'Course_Environment', - header => [{col1 => 'Setting', - col2 => 'Value'}], ordered => ['task_messages','task_grading', 'suppress_embed_prompt'], itemtext => { @@ -332,7 +315,7 @@ sub handler { \@prefs_order,\%prefs,\%values, $cnum,undef,\@allitems); } elsif ($phase eq 'display') { - my $jscript = &get_jscript($cdom,$phase); + my $jscript = &get_jscript($cdom,$phase,$crstype); my @allitems = &get_allitems(%prefs); &Apache::lonconfigsettings::display_settings($r,$cdom,$phase,$context, \@prefs_order,\%prefs,\%values,undef,$jscript,\@allitems,$crstype); @@ -365,21 +348,20 @@ sub print_config_box { my $itemtext = $item->{'itemtext'}; my $rowtotal = 0; my $output = - ' - - '."\n". - ''; + '

'.&mt($item->{text}).'

+
 '. + &Apache::loncommon::help_open_topic($item->{'help'}).''; if (($action eq 'feedback') || ($action eq 'classlists')) { $output .= ' -
- - - - - - -
'. - &mt($item->{text}).' '. - &Apache::loncommon::help_open_topic($item->{'help'}).'
- - +
'; + if (exists $item->{'header'}->[0]->{'col1'} || + exists $item->{'header'}->[0]->{'col2'}) { + $output .= ' + - '; + '; + } $rowtotal ++; if ($action eq 'feedback') { $output .= &print_feedback('top',$cdom,$settings,$ordered,$itemtext,\$rowtotal); @@ -388,10 +370,6 @@ sub print_config_box { } $output .= '
'.&mt($item->{'header'}->[0]->{'col1'}).' '.&mt($item->{'header'}->[0]->{'col2'}).'
-
'; @@ -402,25 +380,27 @@ sub print_config_box { $output .= &print_classlists('middle',$cdom,$settings,$itemtext,\$rowtotal,$crstype). '
'.&mt($item->{'header'}->[1]->{'col1'}).'
-
- - - - - '; +
'.&mt($item->{'header'}->[2]->{'col1'}).''.&mt($item->{'header'}->[2]->{'col2'}).'
'; + if (exists $item->{'header'}->[0]->{'col1'} || + exists $item->{'header'}->[0]->{'col2'}) { + $output .= ' + + + + '; + } } } else { $output .= ' - - - -
'.&mt($item->{'header'}->[0]->{'col1'}).''.&mt($item->{'header'}->[0]->{'col2'}).'
- - +
'; + if (exists $item->{'header'}->[0]->{'col1'} || + exists $item->{'header'}->[0]->{'col2'}) { + $output .= ' + - '; + '; + } } $rowtotal ++; if ($action eq 'courseinfo') { @@ -448,9 +428,7 @@ sub print_config_box { } $output .= '
'.&mt($item->{'header'}->[0]->{'col1'}).' '.&mt($item->{'header'}->[0]->{'col2'}).'
-

'; +'; return ($output,$rowtotal); } @@ -983,15 +961,21 @@ sub store_changes { $displayname = &mt($text); } if (defined($yesno{$key})) { - $displayval = 'no'; + $displayval = &mt('No'); if ($changes->{$item}{$key} eq 'yes') { - $displayval = 'yes'; + $displayval = &mt('Yes'); } } elsif (($key =~ /^default_enrollment_(start|end)_date$/) && ($displayval)) { $displayval = &Apache::lonlocal::locallocaltime($displayval); } elsif ($key eq 'categories') { $displayval = $env{'form.categories_display'}; - } + } elsif ($key eq 'canuse_pdfforms') { + if ($changes->{$item}{$key} eq '1') { + $displayval = &mt('Yes'); + } elsif ($changes->{$item}{$key} eq '0') { + $displayval = &mt('No'); + } + } if ($changes->{$item}{$key} eq '') { push(@delkeys,$key); $output .= '
  • '.&mt('Deleted setting for [_1]', @@ -1037,6 +1021,10 @@ sub store_changes { $output .= &mt('An error occurred when removing course settings which are no longer in use.'); } $output .= ''; + } else { + foreach my $key (@delkeys) { + &Apache::lonnet::delenv('course.'.$cdom.'_'.$cnum.'.'.$key); + } } } if (@need_env_update) { @@ -1174,8 +1162,8 @@ sub get_course { } sub get_jscript { - my ($cdom,$phase) = @_; - my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom); + my ($cdom,$phase,$crstype) = @_; + my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom,$crstype); my ($jscript,$categorize_js); my $stubrowse_js = &Apache::loncommon::studentbrowser_javascript(); my $browse_js = &Apache::loncommon::browser_and_searcher_javascript('parmset'); @@ -1294,14 +1282,14 @@ sub print_courseinfo { if (ref($cathash) eq 'HASH') { $categoriesform = &Apache::loncommon::assign_categories_table($cathash, - $settings->{'categories'})."\n"; + $settings->{'categories'},$crstype)."\n"; } } if (!defined($categoriesform)) { - $categoriesform = &mt('No categories defined for this domain'); + $categoriesform = &mt('No categories defined in this domain.'); } - my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom); + my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom,$crstype); my $replace; if ($crstype eq 'Community') { @@ -1319,6 +1307,7 @@ sub print_courseinfo { '', input => 'textbox', size => '40', + advanced => 1 }, 'description' => { text => ''.&mt($itemtext->{'description'}).'', @@ -1336,12 +1325,14 @@ sub print_courseinfo { &mt('Coordinators included automatically'), input => 'textbox', size => '40', + advanced => 1 }, 'rolenames' => { text => ''.&mt($itemtext->{'rolenames'}).'
    '. '('.$replace.')', input => 'textbox', size => '20', + advanced => 1 }, 'externalsyllabus' => { text => ''.&mt($itemtext->{'externalsyllabus'}).'
    ('. @@ -1370,7 +1361,11 @@ sub print_courseinfo { next if (!$can_categorize); } $count ++; - $datatable .= &item_table_row_start($items{$item}{text},$count); + if (exists $items{$item}{advanced} && $items{$item}{advanced} == 1) { + $datatable .= &item_table_row_start($items{$item}{text},$count,"advanced"); + } else { + $datatable .= &item_table_row_start($items{$item}{text},$count); + } if ($items{$item}{input} eq 'radio') { $datatable .= &yesno_radio($item,$settings); } elsif ($item eq 'cloners') { @@ -1507,15 +1502,24 @@ sub new_cloners_dom_row { } sub can_modify_catsettings { - my ($dom) = @_; + my ($dom,$crstype) = @_; 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; + if ($crstype eq 'Community') { + if ($domconf{'coursecategories'}{'togglecatscomm'} eq 'comm') { + $can_toggle_cat = 1; + } + if ($domconf{'coursecategories'}{'categorizecomm'} eq 'comm') { + $can_categorize = 1; + } + } else { + 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); @@ -1531,7 +1535,13 @@ sub assign_course_categories { if (ref($domconf{'coursecategories'}) eq 'HASH') { $cathash = $domconf{'coursecategories'}{'cats'}; if (ref($cathash) eq 'HASH') { - $hascats = 1; + foreach my $cat (keys(%{$cathash})) { + next if ($cat eq 'instcode::0'); + unless ($crstype eq 'Community') { + next if ($cat eq 'communities::0'); + } + $hascats ++; + } } } my $catwin_js; @@ -1597,15 +1607,20 @@ ENDSCRIPT if ($hascats) { my %currsettings = &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum); - $categoriesform .= $assign.'

    '. - '
    '."\n". - &Apache::loncommon::assign_categories_table($cathash, - $currsettings{'categories'})."\n". - '

    '; + my $cattable = &Apache::loncommon::assign_categories_table($cathash, + $currsettings{'categories'},$crstype); + if ($cattable eq '') { + $categoriesform .= &mt('No suitable categories defined for this course type in this domain.'); + } else { + $categoriesform .= $assign.'

    '. + '
    '."\n". + $cattable."\n". + '

    '; + } } else { - $categoriesform .= &mt('No categories defined for this domain'); + $categoriesform .= &mt('No categories defined in this domain.'); } $r->print($start_page.$categoriesform.$end_page); return; @@ -1618,16 +1633,16 @@ sub print_localization { } my %items = ( languages => { - text => &mt($itemtext->{'languages'}).'
    '. - &mt("(will override user's preference)"), + text => ''.&mt($itemtext->{'languages'}).'
    '. + &mt("(overrides individual user preference)"), input => 'selectbox', }, timezone => { - text => &mt($itemtext->{'timezone'}), + text => ''.&mt($itemtext->{'timezone'}).'', input => 'selectbox', }, datelocale => { - text => &mt($itemtext->{'datelocale'}), + text => ''.&mt($itemtext->{'datelocale'}).'', input => 'selectbox', }, ); @@ -1745,7 +1760,11 @@ sub print_feedback { foreach my $item (@{$ordered}) { $count ++; - $datatable .= &item_table_row_start($items{$item}{text},$count); + if ($position eq 'top') { + $datatable .= &item_table_row_start($items{$item}{text},$count); + } else { + $datatable .= &item_table_row_start($items{$item}{text}."
    (Custom text)",$count, "advanced"); + } if ($position eq 'top') { my $includeempty = 0; $datatable .= &user_table($cdom,$item,\@sections, @@ -1768,7 +1787,7 @@ sub user_table { } else { my $num = 0; my @curr = split(/,/,$currvalue); - $output .= &Apache::loncommon::start_data_table(); + $output .= ''; my ($currusers); foreach my $val (@curr) { next if ($val eq ''); @@ -1799,24 +1818,23 @@ sub user_table { $num ++; } if ($num) { - $output .= &Apache::loncommon::start_data_table_row(). + $output .= ''. ''. - &Apache::loncommon::end_data_table_row(); + ''; } - $output .= &Apache::loncommon::start_data_table_row(). + $output .= ''. ''.&Apache::loncommon::end_data_table_row(). - &Apache::loncommon::end_data_table(); + '
    '; - if ($num > 1) { + if ($num == 1) { $output .= $lt->{'currone'}; } else { - $output .= $lt->{'currmult'}; + $output .= $lt->{'curmult'}; } $output .= '
    '. ''.$currusers.'
    '. $lt->{'add'}.'
    '. &select_recipient($item,$num,$cdom,$sections). ''. - '
    '; } return $output; } @@ -1827,9 +1845,8 @@ sub select_recipient { my $selectlink = &Apache::loncommon::selectstudent_link('display',$item.'_uname_'.$num, $item.'_udom_'.$num,1); - my $css_class = ($num % 2)?'LC_even_row':'LC_odd_row'; my $output = - '
    '.&mt('Username').'
    '. + ''. ''; if (ref($sections) eq 'ARRAY') { @@ -1883,8 +1900,8 @@ sub print_discussion { } my %items = ( 'plc.roles.denied' => { - text => ''.&mt($itemtext->{'plc.roles.denied'}).''. - &Apache::loncommon::help_open_topic("Course_Disable_Discussion"). + text => ''.&mt($itemtext->{'plc.roles.denied'}).''. + &Apache::loncommon::help_open_topic("Course_Disable_Discussion").'
    '. &mt('(role-based)'), input => 'checkbox', }, @@ -1896,8 +1913,8 @@ sub print_discussion { }, 'pch.roles.denied' => { - text => ''.&mt($itemtext->{'pch.roles.denied'}).''. - &Apache::loncommon::help_open_topic("Course_Disable_Discussion").'
    '. + text => ''.&mt($itemtext->{'pch.roles.denied'}).''. + &Apache::loncommon::help_open_topic("Course_Disable_Discussion").'
    '. &mt('(role-based)'), input => 'checkbox', }, @@ -2203,14 +2220,15 @@ sub print_grading { input => 'selectbox', options => { standard => &mt('Standard: shows points'), - external => &mt('External: shows number of completed parts'), + external => &mt('External: shows number of completed parts and totals'), + externalnototals => &mt('External: shows only number of completed parts'), spreadsheet => &mt('Spreadsheet: (with link to detailed scores)'), }, - order => ['standard','external','spreadsheet'], + order => ['standard','external','externalnototals','spreadsheet'], }, 'rndseed' => { text => ''.&mt($itemtext->{'rndseed'}).''. - ''.'
    '. + ''.'
    '. &mt('Modifying this will make problems have different numbers and answers!'). '
    ', input => 'selectbox', @@ -2282,6 +2300,16 @@ sub print_printouts { text => ''.&mt($itemtext->{'disableexampointprint'}).'', input => 'radio', }, + canuse_pdfforms => { + text => ''.&mt($itemtext->{'canuse_pdfforms'}).'', + input => 'selectbox', + options => { + 1 => &mt('Yes'), + 0 => &mt('No'), + }, + order => ['1','0'], + nullval => 'None specified - use domain default', + } ); return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype); } @@ -2412,15 +2440,13 @@ sub get_other_items { } sub item_table_row_start { - my ($text,$count) = @_; + my ($text,$count,$add_class) = @_; my $output; - if ($count%2) { - $output .= '
    '; - } else { - $output .= ''; - } + my $css_class = ($count % 2) ? 'LC_odd_row' : 'LC_even_row'; + $css_class = (join(' ',$css_class,$add_class)) unless ($add_class eq ''); + $output .= ''."\n";; $output .= '
    '.&mt('Username').'
    '. '
    '.&mt('Domain').'
    '.$domform.'
    '.$text. - ''; + ''; return $output; } @@ -2678,11 +2704,11 @@ function getIndexByName(item) { ENDJS - $output .= $currstr.&Apache::loncommon::start_data_table(); + $output .= $currstr.''; if (@curr > 0) { for (my $i=0; $i<@curr; $i++) { my $pos = $i+1; - $output .= &Apache::loncommon::start_data_table_row(). + $output .= ''. ''; } - $output .= &Apache::loncommon::end_data_table_row(); + $output .= ''; } } my $pos = $currnum+1; - $output .= &Apache::loncommon::start_data_table_row(). + $output .= ''. ''. - &Apache::loncommon::end_data_table_row(); + ''; $pos ++; $currnum ++; - $output .= &Apache::loncommon::start_data_table_row(). + $output .= ''. ''. @@ -2717,8 +2743,8 @@ ENDJS '" value="" size ="25" />'. ''. - &Apache::loncommon::end_data_table_row(). - &Apache::loncommon::end_data_table(); + ''. + '
    '. &position_selector($pos,$i,$maxnum).&mt('Delete:'). '
    '. &position_selector($pos,$currnum,$maxnum). ''.&mt('New').''. &substitution_selector($currnum).'
    '. &position_selector($pos,$currnum,$maxnum). ''.&mt('New').'
    '; return $output; }