--- loncom/interface/lonparmset.pm 2009/02/19 10:19:49 1.434 +++ loncom/interface/lonparmset.pm 2009/07/01 17:11:38 1.466 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.434 2009/02/19 10:19:49 biermanm Exp $ +# $Id: lonparmset.pm,v 1.466 2009/07/01 17:11:38 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -214,19 +214,6 @@ Variables used (guessed by Jeremy): When storing information, store as part 0 When requesting information, request from full part -=item crsenv() - -Show and set course data and parameters. This is a large routine that should -be simplified and shortened... someday. - -Inputs: $r - -Returns: nothing - -=item can_modify_catsettings() - -=item assign_course_categories() - =item tablestart() =item tableend() @@ -322,7 +309,7 @@ Set portfolio metadata =item handler() : -Main handler. Calls &assessparms and &crsenv subroutines. +Main handler. Calls &assessparms subroutine. =back @@ -366,7 +353,7 @@ sub parmval_by_symb { my $result=''; my @outpar=(); # ----------------------------------------------------- Cascading lookup scheme - my $map=(&Apache::lonnet::decode_symb($symb))[0]; + my $map=(&Apache::lonnet::decode_symb($symb))[0]; $map = &Apache::lonnet::deversion($map); my $symbparm=$symb.'.'.$what; @@ -468,7 +455,7 @@ sub parmval_by_symb { # --- Caches local to lonparmset - + sub reset_caches { &resetparmhash(); &resetsymbcache(); @@ -482,7 +469,7 @@ sub reset_caches { undef($parmhashid); undef(%parmhash); } - + sub cacheparmhash { if ($parmhashid eq $env{'request.course.fn'}) { return; } my %parmhashfile; @@ -493,7 +480,7 @@ sub reset_caches { $parmhashid=$env{'request.course.fn'}; } } - + sub parmhash { my ($id) = @_; &cacheparmhash(); @@ -501,14 +488,14 @@ sub reset_caches { } } -{ +{ my $symbsid; my %symbs; sub resetsymbcache { undef($symbsid); undef(%symbs); } - + sub symbcache { my $id=shift; if ($symbsid ne $env{'request.course.id'}) { @@ -529,14 +516,14 @@ sub reset_caches { } } -{ +{ my $rulesid; my %rules; sub resetrulescache { undef($rulesid); undef(%rules); } - + sub rulescache { my $id=shift; if ($rulesid ne $env{'request.course.id'} @@ -683,7 +670,7 @@ sub storeparm_by_symb_inner { my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$cgroup)=@_; # ---------------------------------------------------------- Construct prefixes $spnam=~s/\_([^\_]+)$/\.$1/; - my $map=(&Apache::lonnet::decode_symb($symb))[0]; + my $map=(&Apache::lonnet::decode_symb($symb))[0]; $map = &Apache::lonnet::deversion($map); my $symbparm=$symb.'.'.$spnam; @@ -696,11 +683,11 @@ sub storeparm_by_symb_inner { my $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$spnam; my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm; my $seclevelm=$env{'request.course.id'}.'.['.$csec.'].'.$mapparm; - + my $courselevel=$env{'request.course.id'}.'.'.$spnam; my $courselevelr=$env{'request.course.id'}.'.'.$symbparm; my $courselevelm=$env{'request.course.id'}.'.'.$mapparm; - + my $storeunder=''; if (($snum==14) || ($snum==3)) { $storeunder=$courselevel; } if (($snum==13) || ($snum==2)) { $storeunder=$courselevelm; } @@ -712,7 +699,7 @@ sub storeparm_by_symb_inner { if ($snum==5) { $storeunder=$grplevelm; } if ($snum==4) { $storeunder=$grplevelr; } - + my $delete; if ($nval eq '') { $delete=1;} my %storecontent = ($storeunder => $nval, @@ -769,7 +756,7 @@ sub storeparm_by_symb_inner { } &Apache::lonnet::devalidateuserresdata($uname,$udom); } - + if ($reply=~/^error\:(.*)/) { return "Write Error: $1"; } @@ -867,7 +854,7 @@ sub page_js { return(< - +// $selscript ENDJS @@ -926,11 +914,11 @@ sub startpage { text=>"Table Mode", help => 'Course_Setting_Parameters'}); } - my $start_page = + my $start_page = &Apache::loncommon::start_page('Set/Modify Course Parameters', &page_js(), {'add_entries' => \%loaditems,}); - my $breadcrumbs = + my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Table Mode Parameter Setting','Table_Mode'); $r->print(<0;$i--) { - if ($typeoutpar[$i]) { + if ($typeoutpar[$i]) { $cascadetype=$typeoutpar[$i]; } else { $typeoutpar[$i]=$cascadetype; @@ -981,7 +969,7 @@ sub print_row { $parm.='
'.&mt('Automatically sets').' '.join(', ',split(/\:/,$automatic)).'
'; } $r->print(''.$parm.''); - + my $thismarker=$which; $thismarker=~s/^parameter\_//; my $mprefix=$rid.'&'.$thismarker.'&'; @@ -995,9 +983,9 @@ sub print_row { } elsif ($cgroup) { &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); } elsif ($csec) { - &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); } else { - &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); } } elsif ($parmlev eq 'map') { @@ -1034,7 +1022,7 @@ sub print_row { &print_td($r,12,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); &print_td($r,11,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); &print_td($r,10,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); - + if ($csec) { &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); @@ -1046,7 +1034,7 @@ sub print_row { &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); &print_td($r,4,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); } - + if ($uname) { if ($othergrp) { $r->print($othergrp); @@ -1076,12 +1064,20 @@ sub print_td { my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display)=@_; $r->print(''); - if ($which<11 || $which > 12) { - $r->print(&plink($$typeoutpar[$which], - $$display{$value},$$outpar[$which], - $mprefix."$which",'parmform.pres','psub')); + my $nolink = 0; + if ($which == 11 || $which == 12) { + $nolink = 1; + } elsif ($mprefix =~ /availablestudent\&$/) { + if ($which > 3) { + $nolink = 1; + } + } + if ($nolink) { + $r->print(&valout($$outpar[$which],$$typeoutpar[$which])); } else { - $r->print(&valout($$outpar[$which],$$typeoutpar[$which])); + $r->print(&plink($$typeoutpar[$which], + $$display{$value},$$outpar[$which], + $mprefix."$which",'parmform.pres','psub')); } $r->print(''."\n"); } @@ -1099,7 +1095,7 @@ sub print_usergroups { $courseopt); my $bgcolor = $defbg; my $grp_parm; - if (($coursereply) && ($cgroup ne $resultgroup)) { + if (($coursereply) && ($cgroup ne $resultgroup)) { if ($result > 3) { $bgcolor = '#AAFFAA'; $grp_parm = &valout($coursereply,$resulttype); @@ -1213,14 +1209,14 @@ sub extractResourceInformation { } # # Put in order -# +# unless ($$keyorder{$key}) { $$keyorder{$key}=$keyordercnt; $keyordercnt++; } } - + if (!exists($$mapp{$mapid})) { $$mapp{$id}= &Apache::lonnet::declutter($resource->enclosing_map_src()); @@ -1230,7 +1226,7 @@ sub extractResourceInformation { $$maptitles{$mapid}=&mt('Main Course Documents'); } else { $$maptitles{$mapid}= - &Apache::lonnet::gettitle($$mapp{$id}); + &Apache::lonnet::gettitle($$mapp{$id}); } $$maptitles{$$mapp{$id}}=$$maptitles{$mapid}; $$symbp{$mapid}=$$mapp{$id}.'___(all)'; @@ -1253,16 +1249,29 @@ sub parmmenu { my $tempkey; $r->print(< +// ENDSCRIPT - $r->print(); - $r->print("\n".''); - my $cnt=0; + $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parameters to View'))); + + #part to print selected parms overview + $r->print(&mt('Selected Parameters:').'
'); + + #print out all possible parms and hide them by default + $r->print('
    '); foreach $tempkey (&keysindisplayorder($allparms,$keyorder)) { - $r->print("\n".'
