--- loncom/interface/lonparmset.pm 2011/01/15 15:14:47 1.508 +++ loncom/interface/lonparmset.pm 2015/04/28 13:34:12 1.550 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.508 2011/01/15 15:14:47 www Exp $ +# $Id: lonparmset.pm,v 1.550 2015/04/28 13:34:12 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -46,8 +46,6 @@ This module sets coursewide and assessme =over -=pod - =item parmval() Figure out a cascading parameter. @@ -137,33 +135,49 @@ javascript function 'pjump'. =item extractResourceInformation() : -Given the course data hash, extractResourceInformation extracts lots of information about the course's resources into a variety of hashes. + extractResourceInformation extracts lots of information about all of the the course's resources into a variety of hashes. + +Input: See list below -Input: See list below: +=over 4 -=item * B : An array that will contain all of the ids in the course. +=item * B : Current username -=item * B : hash, id->type, where "type" contains the extension of the file, thus, I. +=item * B : Domain of current user. + +=item * B : Course + +=back -=item * B : hash, id->key list, will contain a comma separated list of the meta-data keys available for the given id +Outputs: See list below: -=item * B : hash, name of parameter->display value (what is the display value?) +=over 4 -=item * B : hash, part identification->text representation of part, where the text representation is "[Part $part]" +=item * B (out) : An array that will contain all of the ids in the course. -=item * B : hash, full key to part->display value (what's display value?) +=item * B(out) : hash, id->type, where "type" contains the extension of the file, thus, I. -=item * B : hash, ??? +=item * B (out) : hash, id->key list, will contain a comma separated list of the meta-data keys available for the given id -=item * B : ??? +=item * B (out) : hash, name of parameter->display value (what is the display value?) -=item * B : hash, ??? +=item * B (out) : hash, part identification->text representation of part, where the text representation is "[Part $part]" + +=item * B (out) : hash, ??? =item * B : ?? =item * B : hash, id->full sym? +=item * B + +=item * B + +=item * B +=item * B + +=back =item isdateparm() @@ -196,12 +210,14 @@ Input: See list below: Show assessment data and parameters. This is a large routine that should be simplified and shortened... someday. -Inputs: $r - +Inputs: $r - the Apache request object. + Returns: nothing Variables used (guessed by Jeremy): +=over + =item * B: ParameterS CATegories? ends up a list of the types of parameters that exist, e.g., tol, weight, acc, opendate, duedate, answerdate, sig, maxtries, type. =item * B: ParameterS PaRTs? a list of the parts of a problem that we are displaying? Used to display only selected parts? @@ -214,6 +230,8 @@ Variables used (guessed by Jeremy): When storing information, store as part 0 When requesting information, request from full part +=back + =item tablestart() =item tableend() @@ -280,7 +298,6 @@ Set portfolio metadata Main handler. Calls &assessparms subroutine. - =back =cut @@ -307,17 +324,21 @@ use LONCAPA qw(:DEFAULT :match); sub startSettingsScreen { - my ($r,$mode)=@_; + my ($r,$mode,$crstype)=@_; + my $tabtext = &mt('Course Settings'); + if ($crstype eq 'Community') { + $tabtext = &mt('Community Settings'); + } $r->print("\n".''."\n"); - $r->print('
'); + $r->print('
'); } sub endSettingsScreen { @@ -653,7 +674,7 @@ sub storeparm_by_symb { } sub log_parmset { - return &Apache::lonnet::instructor_log('parameterlog',@_); + return &Apache::lonnet::write_log('course','parameterlog',@_); } sub storeparm_by_symb_inner { @@ -760,11 +781,14 @@ sub valout { my $result = ''; # Values of zero are valid. if (! $value && $value ne '0') { - if ($editable) { - $result = '*'; - } else { - $result=' '; - } + if ($editable) { + $result = + ''.&mt('Change').''; + } else { + $result=' '; + } } else { if ($type eq 'date_interval') { my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($value); @@ -805,6 +829,7 @@ sub valout { &date_sanity_info($value); } else { $result = $value; + $result=~s/\,/\, /gs; $result = &HTML::Entities::encode($result,'"<>&'); } } @@ -846,16 +871,10 @@ sub page_js { return(< // + $selscript ENDJS } +sub showhide_js { + return <<"COURSECONTENTSCRIPT"; + +function showHide_courseContent() { + var parmlevValue=document.getElementById("parmlev").value; + if (parmlevValue == 'general') { + document.getElementById('mapmenu').style.display="none"; + } else { + if ((parmlevValue == "full") || (parmlevValue == "map")) { + document.getElementById('mapmenu').style.display =""; + } else { + document.getElementById('mapmenu').style.display="none"; + } + } + return; +} + +COURSECONTENTSCRIPT +} + +sub toggleparmtextbox_js { + return <<"ENDSCRIPT"; + +if (!document.getElementsByClassName) { + function getElementsByClassName(node, classname) { + var a = []; + var re = new RegExp('(^| )'+classname+'( |$)'); + var els = node.getElementsByTagName("*"); + for(var i=0,j=els.length; i$remove
'); + }); + + \$(wrapper).delegate(".LC_remove_ipacc","click", function(e){ + e.preventDefault(); \$(this).closest("div").remove(); + }) +}); + + +END +} + sub startpage { - my ($r) = @_; + my ($r,$psymb,$crstype) = @_; - my %loaditems = ('onunload' => "pclose()", - 'onload' => "showHide_courseContent(); group_or_section('cgroup')", - ); + my %loaditems = ( + 'onload' => "group_or_section('cgroup')", + ); + if (!$psymb) { + $loaditems{'onload'} = "showHide_courseContent(); group_or_section('cgroup'); resize_scrollbox('mapmenuscroll','1','1');"; + } if ((($env{'form.command'} eq 'set') && ($env{'form.url'}) && (!$env{'form.dis'})) || ($env{'form.symb'})) { @@ -907,16 +1107,23 @@ sub startpage { text=>"Table Mode", help => 'Course_Setting_Parameters'}); } + my $js = &page_js().' + +'; my $start_page = - &Apache::loncommon::start_page('Set/Modify Course Parameters', - &page_js(), - {'add_entries' => \%loaditems,}); + &Apache::loncommon::start_page('Set/Modify Course Parameters',$js, + {'add_entries' => \%loaditems,}); my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Table Mode Parameter Setting','Table_Mode'); my $escfilter=&Apache::lonhtmlcommon::entity_encode($env{'form.filter'}); my $escpart=&Apache::lonhtmlcommon::entity_encode($env{'form.part'}); $r->print($start_page.$breadcrumbs); - &startSettingsScreen($r,'parmset'); + &startSettingsScreen($r,'parmset',$crstype); $r->print(< @@ -974,26 +1181,25 @@ sub print_row { my ($othergrp,$grp_parm,$controlgrp); if ($parmlev eq 'general') { - if ($uname) { - &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); } elsif ($cgroup) { - &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); } elsif ($csec) { - &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); } else { - &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); } } elsif ($parmlev eq 'map') { if ($uname) { - &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); } elsif ($cgroup) { - &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); } elsif ($csec) { - &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); } else { - &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); } } else { if ($uname) { @@ -1013,33 +1219,32 @@ sub print_row { } } - &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); - - &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); - &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); - &print_td($r,7,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); - } + &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); + &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); + &print_td($r,12,'#FFDDDD',$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); + &print_td($r,11,'#FFDDDD',$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); + &print_td($r,10,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); + + if ($csec) { + &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); + &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); + &print_td($r,7,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); + } if ($cgroup) { - &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); - &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); - &print_td($r,4,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); + &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); + &print_td($r,4,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); } - if ($uname) { + if ($uname) { if ($othergrp) { $r->print($othergrp); } - &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); - &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); - &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); - } + &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); + &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); + &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); + } } # end of $parmlev if/else $r->print(''.$effective_parm.''); @@ -1068,6 +1273,10 @@ sub print_td { if ($which > 3) { $nolink = 1; } + } elsif ($mprefix =~ /examcode\&$/) { + unless ($which == 2) { + $nolink = 1; + } } if ($nolink) { $r->print(&valout($$outpar[$which],$$typeoutpar[$which])); @@ -1165,6 +1374,7 @@ sub extractResourceInformation { $$typep{$id}=$1; $$keyp{$id}=''; $$uris{$id}=$srcf; + foreach my $key (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) { next if ($key!~/^parameter_/); @@ -1220,7 +1430,7 @@ sub extractResourceInformation { $$mapp{$mapid}=$$mapp{$id}; $$allmaps{$mapid}=$$mapp{$id}; if ($mapid eq '1') { - $$maptitles{$mapid}=&mt('Main Course Documents'); + $$maptitles{$mapid}=&mt('Main Content'); } else { $$maptitles{$mapid}=&Apache::lonnet::gettitle($$mapp{$id}); } @@ -1264,14 +1474,12 @@ sub parmmenu { ele = document.forms.parmform.elements[i]; if (ele.name == checkName) { document.forms.parmform.elements[i].checked=value; - document.getElementById(document.forms.parmform.elements[i].value.concat(li)).style.display = displayOverview; } } } function checkthis(thisvalue, checkName) { - document.getElementById(thisvalue.concat("_li")).style.display = ""; for (i=0; i ENDSCRIPT - $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('
  • print(' style="display:none"'); - } - $r->print('>' - .($$allparms{$tempkey}=~/\S/ ? $$allparms{$tempkey} : $tempkey) - .'
  • ' - ); - } - $r->print('
'); $r->print('
'); &shortCuts($r,$allparms,$pscat,$keyorder); $r->print('
'); - - $r->print( - '

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

' - ); - - $r->print(&Apache::lonhtmlcommon::row_closure(1)); } # return a hash sub categories { @@ -1399,6 +1564,8 @@ sub lookUpTableParameter { 'contentopen' => 'time_settings', 'contentclose' => 'time_settings', 'discussend' => 'time_settings', + 'printstartdate' => 'time_settings', + 'printenddate' => 'time_settings', 'weight' => 'grading', 'handgrade' => 'grading', 'maxtries' => 'tries', @@ -1430,7 +1597,10 @@ sub lookUpTableParameter { 'acc' => 'misc', 'maxcollaborators' => 'misc', 'scoreformat' => 'misc', - + 'lenient' => 'grading', + 'retrypartial' => 'tries', + 'discussvote' => 'misc', + 'examcode' => 'high_level_randomization', ); } @@ -1482,9 +1652,7 @@ sub category_order { sub parmboxes { my ($r,$allparms,$pscat,$keyorder)=@_; - my $tempkey; - my $tempparameter; - my %categories = &categories; + my %categories = &categories(); my %category_order = &category_order(); my %categoryList = ( 'time_settings' => [], @@ -1498,56 +1666,30 @@ sub parmboxes { 'file_submission' => [], 'misc' => [], ); - my $hidelink = - '

' - .'' - .&mt('Hide detailed Parameter Selection') - .'' - .'

' - ."\n"; -; - foreach $tempparameter (keys %$allparms) { + + foreach my $tempparameter (keys(%$allparms)) { &whatIsMyCategory($tempparameter, \%categoryList); } #part to print the parm-list - $r->print( - '\n" - ); + $r->print("\n"); } # # This function offers some links on the parameter section to get with one click a group a parameters @@ -1586,8 +1728,12 @@ sub shortCuts { sub partmenu { my ($r,$allparts,$psprt)=@_; + my $selsize = 1+scalar(keys(%{$allparts})); + if ($selsize > 8) { + $selsize = 8; + } - $r->print(''); $r->print(''); @@ -1628,7 +1774,7 @@ sub usermenu { $sections .= qq| onchange="group_or_section('csec')" |; } $sections .= '>'; - foreach my $section ('',sort keys %sectionhash) { + foreach my $section ('',sort(keys(%sectionhash))) { $sections.=''; @@ -1673,7 +1819,7 @@ function group_or_section(caller) { $groups .= qq| onchange="group_or_section('cgroup')" |; } $groups .= '>'; - foreach my $grp ('',sort keys %grouphash) { + foreach my $grp ('',sort(keys(%grouphash))) { $groups.='
' ); - - $r->print(&Apache::loncommon::start_data_table()); + $r->print(&Apache::loncommon::start_scrollbox('700px','680px','400px','mapmenuscroll')); + $r->print(&Apache::loncommon::start_data_table(undef,'mapmenuinner')); # Display row: "All Maps or Folders" $r->print( - &Apache::loncommon::start_data_table_row() + &Apache::loncommon::start_data_table_row(undef,'picklevel') .'' .'
'); @@ -2324,18 +2518,12 @@ COURSECONTENTSCRIPT '
'); $r->print(&Apache::lonhtmlcommon::topic_bar('',&mt('Additional Display Specification (optional)'))); $r->print(&Apache::lonhtmlcommon::start_pick_box()); - $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parts to View')). - ''); &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups); $r->print(&Apache::lonhtmlcommon::row_closure(1)); $r->print(&Apache::lonhtmlcommon::end_pick_box()); $r->print('

' .'' + .' value="'.&mt('Update Display').'" />' .'' .'

'); } @@ -2354,6 +2542,7 @@ COURSECONTENTSCRIPT @pscat = @temp_pscat; + if (($env{'form.prevvisit'}) || ($pschp) || ($pssymb)) { # ----------------------------------------------------------------- Start Table my @catmarker=map { tr|.|_|; 'parameter_'.$_; } @pscat; @@ -2370,7 +2559,7 @@ COURSECONTENTSCRIPT $coursespan += 3; } - $r->print('

'); + $r->print(&Apache::loncommon::start_data_table()); # # This produces the headers # @@ -2381,7 +2570,7 @@ COURSECONTENTSCRIPT $userspan ++; } $r->print('"); + $r->print(&mt('User [_1] at Domain [_2]',"'".$uname."'","'".$udom."'").''); } my %lt=&Apache::lonlocal::texthash( 'pie' => "Parameter in Effect", @@ -2444,9 +2633,8 @@ ENDTABLEHEADFOUR my $defbgtwo=''; my $defbgthree = ''; - foreach (@ids) { + foreach my $rid (@ids) { - my $rid=$_; my ($inmapid)=($rid=~/\.(\d+)$/); if ((!$pssymb && @@ -2480,36 +2668,34 @@ ENDTABLEHEADFOUR my $uri=&Apache::lonnet::declutter($uris{$rid}); my $filter=$env{'form.filter'}; - - foreach (&keysplit($keyp{$rid})) { - my $tempkeyp = $_; + foreach my $tempkeyp (&keysplit($keyp{$rid})) { if (grep $_ eq $tempkeyp, @catmarker) { - my $parmname=&Apache::lonnet::metadata($uri,$_.'.name'); + my $parmname=&Apache::lonnet::metadata($uri,$tempkeyp.'.name'); # We may only want certain parameters listed if ($filter) { unless ($filter=~/\Q$parmname\E/) { next; } } - $name{$_}=$parmname; - $part{$_}=&Apache::lonnet::metadata($uri,$_.'.part'); + $name{$tempkeyp}=$parmname; + $part{$tempkeyp}=&Apache::lonnet::metadata($uri,$tempkeyp.'.part'); - my $parmdis=&Apache::lonnet::metadata($uri,$_.'.display'); - if ($allparms{$name{$_}} ne '') { + my $parmdis=&Apache::lonnet::metadata($uri,$tempkeyp.'.display'); + if ($allparms{$name{$tempkeyp}} ne '') { my $identifier; if ($parmdis =~ /(\s*\[Part.*)$/) { $identifier = $1; } - $display{$_} = $allparms{$name{$_}}.$identifier; + $display{$tempkeyp} = $allparms{$name{$tempkeyp}}.$identifier; } else { - $display{$_} = $parmdis; + $display{$tempkeyp} = $parmdis; } - unless ($display{$_}) { $display{$_}=''; } - $display{$_}.=' ('.$name{$_}.')'; - $default{$_}=&Apache::lonnet::metadata($uri,$_); - $type{$_}=&Apache::lonnet::metadata($uri,$_.'.type'); - $thistitle=&Apache::lonnet::metadata($uri,$_.'.title'); + unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; } + $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')'; + $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$tempkeyp); + $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$tempkeyp.'.type'); + $thistitle=&Apache::lonnet::metadata($uri,$tempkeyp.'.title'); } } - my $totalparms=scalar keys %name; + my $totalparms=scalar(keys(%name)); if ($totalparms>0) { my $firstrow=1; my $title=&Apache::lonnet::gettitle($symbp{$rid}); @@ -2535,14 +2721,13 @@ ENDTABLEHEADFOUR $r->print(''); - - foreach (&keysinorder_bytype(\%name,\%keyorder)) { + foreach my $item (&keysinorder_bytype(\%name,\%keyorder)) { unless ($firstrow) { $r->print(''); } else { undef $firstrow; } - &print_row($r,$_,\%part,\%name,\%symbp,$rid,\%default, + &print_row($r,$item,\%part,\%name,\%symbp,$rid,\%default, \%type,\%display,$defbgone,$defbgtwo, $defbgthree,$parmlev,$uname,$udom,$csec, $cgroup,\@usersgroups); @@ -2551,7 +2736,7 @@ ENDTABLEHEADFOUR } } # end foreach ids # -------------------------------------------------- End entry for one resource - $r->print('
'); - $r->print(&mt("User")." $uname ".&mt('at Domain')." $udom'.$maptitles{$mapp{$rid}}.'
'); + $r->print(&Apache::loncommon::end_data_table); } # end of full #--------------------------------------------------- Entry for parm level map if ($parmlev eq 'map') { @@ -2569,7 +2754,7 @@ ENDTABLEHEADFOUR #-------------------------------------------- for each map, gather information my $mapid; - foreach $mapid (sort {$maplist{$a} cmp $maplist{$b}} keys %maplist) { + foreach $mapid (sort {$maplist{$a} cmp $maplist{$b}} keys(%maplist)) { my $maptitle = $maplist{$mapid}; #----------------------- loop through ids and get all parameter types for map @@ -2583,9 +2768,9 @@ ENDTABLEHEADFOUR # $r->print("Catmarker: @catmarker
\n"); - foreach (@ids) { - ($map)=(/([\d]*?)\./); - my $rid = $_; + foreach my $id (@ids) { + ($map)=($id =~ /([\d]*?)\./); + my $rid = $id; # $r->print("$mapid:$map: $rid
\n"); @@ -2600,12 +2785,11 @@ ENDTABLEHEADFOUR # When storing information, store as part 0 # When requesting information, request from full part #------------------------------------------------------------------- - foreach (&keysplit($keyp{$rid})) { - my $tempkeyp = $_; - my $fullkeyp = $tempkeyp; - $tempkeyp =~ s/_\w+_/_0_/; + foreach my $fullkeyp (&keysplit($keyp{$rid})) { + my $tempkeyp = $fullkeyp; + $tempkeyp =~ s/_\w+_/_0_/; - if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) { + if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) { $part{$tempkeyp}="0"; $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name'); my $parmdis=&Apache::lonnet::metadata($uri,$fullkeyp.'.display'); @@ -2664,9 +2848,9 @@ ENDTABLEHEADFOUR .&Apache::loncommon::end_data_table_header_row() ); - foreach (&keysinorder(\%name,\%keyorder)) { + foreach my $item (&keysinorder(\%name,\%keyorder)) { $r->print(&Apache::loncommon::start_data_table_row()); - &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default, + &print_row($r,$item,\%part,\%name,\%symbp,$mapid,\%default, \%type,\%display,$defbgone,$defbgtwo,$defbgthree, $parmlev,$uname,$udom,$csec,$cgroup); } @@ -2691,8 +2875,8 @@ ENDTABLEHEADFOUR my %type = (); my %default = (); - foreach (@ids) { - my $rid = $_; + foreach $id (@ids) { + my $rid = $id; my $uri=&Apache::lonnet::declutter($uris{$rid}); @@ -2703,11 +2887,10 @@ ENDTABLEHEADFOUR # When storing information, store as part 0 # When requesting information, request from full part #------------------------------------------------------------------- - foreach (&keysplit($keyp{$rid})) { - my $tempkeyp = $_; - my $fullkeyp = $tempkeyp; - $tempkeyp =~ s/_\w+_/_0_/; - if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) { + foreach my $fullkeyp (&keysplit($keyp{$rid})) { + my $tempkeyp = $fullkeyp; + $tempkeyp =~ s/_\w+_/_0_/; + if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) { $part{$tempkeyp}="0"; $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name'); my $parmdis=&Apache::lonnet::metadata($uri,$fullkeyp.'.display'); @@ -2755,9 +2938,9 @@ ENDMAPONE .&Apache::loncommon::end_data_table_header_row() ); - foreach (&keysinorder(\%name,\%keyorder)) { + foreach my $item (&keysinorder(\%name,\%keyorder)) { $r->print(&Apache::loncommon::start_data_table_row()); - &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default, + &print_row($r,$item,\%part,\%name,\%symbp,$mapid,\%default, \%type,\%display,$defbgone,$defbgtwo,$defbgthree, $parmlev,$uname,$udom,$csec,$cgroup); } @@ -2803,19 +2986,19 @@ sub readdata { # Read userdata my $classlist=&Apache::loncoursedata::get_classlist(); - foreach (keys %$classlist) { - if ($_=~/^($match_username)\:($match_domain)$/) { - my ($tuname,$tudom)=($1,$2); - my $useropt=&Apache::lonnet::get_userresdata($tuname,$tudom); - foreach my $userkey (keys %{$useropt}) { - if ($userkey=~/^$env{'request.course.id'}/) { + foreach my $user (keys(%$classlist)) { + if ($user=~/^($match_username)\:($match_domain)$/) { + my ($tuname,$tudom)=($1,$2); + my $useropt=&Apache::lonnet::get_userresdata($tuname,$tudom); + foreach my $userkey (keys(%{$useropt})) { + if ($userkey=~/^\Q$env{'request.course.id'}\E/) { my $newkey=$userkey; - $newkey=~s/^($env{'request.course.id'}\.)/$1\[useropt\:$tuname\:$tudom\]\./; - $$resourcedata{$newkey}=$$useropt{$userkey}; - } + $newkey=~s/^($env{'request.course.id'}\.)/$1\[useropt\:$tuname\:$tudom\]\./; + $$resourcedata{$newkey}=$$useropt{$userkey}; + } + } } } - } return $resourcedata; } @@ -2832,48 +3015,99 @@ sub storedata { my @deldata=(); undef @deldata; my ($got_chostname,$chostname,$cmajor,$cminor); + my $now = time; foreach my $key (keys(%env)) { if ($key =~ /^form\.([a-z]+)\_(.+)$/) { my $cmd=$1; my $thiskey=$2; + next if ($cmd eq 'settext' || $cmd eq 'setipallow' || $cmd eq 'setipdeny'); my ($tuname,$tudom)=&extractuser($thiskey); my $tkey=$thiskey; if ($tuname) { $tkey=~s/\.\[useropt\:$tuname\:$tudom\]\./\./; } if ($cmd eq 'set' || $cmd eq 'datepointer' || $cmd eq 'dateinterval') { - my ($data, $typeof, $text); + my ($data, $typeof, $text, $name, $valchk, $valmatch); if ($cmd eq 'set') { $data=$env{$key}; + $valmatch = ''; + $valchk = $data; $typeof=$env{'form.typeof_'.$thiskey}; $text = &mt('Saved modified parameter for'); if ($typeof eq 'string_questiontype') { - my ($needsrelease,$needsnewer); - $needsrelease = $Apache::lonnet::needsrelease{'parameter:type:'.$data}; - if ($needsrelease) { - unless ($got_chostname) { - ($chostname,$cmajor,$cminor)=&questiontype_release_vars(); - $got_chostname = 1; + $name = 'type'; + } elsif ($typeof eq 'string_lenient') { + $name = 'lenient'; + my $stringmatch = &standard_string_matches($typeof); + if (ref($stringmatch) eq 'ARRAY') { + foreach my $item (@{$stringmatch}) { + if (ref($item) eq 'ARRAY') { + my ($regexpname,$pattern) = @{$item}; + if ($pattern ne '') { + if ($data =~ /$pattern/) { + $valmatch = $regexpname; + $valchk = ''; + last; + } + } + } } - $needsnewer = &questiontype_releasecheck($data,$needsrelease, - $chostname,$cmajor, - $cminor); } - if ($needsnewer) { - $r->print('
'.&oldversion_warning($data,$chostname,$cmajor, - $cminor,$needsrelease)); - next; + } elsif ($typeof eq 'string_discussvote') { + $name = 'discussvote'; + } elsif ($typeof eq 'string_examcode') { + $name = 'examcode'; + if (&Apache::lonnet::validCODE($data)) { + $valchk = 'valid'; + } + } elsif ($typeof eq 'string_yesno') { + if ($thiskey =~ /\.retrypartial$/) { + $name = 'retrypartial'; } } } elsif ($cmd eq 'datepointer') { $data=&Apache::lonhtmlcommon::get_date_from_form($env{$key}); $typeof=$env{'form.typeof_'.$thiskey}; $text = &mt('Saved modified date for'); + if ($typeof eq 'date_start') { + if ($thiskey =~ /\.printstartdate$/) { + $name = 'printstartdate'; + if (($data) && ($data > $now)) { + $valchk = 'future'; + } + } + } elsif ($typeof eq 'date_end') { + if ($thiskey =~ /\.printenddate$/) { + $name = 'printenddate'; + if (($data) && ($data < $now)) { + $valchk = 'past'; + } + } + } } elsif ($cmd eq 'dateinterval') { $data=&get_date_interval_from_form($thiskey); $typeof=$env{'form.typeof_'.$thiskey}; $text = &mt('Saved modified date for'); } + if ($name ne '') { + my ($needsrelease,$needsnewer); + $needsrelease = $Apache::lonnet::needsrelease{"parameter:$name:$valchk:$valmatch"}; + if ($needsrelease) { + unless ($got_chostname) { + ($chostname,$cmajor,$cminor)=¶meter_release_vars(); + $got_chostname = 1; + } + $needsnewer = ¶meter_releasecheck($name,$valchk,$valmatch, + $needsrelease, + $cmajor,$cminor); + if ($needsnewer) { + $r->print('
'.&oldversion_warning($name,$data, + $chostname,$cmajor, + $cminor,$needsrelease)); + next; + } + } + } if (defined($data) and $$olddata{$thiskey} ne $data) { if ($tuname) { if (&Apache::lonnet::put('resourcedata',{$tkey=>$data, @@ -2910,13 +3144,13 @@ sub storedata { } # Store all course level my $delentries=$#deldata+1; - my @newdatakeys=keys %newdata; + my @newdatakeys=keys(%newdata); my $putentries=$#newdatakeys+1; if ($delentries) { if (&Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs) eq 'ok') { my %loghash=map { $_ => '' } @deldata; &log_parmset(\%loghash,1); - $r->print('

'.&mt('Deleted [_1] parameter(s)

',$delentries)); + $r->print('

'.&mt('Deleted [quant,_1,parameter]',$delentries/2).'

'); } else { $r->print('
'. &mt('Error deleting parameters').'
'); @@ -2926,7 +3160,7 @@ sub storedata { if ($putentries) { if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') { &log_parmset(\%newdata,0); - $r->print('

'.&mt('Saved [_1] parameter(s)',$putentries/2).'

'); + $r->print('

'.&mt('Saved [quant,_1,parameter]',$putentries/2).'

'); } else { $r->print('
'. &mt('Error saving parameters').'
'); @@ -3011,7 +3245,7 @@ sub listdata { } $result; - } keys %{$listdata}) { + } keys(%{$listdata})) { if ($$listdata{$thiskey.'.type'}) { my $thistype=$$listdata{$thiskey.'.type'}; @@ -3095,7 +3329,7 @@ sub listdata { $$resourcedata{$thiskey})); } elsif ($thistype =~ m/^string/) { $r->print(&string_selector($thistype,$thiskey, - $$resourcedata{$thiskey})); + $$resourcedata{$thiskey},$name)); } else { $r->print(&default_selector($thiskey,$$resourcedata{$thiskey})); } @@ -3150,6 +3384,62 @@ sub default_selector { return ''; } +sub string_ip_selector { + my ($thiskey, $showval) = @_; + my %access = ( + allow => [], + deny => [], + ); + if ($showval ne '') { + my @current; + if ($showval =~ /,/) { + @current = split(/,/,$showval); + } else { + @current = ($showval); + } + foreach my $item (@current) { + if ($item =~ /^\!([\[\]a-zA-Z\.\d\*\-]+)$/) { + push(@{$access{'deny'}},$1); + } elsif ($item =~ /^([\[\]a-zA-Z\.\d\*\-]+)$/) { + push(@{$access{'allow'}},$item); + } + } + } + if (!@{$access{'allow'}}) { + @{$access{'allow'}} = (''); + } + if (!@{$access{'deny'}}) { + @{$access{'deny'}} = (''); + } + my $output = ' +'; + foreach my $acctype ('allow','deny') { + $output .= ' +'; + } + $output .= ' + +
'.&mt('Allow from').''.&mt('Deny from').'
+
+
'."\n"; + my $num = 0; + foreach my $curr (@{$access{$acctype}}) { + $output .= '
'; + if ($num > 0) { + $output .= ''.&mt('Remove').''; + } + $output .= '
'."\n"; + $num ++; + } + $output .= ' +
+ +
+
'."\n"; + return $output; +} + +{ my %strings = ( 'string_yesno' @@ -3164,13 +3454,42 @@ my %strings = => [[ 'problem', 'Standard Problem'], [ 'survey', 'Survey'], [ 'anonsurveycred', 'Anonymous Survey (credit for submission)'], - [ 'exam', 'Exam'], + [ 'exam', 'Bubblesheet Exam'], [ 'anonsurvey', 'Anonymous Survey'], [ 'randomizetry', 'New Randomization Each N Tries (default N=1)'], [ 'practice', 'Practice'], [ 'surveycred', 'Survey (credit for submission)']], + 'string_lenient' + => [['yes', 'Yes' ], + [ 'no', 'No' ], + [ 'default', 'Default - only bubblesheet grading is lenient' ], + [ 'weighted', 'Yes, weighted (optionresponse in checkbox mode)' ]], + 'string_discussvote' + => [['yes','Yes'], + ['notended','Yes, unless discussion ended'], + ['no','No']], + 'string_ip' + => [['_allowfrom_','Hostname(s), or IP(s) from which access is allowed'], + ['_denyfrom_',], 'Hostname(s) or IP(s) from which access is disallowed'], ); +my %stringmatches = ( + 'string_lenient' + => [['weighted','^\-?[.\d]+,\-?[.\d]+,\-?[.\d]+,\-?[.\d]+$'],], + 'string_ip' + => [['_allowfrom_','[^\!]+'], + ['_denyfrom_','\!']], + ); + +my %stringtypes = ( + type => 'string_questiontype', + lenient => 'string_lenient', + retrypartial => 'string_yesno', + discussvote => 'string_discussvote', + examcode => 'string_examcode', + acc => 'string_ip', + ); + sub standard_string_options { my ($string_type) = @_; if (ref($strings{$string_type}) eq 'ARRAY') { @@ -3179,35 +3498,74 @@ sub standard_string_options { return; } +sub standard_string_matches { + my ($string_type) = @_; + if (ref($stringmatches{$string_type}) eq 'ARRAY') { + return $stringmatches{$string_type}; + } + return; +} + +sub get_stringtype { + my ($name) = @_; + if (exists($stringtypes{$name})) { + return $stringtypes{$name}; + } + return; +} + sub string_selector { - my ($thistype, $thiskey, $showval) = @_; + my ($thistype, $thiskey, $showval, $name) = @_; if (!exists($strings{$thistype})) { - return &default_selector($thiskey,$showval); + return &default_selector($thiskey,$showval); } my %skiptype; - if ($thistype eq 'string_questiontype') { + if (($thistype eq 'string_questiontype') || + ($thistype eq 'string_lenient') || + ($thistype eq 'string_discussvote') || + ($thistype eq 'string_ip') || + ($name eq 'retrypartial')) { my ($got_chostname,$chostname,$cmajor,$cminor); foreach my $possibilities (@{ $strings{$thistype} }) { next unless (ref($possibilities) eq 'ARRAY'); - my ($name, $description) = @{ $possibilities }; - my $needsrelease=$Apache::lonnet::needsrelease{'parameter:type:'.$name}; + my ($parmval, $description) = @{ $possibilities }; + my $parmmatch; + if (ref($stringmatches{$thistype}) eq 'ARRAY') { + foreach my $item (@{$stringmatches{$thistype}}) { + if (ref($item) eq 'ARRAY') { + if ($parmval eq $item->[0]) { + $parmmatch = $parmval; + $parmval = ''; + last; + } + } + } + } + my $needsrelease=$Apache::lonnet::needsrelease{"parameter:$name:$parmval:$parmmatch"}; if ($needsrelease) { unless ($got_chostname) { - ($chostname,$cmajor,$cminor)=&questiontype_release_vars(); + ($chostname,$cmajor,$cminor)=¶meter_release_vars(); $got_chostname = 1; } - my $needsnewer=&questiontype_releasecheck($name,$needsrelease, - $chostname,$cmajor, - $cminor); + my $needsnewer=¶meter_releasecheck($name,$parmval,$parmmatch, + $needsrelease,$cmajor,$cminor); if ($needsnewer) { - $skiptype{$name} = 1; + if ($parmmatch ne '') { + $skiptype{$parmmatch} = 1; + } elsif ($parmval ne '') { + $skiptype{$parmval} = 1; + } } } } } + if ($thistype eq 'string_ip') { + return &string_ip_selector($thiskey,$showval); + } + my $result; my $numinrow = 3; if ($thistype eq 'string_problemstatus') { @@ -3223,7 +3581,7 @@ sub string_selector { foreach my $possibilities (@{ $strings{$thistype} }) { next unless (ref($possibilities) eq 'ARRAY'); my ($name, $description) = @{ $possibilities }; - next if ($skiptype{$name}); + next if ($skiptype{$name}); $rem = $i%($numinrow); if ($rem == 0) { if ($i > 0) { @@ -3231,24 +3589,66 @@ sub string_selector { } $result .= ''; } - $result .= ''. + my $colspan; + if ($i == @{ $strings{$thistype} }-1) { + $rem = @{ $strings{$thistype} }%($numinrow); + if ($rem) { + my $colsleft = $numinrow - $rem; + if ($colsleft) { + $colspan = $colsleft+1; + $colspan = ' colspan="'.$colspan.'"'; + } + } + } + my ($add,$onchange,$css_class); + if ($thistype eq 'string_lenient') { + if ($name eq 'weighted') { + my $display; + my %relatives = &Apache::lonlocal::texthash( + corrchkd => 'Correct (checked)', + corrunchkd => 'Correct (unchecked)', + incorrchkd => 'Incorrect (checked)', + incorrunchkd => 'Incorrect (unchecked)', + ); + my %textval = ( + corrchkd => '1.0', + corrunchkd => '1.0', + incorrchkd => '0.0', + incorrunchkd => '0.0', + ); + if ($showval =~ /^([\-\d\.]+)\,([\-\d\.]+)\,([\-\d\.]+)\,([\-\d\.]+)$/) { + $textval{'corrchkd'} = $1; + $textval{'corrunchkd'} = $2; + $textval{'incorrchkd'} = $3; + $textval{'incorrunchkd'} = $4; + $display = 'inline'; + $showval = $name; + } else { + $display = 'none'; + } + $add = '
'. + ''; + foreach my $reltype ('corrchkd','corrunchkd','incorrchkd','incorrunchkd') { + $add .= ''."\n". + ''; + } + $add .= '
'.&mt("Foil's submission status").''.&mt('Points').'
 '.$relatives{$reltype}.''. + '
'."\n"; + } + $onchange = ' onclick="javascript:toggleParmTextbox(this.form,'."'$thiskey'".');"'; + $css_class = ' class="LC_lenient_radio"'; + } + $result .= ''. ''; + $result .= ' />'.&mt($description).''.$add.''; $i++; } - $rem = @{ $strings{$thistype} }%($numinrow); - my $colsleft = $numinrow - $rem; - if ($colsleft > 1 ) { - $result .= ''. - ' '; - } elsif ($colsleft == 1) { - $result .= ' '; - } $result .= ''; } if ($result) { @@ -3257,6 +3657,64 @@ sub string_selector { return $result; } +sub oldversion_warning { + my ($name,$value,$chostname,$cmajor,$cminor,$needsrelease) = @_; + my $desc; + my $stringtype = &get_stringtype($name); + if ($stringtype ne '') { + if ($name eq 'examcode') { + $desc = $value; + } elsif (ref($strings{$stringtypes{$name}}) eq 'ARRAY') { + foreach my $possibilities (@{ $strings{$stringtypes{$name}} }) { + next unless (ref($possibilities) eq 'ARRAY'); + my ($parmval, $description) = @{ $possibilities }; + my $parmmatch; + if (ref($stringmatches{$stringtypes{$name}}) eq 'ARRAY') { + foreach my $item (@{$stringmatches{$stringtypes{$name}}}) { + if (ref($item) eq 'ARRAY') { + my ($regexpname,$pattern) = @{$item}; + if ($parmval eq $regexpname) { + if ($value =~ /$pattern/) { + $desc = $description; + $parmmatch = 1; + last; + } + } + } + } + last if ($parmmatch); + } elsif ($parmval eq $value) { + $desc = $description; + last; + } + } + } + } elsif (($name eq 'printstartdate') || ($name eq 'printenddate')) { + my $now = time; + if ($value =~ /^\d+$/) { + if ($name eq 'printstartdate') { + if ($value > $now) { + $desc = &Apache::lonlocal::locallocaltime($value); + } + } elsif ($name eq 'printenddate') { + if ($value < $now) { + $desc = &Apache::lonlocal::locallocaltime($value); + } + } + } + } + my $standard_name = &standard_parameter_names($name); + return '

'. + &mt('[_1] was [_2]not[_3] set to [_4].', + $standard_name,'','','"'.$desc.'"').'
'. + &mt('LON-CAPA version ([_1]) installed on home server ([_2]) does not meet version requirements ([_3] or newer).', + $cmajor.'.'.$cminor,$chostname, + $needsrelease). + '

'; +} + +} + # # Shift all start and end dates by $shift # @@ -3267,7 +3725,7 @@ sub dateshift { my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; my %data=&Apache::lonnet::dump('resourcedata',$dom,$crs); # ugly retro fix for broken version of types - foreach my $key (keys %data) { + foreach my $key (keys(%data)) { if ($key=~/\wtype$/) { my $newkey=$key; $newkey=~s/type$/\.type/; @@ -3277,7 +3735,7 @@ sub dateshift { } my %storecontent=(); # go through all parameters and look for dates - foreach my $key (keys %data) { + foreach my $key (keys(%data)) { if ($data{$key.'.type'}=~/^date_(start|end)$/) { my $newdate=$data{$key}+$shift; $storecontent{$key}=$newdate; @@ -3297,14 +3755,33 @@ sub newoverview { my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'}; &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', text=>"Overview Mode"}); - my $start_page = &Apache::loncommon::start_page('Set Parameters'); + + my %loaditems = ( + 'onload' => "showHide_courseContent(); resize_scrollbox('mapmenuscroll','1','1'); showHideLenient();", + ); + my $js = ' + +'; + + my $start_page = &Apache::loncommon::start_page('Set Parameters',$js, + {'add_entries' => \%loaditems,}); my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview'); $r->print($start_page.$breadcrumbs); - &startSettingsScreen($r,'parmset'); + &startSettingsScreen($r,'parmset',$crstype); $r->print(< +
ENDOVER my @ids=(); my %typep=(); @@ -3331,7 +3808,7 @@ ENDOVER my $pschp=$env{'form.pschp'}; my @psprt=&Apache::loncommon::get_env_multiple('form.psprt'); - if (!@psprt) { $psprt[0]='0'; } + if (!@psprt) { $psprt[0]='all'; } my @selected_sections = &Apache::loncommon::get_env_multiple('form.Section'); @@ -3365,7 +3842,7 @@ ENDOVER $r->print('
'); #$r->print('

Step 1

'); $r->print('
'); - $r->print(&Apache::lonhtmlcommon::start_pick_box()); + $r->print(&Apache::lonhtmlcommon::start_pick_box(undef,'parmlevel')); &levelmenu($r,\%alllevs,$parmlev); if ($parmlev ne 'general') { $r->print(&Apache::lonhtmlcommon::row_closure()); @@ -3377,10 +3854,7 @@ ENDOVER $r->print('
'); $r->print('
'); - $r->print(&Apache::lonhtmlcommon::start_pick_box()); - &parmmenu($r,\%allparms,\@pscat,\%keyorder); - $r->print(&Apache::lonhtmlcommon::end_pick_box()); - &parmboxes($r,\%allparms,\@pscat,\%keyorder); + &displaymenu($r,\%allparms,\@pscat,\%keyorder); $r->print(&Apache::lonhtmlcommon::start_pick_box()); $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parts to View'))); $r->print(''. @@ -3450,7 +3924,7 @@ sub secgroup_lister { $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat}; } elsif ($parmlev eq 'map') { # map-level parameter - foreach my $mapid (keys %{$allmaps}) { + foreach my $mapid (keys(%{$allmaps})) { if (($pschp ne 'all') && ($pschp ne $mapid)) { next; } my $newparmkey=$rootparmkey.'.'.$$allmaps{$mapid}.'___(all).'.$part.'.'.$cat; $$listdata{$newparmkey}=1; @@ -3474,14 +3948,25 @@ sub overview { my ($r) = @_; my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; - + my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'}; + my $js = ''."\n"; &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', text=>"Overview Mode"}); - my $start_page=&Apache::loncommon::start_page('Modify Parameters'); + my %loaditems = ( + 'onload' => "showHideLenient();", + ); + + my $start_page=&Apache::loncommon::start_page('Modify Parameters',$js,{'add_entries' => \%loaditems,}); my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview'); $r->print($start_page.$breadcrumbs); - &startSettingsScreen($r,'parmset'); - $r->print(''); + &startSettingsScreen($r,'parmset',$crstype); + $r->print(''); # Store modified @@ -3499,9 +3984,8 @@ sub overview { # List data my $foundkeys=&listdata($r,$resourcedata,$resourcedata,$sortorder); - $r->print(&tableend().'

'. - ($foundkeys?'':&mt('There are no parameters.')).'

'. + ($foundkeys?'':''.&mt('There are no parameters.').'').'

'. &Apache::loncommon::end_page()); } @@ -3577,8 +4061,9 @@ ENDOVER } elsif ($data{'realm_type'} eq 'symb') { my ($map,$resid,$url) = &Apache::lonnet::decode_symb($data{'realm'}); - $r->print(&mt('Resource: [_1]
   with ID: [_2]
   in folder [_3]', - $url,$resid,$map)); + $r->print(&mt('Resource: [_1]with ID: [_2]in folder [_3]', + $url.'
   ', + $resid.'
   ',$map)); } $r->print('
   '.&mt('Part: [_1]',$data{'parameter_part'})); $r->print(''); @@ -3596,14 +4081,15 @@ sub date_shift_one { my ($r) = @_; my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'}; &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'}, text=>"Shifting Dates"}); my $start_page=&Apache::loncommon::start_page('Shift Dates'); my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift'); $r->print($start_page.$breadcrumbs); - &startSettingsScreen($r,'parmset'); - $r->print(''. + &startSettingsScreen($r,'parmset',$crstype); + $r->print(''. '
'. ''. @@ -4563,11 +5078,11 @@ sub update_slots { action => 'reserve', context => 'parameter', ); - &Apache::lonnet::instructor_log('slotreservationslog',\%storehash, - '',$uname,$udom,$cnum,$cdom); + &Apache::lonnet::write_log('course','slotreservationslog',\%storehash, + '',$uname,$udom,$cnum,$cdom); - &Apache::lonnet::instructor_log($cdom.'_'.$cnum.'_slotlog',\%storehash, - '',$uname,$udom,$uname,$udom); + &Apache::lonnet::write_log('course',$cdom.'_'.$cnum.'_slotlog',\%storehash, + '',$uname,$udom,$uname,$udom); } return $success; } @@ -4597,10 +5112,10 @@ sub delete_slots { 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); + &Apache::lonnet::write_log('course','slotreservationslog',\%storehash, + 1,$uname,$udom,$cnum,$cdom); + &Apache::lonnet::write_log('course',$cdom.'_'.$cnum.'_slotlog',\%storehash, + 1,$uname,$udom,$uname,$udom); } } } @@ -4613,7 +5128,7 @@ sub check_for_course_info { return 0; } -sub questiontype_release_vars { +sub parameter_release_vars { my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $chome = $env{'course.'.$env{'request.course.id'}.'.home'}; my $chostname = &Apache::lonnet::hostname($chome); @@ -4622,41 +5137,21 @@ sub questiontype_release_vars { return ($chostname,$cmajor,$cminor); } -sub questiontype_releasecheck { - my ($questiontype,$needsrelease,$chostname,$cmajor,$cminor) = @_; +sub parameter_releasecheck { + my ($name,$value,$valmatch,$needsrelease,$cmajor,$cminor) = @_; my $needsnewer; my ($needsmajor,$needsminor) = split(/\./,$needsrelease); if (($cmajor < $needsmajor) || ($cmajor == $needsmajor && $cminor < $needsminor)) { $needsnewer = 1; - } else { - &Apache::lonnet::update_released_required($Apache::lonnet::needsrelease{'parameter:type:'.$questiontype}); + } elsif ($valmatch) { + &Apache::lonnet::update_released_required($Apache::lonnet::needsrelease{'parameter:'.$name.'::'.$valmatch}); + } elsif ($value) { + &Apache::lonnet::update_released_required($Apache::lonnet::needsrelease{'parameter:'.$name.':'.$value.':'}); } return $needsnewer; } -sub oldversion_warning { - my ($questiontype,$chostname,$cmajor,$cminor,$needsrelease) = @_; - my $desc; - if (ref($strings{'string_questiontype'}) eq 'ARRAY') { - foreach my $possibilities (@{ $strings{'string_questiontype'} }) { - next unless (ref($possibilities) eq 'ARRAY'); - my ($name, $description) = @{ $possibilities }; - if ($name eq $questiontype) { - $desc = $description; - last; - } - } - } - return '

'. - &mt('Question Type was [_1]not[_2] set to [_3].', - '','','"'.$desc.'"').'
'. - &mt('LON-CAPA version ([_1]) installed on home server ([_2]) does not meet version requirements ([_3] or newer).', - $cmajor.'.'.$cminor,$chostname, - $needsrelease). - '

'; -} - sub handler { my $r=shift;
'.&mt('Currently set date:').''. &Apache::lonlocal::locallocaltime($env{'form.timebase'}).'
'.&mt('Shifted date:').''. @@ -3623,18 +4109,25 @@ sub date_shift_two { my ($r) = @_; my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'}; &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'}, text=>"Shifting Dates"}); my $start_page=&Apache::loncommon::start_page('Shift Dates'); my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift'); $r->print($start_page.$breadcrumbs); - &startSettingsScreen($r,'parmset'); + &startSettingsScreen($r,'parmset',$crstype); my $timeshifted=&Apache::lonhtmlcommon::get_date_from_form('timeshifted'); - $r->print(&mt('Shifting all dates such that [_1] becomes [_2]', + $r->print('

'.&mt('Shift Dates').'

'. + '

'.&mt('Shifting all dates such that [_1] becomes [_2]', &Apache::lonlocal::locallocaltime($env{'form.timebase'}), - &Apache::lonlocal::locallocaltime($timeshifted))); + &Apache::lonlocal::locallocaltime($timeshifted)).'

'); my $delta=$timeshifted-$env{'form.timebase'}; &dateshift($delta); + $r->print( + &Apache::lonhtmlcommon::confirm_success(&mt('Done')). + '

'. + &Apache::lonhtmlcommon::actionbox( + [''.&mt('Content and Problem Settings').''])); &endSettingsScreen($r); $r->print(&Apache::loncommon::end_page()); } @@ -3690,7 +4183,10 @@ sub print_main_menu { # $r->print(&header()); $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content and Problem Settings')); - &startSettingsScreen($r,'parmset'); + my $crstype = &Apache::loncommon::course_type(); + my $lc_crstype = lc($crstype); + + &startSettingsScreen($r,'parmset',$crstype); $r->print(< @@ -3700,9 +4196,11 @@ ENDMAINFORMHEAD my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $vgr = &Apache::lonnet::allowed('vgr',$env{'request.course.id'}); my $mgr = &Apache::lonnet::allowed('mgr',$env{'request.course.id'}); - - my $crstype = &Apache::loncommon::course_type(); - my $lc_crstype = lc($crstype); + my $dcm = &Apache::lonnet::allowed('dcm',$env{'request.course.id'}); + if ((!$dcm) && ($env{'request.course.sec'} ne '')) { + $dcm = &Apache::lonnet::allowed('dcm',$env{'request.course.id'}. + '/'.$env{'request.course.sec'}); + } my @menu = ( { categorytitle=>"Content Settings for this $crstype", @@ -3719,7 +4217,12 @@ ENDMAINFORMHEAD linktitle => "Reset access times for folders/maps, resources or the $lc_crstype." , icon => 'start-here.png' , }, - + { linktext => 'Blocking Communication/Resource Access', + url => '/adm/setblock', + permission => $dcm, + linktitle => 'Configure blocking of communication/collaboration and access to resources during an exam', + icon => 'comblock.png', + }, { linktext => 'Set Parameter Setting Default Actions', url => '/adm/parmset?action=setdefaults', permission => $parm_permission, @@ -3766,7 +4269,9 @@ ENDMAINFORMHEAD }]} ); $r->print(&Apache::lonhtmlcommon::generate_menu(@menu)); + $r->print(''); &endSettingsScreen($r); + $r->print(&Apache::loncommon::end_page()); return; } @@ -3834,6 +4339,7 @@ sub order_meta_fields { my $idx = 1; my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'};; $r->print(&Apache::loncommon::start_page('Order Metadata Fields')); &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata', text=>"Add Metadata Field"}); @@ -3842,12 +4348,12 @@ sub order_meta_fields { text=>"Restrict Metadata"}, {text=>"Order Metadata"}); $r->print(&Apache::lonhtmlcommon::breadcrumbs('Order Metadata')); - &startSettingsScreen($r,'parmset'); + &startSettingsScreen($r,'parmset',$crstype); if ($env{'form.storeorder'}) { my $newpos = $env{'form.newpos'} - 1; my $currentpos = $env{'form.currentpos'} - 1; my @neworder = (); - my @oldorder = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'}; + my @oldorder = split(/,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'}); my $i; if ($newpos > $currentpos) { # moving stuff up @@ -3881,10 +4387,10 @@ sub order_meta_fields { } my $fields = &get_added_meta_fieldnames($env{'request.course.id'}); my $ordered_fields; - my @fields_in_order = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'}; + my @fields_in_order = split(/,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'}); if (!@fields_in_order) { # no order found, pick sorted order then create metadata.addedorder key. - foreach my $key (sort keys %$fields) { + foreach my $key (sort(keys(%$fields))) { push @fields_in_order, $key; $ordered_fields = join ",", @fields_in_order; } @@ -3896,7 +4402,7 @@ sub order_meta_fields { foreach my $key (@fields_in_order) { $r->print('
'); $r->print('
'); - $r->print(''); for (my $i = 1;$i le $num_fields;$i ++) { if ($i eq $idx) { $r->print(''); @@ -3932,9 +4438,10 @@ sub addmetafield { text=>"Add Metadata Field"}); $r->print(&Apache::loncommon::start_page('Add Metadata Field')); $r->print(&Apache::lonhtmlcommon::breadcrumbs('Add Metadata Field')); - &startSettingsScreen($r,'parmset'); my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'}; + &startSettingsScreen($r,'parmset',$crstype); if (exists($env{'form.undelete'})) { my @meta_fields = &Apache::loncommon::get_env_multiple('form.undeletefield'); foreach my $meta_field(@meta_fields) { @@ -3989,9 +4496,10 @@ sub setrestrictmeta { text=>"Restrict Metadata"}); $r->print(&Apache::loncommon::start_page('Restrict Metadata')); $r->print(&Apache::lonhtmlcommon::breadcrumbs('Restrict Metadata')); - &startSettingsScreen($r,'parmset'); my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'}; + &startSettingsScreen($r,'parmset',$crstype); my $key_base = $env{'course.'.$env{'request.course.id'}.'.'}; my $save_field = ''; if ($env{'form.restrictmeta'}) { @@ -4103,15 +4611,16 @@ sub defaultsetter { &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setdefaults', text=>"Set Defaults"}); + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'}; my $start_page = - &Apache::loncommon::start_page('Parameter Setting Default Actions'); + &Apache::loncommon::start_page('Parameter Setting Default Actions'); my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Defaults'); $r->print($start_page.$breadcrumbs); - &startSettingsScreen($r,'parmset'); + &startSettingsScreen($r,'parmset',$crstype); $r->print(''); - my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; my @ids=(); my %typep=(); my %keyp=(); @@ -4162,11 +4671,11 @@ sub defaultsetter { } } } - foreach my $key (keys %allparms) { + foreach my $key (keys(%allparms)) { $newrules{$key.'_triggers'}=$triggers{$key}; } - &Apache::lonnet::put('parmdefactions',\%newrules,$dom,$crs); - &Apache::lonnet::del('parmdefactions',\@delrules,$dom,$crs); + &Apache::lonnet::put('parmdefactions',\%newrules,$cdom,$cnum); + &Apache::lonnet::del('parmdefactions',\@delrules,$cdom,$cnum); &resetrulescache(); } my %lt=&Apache::lonlocal::texthash('days' => 'Days', @@ -4343,18 +4852,26 @@ sub standard_parameter_types { sub parm_change_log { my ($r)=@_; + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'} &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable', text=>"Parameter Change Log"}); - $r->print(&Apache::loncommon::start_page('Parameter Change Log')); + my $js = ''."\n"; + $r->print(&Apache::loncommon::start_page('Parameter Change Log',$js)); $r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Change Log')); - &startSettingsScreen($r,'parmset'); - my %parmlog=&Apache::lonnet::dump('nohist_parameterlog', - $env{'course.'.$env{'request.course.id'}.'.domain'}, - $env{'course.'.$env{'request.course.id'}.'.num'}); + &startSettingsScreen($r,'parmset',$crstype); + my %parmlog=&Apache::lonnet::dump('nohist_parameterlog',$cdom,$cnum); if ((keys(%parmlog))[0]=~/^error\:/) { undef(%parmlog); } - $r->print('print('
'. + '
'.&mt('Display of Changes').''. + ''); my %saveable_parameters = ('show' => 'scalar',); @@ -4362,13 +4879,11 @@ sub parm_change_log { \%saveable_parameters); &Apache::loncommon::restore_course_settings('parameter_log', \%saveable_parameters); - $r->print(&Apache::loncommon::display_filter(). - ''. - ''); + $r->print(&Apache::loncommon::display_filter('parmslog').' '."\n". + ''. + '

'); - my $courseopt=&Apache::lonnet::get_courseresdata($env{'course.'.$env{'request.course.id'}.'.num'}, - $env{'course.'.$env{'request.course.id'}.'.domain'}); + my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom); $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row(). '
'.&mt('Time').''.&mt('User').''.&mt('Extent').''.&mt('Users').''. &mt('Parameter').''.&mt('Part').''.&mt('New Value').''.&mt('Announce').'