--- loncom/interface/courseprefs.pm 2010/12/24 16:50:38 1.36 +++ loncom/interface/courseprefs.pm 2014/05/16 17:13:31 1.65 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set configuration settings for a course # -# $Id: courseprefs.pm,v 1.36 2010/12/24 16:50:38 raeburn Exp $ +# $Id: courseprefs.pm,v 1.65 2014/05/16 17:13:31 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -268,10 +268,11 @@ sub handler { my %lt; if ($crstype eq 'Community') { %lt = ( - conf => 'Community Configuration', - edit => 'Edit Community Configuration', + conf => 'Community Settings', + edit => 'Edit Community Settings', gens => 'General community settings', idnu => 'Community ID or number', + unco => 'Unique code', desc => 'Community Description', ownr => 'Community Owner', cown => 'Community Co-owners', @@ -287,19 +288,21 @@ sub handler { defd => 'Default dates for member access', stuv => 'Member-viewable membership list options', stul => 'Member agreement needed to be listed', - clas => 'Membership and Facilitator Listing', - priv => 'Privileged users (Domain Coordinators) in facilitator listing', + clas => 'Membership and facilitator listing', + prus => 'Privileged users (Domain Coordinators) in facilitator listing', defc => 'Default Community Spreadsheet', defs => 'Default User Spreadsheet', seme => 'Send message to member when clicking Done on Tasks' ); } else { %lt = ( - conf => 'Course Configuration', - edit => 'Edit Course Configuration', + conf => 'Course Settings', + edit => 'Edit Course Settings', gens => 'General course settings', idnu => 'Course ID or number', + unco => 'Unique code', desc => 'Course Description', + cred => 'Student credits', ownr => 'Course Owner', cown => 'Course Co-owners', catg => 'Categorize course', @@ -314,8 +317,9 @@ sub handler { defd => 'Default dates for student access', stuv => 'Student-viewable classlist options', stul => 'Student agreement needed to be listed', - clas => 'Classlists and Staff Listing', - priv => 'Privileged users (Domain Coordinators) in staff listing', + clas => 'Classlists and staff listing', + prus => 'Privileged users (Domain Coordinators) in staff listing', + prdo => "Domains to check for privileged users (besides course's domain)", defc => 'Default Course Spreadsheet', defs => 'Default Student Spreadsheet', seme => 'Send message to student when clicking Done on Tasks', @@ -353,27 +357,30 @@ sub handler { my %prefs = ( 'courseinfo' => { text => $lt{'gens'}, - help => 'Course_Environment', + help => 'Course_Prefs_General', ordered => ['owner','co-owners','loncaparev','description', - 'courseid','categories','hidefromcat', - 'externalsyllabus','cloners','url','rolenames'], + 'clonedfrom','courseid','uniquecode','categories', + 'hidefromcat','externalsyllabus','cloners','url', + 'rolenames'], itemtext => { 'owner' => $lt{'ownr'}, 'co-owners' => $lt{'cown'}, 'description' => $lt{'desc'}, 'courseid' => $lt{'idnu'}, + 'uniquecode' => $lt{'unco'}, 'categories' => $lt{'catg'}, 'hidefromcat' => $lt{'excc'}, 'cloners' => $lt{'clon'}, - 'externalsyllabus' => 'URL of Syllabus', + 'externalsyllabus' => 'Syllabus status', 'url' => 'Top Level Map', 'rolenames' => $lt{'rept'}, 'loncaparev' => $lt{'lcrv'}, + 'clonedfrom' => 'Cloned from', }, }, 'localization' => - { text => 'Language and Time Localization', - help => 'Course_Environment', + { text => 'Language and time localization', + help => 'Course_Prefs_Language', ordered => ['languages','timezone','datelocale'], itemtext => { languages => 'Languages used', @@ -383,7 +390,7 @@ sub handler { }, 'feedback' => { text => 'Feedback messages', - help => 'Course_Environment', + help => 'Course_Prefs_Feedback', header => [{col1 => 'Questions about:', col2 => 'Recipients'}], ordered => ['question.email','comment.email','policy.email'], @@ -395,11 +402,12 @@ sub handler { }, 'discussion' => { text => 'Discussion and Chat', - help => 'Course_Environment', + help => 'Course_Prefs_Discussions', ordered => ['pch.roles.denied','pch.users.denied', 'plc.roles.denied','plc.users.denied', 'allow_limited_html_in_feedback', - 'allow_discussion_post_editing'], + 'allow_discussion_post_editing', + 'discussion_post_fonts'], itemtext => { 'pch.roles.denied' => 'No Resource Discussion', 'pch.users.denied' => 'No Resource Discussion', @@ -407,11 +415,12 @@ sub handler { 'plc.users.denied' => 'No Chat room use', allow_limited_html_in_feedback => 'Allow limited HTML in discussion', allow_discussion_post_editing => 'Users can edit/delete own discussion posts', + discussion_post_fonts => 'Discussion post fonts based on likes/unlikes', }, }, 'classlists' => { text => $lt{'clas'}, - help => 'Course_Environment', + help => 'Course_Prefs_Classlists', header => [{col1 => 'Type', col2 => $lt{'defd'}}, {col1 => 'Setting', @@ -420,20 +429,24 @@ sub handler { col2 => $lt{'stuv'}}], ordered => ['default_enrollment_start_date', 'default_enrollment_end_date', - 'nothideprivileged','student_classlist_view', + 'defaultcredits', + 'nothideprivileged','checkforpriv', + 'student_classlist_view', 'student_classlist_opt_in','student_classlist_portfiles'], itemtext => { default_enrollment_start_date => 'Start date', default_enrollment_end_date => 'End date', - nothideprivileged => $lt{'priv'}, + nothideprivileged => $lt{'prus'}, + checkforpriv => $lt{'prdo'}, student_classlist_view => $lt{'stuv'}, student_classlist_opt_in => $lt{'stul'}, student_classlist_portfiles => 'Include link to accessible portfolio files', + defaultcredits => $lt{'cred'}, }, }, 'appearance' => { text => 'Display of resources ', - help => 'Course_Environment', + help => 'Course_Prefs_Display', ordered => ['default_xml_style','pageseparators', 'disable_receipt_display','texengine', 'tthoptions'], @@ -447,7 +460,7 @@ sub handler { }, 'grading' => { text => 'Grading', - help => 'Course_Environment', + help => 'Course_Prefs_Grading', ordered => ['grading','rndseed', 'receiptalg','disablesigfigs'], itemtext => { @@ -460,7 +473,7 @@ sub handler { }, 'printouts' => { text => 'Printout generation', - help => 'Course_Environment', + help => 'Course_Prefs_Printouts', ordered => ['problem_stream_switch','suppress_tries', 'default_paper_size','print_header_format', 'disableexampointprint','canuse_pdfforms'], @@ -469,13 +482,13 @@ sub handler { 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', + disableexampointprint => 'Disable automatically printing point values on bubblesheet exams', canuse_pdfforms => 'Users can print problems as PDF forms and upload later for grading', }, }, 'spreadsheet' => { text => 'Spreadsheets', - help => 'Course_Environment', + help => 'Course_Prefs_Spreadsheet', ordered => ['spreadsheet_default_classcalc', 'spreadsheet_default_studentcalc', 'spreadsheet_default_assesscalc','hideemptyrows'], @@ -488,7 +501,7 @@ sub handler { }, 'bridgetasks' => { text => 'Bridge tasks', - help => 'Course_Environment', + help => 'Course_Prefs_Bridgetasks', ordered => ['task_messages','task_grading', 'suppress_embed_prompt'], itemtext => { @@ -499,7 +512,7 @@ sub handler { }, 'other' => { text => 'Other settings', - help => 'Course_Environment', + help => 'Course_Prefs_Other', header => [ {col1 => 'Item', col2 => 'Value', }], @@ -509,15 +522,15 @@ sub handler { my @allitems = &get_allitems(%prefs); &Apache::lonconfigsettings::make_changes($r,$cdom,$phase,$context, \@prefs_order,\%prefs,\%values, - $cnum,undef,\@allitems); + $cnum,undef,\@allitems,'coursepref'); } elsif ($phase eq 'display') { my $jscript = &get_jscript($cid,$cdom,$phase,$crstype); my @allitems = &get_allitems(%prefs); &Apache::lonconfigsettings::display_settings($r,$cdom,$phase,$context, - \@prefs_order,\%prefs,\%values,undef,$jscript,\@allitems,$crstype); + \@prefs_order,\%prefs,\%values,undef,$jscript,\@allitems,$crstype,'coursepref'); } else { &Apache::lonconfigsettings::display_choices($r,$phase,$context, - \@prefs_order,\%prefs); + \@prefs_order,\%prefs,'coursepref'); } return OK; } @@ -544,18 +557,34 @@ sub print_config_box { my $itemtext = $item->{'itemtext'}; my $rowtotal = 0; my $output = - '

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

