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