-
-
- '.&mt($item->{'header'}->[0]->{'col1'}).' |
- '.&mt($item->{'header'}->[0]->{'col2'}).' |
- ';
+ ';
+ if (exists $item->{'header'}->[0]->{'col1'} ||
+ exists $item->{'header'}->[0]->{'col2'}) {
+ $output .= '
+
+ '.&mt($item->{'header'}->[0]->{'col1'}).' | ';
+ if ($action eq 'feedback') {
+ $output .= '
+ ';
+ } else {
+ $output .= '
+ | ';
+ }
+ $output .= &mt($item->{'header'}->[0]->{'col2'}).' |
+ ';
+ }
$rowtotal ++;
if ($action eq 'feedback') {
- $output .= &print_feedback('top',$cdom,$settings,$ordered,$itemtext,\$rowtotal);
+ $output .= &print_feedback('top',$cdom,$settings,$ordered,$itemtext,\$rowtotal,$noedit);
} elsif ($action eq 'classlists') {
- $output .= &print_classlists('top',$cdom,$settings,$itemtext,\$rowtotal,$crstype);
+ $output .= &print_classlists('top',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit);
}
$output .= '
-
+ |
'.&mt($item->{'header'}->[1]->{'col1'}).' | ';
- $output .= '
- '.&mt($item->{'header'}->[1]->{'col2'}).' |
+ if ($action eq 'classlists') {
+ $output .= '
+ ';
+ } else {
+ $output .= '
+ | ';
+ }
+ $output .= &mt($item->{'header'}->[1]->{'col2'}).' |
';
if ($action eq 'classlists') {
- $output .= &print_classlists('middle',$cdom,$settings,$itemtext,\$rowtotal,$crstype).
+ $output .= &print_classlists('middle',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit).
'
|
-
-
- '.&mt($item->{'header'}->[2]->{'col1'}).' |
- '.&mt($item->{'header'}->[2]->{'col2'}).' |
- ';
+ ';
+ if (exists $item->{'header'}->[2]->{'col1'} ||
+ exists $item->{'header'}->[2]->{'col2'}) {
+ $output .= '
+
+ '.&mt($item->{'header'}->[2]->{'col1'}).' |
+ '.&mt($item->{'header'}->[2]->{'col2'}).' |
+ ';
+ }
}
} else {
$output .= '
-
-
- '.&mt($item->{'header'}->[0]->{'col1'}).' |
- '.&mt($item->{'header'}->[0]->{'col2'}).' |
- ';
+ ';
+ if (exists $item->{'header'}->[0]->{'col1'} ||
+ exists $item->{'header'}->[0]->{'col2'}) {
+ $output .= '
+
+ '.&mt($item->{'header'}->[0]->{'col1'}).' | ';
+ if (($action eq 'courseinfo') || ($action eq 'localization') ||
+ ($action eq 'print_discussion')) {
+ $output .= '';
+ } else {
+ $output .= ' | ';
+ }
+ $output .= &mt($item->{'header'}->[0]->{'col2'}).' |
+ ';
+ }
}
$rowtotal ++;
if ($action eq 'courseinfo') {
- $output .= &print_courseinfo($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype);
+ $output .= &print_courseinfo($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
} elsif ($action eq 'localization') {
- $output .= &print_localization($cdom,$settings,$ordered,$itemtext,\$rowtotal);
+ $output .= &print_localization($cdom,$settings,$ordered,$itemtext,\$rowtotal,$noedit);
} elsif ($action eq 'feedback') {
- $output .= &print_feedback('bottom',$cdom,$settings,$ordered,$itemtext,\$rowtotal);
+ $output .= &print_feedback('bottom',$cdom,$settings,$ordered,$itemtext,\$rowtotal,$noedit);
} elsif ($action eq 'discussion') {
- $output .= &print_discussion($cdom,$settings,$ordered,$itemtext,\$rowtotal);
- } elsif ($action eq 'classlists') {
- $output .= &print_classlists('bottom',$cdom,$settings,$itemtext,\$rowtotal,$crstype);
+ $output .= &print_discussion($cdom,$settings,$ordered,$itemtext,\$rowtotal,$noedit);
+ } elsif (($action eq 'classlists') || ($action eq 'viewableroster')) {
+ $output .= &print_classlists('bottom',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit);
} elsif ($action eq 'appearance') {
- $output .= &print_appearance($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype);
+ $output .= &print_appearance($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
} elsif ($action eq 'grading') {
- $output .= &print_grading($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype);
+ $output .= &print_grading($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
} elsif ($action eq 'printouts') {
- $output .= &print_printouts($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype);
+ $output .= &print_printouts($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
} elsif ($action eq 'spreadsheet') {
- $output .= &print_spreadsheet($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype);
+ $output .= &print_spreadsheet($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
} elsif ($action eq 'bridgetasks') {
- $output .= &print_bridgetasks($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype);
+ $output .= &print_bridgetasks($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
} elsif ($action eq 'other') {
- $output .= &print_other($cdom,$settings,$allitems,\$rowtotal,$crstype);
+ $output .= &print_other($cdom,$settings,$allitems,\$rowtotal,$crstype,$noedit);
}
$output .= '
@@ -659,7 +756,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') {
@@ -708,9 +825,9 @@ sub process_changes {
my @clonedoms;
if (exists($env{'form.cloners_activate'})) {
my $actnum = $env{'form.cloners_activate'};
- if ($actnum ne '') {
- if ($env{'form.clonersdom_'.$actnum} ne '') {
- my $clonedom = $env{'form.clonersdom_'.$actnum};
+ if ($actnum ne '-1') {
+ if ($env{'form.cloners_dom_'.$actnum} ne '') {
+ my $clonedom = $env{'form.cloners_dom_'.$actnum};
if (&check_clone($clonedom,$disallowed) eq 'ok') {
$newvalues{$entry} = '*:'.$clonedom;
push(@clonedoms,$newvalues{$entry});
@@ -726,7 +843,7 @@ sub process_changes {
my $clonedom = $env{'form.cloners_dom_'.$i};
if (&check_clone($clonedom,$disallowed) eq 'ok') {
if (!grep(/^\*:\Q$clonedom\E$/,@clonedoms)) {
- push (@clonedoms,'*:'.$clonedom);
+ push(@clonedoms,'*:'.$clonedom);
}
}
}
@@ -772,6 +889,37 @@ sub process_changes {
}
}
}
+ if (ref($values) eq 'HASH') {
+ my (@code_order,%codedefaults);
+ &Apache::lonnet::auto_instcode_defaults($cdom,\%codedefaults,
+ \@code_order);
+ my $clonebycode;
+ if ($env{'form.cloners_instcode'}) {
+ if (@code_order > 0) {
+ my @standardnames = &Apache::loncommon::get_standard_codeitems();
+ my %local_to_standard;
+ for (my $i=0; $i<@code_order; $i++) {
+ $local_to_standard{$code_order[$i]} = $standardnames[$i];
+ }
+ foreach my $item (@code_order) {
+ my $key = $local_to_standard{$item};
+ if ($key ne '') {
+ if ($env{'form.'.$key}) {
+ $clonebycode .= $key.'='.&escape($env{'form.'.$key}).'&';
+ }
+ }
+ }
+ $clonebycode =~ s/\&$//;
+ }
+ }
+ if ($clonebycode) {
+ if ($newvalues{$entry}) {
+ $newvalues{$entry} .= ','.$clonebycode;
+ } else {
+ $newvalues{$entry} = $clonebycode;
+ }
+ }
+ }
}
if (ref($disallowed) eq 'HASH') {
if (ref($disallowed->{'cloners'}) eq 'HASH') {
@@ -789,7 +937,7 @@ sub process_changes {
}
if (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
my $autocoowner;
- if (($crstype eq 'Course') &&
+ if (($crstype eq 'Course') &&
($values->{'internal.coursecode'})) {
my %domconf =
&Apache::lonnet::get_dom('configuration',['autoenroll'],$cdom);
@@ -911,7 +1059,8 @@ sub process_changes {
}
}
}
- } elsif (($entry eq 'plc.roles.denied') || ($entry eq 'pch.roles.denied')) {
+ } elsif (($entry eq 'plc.roles.denied') || ($entry eq 'pch.roles.denied') ||
+ ($entry eq 'pac.roles.denied')) {
my @denied = &Apache::loncommon::get_env_multiple('form.'.$entry);
@denied = sort(@denied);
my $deniedstr = '';
@@ -919,7 +1068,8 @@ sub process_changes {
$deniedstr = join(',',@denied);
}
$newvalues{$entry} = $deniedstr;
- } elsif (($entry eq 'plc.users.denied') || ($entry eq 'pch.users.denied')) {
+ } elsif (($entry eq 'plc.users.denied') || ($entry eq 'pch.users.denied') ||
+ ($entry eq 'pac.users.denied')) {
my $total = $env{'form.'.$entry.'_total'};
my $userstr = '';
my @denied;
@@ -967,6 +1117,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;
@@ -1022,8 +1201,8 @@ sub process_changes {
$hdr .= $env{'form.printfmthdr_limit_'.$i};
}
$hdr .= $env{'form.printfmthdr_sub_'.$i};
- } elsif ($env{'form.printfmthdr_sub_'.$i} ne '') {
- $hdr = $env{'form.printfmthdr_sub_'.$i};
+ } elsif ($env{'form.printfmthdr_text_'.$i} ne '') {
+ $hdr = $env{'form.printfmthdr_text_'.$i};
}
$newhdr[$env{'form.printfmthdr_pos_'.$i}] = $hdr;
}
@@ -1041,36 +1220,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};
}
@@ -1149,16 +1339,16 @@ sub store_changes {
$output .= ''.&mt($prefs->{$item}{'text'}).'';
if (ref($changes->{$item}) eq 'HASH') {
if (keys(%{$changes->{$item}}) > 0) {
- $output .= &mt('Changes made:').'';
+ $output .= &mt('Changes made:').'';
if ($item eq 'other') {
foreach my $key (sort(keys(%{$changes->{$item}}))) {
$storehash{$key} = $changes->{$item}{$key};
if ($changes->{$item}{$key} eq '') {
push(@delkeys,$key);
- $output .= '- '.&mt('Deleted setting for [_1]',''.$key.'').'
';
+ $output .= '- '.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]',''.$key.'')).'
';
} else {
- $output .= '- '.&mt('[_1] set to [_2]',''.$key.'',
- "'$storehash{$key}'").'
';
+ $output .= '- '.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',''.$key.'',
+ "'$storehash{$key}'")).'
';
}
}
} else {
@@ -1190,14 +1380,14 @@ sub store_changes {
"'".$newname."'").'';
}
if ($msg ne '') {
- $output .= '- '.&mt($displayname).'
';
+ $output .= '- '.&Apache::lonhtmlcommon::confirm_success(&mt($displayname)).'
';
}
} else {
next if (!exists($changes->{$item}{$key}));
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') {
@@ -1233,6 +1423,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);
}
@@ -1253,12 +1473,18 @@ sub store_changes {
if (defined($yesno{$key})) {
$displayval = &mt('No');
if ($changes->{$item}{$key} eq 'yes') {
- $displayval = &mt('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') || ($key eq 'usejsme') || ($key eq 'uselcmath')) {
+ if ($changes->{$item}{$key} eq '1') {
+ $displayval = &mt('Yes');
+ } elsif ($changes->{$item}{$key} eq '0') {
+ $displayval = &mt('No');
+ }
}
if ($key eq 'co-owners') {
if (ref($changes->{$item}{$key}) eq 'HASH') {
@@ -1312,7 +1538,7 @@ sub store_changes {
if ($key eq 'url') {
my $bkuptime=time;
$output .= (' 'x2).&mt('(Previous URL backed up)').': '.
- $storehash{'top level map backup '.$bkuptime} => $values->{$key};
+ $storehash{'top level map backup '.$bkuptime} = $values->{$key};
}
$output .= '';
}
@@ -1326,12 +1552,14 @@ sub store_changes {
}
}
} else {
- $storehash{$key} = $changes->{$item}{$key};
+ unless ($key eq 'discussion_post_fonts') {
+ $storehash{$key} = $changes->{$item}{$key};
+ }
}
}
if ($key eq 'cloners') {
# Get existing cloners
- my %clonenames =
+ my %clonenames =
&Apache::lonnet::dump('environment',$cdom,$cnum,'cloners');
if ($clonenames{'cloners'} =~ /,/) {
@oldcloner = split(/\s*\,\s*/,$clonenames{'cloners'});
@@ -1350,9 +1578,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.');
}
}
}
@@ -1376,10 +1604,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);
+ } else {
+ foreach my $key (@delkeys) {
+ &Apache::lonnet::delenv('course.'.$cdom.'_'.$cnum.'.'.$key);
+ }
}
}
if (@need_env_update) {
@@ -1523,16 +1751,98 @@ sub get_course {
}
my $cdom=$env{'course.'.$courseid.'.domain'};
my $cnum=$env{'course.'.$courseid.'.num'};
- return ($cnum,$cdom);
+ my $chome=$env{'course.'.$courseid.'.home'};
+ return ($cnum,$cdom,$chome);
}
sub get_jscript {
- my ($cdom,$phase,$crstype) = @_;
+ my ($cid,$cdom,$phase,$crstype,$settings) = @_;
my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom,$crstype);
- my ($jscript,$categorize_js);
+ my ($jscript,$categorize_js,$loncaparev_js,$instcode_js);
my $stubrowse_js = &Apache::loncommon::studentbrowser_javascript();
my $browse_js = &Apache::loncommon::browser_and_searcher_javascript('parmset');
my $cloners_js = &cloners_javascript($phase);
+ my @code_order;
+ if ($crstype ne 'Community') {
+ if (ref($settings) eq 'HASH') {
+ my %codedefaults;
+ &Apache::lonnet::auto_instcode_defaults($cdom,\%codedefaults,
+ \@code_order);
+ if (@code_order > 0) {
+ if ($phase eq 'display') {
+ my @actions = &Apache::loncommon::get_env_multiple('form.actions');
+ if (grep(/^courseinfo$/,@actions)) {
+ if ($settings->{'cloners'} ne '') {
+ unless ($settings->{'cloners'} eq '*') {
+ my @cloners = split(/,/,$settings->{'cloners'});
+ my @standardnames = &Apache::loncommon::get_standard_codeitems();
+ my %local_to_standard;
+ for (my $i=0; $i<@code_order; $i++) {
+ $local_to_standard{$code_order[$i]} = $standardnames[$i];
+ }
+ foreach my $cloner (@cloners) {
+ if (($cloner !~ /^\Q*:\E$match_domain$/) &&
+ ($cloner !~ /^$match_username\:$match_domain$/)) {
+ foreach my $item (split(/\&/,$cloner)) {
+ my ($key,$val) = split(/\=/,$item);
+ $val = &unescape($val);
+ foreach my $code (@code_order) {
+ if ($key eq $local_to_standard{$code}) {
+ $env{'form.'.$key} = $val;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ my @codetitles;
+ (undef,$instcode_js) =
+ &Apache::courseclassifier::instcode_selectors($cdom,'display',undef,
+ \@codetitles);
+ $instcode_js .= <'."\n".
- $browse_js."\n".$categorize_js."\n".$cloners_js."\n".''.
- "\n".$stubrowse_js."\n";
+ '// '."\n".
+ ''."\n".$stubrowse_js."\n";
return $jscript;
}
@@ -1582,7 +1921,7 @@ function update_cloners(caller,num) {
if (document.$formname.cloners_activate[i].value == '0') {
document.$formname.cloners_activate[i].checked = false;
}
- if (document.$formname.cloners_activate[i].value == '') {
+ if (document.$formname.cloners_activate[i].value == '-1') {
document.$formname.cloners_activate[i].checked = true;
}
}
@@ -1635,13 +1974,14 @@ ENDSCRIPT
sub print_courseinfo {
- my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_;
+ my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
return;
}
- my ($cathash,$categoriesform,$autocoowner);
+ my ($cathash,$categoriesform,$autocoowner,$clonedefaults);
my %domconf =
- &Apache::lonnet::get_dom('configuration',['coursecategories','autoenroll'],$cdom);
+ &Apache::lonnet::get_dom('configuration',
+ ['coursecategories','autoenroll','coursedefaults'],$cdom);
if (ref($domconf{'coursecategories'}) eq 'HASH') {
$cathash = $domconf{'coursecategories'}{'cats'};
if (ref($cathash) eq 'HASH') {
@@ -1653,11 +1993,60 @@ sub print_courseinfo {
if (ref($domconf{'autoenroll'}) eq 'HASH') {
$autocoowner = $domconf{'autoenroll'}{'co-owners'};
}
+ my ($currcanclone,@code_order,$cloner_instcode);
+ my %codedefaults;
+ &Apache::lonnet::auto_instcode_defaults($cdom,\%codedefaults,
+ \@code_order);
+ if ($settings->{'cloners'}) {
+ unless ($settings->{'cloners'} eq '*') {
+ my @currclone = split(/,/,$settings->{'cloners'});
+ foreach my $item (@currclone) {
+ unless ($item eq '*') {
+ if (($item !~ /\:/) && ($item =~ /=/)) {
+ $cloner_instcode = 1;
+ }
+ }
+ }
+ }
+ }
+ if (ref($domconf{'coursedefaults'}) eq 'HASH') {
+ my $canclone = $domconf{'coursedefaults'}{'canclone'};
+ if (ref($canclone) eq 'HASH') {
+ if (ref($canclone->{'instcode'}) eq 'ARRAY') {
+ if ($settings->{'internal.coursecode'}) {
+ my @posscodes;
+ if (@code_order > 0) {
+ $currcanclone = 'instcode';
+ foreach my $item (@{$canclone->{'instcode'}}) {
+ if (grep(/^\Q$item\E$/,@code_order)) {
+ push(@posscodes,$item);
+ }
+ }
+ my $codestr = join(' + ',@posscodes);
+ $clonedefaults = &mt('Default for official courses is to also allow cloning if [_1] match in cloner and cloned.',
+ '"'.$codestr.'"').' ';
+ }
+ }
+ }
+ } elsif ($canclone eq 'domain') {
+ $clonedefaults = &mt('Default is for any course requester in [_1] domain to be able to clone.',
+ ''.$cdom.'').' ';
+ $currcanclone = 'domain';
+ }
+ if ($clonedefaults) {
+ if ($settings->{'cloners'} ne '') {
+ $clonedefaults .= ' '.&mt('Default does [_1]not[_2] currently apply because values have been set in the course.','','');
+ } else {
+ $clonedefaults .= &mt('Default is disregarded if [_1]any[_2] values are set here in the course.','','');
+ }
+ $clonedefaults = '
'.$clonedefaults;
+ }
+ }
if (!defined($categoriesform)) {
$categoriesform = &mt('No categories defined in this domain.');
}
-
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') {
@@ -1674,12 +2063,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'}).'',
@@ -1687,29 +2077,37 @@ 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'),
+ &mt('Owner and Coordinators included automatically').
+ $clonedefaults,
input => 'textbox',
- size => '40',
+ size => '40'
},
'rolenames' => {
text => ''.&mt($itemtext->{'rolenames'}).' '.
'('.$replace.')',
input => 'textbox',
size => '20',
+ 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'}).' '.
@@ -1722,23 +2120,44 @@ sub print_courseinfo {
input => 'textbox',
size => '25',
},
+ 'loncaparev' => {
+ text => ''.&mt($itemtext->{'loncaparev'}).'',
+ },
+ 'defaultcredits' => {
+ text => ''.&mt($itemtext->{'defaultcredits'}).'',
+ },
);
my $datatable;
my $count = 0;
+ my $disabled;
+ if ($noedit) {
+ $disabled = ' disabled="disabled"';
+ }
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 ++;
- $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",$colspan);
+ } else {
+ $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan);
+ }
if ($items{$item}{input} eq 'radio') {
- $datatable .= &yesno_radio($item,$settings);
+ $datatable .= &yesno_radio($item,$settings,undef,undef,undef,$noedit);
} 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().
' | '.
- (' 'x2).''.&mt('Yes').''.
+ (' 'x2).' | '.
+ "'cloners_all'".');"'.$disabled.' />'.&mt('No').''.
&Apache::loncommon::end_data_table_row().
&Apache::loncommon::end_data_table().
- ''.
+ ''.
&Apache::loncommon::start_data_table();
my @cloners;
if ($settings->{$item} eq '') {
- $datatable .= &new_cloners_dom_row($cdom,'0');
+ unless ($noedit) {
+ my $default;
+ if ($currcanclone eq 'domain') {
+ $default = '0';
+ }
+ $datatable .= &new_cloners_dom_row($cdom,'0',$default);
+ }
} elsif ($settings->{$item} ne '*') {
my @entries = split(/,/,$settings->{$item});
if (@entries > 0) {
@@ -1782,7 +2208,7 @@ sub print_courseinfo {
' '.
''.
&Apache::loncommon::end_data_table_row();
$num ++;
@@ -1805,23 +2231,56 @@ sub print_courseinfo {
''.
$add_domtitle.' '.
&Apache::loncommon::select_dom_form('','cloners_newdom',
- $includeempty).
+ $includeempty,undef,undef,
+ undef,undef,$noedit).
''.
' | '.&Apache::loncommon::end_data_table_row().
&Apache::loncommon::end_data_table().
- ''.
+ ''.
&Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_row().
''.
&mt('Specific users').' ('.
&mt('user:domain,user:domain').') '.
&Apache::lonhtmlcommon::textbox($item,$cloners_str,
- $items{$item}{'size'}).
+ $items{$item}{'size'},$disabled).
' | '.&Apache::loncommon::end_data_table_row().
&Apache::loncommon::end_data_table();
+ if (@code_order > 0) {
+ my (%cat_items,@codetitles,%cat_titles,%cat_order);
+ my ($jscript,$totcodes,$numtitles,$lasttitle) =
+ &Apache::courseclassifier::instcode_selectors_data($cdom,'display',
+ \%cat_items,\@codetitles,
+ \%cat_titles,\%cat_order);
+ my $showncodes = 'off';
+ my $checkedoff = ' checked="checked"';
+ my $checkedon = '';
+ if ($cloner_instcode) {
+ $checkedon = $checkedoff;
+ $checkedoff = '';
+ $showncodes = 'on';
+ }
+ $datatable .= ''.
+ &Apache::loncommon::start_data_table().
+ &Apache::loncommon::start_data_table_row().
+ ''.
+ &mt('Cloning by official course(s) based on course category').(' 'x2).
+ ''.
+ (' ').
+ ''.
+ &Apache::courseclassifier::build_instcode_selectors($numtitles,
+ $lasttitle,\%cat_items,\@codetitles,\%cat_titles,\%cat_order,
+ $showncodes,'LC_cloners_instcodes','LC_cloners_instcode',$noedit).
+ ' | '.&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');
@@ -1836,29 +2295,47 @@ sub print_courseinfo {
' | '.
&Apache::lonhtmlcommon::textbox('rolenames_'.$role,
$settings->{$role.'.plaintext'},
- $items{$item}{size}).' | '.
+ $items{$item}{size},$disabled).''.
&Apache::loncommon::end_data_table_row();
}
$datatable .= &Apache::loncommon::end_data_table().'';
} elsif ($item eq 'categories') {
- my $launcher = 'onFocus="this.blur();javascript:catsbrowser();";';
+ my $launcher;
+ if ($noedit) {
+ $launcher = $disabled;
+ } else {
+ $launcher = 'onfocus="this.blur();javascript:catsbrowser();"';
+ }
$datatable .= ''.
&Apache::lonhtmlcommon::textbox($item.'_display',$settings->{$item},
$items{$item}{size},$launcher);
} elsif ($item eq 'owner') {
my $owner = $env{'course.'.$env{'request.course.id'}.'.internal.courseowner'};
if ($owner =~ /:/) {
- my ($ownername,$ownerdom) = split(':',$owner);
+ my ($ownername,$ownerdom) = split(':',$owner);
$owner = &Apache::loncommon::plainname($ownername,$ownerdom);
} elsif ($owner ne '') {
$owner = &Apache::loncommon::plainname($owner,$cdom);
} else {
$owner = &mt('None specified');
}
- my $domdesc = &Apache::lonnet::domain($cdom,'description');
$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) {
@@ -1868,17 +2345,57 @@ sub print_courseinfo {
if (($crstype eq 'Course') && ($env{'course.'.$env{'request.course.id'}.'.internal.coursecode'}) && ($autocoowner)) {
$datatable .= &show_autocoowners(@currcoown);
} else {
- $datatable .= &coowner_invitations($cnum,$cdom,@currcoown);
+ $datatable .= &coowner_invitations($cnum,$cdom,\@currcoown,$noedit);
}
} else {
if (($crstype eq 'Course') && ($env{'course.'.$env{'request.course.id'}.'.internal.coursecode'}) && ($autocoowner)) {
$datatable .= &show_autocoowners(@currcoown);
} else {
- $datatable .= &manage_coownership($cnum,$cdom,@currcoown);
+ $datatable .= &manage_coownership($cnum,$cdom,\@currcoown,$noedit);
}
}
+ } 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').'';
+ } else {
+ $showreqd = &mt('No specific version required');
+ }
+ $datatable .= $showreqd;
} else {
- $datatable .= &Apache::lonhtmlcommon::textbox($item,$settings->{$item},$items{$item}{size});
+ $datatable .= &Apache::lonhtmlcommon::textbox($item,$settings->{$item},$items{$item}{size},$disabled);
}
$datatable .= &item_table_row_end();
}
@@ -1887,19 +2404,24 @@ sub print_courseinfo {
}
sub new_cloners_dom_row {
- my ($newdom,$num) = @_;
- my $output;
+ my ($newdom,$num,$default) = @_;
+ my ($output,$checkedon,$checkedoff);
if ($newdom ne '') {
+ if ($num eq $default) {
+ $checkedon = 'checked="checked" ';
+ } else {
+ $checkedoff = 'checked="checked" ';
+ }
$output .= &Apache::loncommon::start_data_table_row().
''.
&mt('Any user in domain:').' '.$newdom.''.
(' 'x2).''.(' 'x2).
'
@@ -2034,26 +2557,719 @@ ENDSCRIPT
return;
}
+sub display_loncaparev_constraints {
+ my ($r,$navmap,$loncaparev,$crstype) = @_;
+ my ($reqdmajor,$reqdminor);
+ my $cid = $env{'request.course.id'};
+ 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',
+ );
+ &Apache::lonrelrequtils::init_global_hashes();
+ if (defined($Apache::lonrelrequtils::checkcrstypes{$crstype})) {
+ ($reqdmajor,$reqdminor) = split(/\./,$Apache::lonrelrequtils::checkcrstypes{$crstype});
+ $output .= ''.&mt('Course type: [_1] requires [_2] or newer',$crstype,
+ $Apache::lonrelrequtils::checkcrstypes{$crstype}).'';
+ }
+ my (%fromparam,%rowspan,%bymap,%byresource,@scopeorder,%toshow,%allmaps,
+ %byresponsetype,%bysubmission,%fromblocks);
+ @scopeorder = ('all','section/group','user');
+ my $now = time;
+ my $resourcedata = &Apache::lonparmset::readdata($cnum,$cdom);
+ if (ref($resourcedata) eq 'HASH') {
+ foreach my $key (keys(%{$resourcedata})) {
+ my %found;
+ foreach my $item (keys(%Apache::lonrelrequtils::checkparms)) {
+ if ($key =~ /(\Q$item\E)$/) {
+ if (ref($Apache::lonrelrequtils::checkparms{$item}) eq 'ARRAY') {
+ my $value = $resourcedata->{$key};
+ if ($item eq 'examcode') {
+ if (&Apache::lonnet::validCODE($value)) {
+ $value = 'valid';
+ } else {
+ $value = '';
+ }
+ } elsif ($item eq 'printstartdate') {
+ if ($value =~ /^\d+$/) {
+ if ($value > $now) {
+ $value = 'future';
+ }
+ }
+ } elsif ($item eq 'printenddate') {
+ if ($value =~ /^\d+$/) {
+ if ($value < $now) {
+ $value = 'past';
+ }
+ }
+ }
+ if (grep(/^\Q$value\E$/,@{$Apache::lonrelrequtils::checkparms{$item}})) {
+ my $stdtype = &Apache::lonparmset::standard_parameter_types($item);
+ $found{$item}{'valname'} = &get_param_description($stdtype,$value);
+ $found{$item}{'rev'} = $Apache::lonnet::needsrelease{'parameter:'.$item.':'.$value.'::'};
+ }
+ }
+ }
+ }
+ foreach my $item (keys(%Apache::lonrelrequtils::checkparmvalsmatch)) {
+ if (ref($Apache::lonrelrequtils::checkparmvalsmatch{$item}) eq 'ARRAY') {
+ my $value = $resourcedata->{$key};
+ foreach my $valuematch (@{$Apache::lonrelrequtils::checkparmvalsmatch{$item}}) {
+ if ($value =~ /$valuematch/) {
+ my $stdtype = &Apache::lonparmset::standard_parameter_types($item);
+ $found{$item}{'valname'} = &get_param_description($stdtype,$value,1);
+ $found{$item}{'rev'} =
+ $Apache::lonnet::needsrelease{'parameter:'.$item.'::'.$valuematch.':'};
+ last;
+ }
+ }
+ }
+ }
+ foreach my $item (keys(%Apache::lonrelrequtils::checkparmnamesmatch)) {
+ my $regexp;
+ if ($item eq 'maplevelrecurse') {
+ $regexp = '\.(?:sequence|page)___\(rec\)\.';
+ }
+ if ($regexp ne '') {
+ if ($key =~ /$regexp.*\.(\w+)$/) {
+ my $name = $1;
+ my $value = $resourcedata->{$key};
+ if ($name eq 'type') {
+ last unless (($value eq 'problem') || ($value eq 'practice') || ($value eq 'exam') ||
+ ($value eq 'survey') || ($value eq 'surveycred') || ($value eq 'anonsurvey') ||
+ ($value eq 'anonsurveycred') || ($value eq 'randomizetry') || ($value eq 'library'));
+ }
+ my $stdtype = &Apache::lonparmset::standard_parameter_types($name);
+ $found{$name}{'valname'} = &get_param_description($stdtype,$value);
+ $found{$name}{'extra'} = &mt('Recursive into sub-folders');
+ $found{$name}{'rev'} =
+ $Apache::lonnet::needsrelease{'parameter::::'.$item};
+ }
+ }
+ }
+ foreach my $item (keys(%found)) {
+ my $stdname = &Apache::lonparmset::standard_parameter_names($item);
+ my $rev = $found{$item}{'rev'};
+ my $valname = $found{$item}{'valname'};
+ my $extra = $found{$item}{'extra'};
+ my ($middle,$scope,$which,$level,$map,$resource);
+ my $start = $cid.'.';
+ if ($key =~ /^\Q$start\E(\[useropt\:($match_username\:$match_domain)\]\.)/) {
+ $middle = $1;
+ $which = $2;
+ $scope = 'user';
+ } elsif ($key =~ /^\Q$start\E(\[(\w+)\]\.)/) {
+ $middle = $1;
+ $which = $2;
+ $scope = 'section/group';
+ } else {
+ $scope = 'all';
+ }
+ my $what="$stdname=$valname";
+ if ($extra) {
+ $what .= " $extra ";
+ }
+ if ($key =~ /^\Q$start$middle\E\w+\.\Q$item\E$/) {
+ $level = 'general';
+ if ($scope eq 'all') {
+ if (ref($fromparam{$rev}{$scope}) eq 'ARRAY') {
+ unless(grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}})) {
+ push(@{$fromparam{$rev}{$scope}},$what);
+ }
+ } else {
+ push(@{$fromparam{$rev}{$scope}},$what);
+ }
+ } else {
+ if (ref($fromparam{$rev}{$scope}{$which}) eq 'ARRAY') {
+ unless (grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}{$which}})) {
+ push(@{$fromparam{$rev}{$scope}{$which}},$what);
+ }
+ } else {
+ push(@{$fromparam{$rev}{$scope}{$which}},$what);
+ }
+ }
+ $rowspan{$rev} ++;
+ } elsif ($key =~ /^\Q$start$middle\E(.+)___\((all|rec)\).\w+\.\Q$item\E$/) {
+ $level = 'folder';
+ $map = $1;
+ 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);
+ }
+ } else {
+ push(@{$bymap{$map}{$rev}{$scope}},$what);
+ }
+ } else {
+ if (ref($bymap{$map}{$rev}{$scope}{$which}) eq 'ARRAY') {
+ unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}{$which}})) {
+ push(@{$bymap{$map}{$rev}{$scope}{$which}},$what);
+ }
+ } else {
+ push(@{$bymap{$map}{$rev}{$scope}{$which}},$what);
+ }
+ }
+ } elsif ($key =~ /^\Q$start$middle\E(.+)\.\w+\.\Q$item\E$/) {
+ $level = 'resource';
+ $resource = $1;
+ 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);
+ }
+ } else {
+ push(@{$byresource{$resource}{$rev}{$scope}},$what);
+ }
+ } else {
+ if (ref($byresource{$resource}{$rev}{$scope}{$which}) eq 'ARRAY') {
+ unless (grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}{$which}})) {
+ push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what);
+ }
+ } else {
+ push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what);
+ }
+ }
+ }
+ }
+ }
+ if (keys(%fromparam)) {
+ $output .= ''.&mt('Requirements from general settings').''.
+ &Apache::loncommon::start_data_table().
+ &Apache::loncommon::start_data_table_header_row().
+ ' | '.&mt('Release').' | '.&mt('Scope').' | '.
+ ''.&mt('Extent').' | '.&mt('Setting').' | '.
+ &Apache::loncommon::end_data_table_header_row();
+ foreach my $rev (keys(%fromparam)) {
+ my ($major,$minor) = split(/\./,$rev);
+ ($reqdmajor,$reqdminor) =
+ &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,$reqdmajor,$reqdminor);
+ $output .= &Apache::loncommon::start_data_table_row().
+ ''.$rev.' | ';
+ my $newrow;
+ foreach my $scope (@scopeorder) {
+ if (ref($fromparam{$rev}{$scope}) eq 'HASH') {
+ if ($newrow) {
+ $output .= &Apache::loncommon::continue_data_table_row();
+ }
+ $output .= ''.$lt{$scope}.' | ';
+ foreach my $which (sort(keys(%{$fromparam{$rev}{$scope}}))) {
+ $output .= ''.$which.' | '.
+ join(' ',@{$fromparam{$rev}{$scope}{$which}}).' | ';
+ }
+ $output .= &Apache::loncommon::end_data_table_row();
+ $newrow = 1;
+ } elsif (ref($fromparam{$rev}{$scope}) eq 'ARRAY') {
+ if ($newrow) {
+ $output .= &Apache::loncommon::continue_data_table_row();
+ }
+ $output .= ''.$lt{$scope}.' | | '.
+ join(' ',@{$fromparam{$rev}{$scope}}).' | '.
+ &Apache::loncommon::end_data_table_row();
+ $newrow = 1;
+ }
+ }
+ }
+ $output .= &Apache::loncommon::end_data_table().' ';
+ }
+ }
+
+ my %comm_blocks = &Apache::lonnet::dump('comm_block',$cdom,$cnum);
+ my $now = time;
+ if (keys(%comm_blocks) > 0) {
+ foreach my $block (keys(%comm_blocks)) {
+ if ($block =~ /^firstaccess____(.+)$/) {
+ my $rev = $Apache::lonnet::needsrelease{'course:commblock:timer'};
+ if (ref($comm_blocks{$block}) eq 'HASH') {
+ push(@{$fromblocks{'timer'}{$rev}},&unescape($comm_blocks{$block}{'event'}).
+ ' '.&mt('set by [_1]',
+ &Apache::loncommon::plainname(split(/:/,$comm_blocks{$block}{'setter'}))));
+ }
+ next;
+ } elsif ($block =~ /^(\d+)____(\d+)$/) {
+ my ($start,$end) = ($1,$2);
+ next if ($end < $now);
+ }
+ if (ref($comm_blocks{$block}) eq 'HASH') {
+ if (ref($comm_blocks{$block}{'blocks'}) eq 'HASH') {
+ if (ref($comm_blocks{$block}{'blocks'}{'docs'}) eq 'HASH') {
+ if (keys(%{$comm_blocks{$block}{'blocks'}{'docs'}}) > 0) {
+ my $rev = $Apache::lonnet::needsrelease{'course:commblock:docs'};
+ push(@{$fromblocks{'docs'}{$rev}},&unescape($comm_blocks{$block}{'event'}).
+ ' '.
+ &mt('set by [_1]',
+ &Apache::loncommon::plainname(split(/:/,$comm_blocks{$block}{'setter'}))));
+ }
+ } elsif ($comm_blocks{$block}{'blocks'}{'printout'} eq 'on') {
+ my $rev = $Apache::lonnet::needsrelease{'course:commblock:printout'};
+ push(@{$fromblocks{'printout'}{$rev}},&unescape($comm_blocks{$block}{'event'}).
+ ' '.
+ &mt('set by [_1]',
+ &Apache::loncommon::plainname(split(/:/,$comm_blocks{$block}{'setter'}))));
+
+ }
+ }
+ }
+ }
+ if (keys(%fromblocks)) {
+ my %lt = (
+ docs => 'Content blocking',
+ printout => 'Printout generation',
+ timer => 'Timed quiz trigger',
+ );
+ $output .= ''.&mt('Requirements from exam blocking').''.
+ &Apache::loncommon::start_data_table().
+ &Apache::loncommon::start_data_table_header_row().
+ ''.&mt('Release').' | '.&mt('Setting').' | '.
+ ''.&mt('Event(s)').' | '.
+ &Apache::loncommon::end_data_table_header_row();
+ foreach my $type ('docs','printout','timer') {
+ if (ref($fromblocks{$type}) eq 'HASH') {
+ foreach my $rev (keys(%{$fromblocks{$type}})) {
+ my ($major,$minor) = split(/\./,$rev);
+ ($reqdmajor,$reqdminor) =
+ &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,$reqdmajor,$reqdminor);
+ $output .= &Apache::loncommon::start_data_table_row().
+ ''.$rev.' | '.$lt{$type}.' | ';
+ foreach my $event (sort(@{$fromblocks{$type}{$rev}})) {
+ $output .= $event.' ';
+ }
+ $output =~ s{\Q \E$}{};
+ $output .= ' | '.&Apache::loncommon::end_data_table_row();
+ }
+ }
+ }
+ $output .= &Apache::loncommon::end_data_table().' ';
+ }
+ }
+
+ if (defined($navmap)) {
+ my %anonsubms=&Apache::lonnet::dump('nohist_anonsurveys',$cdom,$cnum);
+ my $rev_anonsurv=$Apache::lonnet::needsrelease{'parameter:type:anonsurvey::'};
+ my %randtrysubms=&Apache::lonnet::dump('nohist_randomizetry',$cdom,$cnum);
+ my $rev_randtry=$Apache::lonnet::needsrelease{'parameter:type:randomizetry::'};
+ my $stdtype=&Apache::lonparmset::standard_parameter_types('type');
+ my $stdname=&Apache::lonparmset::standard_parameter_names('type');
+ my $valanon=&get_param_description($stdtype,'anonsurvey');
+ my $valrandtry=&get_param_description($stdtype,'randomizetry');
+ my %checkedrev;
+ foreach my $res ($navmap->retrieveResources(undef,sub { $_[0]->is_problem() },1,0)) {
+ my @parts = @{$res->parts()};
+ my $symb = $res->symb();
+ my $enclosing_map = &Apache::lonnet::declutter($res->enclosing_map_src());
+ foreach my $part (@parts) {
+ if (exists($anonsubms{$symb."\0".$part})) {
+ my $rev = $rev_anonsurv;
+ my $what="$stdname=$valanon";
+ if (ref($bysubmission{$symb}{$rev}) eq 'ARRAY') {
+ unless (grep(/^\Q$what\E/,@{$bysubmission{$symb}{$rev}})) {
+ push(@{$bysubmission{$symb}{$rev}},$what);
+ }
+ } else {
+ push(@{$bysubmission{$symb}{$rev}},$what);
+ }
+ $allmaps{$enclosing_map} = 1;
+ unless ($checkedrev{'anonsurvey'}) {
+ my ($major,$minor) = split(/\./,$rev);
+ ($reqdmajor,$reqdminor) =
+ &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,
+ $reqdmajor,$reqdminor);
+ $checkedrev{'anonsurvey'} = 1;
+ }
+ }
+ if (exists($randtrysubms{$symb."\0".$part})) {
+ my $rev = $rev_randtry;
+ my $what="$stdname=$valrandtry";
+ if (ref($bysubmission{$symb}{$rev}) eq 'ARRAY') {
+ unless (grep(/^\Q$what\E/,@{$bysubmission{$symb}{$rev}})) {
+ push(@{$bysubmission{$symb}{$rev}},$what);
+ }
+ } else {
+ push(@{$bysubmission{$symb}{$rev}},$what);
+ }
+ $allmaps{$enclosing_map} = 1;
+ unless ($checkedrev{'randomizetry'}) {
+ my ($major,$minor) = split(/\./,$rev);
+ ($reqdmajor,$reqdminor) =
+ &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,
+ $reqdmajor,$reqdminor);
+ $checkedrev{'randomizetry'} = 1;
+ }
+ }
+ }
+ my %responses = $res->responseTypes();
+ foreach my $key (keys(%responses)) {
+ if (exists($Apache::lonrelrequtils::checkresponsetypes{$key})) {
+ my $rev = $Apache::lonrelrequtils::checkresponsetypes{$key};
+ unless ($checkedrev{$key}) {
+ my ($major,$minor) = split(/\./,$rev);
+ ($reqdmajor,$reqdminor) =
+ &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,
+ $reqdmajor,$reqdminor);
+ $checkedrev{$key} = 1;
+ }
+ push(@{$byresponsetype{$symb}{$rev}},$key);
+ $allmaps{$enclosing_map} = 1;
+ }
+ }
+ }
+ if (keys(%byresource) > 0) {
+ foreach my $symb (keys(%byresource)) {
+ my ($map,$resid,$resurl)=&Apache::lonnet::decode_symb($symb);
+ $allmaps{$map} = 1;
+ }
+ }
+ if (keys(%bymap) > 0) {
+ foreach my $map (keys(%bymap)) {
+ $allmaps{$map} = 1;
+ }
+ }
+ foreach my $map (keys(%allmaps)) {
+ my $mapres = $navmap->getResourceByUrl($map);
+ if (ref($mapres)) {
+ my $mapsymb = $mapres->symb();
+ $toshow{$mapsymb} = 1;
+ my $pcslist = $mapres->map_hierarchy();
+ if ($pcslist ne '') {
+ foreach my $pc (split(/,/,$pcslist)) {
+ my $res = $navmap->getByMapPc($pc);
+ if (ref($res)) {
+ my $symb = $res->symb();
+ unless ($symb eq '______') {
+ $toshow{$symb} = 1;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ my $mapres_header = ''.
+ &mt('Requirements for specific folders or resources').
+ '';
+ if ((keys(%toshow) > 0) || (keys(%byresource) > 0) ||
+ (keys(%bysubmission) > 0) || (keys(%byresponsetype))) {
+ $output .= $mapres_header;
+ }
+ my $top_header = ''.&mt('LON-CAPA version dependencies').'';
+ my $title = 'Version Constraints';
+ my $start_page =
+ &Apache::loncommon::start_page($title,undef,{'only_body' => 1,});
+ $r->print($start_page.$top_header);
+ if ($output) {
+ $r->print($output);
+ if (defined($navmap)) {
+ &show_contents_view($r,$navmap,$cid,\%toshow,\%bymap,\%byresource,\%bysubmission,
+ \%byresponsetype,\@scopeorder,\%lt);
+ }
+ $r->print('
');
+ } else {
+ $r->print(''.
+ &mt('No version requirements from resource content or settings.').
+ ' ');
+ }
+ $r->print(&Apache::loncommon::end_page());
+ my ($currmajor,$currminor) = split(/\./,$loncaparev);
+ if (($currmajor != $reqdmajor) || ($currminor != $reqdminor)) {
+ return 1;
+ }
+ return;
+}
+
+sub show_contents_view {
+ 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");
+ my $whitespace = '';
+ my $icon = '';
+ my $topmap = $env{'course.'.$cid.'.url'};
+ $r->print(&Apache::loncommon::start_data_table().
+ &Apache::loncommon::start_data_table_header_row().
+ ''.&mt('Location').' | '.&mt('Release').' | '.
+ ''.&mt('Attribute/Setting').' | '.
+ &Apache::loncommon::end_data_table_header_row().
+ &Apache::loncommon::start_data_table_row().
+ ' '.$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;
+ my $depth = 0;
+ my %parent = ();
+ my $startcount = 5;
+ my $lastcontainer = $startcount;
+ while ($curRes = $it->next()) {
+ if ($curRes == $it->BEGIN_MAP()) {
+ $depth++;
+ $parent{$depth}= $lastcontainer;
+ }
+ if ($curRes == $it->END_MAP()) {
+ $depth--;
+ $lastcontainer = $parent{$depth};
+ }
+ my $indent;
+ for (my $i=0; $i<$depth; $i++) {
+ $indent.= $whitespace;
+ }
+ if (ref($curRes)) {
+ my $symb = $curRes->symb();
+ my $ressymb = $symb;
+ my $srcf = $curRes->src();
+ my $title = &Apache::lonnet::gettitle($srcf);
+ if (($curRes->is_sequence()) || ($curRes->is_page())) {
+ next unless($toshow->{$symb});
+ my ($parent,$ind,$url) = &Apache::lonnet::decode_symb($symb);
+ $icon = '';
+ if ($curRes->is_page()) {
+ $icon = '';
+ }
+ my $rowspan = 1;
+ if (ref($bymap->{$url}) eq 'HASH') {
+ $rowspan = scalar(keys(%{$bymap->{$url}}));
+ }
+ $r->print(&Apache::loncommon::start_data_table_row().
+ ''.$indent.$icon.' '.$title.' | ');
+ &releases_by_map($r,$bymap,$url,$scopeorder,$lt);
+ $r->print(&Apache::loncommon::end_data_table_row());
+ } else {
+ my $rowspan;
+ if (ref($byresource->{$symb}) eq 'HASH') {
+ $rowspan += scalar(keys(%{$byresource->{$symb}}));
+ }
+ if (ref($bysubmission->{$symb}) eq 'HASH') {
+ $rowspan += scalar(keys(%{$bysubmission->{$symb}}));
+ }
+ if (ref($byresponsetype->{$symb}) eq 'HASH') {
+ $rowspan += scalar(keys(%{$byresponsetype->{$symb}}));
+ }
+ next if (!$rowspan);
+ $icon = '';
+ $r->print(&Apache::loncommon::start_data_table_row().
+ ''.$indent.$icon.' '.$title.' | ');
+ my $newrow;
+ if (ref($byresource->{$symb}) eq 'HASH') {
+ foreach my $rev (sort(keys(%{$byresource->{$symb}}))) {
+ if ($newrow) {
+ $r->print(&Apache::loncommon::continue_data_table_row());
+ }
+ $r->print(''.$rev.' | ');
+ if (ref($byresource->{$symb}{$rev}) eq 'HASH') {
+ $r->print('');
+ foreach my $scope (@{$scopeorder}) {
+ if (ref($byresource->{$symb}{$rev}{$scope}) eq 'HASH') {
+ $r->print(''.&mt('Setting - scope: [_1]',$lt->{$scope}).' | ');
+ foreach my $which (sort(keys(%{$byresource->{$symb}{$rev}{$scope}}))) {
+ $r->print(''.$which.' | '.
+ join(' ',@{$byresource->{$symb}{$rev}{$scope}{$which}}).
+ ' | ');
+ }
+ $r->print(' ');
+ } elsif (ref($byresource->{$symb}{$rev}{$scope}) eq 'ARRAY') {
+ $r->print(''.&mt('Setting - scope: [_1]',$lt->{$scope}).' | '.
+ ' | '.
+ join(' ',@{$byresource->{$symb}{$rev}{$scope}}).' | ');
+ }
+ }
+ $r->print(' ');
+ }
+ $r->print(' | ');
+ $r->print(&Apache::loncommon::end_data_table_row());
+ $newrow = 1;
+ }
+ }
+ if (ref($bysubmission->{$symb}) eq 'HASH') {
+ foreach my $rev (sort(keys(%{$bysubmission->{$symb}}))) {
+ if ($newrow) {
+ $r->print(&Apache::loncommon::continue_data_table_row());
+ }
+ $r->print(''.$rev.' | ');
+ if (ref($bysubmission->{$symb}{$rev}) eq 'ARRAY') {
+ $r->print(&mt('Submissions to: ').' '.
+ join(', ',@{$bysubmission->{$symb}{$rev}}));
+ }
+ $r->print(' | ');
+ $r->print(&Apache::loncommon::end_data_table_row());
+ $newrow = 1;
+ }
+ }
+ if (ref($byresponsetype->{$symb}) eq 'HASH') {
+ foreach my $rev (sort(keys(%{$byresponsetype->{$symb}}))) {
+ if ($newrow) {
+ $r->print(&Apache::loncommon::continue_data_table_row());
+ }
+ $r->print(''.$rev.' | ');
+ if (ref($byresponsetype->{$symb}{$rev}) eq 'ARRAY') {
+ $r->print(&mt('Response Type(s): ').' '.
+ join(' ',@{$byresponsetype->{$symb}{$rev}}));
+ }
+ $r->print(' | ');
+ }
+ $r->print(&Apache::loncommon::end_data_table_row());
+ }
+ }
+ }
+ }
+ $r->print(&Apache::loncommon::end_data_table());
+ }
+ return;
+}
+
+sub releases_by_map {
+ my ($r,$bymap,$url,$scopeorder,$lt) = @_;
+ return unless ((ref($bymap) eq 'HASH') && (ref($scopeorder) eq 'ARRAY'));
+ my $newrow = 0;
+ if (ref($bymap->{$url}) eq 'HASH') {
+ foreach my $rev (sort(keys(%{$bymap->{$url}}))) {
+ if ($newrow) {
+ $r->print(&Apache::loncommon::end_data_table_row().
+ &Apache::loncommon::continue_data_table_row());
+ }
+ $r->print(''.$rev.' | ');
+ if (ref($bymap->{$url}{$rev}) eq 'HASH') {
+ $r->print('');
+ foreach my $scope (@{$scopeorder}) {
+ if (ref($bymap->{$url}{$rev}{$scope}) eq 'HASH') {
+ $r->print(''.&mt('Setting - scope: [_1]',$lt->{$scope}).' | ');
+ foreach my $which (sort(keys(%{$bymap->{$url}{$rev}{$scope}}))) {
+ $r->print(''.$which.' | '.
+ join(' ',@{$bymap->{$url}{$rev}{$scope}{$which}}).
+ ' | ');
+ }
+ $r->print(' ');
+ } elsif (ref($bymap->{$url}{$rev}{$scope}) eq 'ARRAY') {
+ $r->print(''.&mt('Setting - scope: [_1]',$lt->{$scope}).
+ ' | | '.
+ join(' ',@{$bymap->{$url}{$rev}{$scope}}).' | ');
+ }
+ }
+ $r->print(' ');
+ }
+ $r->print(' | ');
+ $newrow = 1;
+ }
+ } else {
+ $r->print(' | ');
+ }
+ return;
+}
+
+sub get_param_description {
+ my ($stdtype,$value,$regexp) = @_;
+ my ($name,$parammatches,$paramstrings,@possibles);
+ if ($stdtype =~ /^string/) {
+ $paramstrings = &Apache::lonparmset::standard_string_options($stdtype);
+ } elsif ($stdtype eq 'date_interval') {
+ $paramstrings = &Apache::lonparmset::standard_interval_options($stdtype);
+ }
+ if ($regexp) {
+ if ($stdtype =~ /^string/) {
+ $parammatches = &Apache::lonparmset::standard_string_matches($stdtype);
+ } elsif ($stdtype eq 'date_interval') {
+ $parammatches = &Apache::lonparmset::standard_interval_matches($stdtype);
+ }
+ if (ref($parammatches) eq 'ARRAY') {
+ @possibles = @{$parammatches};
+ } else {
+ undef($regexp);
+ $name = $value;
+ }
+ }
+ unless ($regexp) {
+ $name = $value;
+ if (ref($paramstrings) eq 'ARRAY') {
+ @possibles = @{$paramstrings};
+ } else {
+ if (($stdtype eq 'date_start') || ($stdtype eq 'date_end')) {
+ if ($name == 0) {
+ $name = &mt('Never');
+ } elsif (($name ne '') && ($name !~ /\D/)) {
+ $name = &Apache::lonlocal::locallocaltime($name);
+ }
+ }
+ return $name;
+ }
+ }
+ foreach my $possibilities (@possibles) {
+ next unless (ref($possibilities) eq 'ARRAY');
+ my $gotregexmatch = '';
+ if ($regexp) {
+ last if ($gotregexmatch);
+ my ($item,$pattern) = @{ $possibilities };
+ if ($value =~ /$pattern/) {
+ if (ref($paramstrings) eq 'ARRAY') {
+ foreach my $possibles (@{$paramstrings}) {
+ next unless (ref($possibles) eq 'ARRAY');
+ my ($thing,$description) = @{$possibles};
+ if ($thing eq $item) {
+ $name = $description;
+ $gotregexmatch = 1;
+ last;
+ }
+ }
+ last if ($gotregexmatch);
+ }
+ }
+ } else {
+ my ($thing,$description) = @{ $possibilities };
+ if ($thing eq $value) {
+ $name = $description;
+ last;
+ }
+ }
+ }
+ return $name;
+}
+
+sub update_releasereq {
+ my $readmap = 1;
+ my $getrelreq = 1;
+ if (ref($modified_courses) eq 'ARRAY') {
+ foreach my $item (@{$modified_courses}) {
+ if (ref($item) eq 'ARRAY') {
+ my ($cdom,$cnum,$chome,$crstype) = @{$item};
+ &Apache::lonrelrequtils::modify_course_relreq(undef,undef,$cnum,$cdom,
+ $chome,$crstype,$cdom.'_'.$cnum,
+ $readmap,$getrelreq);
+ }
+ }
+ $modified_courses = [];
+ }
+ undef($registered_cleanup);
+ return;
+}
+
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).').'';
- if (@currcoown > 0) {
+ 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));
} else {
$output .= ' '.&mt('Currently no co-owners.');
- }
+ }
return $output;
}
sub coowner_invitations {
- my ($cnum,$cdom,@currcoown) = @_;
- my ($output,@pendingcoown,@othercoords);
+ my ($cnum,$cdom,$currcoownref,$noedit) = @_;
+ my ($output,@pendingcoown,@othercoords,@currcoown);
my $pendingcoowners =
$env{'course.'.$env{'request.course.id'}.'.internal.pendingco-owners'};
if ($pendingcoowners) {
@pendingcoown = split(',',$pendingcoowners);
}
+ if (ref($currcoownref) eq 'ARRAY') {
+ @currcoown == @{$currcoownref};
+ }
+ my $disabled;
+ if ($noedit) {
+ $disabled = ' disabled="disabled"';
+ }
my $ccrole = 'cc';
my %ccroles = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,undef,[$ccrole]);
foreach my $key (sort(keys(%ccroles))) {
@@ -2071,7 +3287,7 @@ sub coowner_invitations {
''.&mt('Current co-owners').' | ';
foreach my $person (@currcoown) {
my ($co_uname,$co_dom) = split(':',$person);
- $output .= ''.(' 'x2).' ';
+ $output .= ''.(' 'x2).' ';
}
$output .= ' | '.
&Apache::loncommon::end_data_table_row();
@@ -2081,7 +3297,7 @@ sub coowner_invitations {
''.&mt('Invited as co-owners [_1](agreement pending)',' ').' | ';
foreach my $person (@pendingcoown) {
my ($co_uname,$co_dom) = split(':',$person);
- $output .= ''.(' 'x2).' ';
+ $output .= ''.(' 'x2).' ';
}
$output .= ' | '.
&Apache::loncommon::end_data_table_row();
@@ -2091,7 +3307,7 @@ sub coowner_invitations {
''.&mt('Invite other Coordinators [_1]to become co-owners',' ').' | ';
foreach my $person (@othercoords) {
my ($co_uname,$co_dom) = split(':',$person);
- $output .= ''.(' 'x2).' ';
+ $output .= ''.(' 'x2).' ';
}
$output .= ' | '.
&Apache::loncommon::end_data_table_row();
@@ -2104,13 +3320,20 @@ sub coowner_invitations {
}
sub manage_coownership {
- my ($cnum,$cdom,@currcoown) = @_;
- my (@pendingcoown);
+ my ($cnum,$cdom,$currcoownref,$noedit) = @_;
+ my (@pendingcoown,@currcoown);
my $pendingcoowners =
$env{'course.'.$env{'request.course.id'}.'.internal.pendingco-owners'};
if ($pendingcoowners) {
@pendingcoown = split(',',$pendingcoowners);
}
+ if (ref($currcoownref) eq 'ARRAY') {
+ @currcoown == @{$currcoownref};
+ }
+ my $disabled;
+ if ($noedit) {
+ $disabled = ' disabled="disabled"';
+ }
my ($is_coowner,$is_pending,$output);
my $uname = $env{'user.name'};
my $udom = $env{'user.domain'};
@@ -2124,26 +3347,26 @@ sub manage_coownership {
$output = &Apache::loncommon::start_data_table();
}
if (@currcoown) {
- if ($is_coowner || $is_pending) {
+ if ($is_coowner || $is_pending) {
$output .= &Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_row().'';
}
$output .= &mt('Current co-owners are:').' '.
- join(', ', map { &Apache::loncommon::plainname(split(':',$_)); } (@currcoown));
+ join(', ', map { &Apache::loncommon::plainname(split(':',$_)); } (@currcoown));
if ($is_coowner || $is_pending) {
- $output .= ' | '.&Apache::loncommon::end_data_table_row();
+ $output .= ''.&Apache::loncommon::end_data_table_row();
}
}
if ($is_coowner || $is_pending) {
- if (@currcoown) {
+ if (@currcoown) {
$output .= &Apache::loncommon::start_data_table_row().'';
}
$output .= '';
if ($is_coowner) {
$output .= &mt('You are currently a co-owner:').' ';
} else {
- $output .= &mt('The course owner has invited you to become a co-owner:').' '.(' 'x2).
- '';
+ $output .= &mt('The course owner has invited you to become a co-owner:').' '.(' 'x2).
+ '';
}
$output .= '';
if (@currcoown) {
@@ -2157,36 +3380,43 @@ sub manage_coownership {
}
sub print_localization {
- my ($cdom,$settings,$ordered,$itemtext,$rowtotal) = @_;
+ my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$noedit) = @_;
unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
return;
}
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',
},
);
- my $datatable;
+ my ($datatable,$disabled);
my $count = 0;
+ if ($noedit) {
+ $disabled = ' disabled="disabled"';
+ }
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();
$datatable .=
&Apache::loncommon::select_timezone($item,$timezone,undef,
- $includeempty);
+ $includeempty,$disabled);
} elsif ($item eq 'datelocale') {
my $includeempty = 1;
my $locale_obj = &Apache::lonlocal::getdatelocale();
@@ -2196,15 +3426,18 @@ sub print_localization {
}
$datatable .=
&Apache::loncommon::select_datelocale($item,$currdatelocale,
- undef,$includeempty);
+ undef,$includeempty,$disabled);
} else {
if ($settings->{$item} eq '') {
- $datatable .=
- &Apache::loncommon::select_language('languages_0','',1);
+ unless ($noedit) {
+ $datatable .= ' | '.
+ &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) {
@@ -2219,19 +3452,22 @@ sub print_localization {
' '.
' | '.
&Apache::loncommon::end_data_table_row();
$num ++;
}
}
- $datatable .= &Apache::loncommon::start_data_table_row().
+ unless ($noedit) {
+ $datatable .=
+ &Apache::loncommon::start_data_table_row().
''.
&mt('Additional language:'). ' '.
&Apache::loncommon::select_language('languages_'.$num,'',1).
''.
- ' | '.&Apache::loncommon::end_data_table_row().
- &Apache::loncommon::end_data_table();
+ ''.&Apache::loncommon::end_data_table_row();
+ }
+ $datatable .= &Apache::loncommon::end_data_table().' ';
}
}
$datatable .= &item_table_row_end();
@@ -2252,7 +3488,7 @@ sub get_lang_choices {
}
sub print_feedback {
- my ($position,$cdom,$settings,$ordered,$itemtext,$rowtotal) = @_;
+ my ($position,$cdom,$settings,$ordered,$itemtext,$rowtotal,$noedit) = @_;
unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
return;
}
@@ -2287,17 +3523,25 @@ sub print_feedback {
del => 'Delete?',
sec => 'Sections:',
);
-
+ my $disabled;
+ if ($noedit) {
+ $disabled = ' disabled="disabled"';
+ }
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",2);
+ }
if ($position eq 'top') {
my $includeempty = 0;
- $datatable .= &user_table($cdom,$item,\@sections,
- $settings->{$item},\%lt);
+ $datatable .= ''.
+ &user_table($cdom,$item,\@sections,
+ $settings->{$item},\%lt,$noedit);
} else {
$datatable .= &Apache::lonhtmlcommon::textbox($item.'.text',
- $settings->{$item.'.text'},$items{$item}{size});
+ $settings->{$item.'.text'},$items{$item}{size},$disabled);
}
$datatable .= &item_table_row_end();
}
@@ -2306,15 +3550,21 @@ sub print_feedback {
}
sub user_table {
- my ($cdom,$item,$sections,$currvalue,$lt) = @_;
+ my ($cdom,$item,$sections,$currvalue,$lt,$noedit) = @_;
my $output;
if ($currvalue eq '') {
- $output .= &select_recipient($item,'0',$cdom,$sections);
+ unless ($noedit) {
+ $output .= &select_recipient($item,'0',$cdom,$sections);
+ }
} else {
my $num = 0;
my @curr = split(/,/,$currvalue);
- $output .= '';
+ $output .= '';
my ($currusers);
+ my $disabled;
+ if ($noedit) {
+ $disabled = ' disabled="disabled"';
+ }
foreach my $val (@curr) {
next if ($val eq '');
my ($uname,$udom,$seclist) = ($val =~ /^($match_username):($match_domain)(\(?[^\)]*\)?)$/);
@@ -2326,7 +3576,7 @@ sub user_table {
$currusers .= ''.
''.
''.
''.(' 'x2).
@@ -2337,7 +3587,7 @@ sub user_table {
if (@{$sections}) {
$currusers.= (' 'x3).$lt->{'sec'}.' '.
&select_sections($item,$num,$sections,
- \@selsec);
+ \@selsec,$noedit);
}
}
$currusers .= ' | ';
@@ -2355,12 +3605,16 @@ sub user_table {
''.
'';
}
- $output .= ''.
+ unless ($noedit) {
+ $output .=
+ ' '.
''.
$lt->{'add'}.' '.
&select_recipient($item,$num,$cdom,$sections).
''.
- ' | ';
+ '';
+ }
+ $output .= ' ';
}
return $output;
}
@@ -2387,14 +3641,17 @@ sub select_recipient {
}
sub select_sections {
- my ($item,$num,$sections,$selected) = @_;
- my ($output,@currsecs,$allsec);
+ my ($item,$num,$sections,$selected,$noedit) = @_;
+ my ($output,@currsecs,$allsec,$disabled);
if (ref($selected) eq 'ARRAY') {
@currsecs = @{$selected};
}
if (!@currsecs) {
$allsec = ' selected="selected"';
}
+ if ($noedit) {
+ $disabled = ' disabled="disabled"';
+ }
if (ref($sections) eq 'ARRAY') {
if (@{$sections}) {
my $mult;
@@ -2404,7 +3661,7 @@ sub select_sections {
$mult .= ' size="4"';
}
}
- $output = ' | | | |