Annotation of loncom/interface/lonparmset.pm, revision 1.197
1.1 www 1: # The LearningOnline Network with CAPA
2: # Handler to set parameters for assessments
3: #
1.197 ! www 4: # $Id: lonparmset.pm,v 1.196 2005/06/01 02:02:41 www Exp $
1.40 albertel 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
1.59 matthew 28: ###################################################################
29: ###################################################################
30:
31: =pod
32:
33: =head1 NAME
34:
35: lonparmset - Handler to set parameters for assessments and course
36:
37: =head1 SYNOPSIS
38:
39: lonparmset provides an interface to setting course parameters.
40:
41: =head1 DESCRIPTION
42:
43: This module sets coursewide and assessment parameters.
44:
45: =head1 INTERNAL SUBROUTINES
46:
47: =over 4
48:
49: =cut
50:
51: ###################################################################
52: ###################################################################
1.1 www 53:
54: package Apache::lonparmset;
55:
56: use strict;
57: use Apache::lonnet;
58: use Apache::Constants qw(:common :http REDIRECT);
1.88 matthew 59: use Apache::lonhtmlcommon();
1.36 albertel 60: use Apache::loncommon;
1.1 www 61: use GDBM_File;
1.57 albertel 62: use Apache::lonhomework;
63: use Apache::lonxml;
1.130 www 64: use Apache::lonlocal;
1.197 ! www 65: use Apache::lonnavmaps;
1.1 www 66:
1.2 www 67: my %courseopt;
68: my %useropt;
69: my %parmhash;
70:
1.3 www 71: my @ids;
72: my %symbp;
1.10 www 73: my %mapp;
1.3 www 74: my %typep;
1.16 www 75: my %keyp;
1.196 www 76: my %uris;
1.82 www 77: my %maptitles;
78:
1.59 matthew 79: ##################################################
80: ##################################################
81:
82: =pod
83:
84: =item parmval
85:
86: Figure out a cascading parameter.
87:
1.71 albertel 88: Inputs: $what - a parameter spec (incluse part info and name I.E. 0.weight)
1.162 albertel 89: $id - a bighash Id number
1.71 albertel 90: $def - the resource's default value 'stupid emacs
91:
92: Returns: A list, the first item is the index into the remaining list of items of parm valuse that is the active one, the list consists of parm values at the 11 possible levels
93:
1.182 albertel 94: 11 - General Course
95: 10 - Map or Folder level in course
96: 9- resource default
97: 8- map default
1.71 albertel 98: 7 - resource level in course
99: 6 - General for section
1.82 www 100: 5 - Map or Folder level for section
1.71 albertel 101: 4 - resource level in section
102: 3 - General for specific student
1.82 www 103: 2 - Map or Folder level for specific student
1.71 albertel 104: 1 - resource level for specific student
1.2 www 105:
1.59 matthew 106: =cut
107:
108: ##################################################
109: ##################################################
1.2 www 110: sub parmval {
1.187 www 111: my ($what,$id,$def,$uname,$udom,$csec)=@_;
1.8 www 112: my $result='';
1.44 albertel 113: my @outpar=();
1.2 www 114: # ----------------------------------------------------- Cascading lookup scheme
1.10 www 115:
1.43 albertel 116: my $symbparm=$symbp{$id}.'.'.$what;
117: my $mapparm=$mapp{$id}.'___(all).'.$what;
1.10 www 118:
1.190 albertel 119: my $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$what;
120: my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm;
121: my $seclevelm=$env{'request.course.id'}.'.['.$csec.'].'.$mapparm;
122:
123: my $courselevel=$env{'request.course.id'}.'.'.$what;
124: my $courselevelr=$env{'request.course.id'}.'.'.$symbparm;
125: my $courselevelm=$env{'request.course.id'}.'.'.$mapparm;
1.2 www 126:
1.11 www 127:
128:
1.182 albertel 129: # --------------------------------------------------------- first, check course
1.11 www 130:
1.71 albertel 131: if (defined($courseopt{$courselevel})) {
1.182 albertel 132: $outpar[11]=$courseopt{$courselevel};
133: $result=11;
1.43 albertel 134: }
1.11 www 135:
1.71 albertel 136: if (defined($courseopt{$courselevelm})) {
1.182 albertel 137: $outpar[10]=$courseopt{$courselevelm};
138: $result=10;
1.43 albertel 139: }
1.11 www 140:
1.182 albertel 141: # ------------------------------------------------------- second, check default
142:
143: if (defined($def)) { $outpar[9]=$def; $result=9; }
144:
145: # ------------------------------------------------------ third, check map parms
146:
147: my $thisparm=$parmhash{$symbparm};
148: if (defined($thisparm)) { $outpar[8]=$thisparm; $result=8; }
149:
1.71 albertel 150: if (defined($courseopt{$courselevelr})) {
1.43 albertel 151: $outpar[7]=$courseopt{$courselevelr};
152: $result=7;
153: }
1.11 www 154:
1.182 albertel 155: # ------------------------------------------------------ fourth, back to course
1.71 albertel 156: if (defined($csec)) {
157: if (defined($courseopt{$seclevel})) {
1.43 albertel 158: $outpar[6]=$courseopt{$seclevel};
159: $result=6;
160: }
1.71 albertel 161: if (defined($courseopt{$seclevelm})) {
1.43 albertel 162: $outpar[5]=$courseopt{$seclevelm};
163: $result=5;
164: }
165:
1.71 albertel 166: if (defined($courseopt{$seclevelr})) {
1.43 albertel 167: $outpar[4]=$courseopt{$seclevelr};
168: $result=4;
169: }
170: }
1.11 www 171:
1.182 albertel 172: # ---------------------------------------------------------- fifth, check user
1.11 www 173:
1.71 albertel 174: if (defined($uname)) {
175: if (defined($useropt{$courselevel})) {
1.43 albertel 176: $outpar[3]=$useropt{$courselevel};
177: $result=3;
178: }
1.10 www 179:
1.71 albertel 180: if (defined($useropt{$courselevelm})) {
1.43 albertel 181: $outpar[2]=$useropt{$courselevelm};
182: $result=2;
183: }
1.2 www 184:
1.71 albertel 185: if (defined($useropt{$courselevelr})) {
1.43 albertel 186: $outpar[1]=$useropt{$courselevelr};
187: $result=1;
188: }
189: }
1.44 albertel 190: return ($result,@outpar);
1.2 www 191: }
192:
1.186 www 193:
194: ##################################################
195: ##################################################
196: #
1.197 ! www 197: # Store a parameter by ID
1.186 www 198: #
199: # Takes
200: # - resource id
201: # - name of parameter
202: # - level
203: # - new value
204: # - new type
1.187 www 205: # - username
206: # - userdomain
207:
1.186 www 208: sub storeparm {
1.187 www 209: my ($sresid,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec)=@_;
1.197 ! www 210: my $navmap = Apache::lonnavmaps::navmap->new();
! 211: if ($sresid=~/\./) {
! 212: my $resource=$navmap->getById($sresid);
! 213: &storeparm_by_symb($resource->symb(),$spnam,$snum,$nval,$ntype,$uname,$udom,$csec);
! 214: } else {
! 215: my $resource=$navmap->getByMapPc($sresid);
! 216: &storeparm_by_symb(&Apache::lonnet::declutter($resource->src()),$spnam,$snum,$nval,$ntype,$uname,$udom,$csec);
! 217: }
! 218: }
! 219:
! 220: #
! 221: # Store a parameter by symb
! 222: #
! 223: # Takes
! 224: # - symb
! 225: # - name of parameter
! 226: # - level
! 227: # - new value
! 228: # - new type
! 229: # - username
! 230: # - userdomain
! 231:
! 232: sub storeparm_by_symb {
! 233: # ---------------------------------------------------------- Get symb, map, etc
! 234: my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec)=@_;
! 235: # ---------------------------------------------------------- Construct prefixes
1.186 www 236: $spnam=~s/\_([^\_]+)$/\.$1/;
1.197 ! www 237: my $map=(&Apache::lonnet::decode_symb($symb))[0];
! 238: my $symbparm=$symb.'.'.$spnam;
! 239: my $mapparm=$map.'___(all).'.$spnam;
! 240:
1.190 albertel 241: my $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$spnam;
242: my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm;
243: my $seclevelm=$env{'request.course.id'}.'.['.$csec.'].'.$mapparm;
1.186 www 244:
1.190 albertel 245: my $courselevel=$env{'request.course.id'}.'.'.$spnam;
246: my $courselevelr=$env{'request.course.id'}.'.'.$symbparm;
247: my $courselevelm=$env{'request.course.id'}.'.'.$mapparm;
1.186 www 248:
249: my $storeunder='';
250: if (($snum==11) || ($snum==3)) { $storeunder=$courselevel; }
251: if (($snum==10) || ($snum==2)) { $storeunder=$courselevelm; }
252: if (($snum==7) || ($snum==1)) { $storeunder=$courselevelr; }
253: if ($snum==6) { $storeunder=$seclevel; }
254: if ($snum==5) { $storeunder=$seclevelm; }
255: if ($snum==4) { $storeunder=$seclevelr; }
256:
257: my $delete;
258: if ($nval eq '') { $delete=1;}
259: my %storecontent = ($storeunder => $nval,
260: $storeunder.'.type' => $ntype);
261: my $reply='';
262: if ($snum>3) {
263: # ---------------------------------------------------------------- Store Course
264: #
265: # Expire sheets
266: &Apache::lonnet::expirespread('','','studentcalc');
267: if (($snum==7) || ($snum==4)) {
1.197 ! www 268: &Apache::lonnet::expirespread('','','assesscalc',$symb);
1.186 www 269: } elsif (($snum==8) || ($snum==5)) {
1.197 ! www 270: &Apache::lonnet::expirespread('','','assesscalc',$map);
1.186 www 271: } else {
272: &Apache::lonnet::expirespread('','','assesscalc');
273: }
274: # Store parameter
275: if ($delete) {
276: $reply=&Apache::lonnet::del
277: ('resourcedata',[keys(%storecontent)],
1.190 albertel 278: $env{'course.'.$env{'request.course.id'}.'.domain'},
279: $env{'course.'.$env{'request.course.id'}.'.num'});
1.186 www 280: } else {
281: $reply=&Apache::lonnet::cput
282: ('resourcedata',\%storecontent,
1.190 albertel 283: $env{'course.'.$env{'request.course.id'}.'.domain'},
284: $env{'course.'.$env{'request.course.id'}.'.num'});
1.186 www 285: }
286: } else {
287: # ------------------------------------------------------------------ Store User
288: #
289: # Expire sheets
290: &Apache::lonnet::expirespread($uname,$udom,'studentcalc');
291: if ($snum==1) {
292: &Apache::lonnet::expirespread
1.197 ! www 293: ($uname,$udom,'assesscalc',$symb);
1.186 www 294: } elsif ($snum==2) {
295: &Apache::lonnet::expirespread
1.197 ! www 296: ($uname,$udom,'assesscalc',$map);
1.186 www 297: } else {
298: &Apache::lonnet::expirespread($uname,$udom,'assesscalc');
299: }
300: # Store parameter
301: if ($delete) {
302: $reply=&Apache::lonnet::del
303: ('resourcedata',[keys(%storecontent)],$udom,$uname);
304: } else {
305: $reply=&Apache::lonnet::cput
306: ('resourcedata',\%storecontent,$udom,$uname);
307: }
1.191 albertel 308: &Apache::lonnet::devalidateuserresdata($uname,$udom);
1.186 www 309: }
310:
311: if ($reply=~/^error\:(.*)/) {
312: return "<font color=red>Write Error: $1</font>";
313: }
314: return '';
315: }
316:
1.59 matthew 317: ##################################################
318: ##################################################
319:
320: =pod
321:
322: =item valout
323:
324: Format a value for output.
325:
326: Inputs: $value, $type
327:
328: Returns: $value, formatted for output. If $type indicates it is a date,
329: localtime($value) is returned.
1.9 www 330:
1.59 matthew 331: =cut
332:
333: ##################################################
334: ##################################################
1.9 www 335: sub valout {
336: my ($value,$type)=@_;
1.59 matthew 337: my $result = '';
338: # Values of zero are valid.
339: if (! $value && $value ne '0') {
1.71 albertel 340: $result = ' ';
1.59 matthew 341: } else {
1.66 www 342: if ($type eq 'date_interval') {
343: my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($value);
344: $year=$year-70;
345: $mday--;
346: if ($year) {
347: $result.=$year.' yrs ';
348: }
349: if ($mon) {
350: $result.=$mon.' mths ';
351: }
352: if ($mday) {
353: $result.=$mday.' days ';
354: }
355: if ($hour) {
356: $result.=$hour.' hrs ';
357: }
358: if ($min) {
359: $result.=$min.' mins ';
360: }
361: if ($sec) {
362: $result.=$sec.' secs ';
363: }
364: $result=~s/\s+$//;
365: } elsif ($type=~/^date/) {
1.59 matthew 366: $result = localtime($value);
367: } else {
368: $result = $value;
369: }
370: }
371: return $result;
1.9 www 372: }
373:
1.59 matthew 374: ##################################################
375: ##################################################
376:
377: =pod
1.5 www 378:
1.59 matthew 379: =item plink
380:
381: Produces a link anchor.
382:
383: Inputs: $type,$dis,$value,$marker,$return,$call
384:
385: Returns: scalar with html code for a link which will envoke the
386: javascript function 'pjump'.
387:
388: =cut
389:
390: ##################################################
391: ##################################################
1.5 www 392: sub plink {
393: my ($type,$dis,$value,$marker,$return,$call)=@_;
1.23 www 394: my $winvalue=$value;
395: unless ($winvalue) {
396: if ($type=~/^date/) {
1.190 albertel 397: $winvalue=$env{'form.recent_'.$type};
1.23 www 398: } else {
1.190 albertel 399: $winvalue=$env{'form.recent_'.(split(/\_/,$type))[0]};
1.23 www 400: }
401: }
402: return
1.43 albertel 403: '<a href="javascript:pjump('."'".$type."','".$dis."','".$winvalue."','"
404: .$marker."','".$return."','".$call."'".');">'.
405: &valout($value,$type).'</a><a name="'.$marker.'"></a>';
1.5 www 406: }
407:
1.44 albertel 408:
409: sub startpage {
1.137 albertel 410: my ($r,$id,$udom,$csec,$uname,$have_assesments,$trimheader)=@_;
1.99 albertel 411:
1.120 www 412: my $bodytag=&Apache::loncommon::bodytag('Set/Modify Course Parameters','',
1.98 www 413: 'onUnload="pclose()"');
1.194 albertel 414: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Table');
1.81 www 415: my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '.
416: &Apache::loncommon::selectstudent_link('parmform','uname','udom');
417: my $selscript=&Apache::loncommon::studentbrowser_javascript();
1.88 matthew 418: my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
1.133 www 419: my %lt=&Apache::lonlocal::texthash(
420: 'cep' => "Course Environment Parameters",
421: 'scep' => "Set Course Environment Parameters",
422: 'smcap' => "Set/Modify Course Assessment Parameter",
423: 'mcap' => "Modify Course Assessment Parameters",
424: 'caphm' => "Course Assessment Parameter - Helper Mode",
425: 'capom' => "Course Assessment Parameters - Overview Mode",
426: 'captm' => "Course Assessments Parameters - Table Mode",
427: 'sg' => "Section/Group",
428: 'fu' => "For User",
429: 'oi' => "or ID",
430: 'ad' => "at Domain"
431: );
1.148 www 432: my $overallhelp=
1.166 albertel 433: &Apache::loncommon::help_open_menu('','Setting Parameters','Course_Setting_Parameters','',10,'Instructor Interface');
1.146 www 434: my $assessparmhelp=&Apache::loncommon::help_open_topic("Cascading_Parameters","Assessment Parameters");
1.183 albertel 435: my $html=&Apache::lonxml::xmlbegin();
1.44 albertel 436: $r->print(<<ENDHEAD);
1.183 albertel 437: $html
1.44 albertel 438: <head>
439: <title>LON-CAPA Course Parameters</title>
440: <script>
441:
442: function pclose() {
443: parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
444: "height=350,width=350,scrollbars=no,menubar=no");
445: parmwin.close();
446: }
447:
1.88 matthew 448: $pjump_def
1.44 albertel 449:
450: function psub() {
451: pclose();
452: if (document.parmform.pres_marker.value!='') {
453: document.parmform.action+='#'+document.parmform.pres_marker.value;
454: var typedef=new Array();
455: typedef=document.parmform.pres_type.value.split('_');
456: if (document.parmform.pres_type.value!='') {
457: if (typedef[0]=='date') {
458: eval('document.parmform.recent_'+
459: document.parmform.pres_type.value+
460: '.value=document.parmform.pres_value.value;');
461: } else {
462: eval('document.parmform.recent_'+typedef[0]+
463: '.value=document.parmform.pres_value.value;');
464: }
465: }
466: document.parmform.submit();
467: } else {
468: document.parmform.pres_value.value='';
469: document.parmform.pres_marker.value='';
470: }
471: }
472:
1.57 albertel 473: function openWindow(url, wdwName, w, h, toolbar,scrollbar) {
474: var options = "width=" + w + ",height=" + h + ",";
475: options += "resizable=yes,scrollbars="+scrollbar+",status=no,";
476: options += "menubar=no,toolbar="+toolbar+",location=no,directories=no";
477: var newWin = window.open(url, wdwName, options);
478: newWin.focus();
479: }
1.44 albertel 480: </script>
1.81 www 481: $selscript
1.44 albertel 482: </head>
1.64 www 483: $bodytag
1.193 albertel 484: $breadcrumbs
1.166 albertel 485: $overallhelp
1.137 albertel 486: ENDHEAD
1.91 bowersj2 487:
1.137 albertel 488: unless ($trimheader) {$r->print(<<ENDHEAD2);
1.44 albertel 489: <form method="post" action="/adm/parmset" name="envform">
1.133 www 490: <h4>$lt{'cep'}</h4>
491: <input type="submit" name="crsenv" value="$lt{'scep'}" />
1.120 www 492: </form>
493: <hr />
1.146 www 494: $assessparmhelp
1.120 www 495: <form method="post" action="/adm/helper/parameter.helper" name="helpform">
1.133 www 496: <h4>$lt{'caphm'}</h4>
497: <input type="submit" value="$lt{'smcap'}" />
1.120 www 498: </form>
499: <hr />
500: <form method="post" action="/adm/parmset" name="overview">
1.133 www 501: <h4>$lt{'capom'}</h4>
502: <input type="submit" name="overview" value="$lt{'mcap'}" />
1.44 albertel 503: </form>
1.101 www 504: <hr />
1.137 albertel 505: ENDHEAD2
1.189 www 506: }
507: my %sectionhash=();
508: my $sections='';
509: if (&Apache::loncommon::get_sections(
1.190 albertel 510: $env{'course.'.$env{'request.course.id'}.'.domain'},
511: $env{'course.'.$env{'request.course.id'}.'.num'},
1.189 www 512: \%sectionhash)) {
513: $sections=$lt{'sg'}.': <select name="csec">';
514: foreach ('',sort keys %sectionhash) {
515: $sections.='<option value="'.$_.'"'.
516: ($_ eq $csec?'selected="selected"':'').'>'.$_.'</option>';
517: }
518: $sections.='</select>';
519: }
520: $r->print(<<ENDHEAD3);
1.193 albertel 521: <form method="post" action="/adm/parmset?action=settable" name="parmform">
1.133 www 522: <h4>$lt{'captm'}</h4>
1.137 albertel 523: ENDHEAD3
1.99 albertel 524:
525: if (!$have_assesments) {
1.133 www 526: $r->print('<font color="red">'.&mt('There are no assesment parameters in this course to set.').'</font><br />');
1.99 albertel 527: } else {
528: $r->print(<<ENDHEAD);
1.44 albertel 529: <b>
1.189 www 530: $sections
1.188 www 531: <br />
1.133 www 532: $lt{'fu'}
1.188 www 533: <input type="text" value="$uname" size="12" name="uname" />
1.133 www 534: $lt{'oi'}
1.188 www 535: <input type="text" value="$id" size="12" name="id" />
1.133 www 536: $lt{'ad'}
1.81 www 537: $chooseopt
1.44 albertel 538: </b>
539: <input type="hidden" value='' name="pres_value">
540: <input type="hidden" value='' name="pres_type">
541: <input type="hidden" value='' name="pres_marker">
542: ENDHEAD
1.99 albertel 543: }
1.44 albertel 544: }
545:
546: sub print_row {
1.66 www 547: my ($r,$which,$part,$name,$rid,$default,$defaulttype,$display,$defbgone,
1.187 www 548: $defbgtwo,$parmlev,$uname,$udom,$csec)=@_;
1.66 www 549: # get the values for the parameter in cascading order
550: # empty levels will remain empty
1.44 albertel 551: my ($result,@outpar)=&parmval($$part{$which}.'.'.$$name{$which},
1.187 www 552: $rid,$$default{$which},$uname,$udom,$csec);
1.66 www 553: # get the type for the parameters
554: # problem: these may not be set for all levels
555: my ($typeresult,@typeoutpar)=&parmval($$part{$which}.'.'.
556: $$name{$which}.'.type',
1.187 www 557: $rid,$$defaulttype{$which},$uname,$udom,$csec);
1.66 www 558: # cascade down manually
1.182 albertel 559: my $cascadetype=$$defaulttype{$which};
560: for (my $i=11;$i>0;$i--) {
1.66 www 561: if ($typeoutpar[$i]) {
562: $cascadetype=$typeoutpar[$i];
563: } else {
564: $typeoutpar[$i]=$cascadetype;
565: }
566: }
1.57 albertel 567: my $parm=$$display{$which};
568:
569: if ($parmlev eq 'full' || $parmlev eq 'brief') {
570: $r->print('<td bgcolor='.$defbgtwo.' align="center">'
571: .$$part{$which}.'</td>');
572: } else {
573: $parm=~s|\[.*\]\s||g;
574: }
575:
1.159 albertel 576: $r->print('<td bgcolor='.$defbgone.'>'.$parm.'</td>');
1.57 albertel 577:
1.44 albertel 578: my $thismarker=$which;
579: $thismarker=~s/^parameter\_//;
580: my $mprefix=$rid.'&'.$thismarker.'&';
581:
1.57 albertel 582: if ($parmlev eq 'general') {
583:
584: if ($uname) {
1.66 www 585: &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 586: } elsif ($csec) {
1.66 www 587: &print_td($r,6,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 588: } else {
1.182 albertel 589: &print_td($r,11,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 590: }
591: } elsif ($parmlev eq 'map') {
592:
593: if ($uname) {
1.66 www 594: &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 595: } elsif ($csec) {
1.66 www 596: &print_td($r,5,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 597: } else {
1.182 albertel 598: &print_td($r,10,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 599: }
600: } else {
601:
1.182 albertel 602: &print_td($r,11,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 603:
604: if ($parmlev eq 'brief') {
605:
1.66 www 606: &print_td($r,7,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 607:
608: if ($csec) {
1.66 www 609: &print_td($r,4,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 610: }
611: if ($uname) {
1.66 www 612: &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 613: }
614: } else {
615:
1.182 albertel 616: &print_td($r,10,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
617: &print_td($r,9,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
618: &print_td($r,8,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.66 www 619: &print_td($r,7,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 620:
621: if ($csec) {
1.66 www 622: &print_td($r,6,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
623: &print_td($r,5,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
624: &print_td($r,4,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 625: }
626: if ($uname) {
1.66 www 627: &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
628: &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
629: &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 630: }
631: } # end of $brief if/else
632: } # end of $parmlev if/else
633:
1.136 albertel 634: $r->print('<td bgcolor=#CCCCFF align="center">'.
635: &valout($outpar[$result],$typeoutpar[$result]).'</td>');
636:
1.57 albertel 637: if ($parmlev eq 'full' || $parmlev eq 'brief') {
1.136 albertel 638: my $sessionval=&Apache::lonnet::EXT('resource.'.$$part{$which}.
1.57 albertel 639: '.'.$$name{$which},$symbp{$rid});
1.136 albertel 640:
1.70 albertel 641: # this doesn't seem to work, and I don't think is correct
642: # my $sessionvaltype=&Apache::lonnet::EXT('resource.'.$$part{$which}.
643: # '.'.$$name{$which}.'.type',$symbp{$rid});
644: # this seems to work
1.136 albertel 645: my $sessionvaltype=$typeoutpar[$result];
646: if (!defined($sessionvaltype)) { $sessionvaltype=$$defaulttype{$which}; }
647: $r->print('<td bgcolor=#999999 align="center"><font color=#FFFFFF>'.
1.66 www 648: &valout($sessionval,$sessionvaltype).' '.
1.57 albertel 649: '</font></td>');
1.136 albertel 650: }
1.44 albertel 651: $r->print('</tr>');
1.57 albertel 652: $r->print("\n");
1.44 albertel 653: }
1.59 matthew 654:
1.44 albertel 655: sub print_td {
1.66 www 656: my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display)=@_;
1.57 albertel 657: $r->print('<td bgcolor='.(($result==$which)?'"#AAFFAA"':$defbg).
1.114 www 658: ' align="center">');
1.182 albertel 659: if ($which<8 || $which > 9) {
1.114 www 660: $r->print(&plink($$typeoutpar[$which],
661: $$display{$value},$$outpar[$which],
662: $mprefix."$which",'parmform.pres','psub'));
663: } else {
664: $r->print(&valout($$outpar[$which],$$typeoutpar[$which]));
665: }
666: $r->print('</td>'."\n");
1.57 albertel 667: }
668:
1.63 bowersj2 669: =pod
670:
671: =item B<extractResourceInformation>: Given the course data hash, extractResourceInformation extracts lots of information about the course's resources into a variety of hashes.
672:
673: Input: See list below:
674:
675: =over 4
676:
677: =item B<ids>: An array that will contain all of the ids in the course.
678:
679: =item B<typep>: hash, id->type, where "type" contains the extension of the file, thus, I<problem exam quiz assess survey form>.
680:
1.171 www 681: =item B<keyp>: hash, id->key list, will contain a comma separated list of the meta-data keys available for the given id
1.63 bowersj2 682:
683: =item B<allparms>: hash, name of parameter->display value (what is the display value?)
684:
685: =item B<allparts>: hash, part identification->text representation of part, where the text representation is "[Part $part]"
686:
687: =item B<allkeys>: hash, full key to part->display value (what's display value?)
688:
689: =item B<allmaps>: hash, ???
690:
691: =item B<fcat>: ???
692:
693: =item B<defp>: hash, ???
694:
695: =item B<mapp>: ??
696:
697: =item B<symbp>: hash, id->full sym?
698:
699: =back
700:
701: =cut
702:
703: sub extractResourceInformation {
704: my $ids = shift;
705: my $typep = shift;
706: my $keyp = shift;
707: my $allparms = shift;
708: my $allparts = shift;
709: my $allkeys = shift;
710: my $allmaps = shift;
711: my $fcat = shift;
712: my $defp = shift;
713: my $mapp = shift;
714: my $symbp = shift;
1.82 www 715: my $maptitles=shift;
1.196 www 716: my $uris=shift;
717:
1.63 bowersj2 718:
1.196 www 719: my $navmap = Apache::lonnavmaps::navmap->new();
720: my @allres=$navmap->retrieveResources(undef,undef,1,undef,1);
721: foreach my $resource (@allres) {
722: my $id=$resource->id();
723: my ($mapid,$resid)=split(/\./,$id);
724: if ($mapid eq '0') { next; }
725: $$ids[$#$ids+1]=$id;
726: my $srcf=$resource->src();
727: $srcf=~/\.(\w+)$/;
728: $$typep{$id}=$1;
729: $$keyp{$id}='';
730: $$uris{$id}=$srcf;
731: foreach (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) {
732: if ($_=~/^parameter\_(.*)/) {
733: my $key=$_;
734: my $allkey=$1;
735: $allkey=~s/\_/\./g;
736: if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq
737: 'parm') {
738: next; #hide hidden things
1.63 bowersj2 739: }
1.196 www 740: my $display= &Apache::lonnet::metadata($srcf,$key.'.display');
741: my $name=&Apache::lonnet::metadata($srcf,$key.'.name');
742: my $part= &Apache::lonnet::metadata($srcf,$key.'.part');
743: my $parmdis = $display;
744: $parmdis =~ s|(\[Part.*)$||g;
745: my $partkey = $part;
746: $partkey =~ tr|_|.|;
747: $$allparms{$name} = $parmdis;
748: $$allparts{$part} = "[Part $part]";
749: $$allkeys{$allkey}=$display;
750: if ($allkey eq $fcat) {
751: $$defp{$id}= &Apache::lonnet::metadata($srcf,$key);
752: }
753: if ($$keyp{$id}) {
754: $$keyp{$id}.=','.$key;
1.175 albertel 755: } else {
1.196 www 756: $$keyp{$id}=$key;
1.175 albertel 757: }
1.63 bowersj2 758: }
759: }
1.196 www 760: $$mapp{$id}=
761: &Apache::lonnet::declutter($resource->enclosing_map_src());
762: $$mapp{$mapid}=$$mapp{$id};
763: $$allmaps{$mapid}=$$mapp{$id};
764: if ($mapid eq '1') {
765: $$maptitles{$mapid}='Main Course Documents';
766: } else {
767: $$maptitles{$mapid}=&Apache::lonnet::gettitle(&Apache::lonnet::clutter($$mapp{$id}));
768: }
769: $$maptitles{$$mapp{$id}}=$$maptitles{$mapid};
770: $$symbp{$id}=&Apache::lonnet::encode_symb($$mapp{$id},$resid,$srcf);
771: $$symbp{$mapid}=$$mapp{$id}.'___(all)';
1.63 bowersj2 772: }
773: }
774:
1.59 matthew 775: ##################################################
776: ##################################################
777:
778: =pod
779:
780: =item assessparms
781:
782: Show assessment data and parameters. This is a large routine that should
783: be simplified and shortened... someday.
784:
785: Inputs: $r
786:
787: Returns: nothing
788:
1.63 bowersj2 789: Variables used (guessed by Jeremy):
790:
791: =over 4
792:
793: =item B<pscat>: ParameterS CATegories? ends up a list of the types of parameters that exist, e.g., tol, weight, acc, opendate, duedate, answerdate, sig, maxtries, type.
794:
795: =item B<psprt>: ParameterS PaRTs? a list of the parts of a problem that we are displaying? Used to display only selected parts?
796:
797: =item B<allmaps>:
798:
799: =back
800:
1.59 matthew 801: =cut
802:
803: ##################################################
804: ##################################################
1.30 www 805: sub assessparms {
1.1 www 806:
1.43 albertel 807: my $r=shift;
1.2 www 808: # -------------------------------------------------------- Variable declaration
1.129 www 809: my %allkeys=();
810: my %allmaps=();
811: my %alllevs=();
1.57 albertel 812:
1.187 www 813: my $uname;
814: my $udom;
815: my $uhome;
816: my $csec;
817:
1.190 albertel 818: my $coursename=$env{'course.'.$env{'request.course.id'}.'.description'};
1.187 www 819:
1.57 albertel 820: $alllevs{'Resource Level'}='full';
821: $alllevs{'Map Level'}='map';
822: $alllevs{'Course Level'}='general';
823:
824: my %allparms;
825: my %allparts;
826:
1.43 albertel 827: my %defp;
828: %courseopt=();
829: %useropt=();
830:
831: @ids=();
832: %symbp=();
833: %typep=();
834:
835: my $message='';
836:
1.190 albertel 837: $csec=$env{'form.csec'};
1.188 www 838:
1.190 albertel 839: if ($udom=$env{'form.udom'}) {
840: } elsif ($udom=$env{'request.role.domain'}) {
841: } elsif ($udom=$env{'user.domain'}) {
1.172 albertel 842: } else {
843: $udom=$r->dir_config('lonDefDomain');
844: }
1.43 albertel 845:
1.134 albertel 846: my @pscat=&Apache::loncommon::get_env_multiple('form.pscat');
1.190 albertel 847: my $pschp=$env{'form.pschp'};
1.134 albertel 848: my @psprt=&Apache::loncommon::get_env_multiple('form.psprt');
1.76 www 849: if (!@psprt) { $psprt[0]='0'; }
1.190 albertel 850: my $showoptions=$env{'form.showoptions'};
1.57 albertel 851:
1.43 albertel 852: my $pssymb='';
1.57 albertel 853: my $parmlev='';
1.137 albertel 854: my $trimheader='';
1.190 albertel 855: my $prevvisit=$env{'form.prevvisit'};
1.57 albertel 856:
1.190 albertel 857: unless ($env{'form.parmlev'}) {
1.57 albertel 858: $parmlev = 'map';
859: } else {
1.190 albertel 860: $parmlev = $env{'form.parmlev'};
1.57 albertel 861: }
1.26 www 862:
1.29 www 863: # ----------------------------------------------- Was this started from grades?
864:
1.190 albertel 865: if (($env{'form.command'} eq 'set') && ($env{'form.url'})
866: && (!$env{'form.dis'})) {
867: my $url=$env{'form.url'};
1.194 albertel 868: $url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
1.43 albertel 869: $pssymb=&Apache::lonnet::symbread($url);
1.92 albertel 870: if (!@pscat) { @pscat=('all'); }
1.43 albertel 871: $pschp='';
1.57 albertel 872: $parmlev = 'full';
1.137 albertel 873: $trimheader='yes';
1.190 albertel 874: } elsif ($env{'form.symb'}) {
875: $pssymb=$env{'form.symb'};
1.92 albertel 876: if (!@pscat) { @pscat=('all'); }
1.43 albertel 877: $pschp='';
1.57 albertel 878: $parmlev = 'full';
1.137 albertel 879: $trimheader='yes';
1.43 albertel 880: } else {
1.190 albertel 881: $env{'form.url'}='';
1.43 albertel 882: }
883:
1.190 albertel 884: my $id=$env{'form.id'};
1.43 albertel 885: if (($id) && ($udom)) {
886: $uname=(&Apache::lonnet::idget($udom,$id))[1];
887: if ($uname) {
888: $id='';
889: } else {
890: $message=
1.133 www 891: "<font color=red>".&mt("Unknown ID")." '$id' ".
892: &mt('at domain')." '$udom'</font>";
1.43 albertel 893: }
894: } else {
1.190 albertel 895: $uname=$env{'form.uname'};
1.43 albertel 896: }
897: unless ($udom) { $uname=''; }
898: $uhome='';
899: if ($uname) {
900: $uhome=&Apache::lonnet::homeserver($uname,$udom);
901: if ($uhome eq 'no_host') {
902: $message=
1.133 www 903: "<font color=red>".&mt("Unknown user")." '$uname' ".
904: &mt("at domain")." '$udom'</font>";
1.43 albertel 905: $uname='';
1.12 www 906: } else {
1.103 albertel 907: $csec=&Apache::lonnet::getsection($udom,$uname,
1.190 albertel 908: $env{'request.course.id'});
1.43 albertel 909: if ($csec eq '-1') {
910: $message="<font color=red>".
1.133 www 911: &mt("User")." '$uname' ".&mt("at domain")." '$udom' ".
912: &mt("not in this course")."</font>";
1.43 albertel 913: $uname='';
1.190 albertel 914: $csec=$env{'form.csec'};
1.43 albertel 915: } else {
916: my %name=&Apache::lonnet::userenvironment($udom,$uname,
917: ('firstname','middlename','lastname','generation','id'));
1.133 www 918: $message="\n<p>\n".&mt("Full Name").": ".
1.43 albertel 919: $name{'firstname'}.' '.$name{'middlename'}.' '
920: .$name{'lastname'}.' '.$name{'generation'}.
1.133 www 921: "<br>\n".&mt('ID').": ".$name{'id'}.'<p>';
1.43 albertel 922: }
1.12 www 923: }
1.43 albertel 924: }
1.2 www 925:
1.43 albertel 926: unless ($csec) { $csec=''; }
1.12 www 927:
1.190 albertel 928: my $fcat=$env{'form.fcat'};
1.43 albertel 929: unless ($fcat) { $fcat=''; }
1.2 www 930:
931: # ------------------------------------------------------------------- Tie hashs
1.196 www 932:
1.44 albertel 933: if (!(tie(%parmhash,'GDBM_File',
1.190 albertel 934: $env{'request.course.fn'}.'_parms.db',&GDBM_READER(),0640))) {
935: $r->print("Unable to access parameter data. (File $env{'request.course.fn'}_parms.db not tieable)");
1.44 albertel 936: return ;
937: }
1.63 bowersj2 938:
1.14 www 939: # --------------------------------------------------------- Get all assessments
1.196 www 940: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allkeys, \%allmaps, $fcat, \%defp, \%mapp, \%symbp,\%maptitles,\%uris);
1.63 bowersj2 941:
1.57 albertel 942: $mapp{'0.0'} = '';
943: $symbp{'0.0'} = '';
1.99 albertel 944:
1.14 www 945: # ---------------------------------------------------------- Anything to store?
1.190 albertel 946: if ($env{'form.pres_marker'}) {
947: $message.=&storeparm(split(/\&/,$env{'form.pres_marker'}),
948: $env{'form.pres_value'},
949: $env{'form.pres_type'},
1.187 www 950: $uname,$udom,$csec);
1.68 www 951: # ---------------------------------------------------------------- Done storing
1.130 www 952: $message.='<h3>'.&mt('Changes can take up to 10 minutes before being active for all students.').&Apache::loncommon::help_open_topic('Caching').'</h3>';
1.68 www 953: }
1.67 www 954: # --------------------------------------------- Devalidate cache for this child
1.109 albertel 955: &Apache::lonnet::devalidatecourseresdata(
1.190 albertel 956: $env{'course.'.$env{'request.course.id'}.'.num'},
957: $env{'course.'.$env{'request.course.id'}.'.domain'});
1.191 albertel 958: #&Apache::lonnet::clear_EXT_cache_status();
1.2 www 959: # -------------------------------------------------------------- Get coursedata
1.45 matthew 960: %courseopt = &Apache::lonnet::dump
961: ('resourcedata',
1.190 albertel 962: $env{'course.'.$env{'request.course.id'}.'.domain'},
963: $env{'course.'.$env{'request.course.id'}.'.num'});
1.44 albertel 964: # --------------------------------------------------- Get userdata (if present)
965: if ($uname) {
1.45 matthew 966: %useropt=&Apache::lonnet::dump('resourcedata',$udom,$uname);
1.44 albertel 967: }
1.14 www 968:
1.2 www 969: # ------------------------------------------------------------------- Sort this
1.17 www 970:
1.44 albertel 971: @ids=sort {
972: if ($fcat eq '') {
973: $a<=>$b;
974: } else {
1.187 www 975: my ($result,@outpar)=&parmval($fcat,$a,$defp{$a},$uname,$udom,$csec);
1.44 albertel 976: my $aparm=$outpar[$result];
1.187 www 977: ($result,@outpar)=&parmval($fcat,$b,$defp{$b},$uname,$udom,$csec);
1.44 albertel 978: my $bparm=$outpar[$result];
979: 1*$aparm<=>1*$bparm;
980: }
981: } @ids;
1.57 albertel 982: #----------------------------------------------- if all selected, fill in array
983: if ($pscat[0] eq "all" || !@pscat) {@pscat = (keys %allparms);}
984: if ($psprt[0] eq "all" || !@psprt) {@psprt = (keys %allparts);}
1.2 www 985: # ------------------------------------------------------------------ Start page
1.63 bowersj2 986:
1.99 albertel 987: my $have_assesments=1;
988: if (scalar(keys(%allkeys)) eq 0) { $have_assesments=0; }
989:
1.193 albertel 990: $trimheader = 'yes';
1.137 albertel 991: &startpage($r,$id,$udom,$csec,$uname,$have_assesments,$trimheader);
1.99 albertel 992:
1.112 albertel 993: if (!$have_assesments) {
994: untie(%parmhash);
995: return '';
996: }
1.190 albertel 997: # if ($env{'form.url'}) {
998: # $r->print('<input type="hidden" value="'.$env{'form.url'}.
1.44 albertel 999: # '" name="url"><input type="hidden" name="command" value="set">');
1000: # }
1.57 albertel 1001: $r->print('<input type="hidden" value="true" name="prevvisit">');
1002:
1.44 albertel 1003: foreach ('tolerance','date_default','date_start','date_end',
1004: 'date_interval','int','float','string') {
1005: $r->print('<input type="hidden" value="'.
1.190 albertel 1006: $env{'form.recent_'.$_}.'" name="recent_'.$_.'">');
1.44 albertel 1007: }
1008:
1.57 albertel 1009: $r->print('<h2>'.$message.'</h2><table>');
1010:
1.130 www 1011: my $submitmessage = &mt('Update Section or Specific User');
1.44 albertel 1012: if (!$pssymb) {
1.160 www 1013: $r->print('<tr><td>'.&mt('Select Parameter Level').
1014: &Apache::loncommon::help_open_topic('Course_Parameter_Levels').
1015: '</td><td colspan="2">');
1.57 albertel 1016: $r->print('<select name="parmlev">');
1017: foreach (reverse sort keys %alllevs) {
1018: $r->print('<option value="'.$alllevs{$_}.'"');
1019: if ($parmlev eq $alllevs{$_}) {
1020: $r->print(' selected');
1021: }
1022: $r->print('>'.$_.'</option>');
1023: }
1024: $r->print("</select></td>\n");
1025:
1.101 www 1026: $r->print('</tr>');
1.128 albertel 1027: if ($parmlev ne 'general') {
1.130 www 1028: $r->print('<tr><td>'.&mt('Select Enclosing Map or Folder').'</td>');
1.128 albertel 1029: $r->print('<td colspan="2"><select name="pschp">');
1.130 www 1030: $r->print('<option value="all">'.&mt('All Maps or Folders').'</option>');
1.128 albertel 1031: foreach (sort {$allmaps{$a} cmp $allmaps{$b}} keys %allmaps) {
1032: $r->print('<option value="'.$_.'"');
1033: if (($pschp eq $_)) { $r->print(' selected'); }
1034: $r->print('>'.$maptitles{$_}.($allmaps{$_}!~/^uploaded/?' ['.$allmaps{$_}.']':'').'</option>');
1035: }
1036: $r->print("</select></td></tr>\n");
1037: }
1.44 albertel 1038: } else {
1.125 www 1039: my ($map,$id,$resource)=&Apache::lonnet::decode_symb($pssymb);
1.130 www 1040: $r->print("<tr><td>".&mt('Specific Resource')."</td><td>$resource</td>");
1.57 albertel 1041: $r->print('<td><input type="submit" name="dis" value="'.$submitmessage.'"></td>');
1042: $r->print('</tr>');
1043: $r->print('<input type="hidden" value="'.$pssymb.'" name="symb">');
1044: }
1045:
1.185 albertel 1046: $r->print('<tr><td colspan="3"><hr /><label><input type="checkbox"');
1.57 albertel 1047: if ($showoptions eq 'show') {$r->print(" checked ");}
1.185 albertel 1048: $r->print(' name="showoptions" value="show" />'.&mt('Show More Options').'</label><hr /></td></tr>');
1.57 albertel 1049: # $r->print("<tr><td>Show: $showoptions</td></tr>");
1050: # $r->print("<tr><td>pscat: @pscat</td></tr>");
1051: # $r->print("<tr><td>psprt: @psprt</td></tr>");
1052: # $r->print("<tr><td>fcat: $fcat</td></tr>");
1053:
1054: if ($showoptions eq 'show') {
1055: my $tempkey;
1056:
1.130 www 1057: $r->print('<tr><td colspan="3" align="center">'.&mt('Select Parameters to View').'</td></tr>');
1.57 albertel 1058:
1.176 albertel 1059: $r->print('<tr><td colspan="2"><table><tr>');
1.57 albertel 1060: my $cnt=0;
1061: foreach $tempkey (sort { $allparms{$a} cmp $allparms{$b} }
1062: keys %allparms ) {
1063: ++$cnt;
1.176 albertel 1064: $r->print('</tr><tr>') if ($cnt%2);
1.57 albertel 1065: $r->print('<td><input type="checkbox" name="pscat" ');
1066: $r->print('value="'.$tempkey.'"');
1067: if ($pscat[0] eq "all" || grep $_ eq $tempkey, @pscat) {
1068: $r->print(' checked');
1069: }
1.176 albertel 1070: $r->print('>'.$allparms{$tempkey}.'</td>');
1071: }
1072: $r->print('
1073: </tr><tr><td>
1074: <script type="text/javascript">
1075: function checkall(value, checkName) {
1076: for (i=0; i<document.forms.parmform.elements.length; i++) {
1077: ele = document.forms.parmform.elements[i];
1078: if (ele.name == checkName) {
1079: document.forms.parmform.elements[i].checked=value;
1080: }
1.57 albertel 1081: }
1.176 albertel 1082: }
1083: </script>
1084: <input type="button" onclick="checkall(true, \'pscat\')" value="Select All" />
1085: </td><td>
1086: <input type="button" onclick="checkall(false, \'pscat\')" value="Unselect All" />
1087: </td>
1088: ');
1.57 albertel 1089: $r->print('</tr></table>');
1090:
1091: # $r->print('<tr><td>Select Parts</td><td>');
1092: $r->print('<td><select multiple name="psprt" size="5">');
1093: $r->print('<option value="all"');
1094: $r->print(' selected') unless (@psprt);
1.130 www 1095: $r->print('>'.&mt('All Parts').'</option>');
1.76 www 1096: my %temphash=();
1097: foreach (@psprt) { $temphash{$_}=1; }
1.57 albertel 1098: foreach $tempkey (sort keys %allparts) {
1099: unless ($tempkey =~ /\./) {
1100: $r->print('<option value="'.$tempkey.'"');
1.76 www 1101: if ($psprt[0] eq "all" || $temphash{$tempkey}) {
1.57 albertel 1102: $r->print(' selected');
1103: }
1104: $r->print('>'.$allparts{$tempkey}.'</option>');
1105: }
1106: }
1107: $r->print('</select></td></tr><tr><td colspan="3"><hr /></td></tr>');
1108:
1.130 www 1109: $r->print('<tr><td>'.&mt('Sort list by').'</td><td>');
1.57 albertel 1110: $r->print('<select name="fcat">');
1.130 www 1111: $r->print('<option value="">'.&mt('Enclosing Map or Folder').'</option>');
1.57 albertel 1112: foreach (sort keys %allkeys) {
1113: $r->print('<option value="'.$_.'"');
1114: if ($fcat eq $_) { $r->print(' selected'); }
1115: $r->print('>'.$allkeys{$_}.'</option>');
1116: }
1117: $r->print('</select></td>');
1118:
1119: $r->print('</tr><tr><td colspan="3"><hr /></td></tr>');
1120:
1121: } else { # hide options - include any necessary extras here
1122:
1123: $r->print('<input type="hidden" name="fcat" value="'.$fcat.'">'."\n");
1124:
1125: unless (@pscat) {
1126: foreach (keys %allparms ) {
1127: $r->print('<input type="hidden" name="pscat" value="'.$_.'">'."\n");
1128: }
1129: } else {
1130: foreach (@pscat) {
1131: $r->print('<input type="hidden" name="pscat" value="'.$_.'">'."\n");
1132: }
1133: }
1134:
1135: unless (@psprt) {
1136: foreach (keys %allparts ) {
1137: $r->print('<input type="hidden" name="psprt" value="'.$_.'">'."\n");
1138: }
1139: } else {
1140: foreach (@psprt) {
1141: $r->print('<input type="hidden" name="psprt" value="'.$_.'">'."\n");
1142: }
1143: }
1144:
1.44 albertel 1145: }
1.101 www 1146: $r->print('</table><br />');
1147: if (($prevvisit) || ($pschp) || ($pssymb)) {
1.130 www 1148: $submitmessage = &mt("Update Course Assessment Parameter Display");
1.101 www 1149: } else {
1.130 www 1150: $submitmessage = &mt("Set/Modify Course Assessment Parameters");
1.101 www 1151: }
1152: $r->print('<input type="submit" name="dis" value="'.$submitmessage.'">');
1.57 albertel 1153:
1.76 www 1154: # my @temp_psprt;
1155: # foreach my $t (@psprt) {
1156: # push(@temp_psprt, grep {eval (/^$t\./ || ($_ == $t))} (keys %allparts));
1157: # }
1.57 albertel 1158:
1.76 www 1159: # @psprt = @temp_psprt;
1.57 albertel 1160:
1161: my @temp_pscat;
1162: map {
1163: my $cat = $_;
1164: push(@temp_pscat, map { $_.'.'.$cat } @psprt);
1165: } @pscat;
1166:
1167: @pscat = @temp_pscat;
1168:
1169: if (($prevvisit) || ($pschp) || ($pssymb)) {
1.10 www 1170: # ----------------------------------------------------------------- Start Table
1.57 albertel 1171: my @catmarker=map { tr|.|_|; 'parameter_'.$_; } @pscat;
1.190 albertel 1172: my $csuname=$env{'user.name'};
1173: my $csudom=$env{'user.domain'};
1.57 albertel 1174:
1175: if ($parmlev eq 'full' || $parmlev eq 'brief') {
1176: my $coursespan=$csec?8:5;
1177: $r->print('<p><table border=2>');
1178: $r->print('<tr><td colspan=5></td>');
1.130 www 1179: $r->print('<th colspan='.($coursespan).'>'.&mt('Any User').'</th>');
1.57 albertel 1180: if ($uname) {
1181: $r->print("<th colspan=3 rowspan=2>");
1.130 www 1182: $r->print(&mt("User")." $uname ".&mt('at Domain')." $udom</th>");
1.57 albertel 1183: }
1.133 www 1184: my %lt=&Apache::lonlocal::texthash(
1185: 'pie' => "Parameter in Effect",
1186: 'csv' => "Current Session Value",
1187: 'at' => 'at',
1188: 'rl' => "Resource Level",
1189: 'ic' => 'in Course',
1190: 'aut' => "Assessment URL and Title",
1.143 albertel 1191: 'type' => 'Type',
1.133 www 1192: 'emof' => "Enclosing Map or Folder",
1.143 albertel 1193: 'part' => 'Part',
1.133 www 1194: 'pn' => 'Parameter Name',
1195: 'def' => 'default',
1196: 'femof' => 'from Enclosing Map or Folder',
1197: 'gen' => 'general',
1198: 'foremf' => 'for Enclosing Map or Folder',
1199: 'fr' => 'for Resource'
1200: );
1.57 albertel 1201: $r->print(<<ENDTABLETWO);
1.133 www 1202: <th rowspan=3>$lt{'pie'}</th>
1203: <th rowspan=3>$lt{'csv'}<br>($csuname $lt{'at'} $csudom)</th>
1.182 albertel 1204: </tr><tr><td colspan=5></td><th colspan=2>$lt{'ic'}</th><th colspan=2>$lt{'rl'}</th>
1205: <th colspan=1>$lt{'ic'}</th>
1206:
1.10 www 1207: ENDTABLETWO
1.57 albertel 1208: if ($csec) {
1.133 www 1209: $r->print("<th colspan=3>".
1210: &mt("in Section/Group")." $csec</th>");
1.57 albertel 1211: }
1212: $r->print(<<ENDTABLEHEADFOUR);
1.133 www 1213: </tr><tr><th>$lt{'aut'}</th><th>$lt{'type'}</th>
1214: <th>$lt{'emof'}</th><th>$lt{'part'}</th><th>$lt{'pn'}</th>
1.192 albertel 1215: <th>$lt{'gen'}</th><th>$lt{'foremf'}</th>
1216: <th>$lt{'def'}</th><th>$lt{'femof'}</th><th>$lt{'fr'}</th>
1.10 www 1217: ENDTABLEHEADFOUR
1.57 albertel 1218:
1219: if ($csec) {
1.130 www 1220: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
1.57 albertel 1221: }
1222:
1223: if ($uname) {
1.130 www 1224: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
1.57 albertel 1225: }
1226:
1227: $r->print('</tr>');
1228:
1229: my $defbgone='';
1230: my $defbgtwo='';
1231:
1232: foreach (@ids) {
1233:
1234: my $rid=$_;
1235: my ($inmapid)=($rid=~/\.(\d+)$/);
1236:
1.152 albertel 1237: if ((!$pssymb &&
1238: (($pschp eq 'all') || ($allmaps{$pschp} eq $mapp{$rid})))
1239: ||
1240: ($pssymb && $pssymb eq $symbp{$rid})) {
1.4 www 1241: # ------------------------------------------------------ Entry for one resource
1.184 albertel 1242: if ($defbgone eq '"#E0E099"') {
1243: $defbgone='"#E0E0DD"';
1.57 albertel 1244: } else {
1.184 albertel 1245: $defbgone='"#E0E099"';
1.57 albertel 1246: }
1.184 albertel 1247: if ($defbgtwo eq '"#FFFF99"') {
1248: $defbgtwo='"#FFFFDD"';
1.57 albertel 1249: } else {
1.184 albertel 1250: $defbgtwo='"#FFFF99"';
1.57 albertel 1251: }
1252: my $thistitle='';
1253: my %name= ();
1254: undef %name;
1255: my %part= ();
1256: my %display=();
1257: my %type= ();
1258: my %default=();
1.196 www 1259: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 1260:
1261: foreach (split(/\,/,$keyp{$rid})) {
1262: my $tempkeyp = $_;
1263: if (grep $_ eq $tempkeyp, @catmarker) {
1264: $part{$_}=&Apache::lonnet::metadata($uri,$_.'.part');
1265: $name{$_}=&Apache::lonnet::metadata($uri,$_.'.name');
1266: $display{$_}=&Apache::lonnet::metadata($uri,$_.'.display');
1267: unless ($display{$_}) { $display{$_}=''; }
1268: $display{$_}.=' ('.$name{$_}.')';
1269: $default{$_}=&Apache::lonnet::metadata($uri,$_);
1270: $type{$_}=&Apache::lonnet::metadata($uri,$_.'.type');
1271: $thistitle=&Apache::lonnet::metadata($uri,$_.'.title');
1272: }
1273: }
1274: my $totalparms=scalar keys %name;
1275: if ($totalparms>0) {
1276: my $firstrow=1;
1.180 albertel 1277: my $title=&Apache::lonnet::gettitle($uri);
1.57 albertel 1278: $r->print('<tr><td bgcolor='.$defbgone.
1279: ' rowspan='.$totalparms.
1280: '><tt><font size=-1>'.
1281: join(' / ',split(/\//,$uri)).
1282: '</font></tt><p><b>'.
1.154 albertel 1283: "<a href=\"javascript:openWindow('".
1284: &Apache::lonnet::clutter($uri).
1.57 albertel 1285: "', 'metadatafile', '450', '500', 'no', 'yes')\";".
1.127 albertel 1286: " TARGET=_self>$title");
1.57 albertel 1287:
1288: if ($thistitle) {
1289: $r->print(' ('.$thistitle.')');
1290: }
1291: $r->print('</a></b></td>');
1292: $r->print('<td bgcolor='.$defbgtwo.
1293: ' rowspan='.$totalparms.'>'.$typep{$rid}.
1294: '</td>');
1295:
1296: $r->print('<td bgcolor='.$defbgone.
1297: ' rowspan='.$totalparms.
1298: '><tt><font size=-1>');
1299:
1300: $r->print(' / res / ');
1301: $r->print(join(' / ', split(/\//,$mapp{$rid})));
1302:
1303: $r->print('</font></tt></td>');
1304:
1305: foreach (sort keys %name) {
1306: unless ($firstrow) {
1307: $r->print('<tr>');
1308: } else {
1309: undef $firstrow;
1310: }
1311:
1312: &print_row($r,$_,\%part,\%name,$rid,\%default,
1313: \%type,\%display,$defbgone,$defbgtwo,
1.187 www 1314: $parmlev,$uname,$udom,$csec);
1.57 albertel 1315: }
1316: }
1317: }
1318: } # end foreach ids
1.43 albertel 1319: # -------------------------------------------------- End entry for one resource
1.57 albertel 1320: $r->print('</table>');
1321: } # end of brief/full
1322: #--------------------------------------------------- Entry for parm level map
1323: if ($parmlev eq 'map') {
1324: my $defbgone = '"E0E099"';
1325: my $defbgtwo = '"FFFF99"';
1326:
1327: my %maplist;
1328:
1329: if ($pschp eq 'all') {
1330: %maplist = %allmaps;
1331: } else {
1332: %maplist = ($pschp => $mapp{$pschp});
1333: }
1334:
1335: #-------------------------------------------- for each map, gather information
1336: my $mapid;
1.60 albertel 1337: foreach $mapid (sort {$maplist{$a} cmp $maplist{$b}} keys %maplist) {
1338: my $maptitle = $maplist{$mapid};
1.57 albertel 1339:
1340: #----------------------- loop through ids and get all parameter types for map
1341: #----------------------------------------- and associated information
1342: my %name = ();
1343: my %part = ();
1344: my %display = ();
1345: my %type = ();
1346: my %default = ();
1347: my $map = 0;
1348:
1349: # $r->print("Catmarker: @catmarker<br />\n");
1350:
1351: foreach (@ids) {
1352: ($map)=(/([\d]*?)\./);
1353: my $rid = $_;
1354:
1355: # $r->print("$mapid:$map: $rid <br /> \n");
1356:
1357: if ($map eq $mapid) {
1.196 www 1358: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 1359: # $r->print("Keys: $keyp{$rid} <br />\n");
1360:
1361: #--------------------------------------------------------------------
1362: # @catmarker contains list of all possible parameters including part #s
1363: # $fullkeyp contains the full part/id # for the extraction of proper parameters
1364: # $tempkeyp contains part 0 only (no ids - ie, subparts)
1365: # When storing information, store as part 0
1366: # When requesting information, request from full part
1367: #-------------------------------------------------------------------
1368: foreach (split(/\,/,$keyp{$rid})) {
1369: my $tempkeyp = $_;
1370: my $fullkeyp = $tempkeyp;
1.73 albertel 1371: $tempkeyp =~ s/_\w+_/_0_/;
1.57 albertel 1372:
1373: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
1374: $part{$tempkeyp}="0";
1375: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
1376: $display{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
1377: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
1378: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
1.73 albertel 1379: $display{$tempkeyp} =~ s/_\w+_/_0_/;
1.57 albertel 1380: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
1381: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
1382: }
1383: } # end loop through keys
1384: }
1385: } # end loop through ids
1386:
1387: #---------------------------------------------------- print header information
1.133 www 1388: my $foldermap=&mt($maptitle=~/^uploaded/?'Folder':'Map');
1.82 www 1389: my $showtitle=$maptitles{$maptitle}.($maptitle!~/^uploaded/?' ['.$maptitle.']':'');
1.57 albertel 1390: $r->print(<<ENDMAPONE);
1391: <center><h4>
1.135 albertel 1392: Set Defaults for All Resources in $foldermap<br />
1393: <font color="red"><i>$showtitle</i></font><br />
1.57 albertel 1394: Specifically for
1395: ENDMAPONE
1396: if ($uname) {
1397: my %name=&Apache::lonnet::userenvironment($udom,$uname,
1398: ('firstname','middlename','lastname','generation', 'id'));
1399: my $person=$name{'firstname'}.' '.$name{'middlename'}.' '
1400: .$name{'lastname'}.' '.$name{'generation'};
1.135 albertel 1401: $r->print(&mt("User")." <font color=\"red\"><i>$uname \($person\) </i></font> ".
1.130 www 1402: &mt('in')." \n");
1.57 albertel 1403: } else {
1.135 albertel 1404: $r->print("<font color=\"red\"><i>".&mt('all').'</i></font> '.&mt('users in')." \n");
1.57 albertel 1405: }
1406:
1.135 albertel 1407: if ($csec) {$r->print(&mt("Section")." <font color=\"red\"><i>$csec</i></font> ".
1.130 www 1408: &mt('of')." \n")};
1.57 albertel 1409:
1.135 albertel 1410: $r->print("<font color=\"red\"><i>$coursename</i></font><br />");
1411: $r->print("</h4>\n");
1.57 albertel 1412: #---------------------------------------------------------------- print table
1413: $r->print('<p><table border="2">');
1.130 www 1414: $r->print('<tr><th>'.&mt('Parameter Name').'</th>');
1415: $r->print('<th>'.&mt('Default Value').'</th>');
1416: $r->print('<th>'.&mt('Parameter in Effect').'</th></tr>');
1.57 albertel 1417:
1418: foreach (sort keys %name) {
1.168 matthew 1419: $r->print('<tr>');
1.57 albertel 1420: &print_row($r,$_,\%part,\%name,$mapid,\%default,
1421: \%type,\%display,$defbgone,$defbgtwo,
1.187 www 1422: $parmlev,$uname,$udom,$csec);
1.57 albertel 1423: # $r->print("<tr><td>resource.$part{$_}.$name{$_},$symbp{$mapid}</td></tr>\n");
1424: }
1425: $r->print("</table></center>");
1426: } # end each map
1427: } # end of $parmlev eq map
1428: #--------------------------------- Entry for parm level general (Course level)
1429: if ($parmlev eq 'general') {
1430: my $defbgone = '"E0E099"';
1431: my $defbgtwo = '"FFFF99"';
1432:
1433: #-------------------------------------------- for each map, gather information
1434: my $mapid="0.0";
1435: #----------------------- loop through ids and get all parameter types for map
1436: #----------------------------------------- and associated information
1437: my %name = ();
1438: my %part = ();
1439: my %display = ();
1440: my %type = ();
1441: my %default = ();
1442:
1443: foreach (@ids) {
1444: my $rid = $_;
1445:
1.196 www 1446: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 1447:
1448: #--------------------------------------------------------------------
1449: # @catmarker contains list of all possible parameters including part #s
1450: # $fullkeyp contains the full part/id # for the extraction of proper parameters
1451: # $tempkeyp contains part 0 only (no ids - ie, subparts)
1452: # When storing information, store as part 0
1453: # When requesting information, request from full part
1454: #-------------------------------------------------------------------
1455: foreach (split(/\,/,$keyp{$rid})) {
1456: my $tempkeyp = $_;
1457: my $fullkeyp = $tempkeyp;
1.73 albertel 1458: $tempkeyp =~ s/_\w+_/_0_/;
1.57 albertel 1459: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
1460: $part{$tempkeyp}="0";
1461: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
1462: $display{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
1463: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
1464: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
1.73 albertel 1465: $display{$tempkeyp} =~ s/_\w+_/_0_/;
1.57 albertel 1466: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
1467: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
1468: }
1469: } # end loop through keys
1470: } # end loop through ids
1471:
1472: #---------------------------------------------------- print header information
1.133 www 1473: my $setdef=&mt("Set Defaults for All Resources in Course");
1.57 albertel 1474: $r->print(<<ENDMAPONE);
1.133 www 1475: <center><h4>$setdef
1.135 albertel 1476: <font color="red"><i>$coursename</i></font><br />
1.57 albertel 1477: ENDMAPONE
1478: if ($uname) {
1479: my %name=&Apache::lonnet::userenvironment($udom,$uname,
1480: ('firstname','middlename','lastname','generation', 'id'));
1481: my $person=$name{'firstname'}.' '.$name{'middlename'}.' '
1482: .$name{'lastname'}.' '.$name{'generation'};
1.135 albertel 1483: $r->print(" ".&mt("User")."<font color=\"red\"> <i>$uname \($person\) </i></font> \n");
1.57 albertel 1484: } else {
1.135 albertel 1485: $r->print("<i><font color=\"red\"> ".&mt("ALL")."</i> ".&mt("USERS")."</font> \n");
1.57 albertel 1486: }
1487:
1.135 albertel 1488: if ($csec) {$r->print(&mt("Section")."<font color=\"red\"> <i>$csec</i></font>\n")};
1489: $r->print("</h4>\n");
1.57 albertel 1490: #---------------------------------------------------------------- print table
1491: $r->print('<p><table border="2">');
1.130 www 1492: $r->print('<tr><th>'.&mt('Parameter Name').'</th>');
1493: $r->print('<th>'.&mt('Default Value').'</th>');
1494: $r->print('<th>'.&mt('Parameter in Effect').'</th></tr>');
1.57 albertel 1495:
1496: foreach (sort keys %name) {
1.168 matthew 1497: $r->print('<tr>');
1.57 albertel 1498: &print_row($r,$_,\%part,\%name,$mapid,\%default,
1.187 www 1499: \%type,\%display,$defbgone,$defbgtwo,$parmlev,$uname,$udom,$csec);
1.57 albertel 1500: # $r->print("<tr><td>resource.$part{$_}.$name{$_},$symbp{$mapid}</td></tr>\n");
1501: }
1502: $r->print("</table></center>");
1503: } # end of $parmlev eq general
1.43 albertel 1504: }
1.44 albertel 1505: $r->print('</form></body></html>');
1506: untie(%parmhash);
1.57 albertel 1507: } # end sub assessparms
1.30 www 1508:
1.59 matthew 1509:
1510: ##################################################
1511: ##################################################
1512:
1513: =pod
1514:
1515: =item crsenv
1516:
1.105 matthew 1517: Show and set course data and parameters. This is a large routine that should
1.59 matthew 1518: be simplified and shortened... someday.
1519:
1520: Inputs: $r
1521:
1522: Returns: nothing
1523:
1524: =cut
1525:
1526: ##################################################
1527: ##################################################
1.30 www 1528: sub crsenv {
1529: my $r=shift;
1530: my $setoutput='';
1.64 www 1531: my $bodytag=&Apache::loncommon::bodytag(
1532: 'Set Course Environment Parameters');
1.194 albertel 1533: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,
1534: 'Edit Course Environment');
1.190 albertel 1535: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1536: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.105 matthew 1537:
1538: #
1539: # Go through list of changes
1.190 albertel 1540: foreach (keys %env) {
1.105 matthew 1541: next if ($_!~/^form\.(.+)\_setparmval$/);
1542: my $name = $1;
1.190 albertel 1543: my $value = $env{'form.'.$name.'_value'};
1.105 matthew 1544: if ($name eq 'newp') {
1.190 albertel 1545: $name = $env{'form.newp_name'};
1.105 matthew 1546: }
1547: if ($name eq 'url') {
1548: $value=~s/^\/res\///;
1549: my $bkuptime=time;
1550: my @tmp = &Apache::lonnet::get
1551: ('environment',['url'],$dom,$crs);
1.130 www 1552: $setoutput.=&mt('Backing up previous URL').': '.
1.105 matthew 1553: &Apache::lonnet::put
1554: ('environment',
1555: {'top level map backup '.$bkuptime => $tmp[1] },
1556: $dom,$crs).
1557: '<br>';
1558: }
1559: #
1560: # Deal with modified default spreadsheets
1561: if ($name =~ /^spreadsheet_default_(classcalc|
1562: studentcalc|
1563: assesscalc)$/x) {
1564: my $sheettype = $1;
1565: if ($sheettype eq 'classcalc') {
1566: # no need to do anything since viewing the sheet will
1567: # cause it to be updated.
1568: } elsif ($sheettype eq 'studentcalc') {
1569: # expire all the student spreadsheets
1570: &Apache::lonnet::expirespread('','','studentcalc');
1571: } else {
1572: # expire all the assessment spreadsheets
1573: # this includes non-default spreadsheets, but better to
1574: # be safe than sorry.
1575: &Apache::lonnet::expirespread('','','assesscalc');
1576: # expire all the student spreadsheets
1577: &Apache::lonnet::expirespread('','','studentcalc');
1.30 www 1578: }
1.105 matthew 1579: }
1580: #
1.107 matthew 1581: # Deal with the enrollment dates
1582: if ($name =~ /^default_enrollment_(start|end)_date$/) {
1583: $value=&Apache::lonhtmlcommon::get_date_from_form($name.'_value');
1584: }
1.178 raeburn 1585: # Get existing cloners
1586: my @oldcloner = ();
1587: if ($name eq 'cloners') {
1588: my %clonenames=&Apache::lonnet::dump('environment',$dom,$crs,'cloners');
1589: if ($clonenames{'cloners'} =~ /,/) {
1590: @oldcloner = split/,/,$clonenames{'cloners'};
1591: } else {
1592: $oldcloner[0] = $clonenames{'cloners'};
1593: }
1594: }
1.107 matthew 1595: #
1.105 matthew 1596: # Let the user know we made the changes
1.153 albertel 1597: if ($name && defined($value)) {
1.178 raeburn 1598: if ($name eq 'cloners') {
1599: $value =~ s/^,//;
1600: $value =~ s/,$//;
1601: }
1.105 matthew 1602: my $put_result = &Apache::lonnet::put('environment',
1603: {$name=>$value},$dom,$crs);
1604: if ($put_result eq 'ok') {
1.130 www 1605: $setoutput.=&mt('Set').' <b>'.$name.'</b> '.&mt('to').' <b>'.$value.'</b>.<br />';
1.178 raeburn 1606: if ($name eq 'cloners') {
1607: &change_clone($value,\@oldcloner);
1608: }
1.179 raeburn 1609: # Flush the course logs so course description is immediately updated
1610: if ($name eq 'description' && defined($value)) {
1611: &Apache::lonnet::flushcourselogs();
1612: }
1.105 matthew 1613: } else {
1.130 www 1614: $setoutput.=&mt('Unable to set').' <b>'.$name.'</b> '.&mt('to').
1615: ' <b>'.$value.'</b> '.&mt('due to').' '.$put_result.'.<br />';
1.30 www 1616: }
1617: }
1.38 harris41 1618: }
1.108 www 1619: # ------------------------- Re-init course environment entries for this session
1620:
1.190 albertel 1621: &Apache::lonnet::coursedescription($env{'request.course.id'});
1.105 matthew 1622:
1.30 www 1623: # -------------------------------------------------------- Get parameters again
1.45 matthew 1624:
1625: my %values=&Apache::lonnet::dump('environment',$dom,$crs);
1.140 sakharuk 1626: my $SelectStyleFile=&mt('Select Style File');
1.141 sakharuk 1627: my $SelectSpreadsheetFile=&mt('Select Spreadsheet File');
1.30 www 1628: my $output='';
1.45 matthew 1629: if (! exists($values{'con_lost'})) {
1.30 www 1630: my %descriptions=
1.140 sakharuk 1631: ('url' => '<b>'.&mt('Top Level Map').'</b> '.
1.46 matthew 1632: '<a href="javascript:openbrowser'.
1.47 matthew 1633: "('envform','url','sequence')\">".
1.140 sakharuk 1634: &mt('Select Map').'</a><br /><font color=red> '.
1635: &mt('Modification may make assessment data inaccessible').
1636: '</font>',
1637: 'description' => '<b>'.&mt('Course Description').'</b>',
1.158 sakharuk 1638: 'courseid' => '<b>'.&mt('Course ID or number').
1.140 sakharuk 1639: '</b><br />'.
1640: '('.&mt('internal').', '.&mt('optional').')',
1.177 raeburn 1641: 'cloners' => '<b>'.&mt('Users allowed to clone course').'</b><br /><tt>(user:domain,user:domain)</tt><br />'.&mt('Users with active Course Coordinator role in the course automatically have the right to clone it, and can be omitted from list.'),
1.150 www 1642: 'grading' => '<b>'.&mt('Grading').'</b><br />'.
1643: '<tt>"standard", "external", or "spreadsheet"</tt> '.&Apache::loncommon::help_open_topic('GradingOptions'),
1.140 sakharuk 1644: 'default_xml_style' => '<b>'.&mt('Default XML Style File').'</b> '.
1.52 www 1645: '<a href="javascript:openbrowser'.
1646: "('envform','default_xml_style'".
1.140 sakharuk 1647: ",'sty')\">$SelectStyleFile</a><br>",
1.141 sakharuk 1648: 'question.email' => '<b>'.&mt('Feedback Addresses for Resource Content Question').
1649: '</b><br />(<tt>user:domain,'.
1.74 www 1650: 'user:domain(section;section;...;*;...),...</tt>)',
1.141 sakharuk 1651: 'comment.email' => '<b>'.&mt('Feedback Addresses for Course Content Comments').'</b><br />'.
1.74 www 1652: '(<tt>user:domain,user:domain(section;section;...;*;...),...</tt>)',
1.141 sakharuk 1653: 'policy.email' => '<b>'.&mt('Feedback Addresses for Course Policy').'</b>'.
1.75 albertel 1654: '<br />(<tt>user:domain,user:domain(section;section;...;*;...),...</tt>)',
1.141 sakharuk 1655: 'hideemptyrows' => '<b>'.&mt('Hide Empty Rows in Spreadsheets').'</b><br />'.
1.158 sakharuk 1656: '('.&mt('"[_1]" for default hiding','<tt>yes</tt>').')',
1.141 sakharuk 1657: 'pageseparators' => '<b>'.&mt('Visibly Separate Items on Pages').'</b><br />'.
1.158 sakharuk 1658: '('.&mt('"[_1]" for visible separation','<tt>yes</tt>').', '.
1.141 sakharuk 1659: &mt('changes will not show until next login').')',
1.169 matthew 1660: 'student_classlist_view' => '<b>'.&mt('Allow students to view classlist.').'</b>'.&mt('("all":students can view all sections,"section":students can only view their own section.blank or "disabled" prevents student view.'),
1.118 matthew 1661:
1.141 sakharuk 1662: 'plc.roles.denied'=> '<b>'.&mt('Disallow live chatroom use for Roles').
1663: '</b><br />"<tt>st</tt>": '.
1.158 sakharuk 1664: &mt('student').', "<tt>ta</tt>": '.
1.118 matthew 1665: 'TA, "<tt>in</tt>": '.
1.158 sakharuk 1666: &mt('instructor').';<br /><tt>'.&mt('role,role,...').'</tt>) '.
1.118 matthew 1667: Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
1668: 'plc.users.denied' =>
1.141 sakharuk 1669: '<b>'.&mt('Disallow live chatroom use for Users').'</b><br />'.
1.118 matthew 1670: '(<tt>user:domain,user:domain,...</tt>)',
1671:
1.141 sakharuk 1672: 'pch.roles.denied'=> '<b>'.&mt('Disallow Resource Discussion for Roles').
1673: '</b><br />"<tt>st</tt>": '.
1.61 albertel 1674: 'student, "<tt>ta</tt>": '.
1675: 'TA, "<tt>in</tt>": '.
1.75 albertel 1676: 'instructor;<br /><tt>role,role,...</tt>) '.
1.61 albertel 1677: Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
1.53 www 1678: 'pch.users.denied' =>
1.141 sakharuk 1679: '<b>'.&mt('Disallow Resource Discussion for Users').'</b><br />'.
1.53 www 1680: '(<tt>user:domain,user:domain,...</tt>)',
1.49 matthew 1681: 'spreadsheet_default_classcalc'
1.141 sakharuk 1682: => '<b>'.&mt('Default Course Spreadsheet').'</b> '.
1.50 matthew 1683: '<a href="javascript:openbrowser'.
1684: "('envform','spreadsheet_default_classcalc'".
1.141 sakharuk 1685: ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
1.49 matthew 1686: 'spreadsheet_default_studentcalc'
1.141 sakharuk 1687: => '<b>'.&mt('Default Student Spreadsheet').'</b> '.
1.50 matthew 1688: '<a href="javascript:openbrowser'.
1689: "('envform','spreadsheet_default_calc'".
1.141 sakharuk 1690: ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
1.49 matthew 1691: 'spreadsheet_default_assesscalc'
1.141 sakharuk 1692: => '<b>'.&mt('Default Assessment Spreadsheet').'</b> '.
1.50 matthew 1693: '<a href="javascript:openbrowser'.
1694: "('envform','spreadsheet_default_assesscalc'".
1.141 sakharuk 1695: ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
1.75 albertel 1696: 'allow_limited_html_in_feedback'
1.141 sakharuk 1697: => '<b>'.&mt('Allow limited HTML in discussion posts').'</b><br />'.
1.158 sakharuk 1698: '('.&mt('Set value to "[_1]" to allow',"<tt>yes</tt>").')',
1.170 raeburn 1699: 'allow_discussion_post_editing'
1700: => '<b>'.&mt('Allow users to edit/delete their own discussion posts').'</b><br />'.
1701: '('.&mt('Set value to "[_1]" to allow',"<tt>yes</tt>").')',
1.89 albertel 1702: 'rndseed'
1.140 sakharuk 1703: => '<b>'.&mt('Randomization algorithm used').'</b> <br />'.
1704: '<font color="red">'.&mt('Modifying this will make problems').' '.
1705: &mt('have different numbers and answers').'</font>',
1.151 albertel 1706: 'receiptalg'
1707: => '<b>'.&mt('Receipt algorithm used').'</b> <br />'.
1708: &mt('This controls how receipt numbers are generated.'),
1.164 sakharuk 1709: 'suppress_tries'
1710: => '<b>'.&mt('Suppress number of tries in printing').'</b>('.
1711: &mt('yes if supress').')',
1.113 sakharuk 1712: 'problem_stream_switch'
1.141 sakharuk 1713: => '<b>'.&mt('Allow problems to be split over pages').'</b><br />'.
1.158 sakharuk 1714: ' ('.&mt('"[_1]" if allowed, anything else if not','<tt>yes</tt>').')',
1.161 sakharuk 1715: 'default_paper_size'
1716: => '<b>'.&mt('Default paper type').'</b><br />'.
1717: ' ('.&mt('supported types').': Letter [8 1/2x11 in], Legal [8 1/2x14 in],'.
1718: ' Tabloid [11x17 in], Executive [7 1/2x10 in], A2 [420x594 mm],'.
1719: ' A3 [297x420 mm], A4 [210x297 mm], A5 [148x210 mm], A6 [105x148 mm])',
1.111 sakharuk 1720: 'anonymous_quiz'
1.150 www 1721: => '<b>'.&mt('Anonymous quiz/exam').'</b><br />'.
1.141 sakharuk 1722: ' (<tt><b>'.&mt('yes').'</b> '.&mt('to avoid print students names').' </tt>)',
1723: 'default_enrollment_start_date' => '<b>'.&mt('Default beginning date when enrolling students').'</b>',
1724: 'default_enrollment_end_date' => '<b>'.&mt('Default ending date when enrolling students').'</b>',
1.150 www 1725: 'nothideprivileged' => '<b>'.&mt('Privileged users that should not be hidden on staff listings').'</b>'.
1726: '<br />(<tt>user:domain,user:domain,...</tt>)',
1.140 sakharuk 1727: 'languages' => '<b>'.&mt('Languages used').'</b>',
1.115 www 1728: 'disable_receipt_display'
1.141 sakharuk 1729: => '<b>'.&mt('Disable display of problem receipts').'</b><br />'.
1.158 sakharuk 1730: ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
1.163 albertel 1731: 'disablesigfigs'
1732: => '<b>'.&mt('Disable checking of Significant Figures').'</b><br />'.
1733: ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
1.149 albertel 1734: 'tthoptions'
1735: => '<b>'.&mt('Default set of options to pass to tth/m when converting tex').'</b>'
1.107 matthew 1736: );
1.177 raeburn 1737: my @Display_Order = ('url','description','courseid','cloners','grading',
1.107 matthew 1738: 'default_xml_style','pageseparators',
1739: 'question.email','comment.email','policy.email',
1.169 matthew 1740: 'student_classlist_view',
1.118 matthew 1741: 'plc.roles.denied','plc.users.denied',
1.107 matthew 1742: 'pch.roles.denied','pch.users.denied',
1743: 'allow_limited_html_in_feedback',
1.170 raeburn 1744: 'allow_discussion_post_editing',
1.108 www 1745: 'languages',
1.150 www 1746: 'nothideprivileged',
1.107 matthew 1747: 'rndseed',
1.151 albertel 1748: 'receiptalg',
1.107 matthew 1749: 'problem_stream_switch',
1.164 sakharuk 1750: 'suppress_tries',
1.161 sakharuk 1751: 'default_paper_size',
1.115 www 1752: 'disable_receipt_display',
1.107 matthew 1753: 'spreadsheet_default_classcalc',
1754: 'spreadsheet_default_studentcalc',
1755: 'spreadsheet_default_assesscalc',
1756: 'hideemptyrows',
1757: 'default_enrollment_start_date',
1758: 'default_enrollment_end_date',
1.163 albertel 1759: 'tthoptions',
1760: 'disablesigfigs'
1.107 matthew 1761: );
1762: foreach my $parameter (sort(keys(%values))) {
1.142 raeburn 1763: unless ($parameter =~ m/^internal\./) {
1764: if (! $descriptions{$parameter}) {
1765: $descriptions{$parameter}=$parameter;
1766: push(@Display_Order,$parameter);
1767: }
1768: }
1.43 albertel 1769: }
1.107 matthew 1770: foreach my $parameter (@Display_Order) {
1771: my $description = $descriptions{$parameter};
1.51 matthew 1772: # onchange is javascript to automatically check the 'Set' button.
1.69 www 1773: my $onchange = 'onFocus="javascript:window.document.forms'.
1.107 matthew 1774: "['envform'].elements['".$parameter."_setparmval']".
1.51 matthew 1775: '.checked=true;"';
1.107 matthew 1776: $output .= '<tr><td>'.$description.'</td>';
1777: if ($parameter =~ /^default_enrollment_(start|end)_date$/) {
1778: $output .= '<td>'.
1779: &Apache::lonhtmlcommon::date_setter('envform',
1780: $parameter.'_value',
1781: $values{$parameter},
1782: $onchange).
1783: '</td>';
1784: } else {
1785: $output .= '<td>'.
1786: &Apache::lonhtmlcommon::textbox($parameter.'_value',
1787: $values{$parameter},
1788: 40,$onchange).'</td>';
1789: }
1790: $output .= '<td>'.
1791: &Apache::lonhtmlcommon::checkbox($parameter.'_setparmval').
1792: '</td>';
1793: $output .= "</tr>\n";
1.51 matthew 1794: }
1.69 www 1795: my $onchange = 'onFocus="javascript:window.document.forms'.
1.51 matthew 1796: '[\'envform\'].elements[\'newp_setparmval\']'.
1797: '.checked=true;"';
1.130 www 1798: $output.='<tr><td><i>'.&mt('Create New Environment Variable').'</i><br />'.
1.51 matthew 1799: '<input type="text" size=40 name="newp_name" '.
1800: $onchange.' /></td><td>'.
1801: '<input type="text" size=40 name="newp_value" '.
1802: $onchange.' /></td><td>'.
1803: '<input type="checkbox" name="newp_setparmval" /></td></tr>';
1.43 albertel 1804: }
1.157 sakharuk 1805: my %lt=&Apache::lonlocal::texthash(
1806: 'par' => 'Parameter',
1807: 'val' => 'Value',
1808: 'set' => 'Set',
1809: 'sce' => 'Set Course Environment'
1810: );
1811:
1.140 sakharuk 1812: my $Parameter=&mt('Parameter');
1813: my $Value=&mt('Value');
1.141 sakharuk 1814: my $Set=&mt('Set');
1.167 albertel 1815: my $browse_js=&Apache::loncommon::browser_and_searcher_javascript('parmset');
1.183 albertel 1816: my $html=&Apache::lonxml::xmlbegin();
1.190 albertel 1817: $r->print(<<ENDenv);
1.183 albertel 1818: $html
1819: <head>
1.46 matthew 1820: <script type="text/javascript" language="Javascript" >
1.155 albertel 1821: $browse_js
1.46 matthew 1822: </script>
1.30 www 1823: <title>LON-CAPA Course Environment</title>
1824: </head>
1.64 www 1825: $bodytag
1.193 albertel 1826: $breadcrumbs
1827: <form method="post" action="/adm/parmset?action=crsenv" name="envform">
1.30 www 1828: $setoutput
1829: <p>
1830: <table border=2>
1.157 sakharuk 1831: <tr><th>$lt{'par'}</th><th>$lt{'val'}</th><th>$lt{'set'}?</th></tr>
1.30 www 1832: $output
1833: </table>
1.157 sakharuk 1834: <input type="submit" name="crsenv" value="$lt{'sce'}">
1.30 www 1835: </form>
1836: </body>
1837: </html>
1.190 albertel 1838: ENDenv
1.30 www 1839: }
1.120 www 1840: ##################################################
1.30 www 1841:
1.124 www 1842: my $tableopen;
1843:
1844: sub tablestart {
1845: if ($tableopen) {
1846: return '';
1847: } else {
1848: $tableopen=1;
1.130 www 1849: return '<table border="2"><tr><th>'.&mt('Parameter').'</th><th>'.
1850: &mt('Delete').'</th><th>'.&mt('Set to ...').'</th></tr>';
1.124 www 1851: }
1852: }
1853:
1854: sub tableend {
1855: if ($tableopen) {
1856: $tableopen=0;
1857: return '</table>';
1858: } else {
1859: return'';
1860: }
1861: }
1862:
1.120 www 1863: sub overview {
1864: my $r=shift;
1865: my $bodytag=&Apache::loncommon::bodytag(
1866: 'Set/Modify Course Assessment Parameters');
1.190 albertel 1867: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1868: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.194 albertel 1869: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Overview');
1.183 albertel 1870: my $html=&Apache::lonxml::xmlbegin();
1.120 www 1871: $r->print(<<ENDOVER);
1.183 albertel 1872: $html
1.120 www 1873: <head>
1874: <title>LON-CAPA Course Environment</title>
1875: </head>
1876: $bodytag
1.193 albertel 1877: $breadcrumbs
1878: <form method="post" action="/adm/parmset?action=setoverview" name="overviewform">
1.120 www 1879: <input type="hidden" name="overview" value="1" />
1880: ENDOVER
1.124 www 1881: # Setting
1882: my %olddata=&Apache::lonnet::dump('resourcedata',$dom,$crs);
1883: my %newdata=();
1884: undef %newdata;
1885: my @deldata=();
1886: undef @deldata;
1.190 albertel 1887: foreach (keys %env) {
1.124 www 1888: if ($_=~/^form\.([a-z]+)\_(.+)$/) {
1889: my $cmd=$1;
1890: my $thiskey=$2;
1891: if ($cmd eq 'set') {
1.190 albertel 1892: my $data=$env{$_};
1.124 www 1893: if ($olddata{$thiskey} ne $data) { $newdata{$thiskey}=$data; }
1894: } elsif ($cmd eq 'del') {
1895: push (@deldata,$thiskey);
1896: } elsif ($cmd eq 'datepointer') {
1.190 albertel 1897: my $data=&Apache::lonhtmlcommon::get_date_from_form($env{$_});
1.153 albertel 1898: if (defined($data) and $olddata{$thiskey} ne $data) { $newdata{$thiskey}=$data; }
1.124 www 1899: }
1900: }
1901: }
1902: # Store
1.144 www 1903: my $delentries=$#deldata+1;
1904: my @newdatakeys=keys %newdata;
1905: my $putentries=$#newdatakeys+1;
1906: if ($delentries) {
1907: if (&Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs) eq 'ok') {
1908: $r->print('<h2>'.&mt('Deleted [_1] parameter(s)</h2>',$delentries));
1909: } else {
1910: $r->print('<h2><font color="red">'.
1911: &mt('Error deleting parameters').'</font></h2>');
1912: }
1913: }
1914: if ($putentries) {
1915: if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') {
1916: $r->print('<h2>'.&mt('Stored [_1] parameter(s)</h2>',$putentries));
1917: } else {
1918: $r->print('<h2><font color="red">'.
1919: &mt('Error storing parameters').'</font></h2>');
1920: }
1921: }
1.122 www 1922: # Read and display
1923: my %resourcedata=&Apache::lonnet::dump('resourcedata',$dom,$crs);
1924: my $oldsection='';
1925: my $oldrealm='';
1926: my $oldpart='';
1.123 www 1927: my $pointer=0;
1.124 www 1928: $tableopen=0;
1.145 www 1929: my $foundkeys=0;
1.122 www 1930: foreach my $thiskey (sort keys %resourcedata) {
1.123 www 1931: if ($resourcedata{$thiskey.'.type'}) {
1932: my ($course,$middle,$part,$name)=
1933: ($thiskey=~/^(\w+)\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
1.130 www 1934: my $section=&mt('All Students');
1.122 www 1935: if ($middle=~/^\[(.*)\]\./) {
1.130 www 1936: $section=&mt('Group/Section').': '.$1;
1.122 www 1937: $middle=~s/^\[(.*)\]\.//;
1938: }
1.123 www 1939: $middle=~s/\.$//;
1.130 www 1940: my $realm='<font color="red">'.&mt('All Resources').'</font>';
1.122 www 1941: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
1.174 albertel 1942: $realm='<font color="green">'.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' <br /><font color="#aaaaaa" size="-2">('.$1.')</font></font>';
1.122 www 1943: } elsif ($middle) {
1.174 albertel 1944: my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
1945: $realm='<font color="orange">'.&mt('Resource').': '.&Apache::lonnet::gettitle($middle).' <br /><font color="#aaaaaa" size="-2">('.$url.' in '.$map.' id: '.$id.')</font></font>';
1.122 www 1946: }
1947: if ($section ne $oldsection) {
1.124 www 1948: $r->print(&tableend()."\n<hr /><h1>$section</h1>");
1.122 www 1949: $oldsection=$section;
1950: $oldrealm='';
1951: }
1952: if ($realm ne $oldrealm) {
1.124 www 1953: $r->print(&tableend()."\n<h2>$realm</h2>");
1.122 www 1954: $oldrealm=$realm;
1955: $oldpart='';
1956: }
1957: if ($part ne $oldpart) {
1.124 www 1958: $r->print(&tableend().
1.130 www 1959: "\n<h3><font color='blue'>".&mt('Part').": $part</font></h3>");
1.122 www 1960: $oldpart=$part;
1961: }
1.123 www 1962: #
1963: # Ready to print
1964: #
1.124 www 1965: $r->print(&tablestart().'<tr><td><b>'.$name.
1966: ':</b></td><td><input type="checkbox" name="del_'.
1967: $thiskey.'" /></td><td>');
1.145 www 1968: $foundkeys++;
1.123 www 1969: if ($resourcedata{$thiskey.'.type'}=~/^date/) {
1970: my $jskey='key_'.$pointer;
1971: $pointer++;
1972: $r->print(
1973: &Apache::lonhtmlcommon::date_setter('overviewform',
1974: $jskey,
1975: $resourcedata{$thiskey}).
1976: '<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'
1977: );
1978: } else {
1979: $r->print(
1980: '<input type="text" name="set_'.$thiskey.'" value="'.
1981: $resourcedata{$thiskey}.'">');
1982: }
1.124 www 1983: $r->print('</td></tr>');
1.122 www 1984: }
1.121 www 1985: }
1.124 www 1986:
1.145 www 1987: $r->print(&tableend().'<p>'.
1988: ($foundkeys?'<input type="submit" value="'.&mt('Modify Parameters').'" />':&mt('There are no course or section parameters.')).'</p></form></body></html>');
1.120 www 1989: }
1.121 www 1990:
1.59 matthew 1991: ##################################################
1992: ##################################################
1.178 raeburn 1993:
1994: =pod
1995:
1996: =item change clone
1997:
1998: Modifies the list of courses a user can clone (stored
1999: in the user's environemnt.db file), called when a
2000: change is made to the list of users allowed to clone
2001: a course.
2002:
2003: Inputs: $action,$cloner
2004: where $action is add or drop, and $cloner is identity of
2005: user for whom cloning ability is to be changed in course.
2006:
2007: Returns:
2008:
2009: =cut
2010:
2011: ##################################################
2012: ##################################################
2013:
2014:
2015: sub change_clone {
2016: my ($clonelist,$oldcloner) = @_;
2017: my ($uname,$udom);
1.190 albertel 2018: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
2019: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.178 raeburn 2020: my $clone_crs = $cnum.':'.$cdom;
2021:
2022: if ($cnum && $cdom) {
2023: my @allowclone = ();
2024: if ($clonelist =~ /,/) {
2025: @allowclone = split/,/,$clonelist;
2026: } else {
2027: $allowclone[0] = $clonelist;
2028: }
2029: foreach my $currclone (@allowclone) {
2030: if (!grep/^$currclone$/,@$oldcloner) {
2031: ($uname,$udom) = split/:/,$currclone;
2032: if ($uname && $udom) {
2033: unless (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
2034: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
2035: if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) {
2036: if ($currclonecrs{'cloneable'} eq '') {
2037: $currclonecrs{'cloneable'} = $clone_crs;
2038: } else {
2039: $currclonecrs{'cloneable'} .= ','.$clone_crs;
2040: }
2041: &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname);
2042: }
2043: }
2044: }
2045: }
2046: }
2047: foreach my $oldclone (@$oldcloner) {
2048: if (!grep/^$oldclone$/,@allowclone) {
2049: ($uname,$udom) = split/:/,$oldclone;
2050: if ($uname && $udom) {
2051: unless (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
2052: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
2053: my %newclonecrs = ();
2054: if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) {
2055: if ($currclonecrs{'cloneable'} =~ /,/) {
2056: my @currclonecrs = split/,/,$currclonecrs{'cloneable'};
2057: foreach (@currclonecrs) {
2058: unless ($_ eq $clone_crs) {
2059: $newclonecrs{'cloneable'} .= $_.',';
2060: }
2061: }
2062: $newclonecrs{'cloneable'} =~ s/,$//;
2063: } else {
2064: $newclonecrs{'cloneable'} = '';
2065: }
2066: &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname);
2067: }
2068: }
2069: }
2070: }
2071: }
2072: }
2073: }
2074:
1.193 albertel 2075:
2076: ##################################################
2077: ##################################################
2078:
2079: =pod
2080:
2081: =item * header
2082:
2083: Output html header for page
2084:
2085: =cut
2086:
2087: ##################################################
2088: ##################################################
2089: sub header {
2090: my $html=&Apache::lonxml::xmlbegin();
2091: my $bodytag=&Apache::loncommon::bodytag('Parameter Manager');
2092: my $title = &mt('LON-CAPA Parameter Manager');
2093: return(<<ENDHEAD);
2094: $html
2095: <head>
2096: <title>$title</title>
2097: </head>
2098: $bodytag
2099: ENDHEAD
2100: }
2101: ##################################################
2102: ##################################################
2103: sub print_main_menu {
2104: my ($r,$parm_permission)=@_;
2105: #
2106: $r->print(<<ENDMAINFORMHEAD);
2107: <form method="post" enctype="multipart/form-data"
2108: action="/adm/parmset" name="studentform">
2109: ENDMAINFORMHEAD
2110: #
1.195 albertel 2111: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
2112: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.193 albertel 2113: my @menu =
2114: (
2115: { text => 'Set Course Environment Parameters',
2116: help => 'Course_Setting_Parameters',
2117: action => 'crsenv',
2118: permission => $parm_permission,
2119: },
2120: { text => 'Set/Modify Course Assessment Parameters - Helper Mode',
2121: url => '/adm/helper/parameter.helper',
2122: permission => $parm_permission,
2123: },
2124: { text => 'Modify Course Assessment Parameters - Overview Mode',
2125: action => 'setoverview',
2126: permission => $parm_permission,
2127: },
2128: { text => 'Set/Modify Course Assessment Parameters - Table Mode',
2129: action => 'settable',
2130: permission => $parm_permission,
2131: },
2132: # { text => 'Set Parameter Default Preferences',
2133: # help => 'Course_View_Class_List',
2134: # action => 'setdefaults',
2135: # permission => $parm_permission,
2136: # },
2137: );
2138: my $menu_html = '';
2139: foreach my $menu_item (@menu) {
2140: next if (! $menu_item->{'permission'});
2141: $menu_html.='<p>';
2142: $menu_html.='<font size="+1">';
2143: if (exists($menu_item->{'url'})) {
2144: $menu_html.=qq{<a href="$menu_item->{'url'}">};
2145: } else {
2146: $menu_html.=
2147: qq{<a href="/adm/parmset?action=$menu_item->{'action'}">};
2148: }
2149: $menu_html.= &mt($menu_item->{'text'}).'</a></font>';
2150: if (exists($menu_item->{'help'})) {
2151: $menu_html.=
2152: &Apache::loncommon::help_open_topic($menu_item->{'help'});
2153: }
2154: $menu_html.='</p>'.$/;
2155: }
2156: $r->print($menu_html);
2157: return;
2158: }
2159:
2160:
2161:
2162:
1.178 raeburn 2163: ##################################################
2164: ##################################################
1.30 www 2165:
1.59 matthew 2166: =pod
2167:
1.83 bowersj2 2168: =item * handler
1.59 matthew 2169:
2170: Main handler. Calls &assessparms and &crsenv subroutines.
2171:
2172: =cut
2173: ##################################################
2174: ##################################################
1.85 bowersj2 2175: use Data::Dumper;
1.30 www 2176: sub handler {
1.43 albertel 2177: my $r=shift;
1.30 www 2178:
1.43 albertel 2179: if ($r->header_only) {
1.126 www 2180: &Apache::loncommon::content_type($r,'text/html');
1.43 albertel 2181: $r->send_http_header;
2182: return OK;
2183: }
1.193 albertel 2184: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.194 albertel 2185: ['action','state']);
1.131 www 2186:
2187: # ----------------------------------------------------------- Clear out garbage
2188:
1.132 albertel 2189: %courseopt=();
2190: %useropt=();
2191: %parmhash=();
1.131 www 2192:
1.132 albertel 2193: @ids=();
2194: %symbp=();
2195: %mapp=();
2196: %typep=();
2197: %keyp=();
1.131 www 2198:
1.132 albertel 2199: %maptitles=();
1.83 bowersj2 2200:
1.193 albertel 2201: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.194 albertel 2202: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset",
2203: text=>"Parameter Manager",
2204: faq=>9,
2205: bug=>'Instructor Interface'});
1.30 www 2206: # ----------------------------------------------------- Needs to be in a course
1.194 albertel 2207: my $parm_permission =
2208: (&Apache::lonnet::allowed('opa',$env{'request.course.id'}) ||
1.190 albertel 2209: &Apache::lonnet::allowed('opa',$env{'request.course.id'}.'/'.
1.193 albertel 2210: $env{'request.course.sec'}));
1.194 albertel 2211: if ($env{'request.course.id'} && $parm_permission) {
1.193 albertel 2212:
2213: # Start Page
1.126 www 2214: &Apache::loncommon::content_type($r,'text/html');
1.106 www 2215: $r->send_http_header;
1.30 www 2216:
1.193 albertel 2217: #
2218: # Main switch on form.action and form.state, as appropriate
2219: #
2220: # Check first if coming from someone else headed directly for
2221: # the table mode
2222: if ((($env{'form.command'} eq 'set') && ($env{'form.url'})
2223: && (!$env{'form.dis'})) || ($env{'form.symb'})) {
2224: &assessparms($r);
2225:
2226: } elsif (! exists($env{'form.action'})) {
2227: $r->print(&header());
1.194 albertel 2228: $r->print(&Apache::lonhtmlcommon::breadcrumbs(undef,
2229: 'Parameter Manager'));
1.193 albertel 2230: &print_main_menu($r,$parm_permission);
2231: } elsif ($env{'form.action'} eq 'crsenv' && $parm_permission) {
1.194 albertel 2232: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=crsenv',
2233: text=>"Course Environment"});
2234: $r->print(&Apache::lonhtmlcommon::breadcrumbs(undef,
2235: 'Edit Course Environment'));
1.193 albertel 2236: &crsenv($r);
2237: } elsif ($env{'form.action'} eq 'setoverview' && $parm_permission) {
1.194 albertel 2238: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
2239: text=>"Overview Mode"});
1.121 www 2240: &overview($r);
1.193 albertel 2241: } elsif ($env{'form.action'} eq 'settable' && $parm_permission) {
1.194 albertel 2242: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
2243: text=>"Table Mode"});
1.121 www 2244: &assessparms($r);
1.193 albertel 2245: }
2246:
1.43 albertel 2247: } else {
1.1 www 2248: # ----------------------------- Not in a course, or not allowed to modify parms
1.190 albertel 2249: $env{'user.error.msg'}=
1.43 albertel 2250: "/adm/parmset:opa:0:0:Cannot modify assessment parameters";
2251: return HTTP_NOT_ACCEPTABLE;
2252: }
2253: return OK;
1.1 www 2254: }
2255:
2256: 1;
2257: __END__
2258:
1.59 matthew 2259: =pod
1.38 harris41 2260:
2261: =back
2262:
2263: =cut
1.1 www 2264:
2265:
2266:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>