--- loncom/interface/lonparmset.pm 2003/06/30 20:24:26 1.113 +++ loncom/interface/lonparmset.pm 2003/10/09 16:21:20 1.131 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.113 2003/06/30 20:24:26 sakharuk Exp $ +# $Id: lonparmset.pm,v 1.131 2003/10/09 16:21:20 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -61,7 +61,7 @@ use Apache::loncommon; use GDBM_File; use Apache::lonhomework; use Apache::lonxml; - +use Apache::lonlocal; my %courseopt; my %useropt; @@ -287,7 +287,7 @@ sub plink { sub startpage { my ($r,$id,$udom,$csec,$uname,$have_assesments)=@_; - my $bodytag=&Apache::loncommon::bodytag('Set Course Parameters','', + my $bodytag=&Apache::loncommon::bodytag('Set/Modify Course Parameters','', 'onUnload="pclose()"'); my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '. &Apache::loncommon::selectstudent_link('parmform','uname','udom'); @@ -343,16 +343,22 @@ $selscript $bodytag
-

Course Environment

- +

Course Environment Parameters

+ +
+
+
+

Course Assessment Parameter - Helper Mode

+ +
+
+
+

Course Assessment Parameters - Overview Mode

+

-

Course Assessments

- -Use Assignment Parameter Helper, a -simpler interface to set open, due, or answer open dates for problems or -sequences.
 
+

Course Assessments Parameters - Table Mode