-
 '. - &Apache::loncommon::help_open_topic($item->{'help'}).''; + ' + + '."\n". + ''; if (($action eq 'feedback') || ($action eq 'classlists')) { $output .= ' + + + + + + + + '. &Apache::loncommon::end_data_table_row(). &Apache::loncommon::end_data_table(). - '
'. + &mt($item->{text}); + if ($item->{'help'}) { + $output .= ' '. + &Apache::loncommon::help_open_topic($item->{'help'}); + } + $output .= '
'; if (exists $item->{'header'}->[0]->{'col1'} || exists $item->{'header'}->[0]->{'col2'}) { $output .= ' - - + '; + if ($action eq 'feedback') { + $output .= ' + '; } $rowtotal ++; @@ -566,35 +595,57 @@ sub print_config_box { } $output .= '
'.&mt($item->{'header'}->[0]->{'col1'}).''.&mt($item->{'header'}->[0]->{'col2'}).''.&mt($item->{'header'}->[0]->{'col1'}).''; + } else { + $output .= ' + '; + } + $output .= &mt($item->{'header'}->[0]->{'col2'}).'
+
'; - $output .= ' - + if ($action eq 'classlists') { + $output .= ' + '; if ($action eq 'classlists') { $output .= &print_classlists('middle',$cdom,$settings,$itemtext,\$rowtotal,$crstype). '
'.&mt($item->{'header'}->[1]->{'col1'}).''.&mt($item->{'header'}->[1]->{'col2'}).''; + } else { + $output .= ' + '; + } + $output .= &mt($item->{'header'}->[1]->{'col2'}).'
+
'; - if (exists $item->{'header'}->[0]->{'col1'} || - exists $item->{'header'}->[0]->{'col2'}) { + if (exists $item->{'header'}->[2]->{'col1'} || + exists $item->{'header'}->[2]->{'col2'}) { $output .= ' - - + + '; } } } else { $output .= ' + + + +
'.&mt($item->{'header'}->[0]->{'col1'}).''.&mt($item->{'header'}->[0]->{'col2'}).''.&mt($item->{'header'}->[2]->{'col1'}).''.&mt($item->{'header'}->[2]->{'col2'}).'
'; if (exists $item->{'header'}->[0]->{'col1'} || exists $item->{'header'}->[0]->{'col2'}) { $output .= ' - - + '; + if (($action eq 'courseinfo') || ($action eq 'localization') || + ($action eq 'print_discussion')) { + $output .= ''; } } @@ -607,7 +658,7 @@ sub print_config_box { $output .= &print_feedback('bottom',$cdom,$settings,$ordered,$itemtext,\$rowtotal); } elsif ($action eq 'discussion') { $output .= &print_discussion($cdom,$settings,$ordered,$itemtext,\$rowtotal); - } elsif ($action eq 'classlists') { + } elsif (($action eq 'classlists') || ($action eq 'viewableroster')) { $output .= &print_classlists('bottom',$cdom,$settings,$itemtext,\$rowtotal,$crstype); } elsif ($action eq 'appearance') { $output .= &print_appearance($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype); @@ -624,7 +675,9 @@ sub print_config_box { } $output .= '
'.&mt($item->{'header'}->[0]->{'col1'}).''.&mt($item->{'header'}->[0]->{'col2'}).''.&mt($item->{'header'}->[0]->{'col1'}).''; + } else { + $output .= ''; + } + $output .= &mt($item->{'header'}->[0]->{'col2'}).'
-'; +

'; return ($output,$rowtotal); } @@ -648,7 +701,27 @@ sub process_changes { } } } elsif (ref($item->{'ordered'}) eq 'ARRAY') { - @ordered = @{$item->{'ordered'}}; + if ($action eq 'courseinfo') { + my ($can_toggle_cat,$can_categorize) = + &can_modify_catsettings($cdom,$crstype); + foreach my $entry (@{$item->{'ordered'}}) { + next if (($entry eq 'hidefromcat') && + (!$can_toggle_cat)); + next if (($entry eq 'categories') && + (!$can_categorize)); + next if (($entry eq 'loncaparev') || + ($entry eq 'owner') || + ($entry eq 'clonedfrom')); + push(@ordered,$entry); + } + } elsif ($action eq 'classlists') { + foreach my $entry (@{$item->{'ordered'}}) { + next if ($entry eq 'defaultcredits'); + push(@ordered,$entry); + } + } else { + @ordered = @{$item->{'ordered'}}; + } } if (@ordered > 0) { if ($action eq 'feedback') { @@ -690,7 +763,6 @@ sub process_changes { } } else { foreach my $entry (@ordered) { - next if (($entry eq 'loncaparev') || ($entry eq 'owner')); if ($entry eq 'cloners') { if ($env{'form.cloners_all'}) { $newvalues{$entry} = '*'; @@ -957,6 +1029,35 @@ sub process_changes { } } $newvalues{$entry} =~ s/,$//; + } elsif ($entry eq 'discussion_post_fonts') { + my ($classorder,$classtitles) = &discussion_vote_classes(); + my $fontchange = 0; + foreach my $class (@{$classorder}) { + my $ext_entry = $entry.'_'.$class; + my $size = $env{'form.'.$ext_entry.'_size'}; + my $unit = $env{'form.'.$ext_entry.'_unit'}; + my $weight = $env{'form.'.$ext_entry.'_weight'}; + my $style = $env{'form.'.$ext_entry.'_style'}; + my $other = $env{'form.'.$ext_entry.'_other'}; + $size =~ s/,//g; + $unit =~ s/,//g; + $weight =~ s/,//g; + $style =~ s/,//g; + $other =~ s/[^\w;:\s\-\%.]//g; + $other =~ s/(^\s+|\s+$)//g; + $newvalues{$ext_entry} = join(',',($size.$unit,$weight,$style,$other)); + my $current = $values->{$ext_entry}; + if ($values->{$ext_entry} eq '') { + $current = ',,,'; + } + if ($newvalues{$ext_entry} ne $current) { + $changes->{$ext_entry} = $newvalues{$ext_entry}; + $fontchange ++; + } + } + if ($fontchange) { + $changes->{$entry} = 1; + } } elsif ($entry eq 'nothideprivileged') { my @curr_nothide; my @new_nothide; @@ -1031,36 +1132,47 @@ sub process_changes { my $newtext = $maxnum-1; $newhdr[$env{'form.printfmthdr_pos_'.$newtext}] = $env{'form.printfmthdr_text_'.$newtext}; $newvalues{$entry} = join('',@newhdr); - } elsif ($entry eq 'languages') { - my $langstr; + } elsif (($entry eq 'languages') || + ($entry eq 'checkforpriv')) { + my $settings; my $total = $env{'form.'.$entry.'_total'}; if ($total) { my @deletes = &Apache::loncommon::get_env_multiple('form.'.$entry.'_delete'); for (my $i=0; $i<$total; $i++) { unless (grep(/^$i$/,@deletes)) { - $langstr .= $env{'form.'.$entry.'_'.$i}.','; + $settings .= $env{'form.'.$entry.'_'.$i}.','; } } } else { $total = 0; } if ($env{'form.'.$entry.'_'.$total} ne '') { - my $newlang = $env{'form.'.$entry.'_'.$total}; - my %langchoices = &get_lang_choices(); - if ($langchoices{$newlang}) { - $langstr .= $newlang; + my $new = $env{'form.'.$entry.'_'.$total}; + if ($entry eq 'languages') { + my %langchoices = &get_lang_choices(); + if ($langchoices{$new}) { + $settings .= $new; + } else { + $settings =~ s/,$//; + $disallowed->{'localization'}{$entry} = $new; + } } else { - $langstr =~ s/,$//; - $disallowed->{'localization'}{$entry} = $newlang; + my %domains=map { $_ => 1; } &Apache::lonnet::all_domains(); + if ($domains{$new}) { + $settings .= $new; + } else { + $settings =~ s/,$//; + $disallowed->{'classlists'}{$entry} = $new; + } } } else { - $langstr =~ s/,$//; + $settings =~ s/,$//; } - $newvalues{$entry} = $langstr; + $newvalues{$entry} = $settings; } else { $newvalues{$entry} = $env{'form.'.$entry}; } - unless ($entry eq 'co-owners') { + unless (($entry eq 'co-owners') || ($entry eq 'discussion_post_fonts')) { if ($newvalues{$entry} ne $values->{$entry}) { $changes->{$entry} = $newvalues{$entry}; } @@ -1187,7 +1299,7 @@ sub store_changes { my ($displayname,$text); $text = $prefs->{$item}->{'itemtext'}{$key}; my $displayval; - unless ($key eq 'co-owners') { + unless (($key eq 'co-owners') || ($key eq 'discussion_post_fonts')) { $displayval = $changes->{$item}{$key}; } if ($item eq 'feedback') { @@ -1223,6 +1335,36 @@ sub store_changes { } $displayval = join(', ',@longroles); } + } elsif ($key eq 'discussion_post_fonts') { + my ($classorder,$classtitles)=&discussion_vote_classes(); + my ($styleorder,$styleitems)=&discussion_vote_styles(); + my $count = 1; + my $total = scalar(keys(%{$changes->{$item}})); + foreach my $class (@{$classorder}) { + $count ++; + next unless ($changes->{$item}{$key.'_'.$class}); + my @vals = split(/,/,$changes->{$item}{$key.'_'.$class}); + my $showval = ''; + for (my $i=0; $i<@{$styleorder}; $i++) { + if ($vals[$i] ne '') { + $showval .= 'font-'.$styleorder->[$i].': '.$vals[$i].'; '; + } + } + if ($vals[3] ne '') { + $showval .= $vals[3]; + } + if ($showval ne '') { + $displayval .= $classtitles->{$class}.':{ '. + $showval.'}'; + $storehash{$key.'_'.$class} = $changes->{$item}{$key.'_'.$class}; + } else { + $displayval .= $classtitles->{$class}.': '.&mt('None'); + push(@delkeys,$key.'_'.$class); + } + unless ($count == $total) { + $displayval .= (' 'x2); + } + } } $displayname = &mt($text); } @@ -1322,7 +1464,9 @@ sub store_changes { } } } else { - $storehash{$key} = $changes->{$item}{$key}; + unless ($key eq 'discussion_post_fonts') { + $storehash{$key} = $changes->{$item}{$key}; + } } } if ($key eq 'cloners') { @@ -1346,9 +1490,9 @@ sub store_changes { $output .= ''; } else { if ($crstype eq 'Community') { - $output = &mt('No changes made to community settings.'); + $output .= &mt('No changes made to community settings.'); } else { - $output = &mt('No changes made to course settings.'); + $output .= &mt('No changes made to course settings.'); } } } @@ -1556,9 +1700,24 @@ function loncaparevinfo() { } ENDSCRIPT } + my $cnum = $env{'course.'.$cid.'.num'}; + my $syllabus_js = <'."\n".$stubrowse_js."\n"; + $cloners_js."\n". + $syllabus_js."\n".'//]]>'."\n". + ''."\n".$stubrowse_js."\n"; return $jscript; } @@ -1668,6 +1827,7 @@ sub print_courseinfo { } my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom,$crstype); + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; my $replace; if ($crstype eq 'Community') { @@ -1684,13 +1844,13 @@ sub print_courseinfo { &mt('Modification may make assessment data inaccessible!'). '', input => 'textbox', - size => '40', + size => '55', advanced => 1 }, 'description' => { text => ''.&mt($itemtext->{'description'}).'', input => 'textbox', - size => '25', + size => '55', }, 'owner' => { text => ''.&mt($itemtext->{'owner'}).'', @@ -1698,18 +1858,23 @@ sub print_courseinfo { 'co-owners' => { text => ''.&mt($itemtext->{'co-owners'}).'', }, + 'clonedfrom' => { + text => ''.&mt($itemtext->{'clonedfrom'}).'', + }, 'courseid' => { text => ''.&mt($itemtext->{'courseid'}).'
'.'('. &mt('internal, optional').')', input => 'textbox', size => '25', }, + 'uniquecode' => { + text => ''.&mt($itemtext->{'uniquecode'}).'', + }, 'cloners' => { text => ''.&mt($itemtext->{'cloners'}).'
'. &mt('Owner and Coordinators included automatically'), input => 'textbox', - size => '40', - advanced => 1 + size => '40' }, 'rolenames' => { text => ''.&mt($itemtext->{'rolenames'}).'
'. @@ -1719,10 +1884,10 @@ sub print_courseinfo { advanced => 1 }, 'externalsyllabus' => { - text => ''.&mt($itemtext->{'externalsyllabus'}).'
('. - &mt('not using syllabus template)'), - input => 'textbox', - size => '40', + text => ''.&mt($itemtext->{'externalsyllabus'}).'
'. + &mt('(Syllabus type in use)').(' ' x2). + &mt('[_1]Edit[_2]','', + ''), }, 'hidefromcat' => { text => ''.&mt($itemtext->{'hidefromcat'}).'
'. @@ -1738,27 +1903,37 @@ sub print_courseinfo { 'loncaparev' => { text => ''.&mt($itemtext->{'loncaparev'}).'', }, + 'defaultcredits' => { + text => ''.&mt($itemtext->{'defaultcredits'}).'', + }, ); my $datatable; my $count = 0; foreach my $item (@{$ordered}) { + my $colspan; if ($item eq 'hidefromcat') { next if (!$can_toggle_cat); } elsif ($item eq 'categories') { next if (!$can_categorize); + } elsif ($item eq 'uniquecode') { + next if (!$env{'course.'.$env{'request.course.id'}.'.internal.uniquecode'}); + } + unless (($item eq 'cloners') || ($item eq 'rolenames')) { + $colspan = 2; } $count ++; if (exists $items{$item}{advanced} && $items{$item}{advanced} == 1) { - $datatable .= &item_table_row_start($items{$item}{text},$count,"advanced"); + $datatable .= &item_table_row_start($items{$item}{text},$count,"advanced",$colspan); } else { - $datatable .= &item_table_row_start($items{$item}{text},$count); + $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan); } if ($items{$item}{input} eq 'radio') { $datatable .= &yesno_radio($item,$settings); } elsif ($item eq 'cloners') { my $includeempty = 1; my $num = 0; - $datatable .= &Apache::loncommon::start_data_table(). + $datatable .= '
'. + &Apache::loncommon::start_data_table(). &Apache::loncommon::start_data_table_row(). '
'.&mt('Or'). - '
'. + '
'.&mt('Or'). + '
'. &Apache::loncommon::start_data_table(); my @cloners; if ($settings->{$item} eq '') { @@ -1829,8 +2004,8 @@ sub print_courseinfo { ''. ''.&Apache::loncommon::end_data_table_row(). &Apache::loncommon::end_data_table(). - '
'.&mt('And'). - '
'. + '
'.&mt('And'). + '
'. &Apache::loncommon::start_data_table(). &Apache::loncommon::start_data_table_row(). ''. @@ -1841,7 +2016,8 @@ sub print_courseinfo { ''.&Apache::loncommon::end_data_table_row(). &Apache::loncommon::end_data_table(); } elsif ($item eq 'rolenames') { - $datatable .= &Apache::loncommon::start_data_table(); + $datatable .= ''. + &Apache::loncommon::start_data_table(); my @roles; if ($crstype eq 'Community') { @roles = ('co'); @@ -1861,7 +2037,7 @@ sub print_courseinfo { } $datatable .= &Apache::loncommon::end_data_table().''; } elsif ($item eq 'categories') { - my $launcher = 'onFocus="this.blur();javascript:catsbrowser();";'; + my $launcher = 'onfocus="this.blur();javascript:catsbrowser();"'; $datatable .= ''. &Apache::lonhtmlcommon::textbox($item.'_display',$settings->{$item}, $items{$item}{size},$launcher); @@ -1876,8 +2052,22 @@ sub print_courseinfo { $owner = &mt('None specified'); } $datatable .= $owner; + } elsif ($item eq 'clonedfrom') { + my $clonesrc = $env{'course.'.$env{'request.course.id'}.'.clonedfrom'}; + my $clonedfrom = &mt('None'); + if ($clonesrc =~ m{/$match_domain/$match_courseid}) { + my %clonesrcinfo = &Apache::lonnet::coursedescription($clonesrc); + if ($clonesrcinfo{'description'}) { + $clonedfrom = $clonesrcinfo{'description'}.' '.($clonesrc); + } + } + $datatable .= $clonedfrom; + } elsif ($item eq 'uniquecode') { + my $code = $env{'course.'.$env{'request.course.id'}.'.internal.uniquecode'}; + if ($code) { + $datatable .= $code; + } } elsif ($item eq 'co-owners') { - my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; my $coowners = $env{'course.'.$env{'request.course.id'}.'.internal.co-owners'}; my @currcoown; if ($coowners) { @@ -1896,12 +2086,42 @@ sub print_courseinfo { $datatable .= &manage_coownership($cnum,$cdom,@currcoown); } } + } elsif ($item eq 'externalsyllabus') { + my $external = $env{'course.'.$env{'request.course.id'}.'.externalsyllabus'}; + my $uploaded = $env{'course.'.$env{'request.course.id'}.'.uploadedsyllabus'}; + my $minimal = $env{'course.'.$env{'request.course.id'}.'.minimalsyllabus'}; + if (($minimal =~/\w/) || ($uploaded =~/\w/)) { + if ($minimal =~/\w/) { + if ($external =~ m{\Q$minimal\E$}) { + undef($external); + } + } elsif ($uploaded =~/\w/) { + if ($external =~ m{\Q$uploaded\E$}) { + undef($external); + } + } + } elsif ($external!~/\w/) { + undef($external); + } + if ($external) { + $datatable .= &mt('External URL'); + } elsif ($minimal) { + $datatable .= &mt('Minimal template'); + } elsif ($uploaded) { + $datatable .= &mt('Uploaded file'); + } else { + $datatable .= &mt('Standard template'); + } + $datatable .= (' ' x 2). + &mt('[_1]View[_2]', + '', + ''); } elsif ($item eq 'loncaparev') { my $loncaparev = $env{'course.'.$env{'request.course.id'}.'.internal.releaserequired'}; my $showreqd; if ($loncaparev) { $showreqd = &mt('[_1] or newer',$loncaparev).' '. - &mt('Details').'', + &mt('Details').''; } else { $showreqd = &mt('No specific version required'); } @@ -2069,23 +2289,21 @@ sub display_loncaparev_constraints { my $cdom = $env{'course.'.$cid.'.domain'}; my $cnum = $env{'course.'.$cid.'.num'}; my $output; + my %lt = &Apache::lonlocal::texthash ( + 'all' => 'all', + 'section/group' => 'section/group', + 'user' => 'user', + ); my (%checkparms,%checkresponsetypes,%checkcrstypes,%anonsurvey,%randomizetry); &Apache::loncommon::build_release_hashes(\%checkparms,\%checkresponsetypes, \%checkcrstypes,\%anonsurvey,\%randomizetry); - -# my %paramstrings = -# ('string_questiontype' => -# [[ 'anonsurveycred', 'Anonymous Survey'], -# [ 'anonsurvey', 'Anonymous Survey'], -# [ 'randomizetry', 'New Randomization Each N Tries']] -# ); if (defined($checkcrstypes{$crstype})) { $output .= '

'.&mt('Course type: [_1] requires [_2] or newer',$crstype, $checkcrstypes{$crstype}).'

'; } my (%fromparam,%rowspan,%bymap,%byresource,@scopeorder,%toshow,%allmaps, %byresponsetype,%bysubmission); - @scopeorder = ('course','section/group','user'); + @scopeorder = ('all','section/group','user'); my $resourcedata = &Apache::lonparmset::readdata($cnum,$cdom); if (ref($resourcedata) eq 'HASH') { foreach my $key (keys(%{$resourcedata})) { @@ -2093,6 +2311,13 @@ sub display_loncaparev_constraints { if ($key =~ /(\Q$item\E)$/) { if (ref($checkparms{$item}) eq 'ARRAY') { my $value = $resourcedata->{$key}; + if ($item eq 'examcode') { + if (&Apache::lonnet::validCODE($value)) { + $value = 'valid'; + } else { + $value = ''; + } + } my ($middle,$scope,$which,$level,$map,$resource); if (grep(/^\Q$value\E$/,@{$checkparms{$item}})) { my $stdtype = &Apache::lonparmset::standard_parameter_types($item); @@ -2109,12 +2334,12 @@ sub display_loncaparev_constraints { $which = $2; $scope = 'section/group'; } else { - $scope = 'course'; + $scope = 'all'; } my $what="$stdname=$valname"; if ($key =~ /^\Q$start$middle\E\w+\.\Q$item\E$/) { $level = 'general'; - if ($scope eq 'course') { + if ($scope eq 'all') { if (ref($fromparam{$rev}{$scope}) eq 'ARRAY') { unless(grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}})) { push(@{$fromparam{$rev}{$scope}},$what); @@ -2135,7 +2360,7 @@ sub display_loncaparev_constraints { } elsif ($key =~ /^\Q$start$middle\E(.+)___\(all\).\w+\.\Q$item\E$/) { $level = 'folder'; $map = $1; - if ($scope eq 'course') { + if ($scope eq 'all') { if (ref($bymap{$map}{$rev}{$scope}) eq 'ARRAY') { unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}})) { push(@{$bymap{$map}{$rev}{$scope}},$what); @@ -2155,7 +2380,7 @@ sub display_loncaparev_constraints { } elsif ($key =~ /^\Q$start$middle\E(.+)\.\w+\.\Q$item\E$/) { $level = 'resource'; $resource = $1; - if ($scope eq 'course') { + if ($scope eq 'all') { if (ref($byresource{$resource}{$rev}{$scope}) eq 'ARRAY') { unless(grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}})) { push(@{$byresource{$resource}{$rev}{$scope}},$what); @@ -2194,7 +2419,7 @@ sub display_loncaparev_constraints { if ($newrow) { $output .= &Apache::loncommon::continue_data_table_row(); } - $output .= ''.$scope.''; + $output .= ''.$lt{$scope}.''; foreach my $which (sort(keys(%{$fromparam{$rev}{$scope}}))) { $output .= ''.$which.''. join('
',@{$fromparam{$rev}{$scope}{$which}}).''; @@ -2205,7 +2430,7 @@ sub display_loncaparev_constraints { if ($newrow) { $output .= &Apache::loncommon::continue_data_table_row(); } - $output .= ''.$scope.' '. + $output .= ''.$lt{$scope}.' '. join('
',@{$fromparam{$rev}{$scope}}).''. &Apache::loncommon::end_data_table_row(); $newrow = 1; @@ -2311,7 +2536,7 @@ sub display_loncaparev_constraints { $r->print($output); if (defined($navmap)) { &show_contents_view($r,$navmap,$cid,\%toshow,\%bymap,\%byresource,\%bysubmission, - \%byresponsetype,\@scopeorder); + \%byresponsetype,\@scopeorder,\%lt); } $r->print('

'); } else { @@ -2324,7 +2549,8 @@ sub display_loncaparev_constraints { } sub show_contents_view { - my ($r,$navmap,$cid,$toshow,$bymap,$byresource,$bysubmission,$byresponsetype,$scopeorder) = @_; + my ($r,$navmap,$cid,$toshow,$bymap,$byresource,$bysubmission,$byresponsetype, + $scopeorder,$lt) = @_; if ((keys(%{$toshow}) > 0) || (keys(%{$byresource}) > 0) || (keys(%{$bysubmission}) > 0) || (keys(%{$byresponsetype}) > 0)) { my $location=&Apache::loncommon::lonhttpdurl("/adm/lonIcons"); @@ -2337,8 +2563,8 @@ sub show_contents_view { ''.&mt('Attribute/Setting').''. &Apache::loncommon::end_data_table_header_row(). &Apache::loncommon::start_data_table_row(). - ' '.$icon.' '.&mt('Main Course Documents').''); - &releases_by_map($r,$bymap,$topmap,$scopeorder); + ' '.$icon.' '.&mt('Main Content').''); + &releases_by_map($r,$bymap,$topmap,$scopeorder,$lt); $r->print(&Apache::loncommon::end_data_table_row()); my $it=$navmap->getIterator(undef,undef,undef,1,1,undef); my $curRes; @@ -2377,7 +2603,7 @@ sub show_contents_view { } $r->print(&Apache::loncommon::start_data_table_row(). ''.$indent.$icon.' '.$title.''); - &releases_by_map($r,$bymap,$url,$scopeorder); + &releases_by_map($r,$bymap,$url,$scopeorder,$lt); $r->print(&Apache::loncommon::end_data_table_row()); } else { my $rowspan; @@ -2406,7 +2632,7 @@ sub show_contents_view { $r->print(''); foreach my $scope (@{$scopeorder}) { if (ref($byresource->{$symb}{$rev}{$scope}) eq 'HASH') { - $r->print(''); + $r->print(''); foreach my $which (sort(keys(%{$byresource->{$symb}{$rev}{$scope}}))) { $r->print(''); } elsif (ref($byresource->{$symb}{$rev}{$scope}) eq 'ARRAY') { - $r->print(''. + $r->print(''. ''); } @@ -2463,7 +2689,7 @@ sub show_contents_view { } sub releases_by_map { - my ($r,$bymap,$url,$scopeorder) = @_; + my ($r,$bymap,$url,$scopeorder,$lt) = @_; return unless ((ref($bymap) eq 'HASH') && (ref($scopeorder) eq 'ARRAY')); if (ref($bymap->{$url}) eq 'HASH') { foreach my $rev (sort(keys(%{$bymap->{$url}}))) { @@ -2472,7 +2698,7 @@ sub releases_by_map { $r->print('
'.&mt('Setting - scope: [_1]',$scope).'
'.&mt('Setting - scope: [_1]',$lt->{$scope}).''.$which.''. join('
',@{$byresource->{$symb}{$rev}{$scope}{$which}}). @@ -2414,7 +2640,7 @@ sub show_contents_view { } $r->print('
'.&mt('Setting - scope: [_1]',$scope).'
'.&mt('Setting - scope: [_1]',$lt->{$scope}).' '. join('
',@{$byresource->{$symb}{$rev}{$scope}}).'
'); foreach my $scope (@{$scopeorder}) { if (ref($bymap->{$url}{$rev}{$scope}) eq 'HASH') { - $r->print(''); + $r->print(''); foreach my $which (sort(keys(%{$bymap->{$url}{$rev}{$scope}}))) { $r->print(''); } elsif (ref($bymap->{$url}{$rev}{$scope}) eq 'ARRAY') { - $r->print(''); } @@ -2515,7 +2741,7 @@ sub get_param_description { sub show_autocoowners { my (@currcoown) = @_; - my $output = ''.&mt('Co-ownership is set automatically when a Course Coordinator role is assigned to official course personnel (from institutional data).').''; + my $output = ''.&mt('Co-ownership is set automatically when a Course Coordinator role[_1] is assigned to official course personnel (from institutional data).','
').'
'; if (@currcoown > 0) { $output .= '
'.&mt('Current co-owners are:').' '. join(', ',map { &Apache::loncommon::plainname(split(':',$_)); } (@currcoown)); @@ -2659,7 +2885,11 @@ sub print_localization { my $count = 0; foreach my $item (@{$ordered}) { $count ++; - $datatable .= &item_table_row_start($items{$item}{text},$count); + my $colspan; + unless ($item eq 'languages') { + $colspan = 2; + } + $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan); if ($item eq 'timezone') { my $includeempty = 1; my $timezone = &Apache::lonlocal::gettimezone(); @@ -2678,12 +2908,13 @@ sub print_localization { undef,$includeempty); } else { if ($settings->{$item} eq '') { - $datatable .= + $datatable .= ''.&Apache::loncommon::end_data_table_row(). - &Apache::loncommon::end_data_table(); + &Apache::loncommon::end_data_table().'
'; } } $datatable .= &item_table_row_end(); @@ -2772,11 +3003,12 @@ sub print_feedback { 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"); + $datatable .= &item_table_row_start($items{$item}{text}."
(Custom text)",$count, "advanced",2); } if ($position eq 'top') { my $includeempty = 0; - $datatable .= &user_table($cdom,$item,\@sections, + $datatable .= '
'.&mt('Setting - scope: [_1]',$scope).'
'.&mt('Setting - scope: [_1]',$lt->{$scope}).''.$which.''. join('
',@{$bymap->{$url}{$rev}{$scope}{$which}}). @@ -2480,7 +2706,7 @@ sub releases_by_map { } $r->print('
'.&mt('Setting - scope: [_1]',$scope). + $r->print('
'.&mt('Setting - scope: [_1]',$lt->{$scope}). ' '. join('
',@{$bymap->{$url}{$rev}{$scope}}).'
'. &Apache::loncommon::select_language('languages_0','',1); } else { my $num = 0; my @languages = split(/\s*[,;:]\s*/,$settings->{$item}); - $datatable .= &Apache::loncommon::start_data_table(); + $datatable .= '
'. + &Apache::loncommon::start_data_table(); if (@languages > 0) { my %langchoices = &get_lang_choices(); foreach my $lang (@languages) { @@ -2710,7 +2941,7 @@ sub print_localization { &Apache::loncommon::select_language('languages_'.$num,'',1). ''. '
'. + &user_table($cdom,$item,\@sections, $settings->{$item},\%lt); } else { $datatable .= &Apache::lonhtmlcommon::textbox($item.'.text', @@ -2796,7 +3028,7 @@ sub user_table { } else { my $num = 0; my @curr = split(/,/,$currvalue); - $output .= ''; + $output .= '
'; my ($currusers); foreach my $val (@curr) { next if ($val eq ''); @@ -2942,6 +3174,11 @@ sub print_discussion { text => ''.&mt($itemtext->{'allow_discussion_post_editing'}).'', input => 'checkbox', }, + 'discussion_post_fonts' => { + text => ''.&mt($itemtext->{'discussion_post_fonts'}).'', + input => 'textbox', + size => '20', + }, ); my $datatable; my $count; @@ -2955,32 +3192,52 @@ sub print_discussion { del => 'Delete?', sec => 'Sections:', ); - foreach my $item (@{$ordered}) { $count ++; - $datatable .= &item_table_row_start($items{$item}{text},$count); + my $colspan; + if ($item eq 'allow_limited_html_in_feedback') { + $colspan = 2; + } + $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan); if ($item eq 'plc.roles.denied') { - $datatable .= '
'.&role_checkboxes($cdom,$cnum,$item,$settings). + $datatable .= '
'. + ''.&role_checkboxes($cdom,$cnum,$item,$settings). '
'; } elsif ($item eq 'plc.users.denied') { - $datatable .= &user_table($cdom,$item,undef, + $datatable .= '
'. + &user_table($cdom,$item,undef, $settings->{$item},\%lt); } elsif ($item eq 'pch.roles.denied') { - $datatable .= ''.&role_checkboxes($cdom,$cnum,$item,$settings). + $datatable .= ''. &Apache::loncommon::end_data_table_row(). &role_checkboxes($cdom,$cnum,$item,$settings,1). - &Apache::loncommon::end_data_table(); + &Apache::loncommon::end_data_table().'
'; + } elsif ($item eq 'discussion_post_fonts') { + $datatable .= ''. + ''. + ''. + ''. + ''. + &Apache::loncommon::end_data_table_row(). + &set_discussion_fonts($cdom,$cnum,$item,$settings). + &Apache::loncommon::end_data_table().'
'; } $datatable .= &item_table_row_end(); } @@ -3102,14 +3359,86 @@ sub role_checkboxes { return $output; } +sub set_discussion_fonts { + my ($cdom,$cnum,$item,$settings) = @_; + my ($classorder,$classtitles) = &discussion_vote_classes(); + my ($styleorder,$styleitems) = &discussion_vote_styles(); + my $output; + if (ref($classorder) eq 'ARRAY') { + foreach my $cat (@{$classorder}) { + my %curr = (); + ($curr{'size'},$curr{'weight'},$curr{'style'},$curr{'other'}) = + split(/,/,$settings->{'discussion_post_fonts_'.$cat}); + $output .= &Apache::loncommon::start_data_table_row(). + ''; + if (ref($styleorder) eq 'ARRAY') { + foreach my $item (@{$styleorder}) { + $output .= ''; + } + $output .= &Apache::loncommon::end_data_table_row(); + } + return $output; +} + +sub discussion_vote_classes { + my $classorder = ['twoplus','oneplus','zero','oneminus','twominus']; + my %classtitles = &Apache::lonlocal::texthash( + 'twoplus' => 'Two sigma above mean', + 'oneplus' => 'One sigma above mean', + 'zero' => 'Within one sigma of mean', + 'oneminus' => 'One sigma below mean', + 'twominus' => 'Two sigma below mean', + ); + return ($classorder,\%classtitles); +} + +sub discussion_vote_styles { + my $styleorder = ['size','weight','style']; + my $styleitems = { + size => ['','px','%','xx-small','x-small','small','medium','large', + 'x-large','xx-large','smaller','larger'], + weight => ['','normal','bold','bolder','lighter','100','200','300','400', + '500','600','700','800','900'], + style => ['','normal','italic','oblique'], + }; + return ($styleorder,$styleitems); +} + sub print_classlists { my ($position,$cdom,$settings,$itemtext,$rowtotal,$crstype) = @_; my @ordered; if ($position eq 'top') { @ordered = ('default_enrollment_start_date', 'default_enrollment_end_date'); + if ($crstype eq 'Course') { + push(@ordered,'defaultcredits'); + } } elsif ($position eq 'middle') { - @ordered = ('nothideprivileged'); + @ordered = ('nothideprivileged','checkforpriv'); } else { @ordered = ('student_classlist_view', 'student_classlist_opt_in', @@ -3140,12 +3469,20 @@ sub print_classlists { text => ''.&mt($itemtext->{'default_enrollment_end_date'}).'', input => 'dates', }, - + 'defaultcredits' => { + text => ''.&mt($itemtext->{'defaultcredits'}).'', + }, + 'nothideprivileged' => { text => ''.&mt($itemtext->{'nothideprivileged'}).'', input => 'checkbox', }, + 'checkforpriv' => { + text => ''.&mt($itemtext->{'checkforpriv'}).'', + input => 'selectbox', + }, + 'student_classlist_view' => { text => ''.&mt($itemtext->{'student_classlist_view'}).'', input => 'selectbox', @@ -3166,7 +3503,7 @@ sub print_classlists { ($settings->{'student_classlist_view'} eq 'section')) { $settings->{'student_classlist_view'} = 'disabled'; } - return &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype); + return &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype,'classlists'); } sub print_appearance { @@ -3202,11 +3539,12 @@ sub print_appearance { text => ''.&mt($itemtext->{'texengine'}).'', input => 'selectbox', options => { + MathJax => 'MathJax', jsMath => 'jsMath', mimetex => &mt('Convert to Images'), tth => &mt('TeX to HTML'), }, - order => ['jsMath','mimetex','tth'], + order => ['MathJax','jsMath','mimetex','tth'], nullval => $mathdef, }, 'tthoptions' => { @@ -3215,7 +3553,7 @@ sub print_appearance { size => 40, }, ); - return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype); + return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'appearance'); } sub print_grading { @@ -3252,6 +3590,7 @@ sub print_grading { '64bit5' => '64bit5', }, order => ['32bit','64bit','64bit2','64bit3','64bit4','64bit5'], + advanced => 1 }, 'receiptalg' => { text => ''.&mt($itemtext->{'receiptalg'}).'
'. @@ -3263,13 +3602,14 @@ sub print_grading { receipt3 => 'receipt3', }, order => ['receipt','receipt2','receipt3'], + advanced => 1 }, 'disablesigfigs' => { text => ''.&mt($itemtext->{'disablesigfigs'}).'', input => 'radio', }, ); - return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype); + return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'grading'); } sub print_printouts { @@ -3301,7 +3641,7 @@ sub print_printouts { A6 => &mt('A6').' [105x148 mm]', }, order => ['Letter','Legal','Tabloid','Executive','A2','A3','A4','A5','A6'], - nullval => 'None specified', + nullval => &mt('None specified'), }, print_header_format => { text => ''.&mt($itemtext->{'print_header_format'}).'', @@ -3319,10 +3659,10 @@ sub print_printouts { 0 => &mt('No'), }, order => ['1','0'], - nullval => 'None specified - use domain default', + nullval => &mt('None specified - use domain default'), } ); - return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype); + return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'printouts'); } sub print_spreadsheet { @@ -3358,7 +3698,7 @@ sub print_spreadsheet { input => 'radio', }, ); - return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype); + return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'spreadsheet'); } sub print_bridgetasks { @@ -3400,7 +3740,7 @@ sub print_bridgetasks { input => 'radio', }, ); - return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype); + return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'bridgetasks'); } sub print_other { @@ -3425,7 +3765,7 @@ sub print_other { input => 'textbox', size => '30', }; - my $output = &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype); + my $output = &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype,'other'); } sub get_other_items { @@ -3442,7 +3782,10 @@ sub get_other_items { unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./) || ($parameter =~ m/^selfenroll_/) || ($parameter =~ /_selfenroll$/) || ($parameter eq 'type') || - ($parameter =~ m/^(cc|co|in|ta|ep|ad|st)\.plaintext$/)) { + ($parameter =~ m/^(cc|co|in|ta|ep|ad|st)\.plaintext$/) + || ($parameter =~ m/^discussion_post_fonts/) || + ($parameter =~ m{^(minimal|updated|uploaded|external)syllabus$}) || + ($parameter eq 'clonedfrom')) { push(@ordered,$parameter); } } @@ -3451,13 +3794,18 @@ sub get_other_items { } sub item_table_row_start { - my ($text,$count,$add_class) = @_; + my ($text,$count,$add_class,$colspan) = @_; my $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 .= ''."\n". + ''; + if ($colspan) { + $output .= '
'. + ''.&role_checkboxes($cdom,$cnum,$item,$settings). '
'; } elsif ($item eq 'pch.users.denied') { - $datatable .= &user_table($cdom,$item,undef, + $datatable .= '
'. + &user_table($cdom,$item,undef, $settings->{$item},\%lt); } elsif ($item eq 'allow_limited_html_in_feedback') { $datatable .= &yesno_radio($item,$settings); } elsif ($item eq 'allow_discussion_post_editing') { - $datatable .= &Apache::loncommon::start_data_table(). + $datatable .= '
'. + &Apache::loncommon::start_data_table(). &Apache::loncommon::start_data_table_row(). '
'.&mt('Role').''. &mt('Sections').'
'. + &Apache::loncommon::start_data_table(). + &Apache::loncommon::start_data_table_row(). + '
'.&mt('Sum of likes/dislikes').''.&mt('font-size').''.&mt('font-weight').''.&mt('font-style').''.&mt('Other css').''.$classtitles->{$cat}.''; + my $selitem = $item; + if ($item eq 'size') { + my ($currsize,$currunit); + if ($curr{'size'} =~ /^(\d+)(px|%)$/) { + ($currsize,$currunit) = ($1,$2); + $curr{'size'} = $currunit; + } + $output .= ''. + ' '; + $selitem = 'unit'; + } + if ((ref($styleitems) eq 'HASH') && (ref($styleitems->{$item}) eq 'ARRAY')) { + $output .= '
'.$text. - ''; + my $css_class = ($count % 2) ? 'LC_odd_row' : 'LC_even_row'; + $css_class = (join(' ',$css_class,$add_class)) unless ($add_class eq ''); + $output .= '
'.$text. + ''; + } else { + $output .= ''; + } return $output; } @@ -3528,15 +3876,35 @@ sub select_from_options { } sub make_item_rows { - my ($cdom,$items,$ordered,$settings,$rowtotal,$crstype) = @_; + my ($cdom,$items,$ordered,$settings,$rowtotal,$crstype,$caller) = @_; my $datatable; if ((ref($items) eq 'HASH') && (ref($ordered) eq 'ARRAY')) { my $count = 0; foreach my $item (@{$ordered}) { $count ++; - $datatable .= &item_table_row_start($items->{$item}{text},$count); - if ($item eq 'nothideprivileged') { + my $colspan; + if ((($caller eq 'classlists') && ($item eq 'nothideprivileged')) || + (($caller eq 'printouts') && ($item ne 'print_header_format'))) { + $colspan = 2; + } + if (exists $items->{$item}{advanced} && $items->{$item}{advanced} == 1) { + $datatable .= &item_table_row_start($items->{$item}{text},$count,"advanced",$colspan); + } else { + $datatable .= &item_table_row_start($items->{$item}{text},$count,undef,$colspan); + } + if ($item eq 'defaultcredits') { + my $defaultcredits = $env{'course.'.$env{'request.course.id'}.'.internal.defaultcredits'}; + my $showcredits; + if ($defaultcredits ne '') { + $showcredits = &mt('Default is [quant,_1,credit]',$defaultcredits); + } else { + $showcredits = &mt('No default set'); + } + $datatable .= $showcredits; + } elsif ($item eq 'nothideprivileged') { $datatable .= ¬hidepriv_row($cdom,$item,$settings,$crstype); + } elsif ($item eq 'checkforpriv') { + $datatable .= &checkforpriv_row($cdom,$item,$settings,$crstype); } elsif ($item eq 'print_header_format') { $datatable .= &print_hdrfmt_row($item,$settings); } elsif ($items->{$item}{input} eq 'dates') { @@ -3568,8 +3936,7 @@ sub make_item_rows { sub nothidepriv_row { my ($cdom,$item,$settings,$crstype) = @_; my ($cnum) = &get_course(); - my %nothide; - my $datatable; + my ($datatable,%nothide,@checkdoms); if (ref($settings) eq 'HASH') { if ($settings->{$item} ne '') { foreach my $user (split(/\s*\,\s*/,$settings->{$item})) { @@ -3580,38 +3947,30 @@ sub nothidepriv_row { } } } + if ($settings->{'checkforpriv'}) { + @checkdoms = split(/,/,$settings->{'checkforpriv'}); + } } - my %coursepersonnel = &Apache::lonnet::dump('nohist_userroles',$cdom,$cnum); - my $now = time; + push(@checkdoms,$cdom); + my %coursepersonnel = + &Apache::lonnet::get_my_roles($cnum,$cdom,'',['previous','future','active']); my @privusers; - my %privileged; foreach my $person (keys(%coursepersonnel)) { - my ($role,$user,$usec) = ($person =~ /^([^:]*):([^:]+:[^:]+):([^:]*)/); - $user =~ s/:$//; - my ($end,$start) = split(/:/,$coursepersonnel{$person}); + my ($uname,$udom,$role) = split(/:/,$person); + my $user = $uname.':'.$udom; + my ($start,$end) = split(/:/,$coursepersonnel{$person}); if ($end == -1 || $start == -1) { next; } - my ($uname,$udom) = split(':',$user); - unless (ref($privileged{$udom}) eq 'HASH') { - my %dompersonnel = &Apache::lonnet::get_domain_roles($udom,['dc'],undef,$now); - $privileged{$udom} = {}; - if (keys(%dompersonnel)) { - foreach my $server (keys(%dompersonnel)) { - foreach my $user (sort(keys(%{$dompersonnel{$server}}))) { - my ($trole,$uname,$udom) = split(/:/,$user); - $privileged{$udom}{$uname} = $trole; - } + foreach my $dom (@checkdoms) { + if (&Apache::lonnet::privileged($uname,$udom,\@checkdoms,['dc','su'])) { + unless (grep(/^\Q$user\E$/,@privusers)) { + push(@privusers,$user); } } } - if (exists($privileged{$udom}{$uname})) { - unless (grep(/^\Q$user\E$/,@privusers)) { - push(@privusers,$user); - } - } } - if (@privusers) { + if (@privusers > 0) { $datatable .= ''; foreach my $user (sort(@privusers)) { my $hideon = ' checked="checked" '; @@ -3643,6 +4002,65 @@ sub nothidepriv_row { return $datatable; } +sub checkforpriv_row { + my ($cdom,$item,$settings,$crstype) = @_; + my $datatable; + my %domains=map { $_ => 1; } &Apache::lonnet::all_domains(); + if (keys(%domains) == 1) { + $datatable = ''. + &Apache::loncommon::end_data_table_row(); + $num ++; + unless (grep(/^\Q$currdom\E$/,@excdoms)) { + push(@excdoms,$currdom); + } + } + } + if ((scalar(keys(%domains)) - scalar(@excdoms)) > 0) { + $datatable .= + &Apache::loncommon::start_data_table_row(). + ''.&Apache::loncommon::end_data_table_row(); + } + $datatable .= &Apache::loncommon::end_data_table(). + ''. + '
'; + } + return $datatable; +} + sub print_hdrfmt_row { my ($item,$settings) = @_; my @curr; @@ -3715,7 +4133,8 @@ function getIndexByName(item) { ENDJS - $output .= $currstr.'
'. + &mt("Course's domain is only domain"); + return $datatable; + } + my @excdoms = ($cdom); + my $num = 0; + if ($settings->{$item} eq '') { + $datatable = ''. + &Apache::loncommon::select_dom_form('','checkforpriv_'.$num, + 1,1,undef,undef,\@excdoms); + } else { + my @privdoms = split(/,/,$settings->{$item}); + my %domains=map { $_ => 1; } &Apache::lonnet::all_domains(); + $datatable = '
'. + &Apache::loncommon::start_data_table(); + if (@privdoms > 0) { + foreach my $currdom (@privdoms) { + next unless ($domains{$currdom}); + my $domdesc = &Apache::lonnet::domain($currdom,'description'); + if ($domdesc eq '') { + $domdesc = $currdom; + } + $datatable .= + &Apache::loncommon::start_data_table_row(). + '
'. + &mt('Domain:').' '.$domdesc. + '
'. + '
'. + &mt('Additional domain:'). '
'. + &Apache::loncommon::select_dom_form('','checkforpriv_'.$num,1, + 1,undef,undef,\@excdoms). + '
'; + $output .= '

'. + $currstr.''; if (@curr > 0) { for (my $i=0; $i<@curr; $i++) { my $pos = $i+1; @@ -3755,7 +4174,7 @@ ENDJS ''. ''. - '
'; + '

'; return $output; }