'); - $cnt++; - if ($cnt==3) { - $r->print("\n"); - $cnt=0; - } + $r->print('
  • print(' style="display:none"'); + } + $r->print('>' + .($$allparms{$tempkey}=~/\S/ ? $$allparms{$tempkey} : $tempkey) + .'
  • ' + ); + } + $r->print('' + .'

    ' + .&mt('Show detailed Parameter Selection') + .'

    ' + ); + + &shortCuts($r,$allparms,$pscat,$keyorder); + + $r->print(&Apache::lonhtmlcommon::row_closure(1)); +} +# return a hash +sub categories { + return ('time_settings' => 'Time Settings', + 'grading' => 'Grading', + 'tries' => 'Tries', + 'problem_appearance' => 'Problem Appearance', + 'behaviour_of_input_fields' => 'Behaviour of Input Fields', + 'hiding' => 'Hiding', + 'high_level_randomization' => 'High Level Randomization', + 'slots' => 'Slots', + 'file_submission' => 'File Submission', + 'misc' => 'Miscellaneous' ); +} + +# return a hash. Like a look-up table +sub lookUpTableParameter { + + return ( + 'opendate' => 'time_settings', + 'duedate' => 'time_settings', + 'answerdate' => 'time_settings', + 'interval' => 'time_settings', + 'contentopen' => 'time_settings', + 'contentclose' => 'time_settings', + 'discussend' => 'time_settings', + 'weight' => 'grading', + 'handgrade' => 'grading', + 'maxtries' => 'tries', + 'hinttries' => 'tries', + 'type' => 'problem_appearance', + 'problemstatus' => 'problem_appearance', + 'display' => 'problem_appearance', + 'ordered' => 'problem_appearance', + 'numbubbles' => 'problem_appearance', + 'tol' => 'behaviour_of_input_fields', + 'sig' => 'behaviour_of_input_fields', + 'turnoffunit' => 'behaviour_of_input_fields', + 'hiddenresource' => 'hiding', + 'hiddenparts' => 'hiding', + 'discusshide' => 'hiding', + 'buttonshide' => 'hiding', + 'turnoffeditor' => 'hiding', + 'encrypturl' => 'hiding', + 'randomorder' => 'high_level_randomization', + 'randompick' => 'high_level_randomization', + 'available' => 'slots', + 'useslots' => 'slots', + 'availablestudent' => 'slots', + 'uploadedfiletypes' => 'file_submission', + 'maxfilesize' => 'file_submission', + 'cssfile' => 'misc', + 'mapalias' => 'misc', + 'acc' => 'misc', + 'maxcollaborators' => 'misc', + 'scoreformat' => 'misc', + + ); +} + +sub whatIsMyCategory { + my $name = shift; + my $catList = shift; + my @list; + my %lookUpList = &lookUpTableParameter; #Initilize the lookupList + my $cat = $lookUpList{$name}; + if (defined($cat)) { + if (!defined($$catList{$cat})){ + push @list, ($name); + $$catList{$cat} = \@list; + } else { + push @{${$catList}{$cat}}, ($name); + } + } else { + if (!defined($$catList{'misc'})){ + push @list, ($name); + $$catList{'misc'} = \@list; + } else { + push @{${$catList}{'misc'}}, ($name); + } + } +} + +sub keysindisplayorderCategory { + my ($name,$keyorder)=@_; + return sort { + $$keyorder{'parameter_0_'.$a} <=> $$keyorder{'parameter_0_'.$b}; + } ( @{$name}); +} + + +sub parmboxes { + my ($r,$allparms,$pscat,$keyorder)=@_; + my $tempkey; + my $tempparameter; + my %categories = &categories; + my %categoryList = ( + 'time_settings' => [], + 'grading' => [], + 'tries' => [], + 'problem_appearance' => [], + 'behaviour_of_input_fields' => [], + 'hiding' => [], + 'high_level_randomization' => [], + 'slots' => [], + 'file_submission' => [], + 'misc' => [], + ); + + foreach $tempparameter (keys %$allparms) { + &whatIsMyCategory($tempparameter, \%categoryList); + } + #part to print the parm-list + $r->print('' - .'' + $r->print('
    ' + .'' + .&mt('Hide') + .'' + ); + + #&shortCuts($r,$allparms,$pscat,$keyorder); + $r->print(''); +} +sub shortCuts { + my ($r,$allparms,$pscat,$keyorder)=@_; + + #part to print out the shortcuts for parmselection + $r->print('
    ' .'' .'' - .'
    ' - .'
    '.&mt('Parameter Selection').'' + .'
    '.&mt('Parameter Selection').'' .'' .'• '.&mt('Select All').'' .'' @@ -1349,7 +1539,7 @@ ENDSCRIPT .'
    ' .'
    ' - .'
    '.&mt('Add Selection for...').'' + .'
    '.&mt('Add Selection for...').'' .'' .'• '.&mt('Problem Dates').'' .'' @@ -1369,12 +1559,12 @@ ENDSCRIPT .'' .'
    ' .'
    ' - ); + .''); } sub partmenu { my ($r,$allparts,$psprt)=@_; + $r->print('
    '; - $g_s_footer='
    '; + $r->print(&Apache::lonhtmlcommon::row_title(&mt('Group/Section'))); + $r->print($sections.$groups); + $r->print(&Apache::lonhtmlcommon::row_closure()); } - $r->print('' - .$g_s_header - .$sections - .$groups - .$g_s_footer - .'
    '.&mt('User').'
    ' - .&mt('For User [_1] or Student/Employee ID [_2] at Domain [_3]' + $r->print(&Apache::lonhtmlcommon::row_title(&mt('User'))); + $r->print(&mt('For User [_1] or Student/Employee ID [_2] at Domain [_3]' ,'' ,' ' - ,$chooseopt) - .'
    ' - .'
    ' - ); + ,$chooseopt)); } sub displaymenu { my ($r,$allparms,$allparts,$pscat,$psprt,$keyorder)=@_; - $r->print('
    '.&mt('Select Parameters to View').''. - &mt('Select Parts to View').'
    '); + $r->print(&Apache::lonhtmlcommon::topic_bar (2,&mt('Select Parameters'))); + $r->print(&Apache::lonhtmlcommon::start_pick_box()); &parmmenu($r,$allparms,$pscat,$keyorder); - $r->print(''); + $r->print(&Apache::lonhtmlcommon::end_pick_box()); + &parmboxes($r,$allparms,$pscat,$keyorder); + $r->print(&Apache::lonhtmlcommon::start_pick_box()); + $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parts to View'))); &partmenu($r,$allparts,$psprt); - $r->print('
    '); + $r->print(&Apache::lonhtmlcommon::row_closure(1)); + $r->print(&Apache::lonhtmlcommon::end_pick_box()); } sub mapmenu { my ($r,$allmaps,$pschp,$maptitles)=@_; - $r->print(''.&mt('Select Enclosing Map or Folder').' '); - $r->print('' + .&mt('All Maps or Folders') + .'' + .&Apache::loncommon::end_data_table_row() + ); + my $whitespace = ''; + foreach my $mapid (@{$tree}) { + # Indentation + my $depth = $treeinfo->{$mapid}->{'depth'}; + my $indent; + for (my $i = 0; $i < $depth; $i++) { + $indent.= $whitespace; + } + $icon = ''; + if ($treeinfo->{$mapid}->{'type'} eq 'page') { + $icon = ''; + } + $r->print(&Apache::loncommon::start_data_table_row() + .''.$indent.$icon + .'' + .'' + .&Apache::loncommon::end_data_table_row() + ); + } + $r->print(&Apache::loncommon::end_data_table()); } - $r->print(""); } sub levelmenu { my ($r,$alllevs,$parmlev)=@_; - $r->print(''.&mt('Select Parameter Level'). - &Apache::loncommon::help_open_topic('Course_Parameter_Levels').' '); + + $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parameter Level').&Apache::loncommon::help_open_topic('Course_Parameter_Levels'))); $r->print('
    '); } - &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups); + $r->print(&Apache::lonhtmlcommon::topic_bar (3,&mt('User Selection'))); + $r->print(&Apache::lonhtmlcommon::start_pick_box()); + &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups); + $r->print(&Apache::lonhtmlcommon::row_closure(1)); + $r->print(&Apache::lonhtmlcommon::end_pick_box()); + + # parm selection is shown: display parm update button + $r->print('

    ' + .'' + .'' + .'

    ' + ); + + $r->print(''); + # ----- End Parameter Selection - $r->print('

    '.$message.'

    '); + # Offer link to display parameter selection again + $r->print(''); + + # Display Messages + $r->print('
    '.$message.'
    '); - $r->print('
    '); my @temp_pscat; map { @@ -1864,8 +2212,8 @@ sub assessparms { my $userspan=3; if ($cgroup ne '') { $coursespan += 3; - } - + } + $r->print('

    '); $r->print(''); $r->print(''); @@ -1941,7 +2289,7 @@ ENDTABLEHEADFOUR my $rid=$_; my ($inmapid)=($rid=~/\.(\d+)$/); - if ((!$pssymb && + if ((!$pssymb && (($pschp eq 'all') || ($allmaps{$pschp} eq $mapp{$rid}))) || ($pssymb && $pssymb eq $symbp{$rid})) { @@ -2046,7 +2394,7 @@ ENDTABLEHEADFOUR my %maplist; if ($pschp eq 'all') { - %maplist = %allmaps; + %maplist = %allmaps; } else { %maplist = ($pschp => $mapp{$pschp}); } @@ -2066,11 +2414,11 @@ ENDTABLEHEADFOUR my $map = 0; # $r->print("Catmarker: @catmarker
    \n"); - + foreach (@ids) { ($map)=(/([\d]*?)\./); my $rid = $_; - + # $r->print("$mapid:$map: $rid
    \n"); if ($map eq $mapid) { @@ -2088,7 +2436,7 @@ ENDTABLEHEADFOUR my $tempkeyp = $_; my $fullkeyp = $tempkeyp; $tempkeyp =~ s/_\w+_/_0_/; - + if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) { $part{$tempkeyp}="0"; $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name'); @@ -2111,7 +2459,7 @@ ENDTABLEHEADFOUR } # end loop through keys } } # end loop through ids - + #---------------------------------------------------- print header information my $foldermap=&mt($maptitle=~/^uploaded/?'Folder':'Map'); my $showtitle=$maptitles{$maptitle}.($maptitle!~/^uploaded/?' ['.$maptitle.']':''); @@ -2174,10 +2522,10 @@ ENDTABLEHEADFOUR my %display = (); my %type = (); my %default = (); - + foreach (@ids) { my $rid = $_; - + my $uri=&Apache::lonnet::declutter($uris{$rid}); #-------------------------------------------------------------------- @@ -2212,7 +2560,7 @@ ENDTABLEHEADFOUR } } # end loop through keys } # end loop through ids - + #---------------------------------------------------- print header information my $setdef=&mt("Set Defaults for All Resources in Course"); $r->print(<print(" ".&mt("ALL")." ".&mt("USERS")." \n"); } - + if ($csec) {$r->print(&mt("Section")." $csec\n")}; if ($cgroup) {$r->print(&mt("Group")." $cgroup\n")}; $r->print("\n"); @@ -2254,619 +2602,6 @@ ENDMAPONE $r->print(''.&Apache::loncommon::end_page()); } # end sub assessparms - - -sub crsenv { - my $r=shift; - my $setoutput=''; - - &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=crsenv', - text=>"Course Environment"}); - my $breadcrumbs = - &Apache::lonhtmlcommon::breadcrumbs('Edit Course Environment'); - my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; - - my (%crsinfo,$chome); - - # - # Go through list of changes - foreach (keys %env) { - next if ($_!~/^form\.(.+)\_setparmval$/); - my $name = $1; - my $value = $env{'form.'.$name.'_value'}; - if ($name eq 'newp') { - $name = $env{'form.newp_name'}; - } - if ($name eq 'url') { - $value=~s/^\/res\///; - my $bkuptime=time; - my @tmp = &Apache::lonnet::get - ('environment',['url'],$dom,$crs); - $setoutput.=&mt('Backing up previous URL').': '. - &Apache::lonnet::put - ('environment', - {'top level map backup '.$bkuptime => $tmp[1] }, - $dom,$crs). - '
    '; - } - # - # Deal with modified default spreadsheets - if ($name =~ /^spreadsheet_default_(classcalc| - studentcalc| - assesscalc)$/x) { - my $sheettype = $1; - if ($sheettype eq 'classcalc') { - # no need to do anything since viewing the sheet will - # cause it to be updated. - } elsif ($sheettype eq 'studentcalc') { - # expire all the student spreadsheets - &Apache::lonnet::expirespread('','','studentcalc'); - } else { - # expire all the assessment spreadsheets - # this includes non-default spreadsheets, but better to - # be safe than sorry. - &Apache::lonnet::expirespread('','','assesscalc'); - # expire all the student spreadsheets - &Apache::lonnet::expirespread('','','studentcalc'); - } - } - # - # Deal with the enrollment dates - if ($name =~ /^default_enrollment_(start|end)_date$/) { - $value=&Apache::lonhtmlcommon::get_date_from_form($name.'_value'); - } - # - # Deal with the emails - if ($name =~ /\.email$/) { - foreach my $specifier (split(',',$value)) { - my ($user,$sections_or_groups)= - ($specifier=~/^([^\(]+)\(([^\)]+)\)/); - if (!$sections_or_groups) { - $user = $specifier; - } - my ($name,$domain) = split(':',$user); - if (!defined($user) || !defined($domain)) { - $setoutput.= '
    '. - &mt("Invalid e-mail address specified, address must be of the form username:domain what was specified was ([_1])",$user). - ''; - undef($value); - } elsif (&Apache::lonnet::homeserver($user,$domain) eq 'no_host') { - $setoutput.= '
    '. - &mt("Invalid e-mail address specified, user [_1] is unknown.",$name). - ''; - undef($value); - } - } - } - # Get existing cloners - my @oldcloner = (); - if ($name eq 'cloners') { - my %clonenames=&Apache::lonnet::dump('environment',$dom,$crs,'cloners'); - if ($clonenames{'cloners'} =~ /,/) { - @oldcloner = split/,/,$clonenames{'cloners'}; - } else { - $oldcloner[0] = $clonenames{'cloners'}; - } - } - # - # Let the user know we made the changes - if ($name && defined($value)) { - my %failed_cloners; - if ($name eq 'cloners') { - $value =~ s/\s//g; - $value =~ s/^,//; - $value =~ s/,$//; - # check requested clones are valid users. - %failed_cloners = &check_cloners(\$value,\@oldcloner); - } - my $put_result = &Apache::lonnet::put('environment', - {$name=>$value},$dom,$crs); - if ($put_result eq 'ok') { - $setoutput.=&mt('Set').' '.$name.' '.&mt('to').' '; - if ($name =~ /^default_enrollment_(start|end)_date$/) { - $setoutput .= &Apache::lonlocal::locallocaltime($value); - } elsif ($name eq 'categories') { - $setoutput .= $env{'form.categories_display'}; - } else { - $setoutput .= $value; - } - $setoutput .= '.
    '; - if ($name eq 'cloners') { - &change_clone($value,\@oldcloner); - } - # Update environment and nohist_courseids.db - if (($name eq 'description') || ($name eq 'cloners') || - ($name eq 'hidefromcat') || ($name eq 'categories')) { - if ($chome eq '') { - %crsinfo = - &Apache::lonnet::courseiddump($dom,'.',1,'.','.', - $crs,undef,undef,'.'); - $chome = &Apache::lonnet::homeserver($crs,$dom); - } - } - if ($name eq 'description' && defined($value)) { - &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.description' => $value}); - if (ref($crsinfo{$env{'request.course.id'}}) eq 'HASH') { - $crsinfo{$env{'request.course.id'}}{'description'} = $value; - my $putresult = - &Apache::lonnet::courseidput($dom,\%crsinfo, - $chome,'notime'); - } - } - if (($name eq 'cloners') || ($name eq 'hidefromcat') || ($name eq 'categories')) { - if (ref($crsinfo{$env{'request.course.id'}}) eq 'HASH') { - &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.'.$name => $value}); - $crsinfo{$env{'request.course.id'}}{$name} = $value; - my $putresult = - &Apache::lonnet::courseidput($dom,\%crsinfo, - $chome,'notime'); - } - } - } else { - $setoutput.=&mt('Unable to set').' '.$name.' '.&mt('to'). - ' '.$value.' '.&mt('due to').' '.$put_result.'.
    '; - } - if (($name eq 'cloners') && (keys(%failed_cloners) > 0)) { - $setoutput.= &mt('Unable to include').': '; - my @fails; - my $num = 0; - if (defined($failed_cloners{'format'})) { - $fails[$num] .= ''.$failed_cloners{'format'}. - ', '.&mt('reason').' - '. - &mt('Invalid format'); - $num ++; - } - if (defined($failed_cloners{'domain'})) { - $fails[$num] .= ''.$failed_cloners{'domain'}. - ', '.&mt('reason').' - '. - &mt('Domain does not exist'); - $num ++; - } - if (defined($failed_cloners{'newuser'})) { - $fails[$num] .= ''.$failed_cloners{'newuser'}. ', '.&mt('reason').' - '. - &mt('LON-CAPA user(s) do(es) not exist.'). - '.
    '.&mt('Please '). - ' '. - &mt('add the user(s)').', '. - &mt('and then return to the '). - ''. - &mt('Course Parameters page').' '. - &mt('to add the new user(s) to the list of possible cloners'); - } - $setoutput .= join(';  ',@fails).'.
    '; - } - } - } - - my $start_table =&Apache::loncommon::start_data_table(); - my $start_header_row=&Apache::loncommon::start_data_table_header_row(); - my $end_header_row =&Apache::loncommon::end_data_table_header_row(); -# ------------------------- Re-init course environment entries for this session - - &Apache::lonnet::coursedescription($env{'request.course.id'}, - {'freshen_cache' => 1}); - -# -------------------------------------------------------- Get parameters again - - my %values=&Apache::lonnet::dump('environment',$dom,$crs); - my $SelectStyleFile=&mt('Select Style File'); - my $SelectSpreadsheetFile=&mt('Select Spreadsheet File'); - my $output=''; - my $can_categorize; - if (! exists($values{'con_lost'})) { - my %descriptions= - ('url' => ''.&mt('Top Level Map').'
    '. - '". - &mt('Select Map').'
    '. - &mt('Modification may make assessment data inaccessible!'). - '', - 'description' => ''.&mt('Course Description').'', - 'courseid' => ''.&mt('Course ID or number'). - '
    '. - '('.&mt('internal, optional').')', - 'cloners' => ''.&mt('Users allowed to clone course').'
    ' - .'("'.&mt('user:domain,user:domain,*:domain').'")
    ' - .&mt('Users with active Course Coordinator role in this course are permitted to clone and need not be included.').'
    ' - .&mt('Use [_1] to allow course to be cloned by anyone in the specified domain.','"*:domain"').'
    ' - .&mt('Use [_1] to allow unrestricted cloning in all domains.','"*"'), - 'grading' => ''.&mt('Grading').'
    '. - &mt('[_1], [_2], or [_3]','"standard"','"external"','"spreadsheet"').&Apache::loncommon::help_open_topic('GradingOptions'), - 'task_grading' => ''.&mt('Bridge Task Grading').'
    ' - .&mt('Instructors and TAs in sections, when grading bridge tasks, should be allowed to grade other sections.').'
    ' - .'('.&mt('[_1]: they are allowed (this is the default). [_2]: no, they can only grade their own section.','"any"','"section"').')', - 'default_xml_style' => ''.&mt('Default XML Style File').'
    '. - '$SelectStyleFile
    ", - 'question.email' => ''.&mt('Feedback Addresses for Resource Content Question').'
    ' - .'("'.&mt('user:domain,user:domain(section;section;...;*;...),...').'")', - 'question.email.text' => ''.&mt('Custom Text for Resource Content Question Option in Feedback').'', - 'comment.email' => ''.&mt('Feedback Addresses for Course Content Comments').'
    ' - .'("'.&mt('user:domain,user:domain(section;section;...;*;...),...').'")', - 'comment.email.text' => ''.&mt('Custom Text for Course Content Option in Feedback').'', - 'policy.email' => ''.&mt('Feedback Addresses for Course Policy').'
    ' - .'("'.&mt('user:domain,user:domain(section;section;...;*;...),...').'")', - 'policy.email.text' => ''.&mt('Custom Text for Course Policy Option in Feedback').'', - 'hideemptyrows' => ''.&mt('Hide Empty Rows in Spreadsheets').'
    ' - .'('.&mt('[_1] for default hiding','"yes"').')', - 'pageseparators' => ''.&mt('Visibly Separate Items on Pages').'
    ' - .'('.&mt('[_1] for visible separation.','"yes"').' ' - .&mt('Changes will not show until next login.').')', - 'student_classlist_view' => ''.&mt('Allow students to view classlist.').'
    ' - .'('.&mt('[_1]: students can view all sections. [_2]: students can only view their own section. blank or [_3] prevents student view.','"all"','"section"','"disabled"').')', - 'student_classlist_portfiles' => ''.&mt('Include link to accessible portfolio files').'
    ' - .'('.&mt("[_1] for link to each a listing of each student's files.",'"yes"').')', - 'student_classlist_opt_in' => ''.&mt("Student's agreement needed for listing in student-viewable roster").'
    ' - .'('.&mt('[_1] to require students to opt-in to listing in the roster (on the roster page).','"yes"').')', - 'plc.roles.denied'=> ''.&mt('Disallow live chatroom use for Roles').'
    ' - .'('.&mt('[_1]: student, [_2]: TA, [_3]: instructor','"st"','"ta"','"in"').')
    ' - .'("'.&mt('role,role,...').'") ' - .Apache::loncommon::help_open_topic("Course_Disable_Discussion"), - 'plc.users.denied' => - ''.&mt('Disallow live chatroom use for Users').'
    '. - '("'.&mt('user:domain,user:domain,...').'")', - - 'pch.roles.denied'=> ''.&mt('Disallow Resource Discussion for Roles').'
    ' - .'('.&mt('[_1]: student, [_2]: TA, [_3]: instructor','"st"','"ta"','"in"') - .'("'.&mt('role,role,...').'") ' - .Apache::loncommon::help_open_topic("Course_Disable_Discussion"), - 'pch.users.denied' => - ''.&mt('Disallow Resource Discussion for Users').'
    '. - '("'.&mt('user:domain,user:domain,...').'")', - 'spreadsheet_default_classcalc' - => ''.&mt('Default Course Spreadsheet').' '. - '$SelectSpreadsheetFile
    ", - 'spreadsheet_default_studentcalc' - => ''.&mt('Default Student Spreadsheet').'
    '. - '$SelectSpreadsheetFile
    ", - 'spreadsheet_default_assesscalc' - => ''.&mt('Default Assessment Spreadsheet').' '. - '$SelectSpreadsheetFile
    ", - 'allow_limited_html_in_feedback' - => ''.&mt('Allow limited HTML in discussion posts').'
    '. - '('.&mt('Set value to [_1] to allow.','"yes"').')', - 'allow_discussion_post_editing' - => ''.&mt('Allow users with specified roles to edit/delete their own discussion posts').'
    ' - .'('.&mt('[_1]: student, [_2]: TA, [_3]: instructor','"st"','"ta"','"in"').')
    ' - .'('.&mt('Set value to [_1] to allow all roles.','"yes"').')' - .'("'.&mt('role:section,role:section,...').'")
    ' - .'('.&mt('Example: "st:001,st:002,in,cc" would permit students in sections 001 and 002 and instructors in any section, and course coordinators to edit their own posts.').')', - 'rndseed' - => ''.&mt('Randomization algorithm used').'
    ' - .'' - .&mt('Modifying this will make problems have different numbers and answers!') - .'', - 'receiptalg' - => ''.&mt('Receipt algorithm used').'
    '. - &mt('This controls how receipt numbers are generated.'), - 'suppress_tries' - => ''.&mt('Suppress number of tries in printing').'
    '. - ' ('.&mt('[_1] to suppress, anything else to not suppress','"yes"').')', - 'problem_stream_switch' - => ''.&mt('Allow problems to be split over pages').'
    '. - ' ('.&mt('[_1] if allowed, anything else if not','"yes"').')', - 'default_paper_size' - => ''.&mt('Default paper type').'
    '. - ' ('.&mt('supported types').': Letter [8 1/2x11 in], Legal [8 1/2x14 in],'. - ' Tabloid [11x17 in], Executive [7 1/2x10 in], A2 [420x594 mm],'. - ' A3 [297x420 mm], A4 [210x297 mm], A5 [148x210 mm], A6 [105x148 mm])', - 'print_header_format' - => ' '.&mt('Print header format').'
    ' - .&mt('Substitutions:
    [_1]: student name, [_2]: course id, [_3]: assignment note. Numbers after the % limit the field size.','"%n"','"%c"','"%a"'), - 'default_enrollment_start_date' => ''.&mt('Default beginning date for student access.').'', - 'default_enrollment_end_date' => ''.&mt('Default ending date for student access.').'', - 'nothideprivileged' => ''.&mt('Privileged users that should not be hidden on staff listings').'
    ' - .'("'.&mt('user:domain,user:domain,*:domain').'")', - 'languages' => ''.&mt('Languages used').'', - 'disable_receipt_display' - => ''.&mt('Disable display of problem receipts').'
    '. - ' ('.&mt('"[_1]" to disable, anything else if not','yes').')', - 'task_messages' - => ''.&mt('Send message to student when clicking Done on Tasks').'
    ('.&mt('[_1] to send a message only to student, [_2] to send message to student and add record to user information page for instructors. Leave blank to disable.','"only_student"','"student_and_user_notes_screen"').')', - 'disablesigfigs' - => ''.&mt('Disable checking of Significant Figures').'
    '. - ' ('.&mt('"[_1]" to disable, anything else if not','yes').')', - 'disableexampointprint' - => ''.&mt('Disable automatically printing point values onto exams.').'
    '. - ' ('.&mt('"[_1]" to disable, anything else if not','yes').')', - 'externalsyllabus' - => ''.&mt('URL of Syllabus (not using internal handler)').'', - 'tthoptions' - => ''.&mt('Default set of options to pass to tth/m when converting TeX').'', - - 'texengine' - => ''.&mt('Force all students in the course to use a specific math rendering engine.').'
    ' - .'('.&mt("[_1], [_2] (Convert to Images), [_3] (TeX to HTML), or blank for student's preference",'"jsMath"','"mimetex"','"tth"').')', - 'timezone' - => ''.&mt('Timezone in which the course takes place').'', - - 'suppress_embed_prompt' - => ''.&mt('Suppress prompt to upload items referenced in a web page being uploaded to portfolio, when current role is student.').'
    '. - ' ('.&mt('[_1] to suppress, anything else to not suppress','"yes"').')', - 'hidefromcat' - => ''.&mt('Exclude from course catalog').'
    '. - ' ('.&mt('[_1] to exclude, anything else to include - included if assigned an institutional code, or manually catagorized','"yes"').')', - 'categories' - => ''.&mt('Categorize course').' '. - &mt('Display Categories').'', - 'datelocale' - => ''.&mt('Locale used for course calendar').'', - ); - my @Display_Order = ('url','description','courseid','cloners'); - (my $can_toggle_cat,$can_categorize) = &can_modify_catsettings($dom); - if ($can_toggle_cat) { - push(@Display_Order,'hidefromcat'); - } - if ($can_categorize) { - push(@Display_Order,'categories'); - } - push (@Display_Order,('grading', - 'externalsyllabus', - 'default_xml_style','pageseparators', - 'question.email','question.email.text','comment.email', - 'comment.email.text','policy.email','policy.email.text', - 'student_classlist_view', - 'student_classlist_opt_in', - 'student_classlist_portfiles', - 'plc.roles.denied','plc.users.denied', - 'pch.roles.denied','pch.users.denied', - 'allow_limited_html_in_feedback', - 'allow_discussion_post_editing', - 'languages', - 'timezone', - 'datelocale', - 'nothideprivileged', - 'rndseed', - 'receiptalg', - 'problem_stream_switch', - 'suppress_tries', - 'suppress_embed_prompt', - 'default_paper_size', - 'print_header_format', - 'disable_receipt_display', - 'spreadsheet_default_classcalc', - 'spreadsheet_default_studentcalc', - 'spreadsheet_default_assesscalc', - 'hideemptyrows', - 'default_enrollment_start_date', - 'default_enrollment_end_date', - 'tthoptions', - 'texengine', - 'disablesigfigs', - 'disableexampointprint', - 'task_messages','task_grading')); - foreach my $parameter (sort(keys(%values))) { - unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./) || - ($parameter =~ m/^selfenroll_/) || ($parameter =~ /_selfenroll$/) - || ($parameter eq 'type')) { - if (! $descriptions{$parameter}) { - $descriptions{$parameter}=$parameter; - push(@Display_Order,$parameter); - } - } - } - - foreach my $parameter (@Display_Order) { - my $description = $descriptions{$parameter}; - # onchange is javascript to automatically check the 'Set' button. - my $onchange = 'onFocus="javascript:window.document.forms'. - "['envform'].elements['".$parameter."_setparmval']". - '.checked=true;"'; - $output .= &Apache::loncommon::start_data_table_row(). - '
    '; - if ($parameter =~ /^default_enrollment_(start|end)_date$/) { - $output .= ''; - } elsif ($parameter eq 'timezone') { - my $includeempty = 1; - my $timezone = &Apache::lonlocal::gettimezone(); - $output .= ''; - } elsif ($parameter eq 'datelocale') { - my $includeempty = 1; - my $locale_obj = &Apache::lonlocal::getdatelocale(); - my $currdatelocale; - if (ref($locale_obj)) { - $currdatelocale = $locale_obj->id(); - } - $output .= ''; - } elsif ($parameter eq 'categories') { - my $catdisplay; - if ($values{'categories'} ne '') { - my @curritems = split(/\&/,$values{'categories'}); - foreach my $item (@curritems) { - my ($name,$parent,$pos) = split(/:/,$item); - $catdisplay .= &unescape($name).'&'; - } - $catdisplay =~ s/\&$//; - } - $output .= ''; - } else { - $output .= ''; - } - $output .= ''; - $output .= &Apache::loncommon::end_data_table_row()."\n"; - } - my $onchange = 'onFocus="javascript:window.document.forms'. - '[\'envform\'].elements[\'newp_setparmval\']'. - '.checked=true;"'; - $output.=&Apache::loncommon::start_data_table_row(). - ''. - &Apache::loncommon::end_data_table_row()."\n"; - } - my %lt=&Apache::lonlocal::texthash( - 'par' => 'Parameter', - 'val' => 'Value', - 'set' => 'Set?', - 'sav' => 'Save' - ); - - my $Parameter=&mt('Parameter'); - my $Value=&mt('Value'); - my $Set=&mt('Set'); - my ($jscript,$categorize_js); - my $browse_js = &Apache::loncommon::browser_and_searcher_javascript('parmset'); - if ($can_categorize) { - $categorize_js = <'; - my $start_page = - &Apache::loncommon::start_page('Set Course Environment', - $jscript); - my $end_page = - &Apache::loncommon::end_page(); - my $end_table=&Apache::loncommon::end_data_table(); - $r->print(< -$setoutput -
    -$start_table -$start_header_row -
    -$end_header_row -$output -$end_table - - -$end_page -ENDENV -} - -sub can_modify_catsettings { - my ($dom) = @_; - my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom); - my ($can_toggle_cat,$can_categorize); - if (ref($domconf{'coursecategories'}) eq 'HASH') { - if ($domconf{'coursecategories'}{'togglecats'} eq 'crs') { - $can_toggle_cat = 1; - } - if ($domconf{'coursecategories'}{'categorize'} eq 'crs') { - $can_categorize = 1; - } - } - return ($can_toggle_cat,$can_categorize); -} - -sub assign_course_categories { - my ($r) = @_; - my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; - my $hascats = 0; - my $cathash; - my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom); - if (ref($domconf{'coursecategories'}) eq 'HASH') { - $cathash = $domconf{'coursecategories'}{'cats'}; - if (ref($cathash) eq 'HASH') { - $hascats = 1; - } - } - my $catwin_js; - if ($hascats) { - my $alert = &mt('Use \"Save\" in the main window to save course categories'); - $catwin_js = < - -function updateCategories() { - var newcategories = ''; - var unescapedcats = ''; - if (document.chgcats.usecategory.length) { - for (var i=0; i 0) { - newcategories = newcategories.slice(0,-1); - } - if (unescapedcats.length > 0) { - unescapedcats = unescapedcats.slice(0,-3); - } - } else { - if (document.chgcats.usecategory.checked == true) { - newcategories = document.chgcats.usecategory.value; - unescapedcats = document.chgcats.catname.value; - } - } - opener.document.envform.categories_value.value = newcategories; - opener.document.envform.categories_display.value = unescapedcats; - opener.document.envform.categories_setparmval.checked = true; - alert("$alert"); - self.close(); - return; -} - - -ENDSCRIPT - } else { - my $onload; - } - my $start_page = - &Apache::loncommon::start_page('Course Categories',$catwin_js, - {'only_body' => 1,}); - my $end_page = &Apache::loncommon::end_page(); - my $categoriesform = '

    '.&mt('Categorize Course').'

    '; - if ($hascats) { - my %currsettings = - &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum); - $categoriesform .= &mt('Assign one or more categories to this course.').'

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

    '; - } else { - $categoriesform .= &mt('No categories defined for this domain'); - } - $r->print($start_page.$categoriesform.$end_page); - return; -} - ################################################## # Overview mode ################################################## @@ -2950,7 +2685,7 @@ sub storedata { $typeof=$env{'form.typeof_'.$thiskey}; $text = &mt('Saved modified date for'); } - if (defined($data) and $$olddata{$thiskey} ne $data) { + if (defined($data) and $$olddata{$thiskey} ne $data) { if ($tuname) { if (&Apache::lonnet::put('resourcedata',{$tkey=>$data, $tkey.'.type' => $typeof}, @@ -2965,8 +2700,8 @@ sub storedata { &Apache::lonnet::devalidateuserresdata($tuname,$tudom); } else { $newdata{$thiskey}=$data; - $newdata{$thiskey.'.type'}=$typeof; - } + $newdata{$thiskey.'.type'}=$typeof; + } } } elsif ($cmd eq 'del') { if ($tuname) { @@ -3020,7 +2755,7 @@ sub parse_listdata_key { my ($key,$listdata) = @_; # split into student/section affected, and # the realm (folder/resource part and parameter - my ($student,$realm) = + my ($student,$realm) = ($key=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)$/); # if course wide student would be undefined if (!defined($student)) { @@ -3061,13 +2796,13 @@ sub listdata { if ($sortorder eq 'realmstudent') { if ($ares ne $bres ) { $result = ($ares cmp $bres); - } elsif ($astudent ne $bstudent) { + } elsif ($astudent ne $bstudent) { $result = ($astudent cmp $bstudent); } elsif ($apart ne $bpart ) { $result = ($apart cmp $bpart); } } else { - if ($astudent ne $bstudent) { + if ($astudent ne $bstudent) { $result = ($astudent cmp $bstudent); } elsif ($ares ne $bres ) { $result = ($ares cmp $bres); @@ -3075,7 +2810,7 @@ sub listdata { $result = ($apart cmp $bpart); } } - + if (!$result) { if (defined($aparm) && defined($bparm)) { $result = ($aparm <=> $bparm); @@ -3225,7 +2960,7 @@ sub default_selector { return ''; } -my %strings = +my %strings = ( 'string_yesno' => [[ 'yes', 'Yes' ], @@ -3240,7 +2975,7 @@ my %strings = sub string_selector { my ($thistype, $thiskey, $showval) = @_; - + if (!exists($strings{$thistype})) { return &default_selector($thiskey,$showval); } @@ -3333,7 +3068,7 @@ ENDOVER my @psprt=&Apache::loncommon::get_env_multiple('form.psprt'); if (!@psprt) { $psprt[0]='0'; } - my @selected_sections = + my @selected_sections = &Apache::loncommon::get_env_multiple('form.Section'); @selected_sections = ('all') if (! @selected_sections); foreach my $sec (@selected_sections) { @@ -3346,14 +3081,14 @@ ENDOVER my $pssymb=''; my $parmlev=''; - + unless ($env{'form.parmlev'}) { $parmlev = 'map'; } else { $parmlev = $env{'form.parmlev'}; } - &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps, + &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps, \%mapp, \%symbp,\%maptitles,\%uris, \%keyorder,\%defkeytype); @@ -3362,21 +3097,36 @@ ENDOVER } # Menu to select levels, etc - $r->print('
    '.&mt('Any User').''.$description.''. - &Apache::lonhtmlcommon::date_setter('envform', - $parameter.'_value', - $values{$parameter}, - $onchange). - ''. - &Apache::loncommon::select_timezone($parameter.'_value', - $timezone, - $onchange,$includeempty).''. - &Apache::loncommon::select_datelocale($parameter.'_value', - $currdatelocale, - $onchange,$includeempty).''. - ''. - ''. - &Apache::lonhtmlcommon::textbox($parameter.'_value', - $values{$parameter}, - 40,$onchange).''. - &Apache::lonhtmlcommon::checkbox($parameter.'_setparmval'). - ''.&mt('Create New Environment Variable').'
    '. - '
    '. - ''. - '$lt{'par'}$lt{'val'}$lt{'set'}
    - '. '' ); - + $r->print(''); - + } } $r->print(&Apache::loncommon::end_data_table().'

    '. @@ -3657,7 +3413,7 @@ sub parse_key { my ($map,$resid,$url) = &Apache::lonnet::decode_symb($data{'realm'}); $data{'realm_exists'} = &Apache::lonnet::symbverify($data{'realm'},$url); } - + $data{'parameter_part'} = $part; $data{'parameter_name'} = $name; @@ -3697,7 +3453,7 @@ sub check_cloners { $disallowed{'format'} .= $currclone.','; } } elsif ($currclone !~/^($match_username)\:($match_domain)$/) { - $disallowed{'format'} .= $currclone.','; + $disallowed{'format'} .= $currclone.','; } else { if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') { $disallowed{'newuser'} .= $currclone.','; @@ -3726,7 +3482,7 @@ sub change_clone { my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $clone_crs = $cnum.':'.$cdom; - + if ($cnum && $cdom) { my @allowclone; &extract_cloners($clonelist,\@allowclone); @@ -3807,10 +3563,10 @@ ENDMAINFORMHEAD my @menu = ( { categorytitle=>'Settings for this Course', items => [ - { linktext => 'Course Environment', - url => '/adm/parmset?action=crsenv', + { linktext => 'Course Configuration', + url => '/adm/courseprefs?origin=params', permission => $parm_permission, - linktitle =>'Edit environment settings for this course.' , + linktitle =>'Edit course configuration.' , icon => 'preferences-desktop-remote-desktop.png' , #help => 'Course_Environment', }, @@ -3838,7 +3594,7 @@ ENDMAINFORMHEAD permission => $parm_permission, linktitle =>'Set default actions for parameters.' , icon => 'folder-new.png' , - }]}, + }]}, { categorytitle => 'New and Existing Parameter Settings for Resources', items => [ { linktext => 'Edit Resource Parameters - Helper Mode', @@ -3870,7 +3626,7 @@ ENDMAINFORMHEAD linktitle =>'Set/Modify existing resource parameters in overview mode.' , icon => 'preferences-desktop-wallpaper.png' , #help => 'Parameter_Overview', - }, + }, { linktext => 'Change Log', url => '/adm/parmset?action=parameterchangelog', permission => $parm_permission, @@ -3902,19 +3658,19 @@ sub output_row { push @options,['deleted', 'Delete Metadata Field']; } $output = &Apache::loncommon::start_data_table_row(); - $output .= '

    '; + $output .= ''; $output .= &Apache::loncommon::end_data_table_row(); foreach my $opt (@options) { my $checked = ($options =~ m/$opt->[0]/) ? ' checked="checked" ' : '' ; $output .= &Apache::loncommon::continue_data_table_row(); - $output .= ''; + &mt($opt->[1]).''; $output .= &Apache::loncommon::end_data_table_row(); } $output .= &Apache::loncommon::continue_data_table_row(); - $output .= ''; + $output .= ''; $output .= &Apache::loncommon::end_data_table_row(); my $multiple_checked; my $single_checked; @@ -3926,14 +3682,14 @@ sub output_row { $single_checked = ''; } $output .= &Apache::loncommon::continue_data_table_row(); - $output .= ''; + '.&mt('Student may select multiple choices from list').''; $output .= &Apache::loncommon::end_data_table_row(); $output .= &Apache::loncommon::continue_data_table_row(); - $output .= ''; + '.&mt('Student may select only one choice from list').''; $output .= &Apache::loncommon::end_data_table_row(); } return ($output); @@ -3987,7 +3743,7 @@ sub order_meta_fields { } my $ordered_fields = join ",", @neworder; my $put_result = &Apache::lonnet::put('environment', - {'metadata.addedorder'=>$ordered_fields},$dom,$crs); + {'metadata.addedorder'=>$ordered_fields},$dom,$crs); &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.metadata.addedorder' => $ordered_fields}); } my $fields = &get_added_meta_fieldnames($env{'request.course.id'}); @@ -4000,8 +3756,8 @@ sub order_meta_fields { $ordered_fields = join ",", @fields_in_order; } my $put_result = &Apache::lonnet::put('environment', - {'metadata.addedorder'=>$ordered_fields},$dom,$crs); - } + {'metadata.addedorder'=>$ordered_fields},$dom,$crs); + } $r->print('
    '); + #$r->print(' + # '); + #$r->print(''); } - $r->print('
    '); + $r->print('
    '); + #$r->print('

    Step 1

    '); + $r->print('
    '); + $r->print(&Apache::lonhtmlcommon::start_pick_box()); &levelmenu($r,\%alllevs,$parmlev); if ($parmlev ne 'general') { - $r->print('
    '); + #$r->print(''); + $r->print(&Apache::lonhtmlcommon::row_closure()); &mapmenu($r,\%allmaps,$pschp,\%maptitles); - $r->print('
    '); - - $r->print(' -
    '); + $r->print(&Apache::lonhtmlcommon::row_closure(1)); + $r->print(&Apache::lonhtmlcommon::end_pick_box()); + $r->print(''); + #$r->print('
    '); + + #$r->print(' + #
    '); + $r->print('
    '); + $r->print('
    '); + $r->print(&Apache::lonhtmlcommon::start_pick_box()); &parmmenu($r,\%allparms,\@pscat,\%keyorder); - $r->print('
    - '. + $r->print(&Apache::lonhtmlcommon::end_pick_box()); + &parmboxes($r,\%allparms,\@pscat,\%keyorder); + $r->print(&Apache::lonhtmlcommon::start_pick_box()); + $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parts to View'))); + #$r->print('
    '. + $r->print(''. '
    '.&mt('Parts').''.&mt('Section(s)'). ''.&mt('Group(s)').'
    '); &partmenu($r,\%allparts,\@psprt); @@ -3385,11 +3135,17 @@ ENDOVER $r->print(''); &groupmenu($r,\@selected_groups); $r->print('
    '); - $r->print('
    '); - + #$r->print('
    '); + $r->print(&Apache::lonhtmlcommon::row_closure(1)); + $r->print(&Apache::lonhtmlcommon::end_pick_box()); + $r->print(''); + + $r->print('
    '); + $r->print('
    '); my $sortorder=$env{'form.sortorder'}; unless ($sortorder) { $sortorder='realmstudent'; } &sortmenu($r,$sortorder); + $r->print('
    '); $r->print('

    '); @@ -3534,11 +3290,11 @@ ENDOVER $r->print(&Apache::loncommon::start_data_table_row(). '
    '); my $display_value = $resourcedata->{$thiskey}; if (&isdateparm($resourcedata->{$thiskey.'.type'})) { - $display_value = + $display_value = &Apache::lonlocal::locallocaltime($display_value); } $r->print(&mt('Parameter: "[_1]" with value: "[_2]"', @@ -3567,7 +3323,7 @@ ENDOVER } $r->print('
       '.&mt('Part: [_1]',$data{'parameter_part'})); $r->print('
    '.$field_text.':'.(' ' x 5).''.(' ' x 5).' '.(' ' x 10).''.(' ' x 10).''.(' ' x 10).''.(' ' x 10).' - '.&mt('Student may select multiple choices from list').''.(' ' x 10).''.(' ' x 10).' - '.&mt('Student may select only one choice from list').'
    '); my $num_fields = scalar(@fields_in_order); foreach my $key (@fields_in_order) { @@ -4052,7 +3808,7 @@ sub addmetafield { $options =~ s/,,/,/; my $put_result = &Apache::lonnet::put('environment', {'metadata.'.$meta_field.'.options'=>$options},$dom,$crs); - + $r->print('Undeleted Metadata Field '.$env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.added'}." with result ".$put_result.'
    '); } $r->print(&continue()); @@ -4111,13 +3867,13 @@ sub setrestrictmeta { $save_field = $meta_field; if ($env{'form.'.$meta_field.'_stuadd'}) { $options.='stuadd,'; - } + } if ($env{'form.'.$meta_field.'_choices'}) { $options.='choices,'; - } + } if ($env{'form.'.$meta_field.'_onlyone'} eq 'single') { $options.='onlyone,'; - } + } if ($env{'form.'.$meta_field.'_active'}) { $options.='active,'; } @@ -4163,7 +3919,7 @@ ENDButtons $output.= &output_row($r, $field, $$added_metadata_fields{$field},$added_flag, $row_alt); } $output .= &Apache::loncommon::end_data_table(); - $r->print(<print(< $output $buttons @@ -4209,7 +3965,7 @@ sub defaultsetter { &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setdefaults', text=>"Set Defaults"}); - my $start_page = + my $start_page = &Apache::loncommon::start_page('Parameter Setting Default Actions'); my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Defaults'); $r->print(<print(&mt('Manual setting rules apply to all interfaces.').'
    '. &mt('Automatic setting rules apply to table mode interfaces only.')); @@ -4347,12 +4103,12 @@ ENDINPUTDATE } elsif ($defkeytype{$tempkey} eq 'string_yesno') { my $yeschecked=''; my $nochecked=''; - if (&rulescache($tempkey.'_value') eq 'yes') { $yeschecked='checked="checked"'; } - if (&rulescache($tempkey.'_value') eq 'no') { $nochecked='checked="checked"'; } + if (&rulescache($tempkey.'_value') eq 'yes') { $yeschecked=' checked="checked"'; } + if (&rulescache($tempkey.'_value') eq 'no') { $nochecked=' checked="checked"'; } $r->print(< $lt{'yes'}
    - +
    + ENDYESNO } else { $r->print(''); @@ -4390,7 +4146,7 @@ sub components { $issection=''; } my $realm=''.&mt('All Resources').''; - my $realmdescription=&mt('all resources'); + my $realmdescription=&mt('all resources'); if ($middle=~/^(.+)\_\_\_\(all\)$/) { $realm=''.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).'
    ('.$1.')
    '; $realmdescription=&mt('folder').' '.&Apache::lonnet::gettitle($1); @@ -4421,7 +4177,7 @@ sub load_parameter_names { close($config); $standard_parms{'int_pos'} = 'Positive Integer'; $standard_parms{'int_zero_pos'} = 'Positive Integer or Zero'; - %standard_parms=&Apache::lonlocal::texthash(%standard_parms); + %standard_parms=&Apache::lonlocal::texthash(%standard_parms); } sub standard_parameter_names { @@ -4430,9 +4186,9 @@ sub standard_parameter_names { &load_parameter_names(); } if ($standard_parms{$name}) { - return $standard_parms{$name}; - } else { - return $name; + return $standard_parms{$name}; + } else { + return $name; } } @@ -4453,7 +4209,7 @@ sub parm_change_log { $r->print('
    '); - + my %saveable_parameters = ('show' => 'scalar',); &Apache::loncommon::store_course_settings('parameter_log', \%saveable_parameters); @@ -4481,7 +4237,7 @@ sub parm_change_log { } if ($last) { ($folder) = &Apache::lonnet::decode_symb($last); } } - foreach my $id (sort + foreach my $id (sort { if ($parmlog{$b}{'exe_time'} ne $parmlog{$a}{'exe_time'}) { return $parmlog{$b}{'exe_time'} <=>$parmlog{$a}{'exe_time'} @@ -4494,15 +4250,15 @@ sub parm_change_log { my $count = 0; my $time = &Apache::lonlocal::locallocaltime($parmlog{$id}{'exe_time'}); - my $plainname = + my $plainname = &Apache::loncommon::plainname($parmlog{$id}{'exe_uname'}, $parmlog{$id}{'exe_udom'}); - my $about_me_link = + my $about_me_link = &Apache::loncommon::aboutmewrapper($plainname, $parmlog{$id}{'exe_uname'}, $parmlog{$id}{'exe_udom'}); my $send_msg_link=''; - if ((($parmlog{$id}{'exe_uname'} ne $env{'user.name'}) + if ((($parmlog{$id}{'exe_uname'} ne $env{'user.name'}) || ($parmlog{$id}{'exe_udom'} ne $env{'user.domain'}))) { $send_msg_link ='
    '. &Apache::loncommon::messagewrapper(&mt('Send message'), @@ -4525,8 +4281,8 @@ sub parm_change_log { } } if ($typeflag) { - $istype{$parmname}=$value; - if (!$env{'form.includetypes'}) { next; } + $istype{$parmname}=$value; + if (!$env{'form.includetypes'}) { next; } } $count++; if ($makenewrow) { @@ -4564,12 +4320,12 @@ sub parm_change_log { my $description=&mt('Changed [_1] for [_2] to [_3]',&standard_parameter_names($parmname),$realmdescription, (&isdateparm($istype{$parmname})?&Apache::lonlocal::locallocaltime($value):$value)); if (($uname) && ($udom)) { - $output .= + $output .= &Apache::loncommon::messagewrapper('Notify User', $uname,$udom,$title, $description); } else { - $output .= + $output .= &Apache::lonrss::course_blog_link($id,$title, $description); } @@ -4580,7 +4336,7 @@ sub parm_change_log { my $wholeentry=$about_me_link.':'. $parmlog{$id}{'exe_uname'}.':'.$parmlog{$id}{'exe_udom'}.':'. $output; - if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; } + if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; } } if ($count) { $r->print($row_start.'
    @@ -4590,13 +4346,101 @@ sub parm_change_log { $send_msg_link.''.$output); $shown++; } - if (!($env{'form.show'} eq &mt('all') + if (!($env{'form.show'} eq &mt('all') || $shown<=$env{'form.show'})) { last; } } $r->print(&Apache::loncommon::end_data_table()); $r->print(&Apache::loncommon::end_page()); } +sub update_slots { + my ($slot_name,$cdom,$cnum,$symb,$uname,$udom) = @_; + my %slot=&Apache::lonnet::get_slot($slot_name); + if (!keys(%slot)) { + return 'error: slot does not exist'; + } + my $max=$slot{'maxspace'}; + if (!defined($max)) { $max=99999; } + + my %consumed=&Apache::lonnet::dump('slot_reservations',$cdom,$cnum, + "^$slot_name\0"); + my ($tmp)=%consumed; + if ($tmp=~/^error: 2 / ) { + return 'error: unable to determine current slot status'; + } + my $last=0; + foreach my $key (keys(%consumed)) { + my $num=(split('\0',$key))[1]; + if ($num > $last) { $last=$num; } + if ($consumed{$key}->{'name'} eq $uname.':'.$udom) { + return 'ok'; + } + } + + if (scalar(keys(%consumed)) >= $max) { + return 'error: no space left in slot'; + } + my $wanted=$last+1; + + my %reservation=('name' => $uname.':'.$udom, + 'timestamp' => time, + 'symb' => $symb); + + my $success=&Apache::lonnet::newput('slot_reservations', + {"$slot_name\0$wanted" => + \%reservation}, + $cdom, $cnum); + if ($success eq 'ok') { + my %storehash = ( + symb => $symb, + slot => $slot_name, + action => 'reserve', + context => 'parameter', + ); + &Apache::lonnet::instructor_log('slotreservationslog',\%storehash, + '',$uname,$udom,$cnum,$cdom); + + &Apache::lonnet::instructor_log($cdom.'_'.$cnum.'_slotlog',\%storehash, + '',$uname,$udom,$uname,$udom); + } + return $success; +} + +sub delete_slots { + my ($slot_name,$cdom,$cnum,$uname,$udom,$symb) = @_; + my $delresult; + my %consumed = &Apache::lonnet::dump('slot_reservations',$cdom, + $cnum, "^$slot_name\0"); + if (&Apache::lonnet::error(%consumed)) { + return 'error: unable to determine current slot status'; + } + my ($tmp)=%consumed; + if ($tmp=~/^error: 2 /) { + return 'error: unable to determine current slot status'; + } + foreach my $key (keys(%consumed)) { + if ($consumed{$key}->{'name'} eq $uname.':'.$udom) { + my $num=(split('\0',$key))[1]; + my $entry = $slot_name.'\0'.$num; + $delresult = &Apache::lonnet::del('slot_reservations',[$entry], + $cdom,$cnum); + if ($delresult eq 'ok') { + my %storehash = ( + symb => $symb, + slot => $slot_name, + action => 'release', + context => 'parameter', + ); + &Apache::lonnet::instructor_log('slotreservationslog',\%storehash, + 1,$uname,$udom,$cnum,$cdom); + &Apache::lonnet::instructor_log($cdom.'_'.$cnum.'_slotlog',\%storehash, + 1,$uname,$udom,$uname,$udom); + } + } + } + return $delresult; +} + sub check_for_course_info { my $navmap = Apache::lonnavmaps::navmap->new(); return 1 if ($navmap); @@ -4626,7 +4470,8 @@ sub handler { text=>"Parameter Manager", faq=>10, bug=>'Instructor Interface', - help => 'Parameter_Manager'}); + help => + 'Parameter_Manager,Course_Environment,Parameter_Helper,Parameter_Overview,Table_Mode'}); # ----------------------------------------------------- Needs to be in a course my $parm_permission = @@ -4646,8 +4491,6 @@ sub handler { &assessparms($r); } elsif (! exists($env{'form.action'})) { &print_main_menu($r,$parm_permission); - } elsif ($env{'form.action'} eq 'crsenv') { - &crsenv($r); } elsif ($env{'form.action'} eq 'setoverview') { &overview($r); } elsif ($env{'form.action'} eq 'addmetadata') { @@ -4672,7 +4515,7 @@ sub handler { &date_shift_two($r); } elsif ($env{'form.action'} eq 'categorizecourse') { &assign_course_categories($r); - } + } } else { # ----------------------------- Not in a course, or not allowed to modify parms if ($exists) { 500 Internal Server Error

    Internal Server Error

    The server encountered an internal error or misconfiguration and was unable to complete your request.

    Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

    More information about this error may be available in the server error log.

    '.$time.'