ENDHEAD if (!$have_assesments) { @@ -488,9 +494,15 @@ sub print_row { sub print_td { my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display)=@_; $r->print(''. - &plink($$typeoutpar[$which],$$display{$value},$$outpar[$which], - $mprefix."$which",'parmform.pres','psub').''."\n"); + ' align="center">'); + if ($which<10) { + $r->print(&plink($$typeoutpar[$which], + $$display{$value},$$outpar[$which], + $mprefix."$which",'parmform.pres','psub')); + } else { + $r->print(&valout($$outpar[$which],$$typeoutpar[$which])); + } + $r->print(''."\n"); } sub get_env_multiple { @@ -641,9 +653,9 @@ sub assessparms { my $r=shift; # -------------------------------------------------------- Variable declaration - my %allkeys; - my %allmaps; - my %alllevs; + my %allkeys=(); + my %allmaps=(); + my %alllevs=(); $alllevs{'Resource Level'}='full'; # $alllevs{'Resource Level [BRIEF]'}='brief'; @@ -852,7 +864,7 @@ sub assessparms { $message.="Write Error: $1"; } # ---------------------------------------------------------------- Done storing - $message.='

Changes can take up to 10 minutes before being active for all students

'; + $message.='

'.&mt('Changes can take up to 10 minutes before being active for all students.').&Apache::loncommon::help_open_topic('Caching').'

'; } # --------------------------------------------- Devalidate cache for this child &Apache::lonnet::devalidatecourseresdata( @@ -911,9 +923,9 @@ sub assessparms { $r->print('

'.$message.'

'); - my $submitmessage; + my $submitmessage = &mt('Update Section or Specific User'); if (!$pssymb) { - $r->print('\n"); $r->print(''); - - $r->print(''); - $r->print('\n"); + if ($parmlev ne 'general') { + $r->print(''); + $r->print('\n"); + } } else { - my ($map,$id,$resource)=split(/___/,$pssymb); - $r->print(""); + my ($map,$id,$resource)=&Apache::lonnet::decode_symb($pssymb); + $r->print(""); $r->print(''); $r->print(''); $r->print(''); @@ -945,7 +958,7 @@ sub assessparms { $r->print(''); + $r->print(' name="showoptions" value="show">'.&mt('Show More Options').'
'); # $r->print(""); # $r->print(""); # $r->print(""); @@ -954,12 +967,12 @@ sub assessparms { if ($showoptions eq 'show') { my $tempkey; - $r->print(''); + $r->print(''); $r->print('
Select Parameter Level'); + $r->print('
'.&mt('Select Parameter Level').''); $r->print('
Select Enclosing Map or Folder
'.&mt('Select Enclosing Map or Folder').'
Specific Resource$resource
".&mt('Specific Resource')."$resource

print(" checked ");} - $r->print(' name="showoptions" value="show">Show More Options
Show: $showoptions
pscat: @pscat
psprt: @psprt
Select Parameters to View
'.&mt('Select Parameters to View').'
'); $r->print(''); + $r->print('>'.&mt('All Parameters').''); my $cnt=0; foreach $tempkey (sort { $allparms{$a} cmp $allparms{$b} } @@ -979,7 +992,7 @@ sub assessparms { $r->print(''); - $r->print('
print(' checked') unless (@pscat); - $r->print('>All Parameters

Sort list by'); + $r->print('
'.&mt('Sort list by').''); $r->print('

'); if (($prevvisit) || ($pschp) || ($pssymb)) { - $submitmessage = "Update Course Assessment Parameter Display"; + $submitmessage = &mt("Update Course Assessment Parameter Display"); } else { - $submitmessage = "Set Course Assessment Parameters"; + $submitmessage = &mt("Set/Modify Course Assessment Parameters"); } $r->print(''); @@ -1063,10 +1076,10 @@ sub assessparms { my $coursespan=$csec?8:5; $r->print('

'); $r->print(''); - $r->print(''); + $r->print(''); if ($uname) { $r->print(""); + $r->print(&mt("User")." $uname ".&mt('at Domain')." $udom"); } $r->print(<Parameter in Effect @@ -1085,11 +1098,11 @@ ENDTABLETWO ENDTABLEHEADFOUR if ($csec) { - $r->print(''); + $r->print(''); } if ($uname) { - $r->print(''); + $r->print(''); } $r->print(''); @@ -1140,7 +1153,8 @@ ENDTABLEHEADFOUR my $totalparms=scalar keys %name; if ($totalparms>0) { my $firstrow=1; - + my $title=$bighash{'title_'.$rid}; + $title=~s/\:/:/g; $r->print('
Any User'.&mt('Any User').'"); - $r->print("User $uname at Domain $udomgeneralfor Enclosing Map or Folderfor Resource'.&mt('general').''.&mt('for Enclosing Map or Folder').''.&mt('for Resource').'generalfor Enclosing Map or Folderfor Resource'.&mt('general').''.&mt('for Enclosing Map or Folder').''.&mt('for Resource').'
'. @@ -1148,7 +1162,7 @@ ENDTABLEHEADFOUR '

'. "$bighash{'title_'.$rid}"); + " TARGET=_self>$title"); if ($thistitle) { $r->print(' ('.$thistitle.')'); @@ -1263,20 +1277,22 @@ ENDMAPONE ('firstname','middlename','lastname','generation', 'id')); my $person=$name{'firstname'}.' '.$name{'middlename'}.' ' .$name{'lastname'}.' '.$name{'generation'}; - $r->print("User $uname \($person\) in \n"); + $r->print(&mt("User")." $uname \($person\) ". + &mt('in')." \n"); } else { - $r->print("all users in \n"); + $r->print("".&mt('all').' '.&mt('users in')." \n"); } - if ($csec) {$r->print("Section $csec of \n")}; + if ($csec) {$r->print(&mt("Section")." $csec ". + &mt('of')." \n")}; $r->print("$coursename
"); $r->print("\n"); #---------------------------------------------------------------- print table $r->print('

'); - $r->print(''); - $r->print(''); - $r->print(''); + $r->print(''); + $r->print(''); + $r->print(''); foreach (sort keys %name) { &print_row($r,$_,\%part,\%name,$mapid,\%default, @@ -1342,18 +1358,18 @@ ENDMAPONE ('firstname','middlename','lastname','generation', 'id')); my $person=$name{'firstname'}.' '.$name{'middlename'}.' ' .$name{'lastname'}.' '.$name{'generation'}; - $r->print(" User $uname \($person\) \n"); + $r->print(" ".&mt("User")." $uname \($person\) \n"); } else { - $r->print("ALL USERS \n"); + $r->print("".&mt("ALL")." ".&mt("USERS")." \n"); } - if ($csec) {$r->print("Section $csec\n")}; + if ($csec) {$r->print(&mt("Section")." $csec\n")}; $r->print("\n"); #---------------------------------------------------------------- print table $r->print('

Parameter NameDefault ValueParameter in Effect
'.&mt('Parameter Name').''.&mt('Default Value').''.&mt('Parameter in Effect').'
'); - $r->print(''); - $r->print(''); - $r->print(''); + $r->print(''); + $r->print(''); + $r->print(''); foreach (sort keys %name) { &print_row($r,$_,\%part,\%name,$mapid,\%default, @@ -1409,7 +1425,7 @@ sub crsenv { my $bkuptime=time; my @tmp = &Apache::lonnet::get ('environment',['url'],$dom,$crs); - $setoutput.='Backing up previous URL: '. + $setoutput.=&mt('Backing up previous URL').': '. &Apache::lonnet::put ('environment', {'top level map backup '.$bkuptime => $tmp[1] }, @@ -1448,10 +1464,10 @@ sub crsenv { my $put_result = &Apache::lonnet::put('environment', {$name=>$value},$dom,$crs); if ($put_result eq 'ok') { - $setoutput.='Set '.$name.' to '.$value.'.
'; + $setoutput.=&mt('Set').' '.$name.' '.&mt('to').' '.$value.'.
'; } else { - $setoutput.='Unable to set '.$name.' to '. - ''.$value.' due to '.$put_result.'.
'; + $setoutput.=&mt('Unable to set').' '.$name.' '.&mt('to'). + ' '.$value.' '.&mt('due to').' '.$put_result.'.
'; } } } @@ -1474,6 +1490,10 @@ sub crsenv { 'description' => 'Course Description', 'courseid' => 'Course ID or number
'. '(internal, optional)', + 'grading' => 'Grading'. + '"standard" or any other value. '. + 'Default for new courses is "standard".', + 'default_xml_style' => 'Default XML Style File '. '
'Visibly Separate Items on Pages
'. '("yes" for visible separation, '. 'changes will not show until next login)', + + 'plc.roles.denied'=> 'Disallow live chatroom use for '. + 'Roles
"st": '. + 'student, "ta": '. + 'TA, "in": '. + 'instructor;
role,role,...) '. + Apache::loncommon::help_open_topic("Course_Disable_Discussion"), + 'plc.users.denied' => + 'Disallow live chatroom use for Users
'. + '(user:domain,user:domain,...)', + 'pch.roles.denied'=> 'Disallow Resource Discussion for '. 'Roles
"st": '. 'student, "ta": '. @@ -1523,7 +1554,7 @@ sub crsenv { 'have different numbers and answers', 'problem_stream_switch' => 'Allow problems to be split over pages
'. - ' ("yes" if allowed, anything else if not)',, + ' ("yes" if allowed, anything else if not)', 'anonymous_quiz' => 'Anonimous quiz/exam
'. ' (yes to avoid print students names )', @@ -1531,16 +1562,21 @@ sub crsenv { 'when enrolling students
', 'default_enrollment_end_date' => 'Default ending date '. 'when enrolling students', - 'languages' => 'Languages used' + 'languages' => 'Languages used', + 'disable_receipt_display' + => 'Disable display of problem receipts
'. + ' ("yes" to disable, anything else if not)' ); - my @Display_Order = ('url','description','courseid', + my @Display_Order = ('url','description','courseid','grading', 'default_xml_style','pageseparators', 'question.email','comment.email','policy.email', + 'plc.roles.denied','plc.users.denied', 'pch.roles.denied','pch.users.denied', 'allow_limited_html_in_feedback', 'languages', 'rndseed', 'problem_stream_switch', + 'disable_receipt_display', 'spreadsheet_default_classcalc', 'spreadsheet_default_studentcalc', 'spreadsheet_default_assesscalc', @@ -1582,7 +1618,7 @@ sub crsenv { my $onchange = 'onFocus="javascript:window.document.forms'. '[\'envform\'].elements[\'newp_setparmval\']'. '.checked=true;"'; - $output.='
'); + } + } + + $r->print(&tableend(). + '

'); +} ################################################## ################################################## @@ -1651,28 +1814,47 @@ sub handler { my $r=shift; if ($r->header_only) { - $r->content_type('text/html'); + &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; return OK; } &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}); +# ----------------------------------------------------------- Clear out garbage + +%courseopt=(); +%useropt=(); +%parmhash=(); + +@ids=(); +%symbp=(); +%mapp=(); +%typep=(); +%keyp=(); + +%maptitles=(); + + # ----------------------------------------------------- Needs to be in a course if (($ENV{'request.course.id'}) && (&Apache::lonnet::allowed('opa',$ENV{'request.course.id'}))) { - $r->content_type('text/html'); + &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; $coursename=$ENV{'course.'.$ENV{'request.course.id'}.'.description'}; - unless (($ENV{'form.crsenv'}) || (!$ENV{'request.course.fn'})) { -# --------------------------------------------------------- Bring up assessment - &assessparms($r); + if (($ENV{'form.crsenv'}) || (!$ENV{'request.course.fn'})) { # ---------------------------------------------- This is for course environment - } else { +# -------------------------- also call if toplevel map coudl not be initialized &crsenv($r); + } elsif ($ENV{'form.overview'}) { +# --------------------------------------------------------------- Overview mode + &overview($r); + } else { +# --------------------------------------------------------- Bring up assessment + &assessparms($r); } } else { # ----------------------------- Not in a course, or not allowed to modify parms
Parameter NameDefault ValueParameter in Effect
'.&mt('Parameter Name').''.&mt('Default Value').''.&mt('Parameter in Effect').'
Create New Environment Variable
'. + $output.='
'.&mt('Create New Environment Variable').'
'. '
'. ' ENDENV } +################################################## + +my $tableopen; + +sub tablestart { + if ($tableopen) { + return ''; + } else { + $tableopen=1; + return ''; + } +} + +sub tableend { + if ($tableopen) { + $tableopen=0; + return '
'.&mt('Parameter').''. + &mt('Delete').''.&mt('Set to ...').'
'; + } else { + return''; + } +} + +sub overview { + my $r=shift; + my $bodytag=&Apache::loncommon::bodytag( + 'Set/Modify Course Assessment Parameters'); + my $dom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}; + my $crs = $ENV{'course.'.$ENV{'request.course.id'}.'.num'}; + $r->print(< + +LON-CAPA Course Environment + +$bodytag + + +ENDOVER +# Setting + my %olddata=&Apache::lonnet::dump('resourcedata',$dom,$crs); + my %newdata=(); + undef %newdata; + my @deldata=(); + undef @deldata; + foreach (keys %ENV) { + if ($_=~/^form\.([a-z]+)\_(.+)$/) { + my $cmd=$1; + my $thiskey=$2; + if ($cmd eq 'set') { + my $data=$ENV{$_}; + if ($olddata{$thiskey} ne $data) { $newdata{$thiskey}=$data; } + } elsif ($cmd eq 'del') { + push (@deldata,$thiskey); + } elsif ($cmd eq 'datepointer') { + my $data=&Apache::lonhtmlcommon::get_date_from_form($ENV{$_}); + if ($olddata{$thiskey} ne $data) { $newdata{$thiskey}=$data; } + } + } + } +# Store + &Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs); + &Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs); +# Read and display + my %resourcedata=&Apache::lonnet::dump('resourcedata',$dom,$crs); + my $oldsection=''; + my $oldrealm=''; + my $oldpart=''; + my $pointer=0; + $tableopen=0; + foreach my $thiskey (sort keys %resourcedata) { + if ($resourcedata{$thiskey.'.type'}) { + my ($course,$middle,$part,$name)= + ($thiskey=~/^(\w+)\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/); + my $section=&mt('All Students'); + if ($middle=~/^\[(.*)\]\./) { + $section=&mt('Group/Section').': '.$1; + $middle=~s/^\[(.*)\]\.//; + } + $middle=~s/\.$//; + my $realm=''.&mt('All Resources').''; + if ($middle=~/^(.+)\_\_\_\(all\)$/) { + $realm=''.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).''; + } elsif ($middle) { + $realm=''.&mt('Resource').': '.&Apache::lonnet::gettitle($middle).''; + } + if ($section ne $oldsection) { + $r->print(&tableend()."\n

$section

"); + $oldsection=$section; + $oldrealm=''; + } + if ($realm ne $oldrealm) { + $r->print(&tableend()."\n

$realm

"); + $oldrealm=$realm; + $oldpart=''; + } + if ($part ne $oldpart) { + $r->print(&tableend(). + "\n

".&mt('Part').": $part

"); + $oldpart=$part; + } +# +# Ready to print +# + $r->print(&tablestart().'
'.$name. + ':'); + if ($resourcedata{$thiskey.'.type'}=~/^date/) { + my $jskey='key_'.$pointer; + $pointer++; + $r->print( + &Apache::lonhtmlcommon::date_setter('overviewform', + $jskey, + $resourcedata{$thiskey}). +'' + ); + } else { + $r->print( + ''); + } + $r->print('