Annotation of loncom/interface/lonparmset.pm, revision 1.200
1.1 www 1: # The LearningOnline Network with CAPA
2: # Handler to set parameters for assessments
3: #
1.200 ! www 4: # $Id: lonparmset.pm,v 1.199 2005/06/02 13:34:14 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.198 www 71:
72: # --- end local caches
73:
74: #
75: # FIXME: get rid of items below
76: #
1.3 www 77: my @ids;
78: my %symbp;
1.10 www 79: my %mapp;
1.3 www 80: my %typep;
1.16 www 81: my %keyp;
1.196 www 82: my %uris;
1.82 www 83: my %maptitles;
84:
1.59 matthew 85: ##################################################
86: ##################################################
87:
88: =pod
89:
90: =item parmval
91:
92: Figure out a cascading parameter.
93:
1.71 albertel 94: Inputs: $what - a parameter spec (incluse part info and name I.E. 0.weight)
1.162 albertel 95: $id - a bighash Id number
1.71 albertel 96: $def - the resource's default value 'stupid emacs
97:
98: 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
99:
1.182 albertel 100: 11 - General Course
101: 10 - Map or Folder level in course
102: 9- resource default
103: 8- map default
1.71 albertel 104: 7 - resource level in course
105: 6 - General for section
1.82 www 106: 5 - Map or Folder level for section
1.71 albertel 107: 4 - resource level in section
108: 3 - General for specific student
1.82 www 109: 2 - Map or Folder level for specific student
1.71 albertel 110: 1 - resource level for specific student
1.2 www 111:
1.59 matthew 112: =cut
113:
114: ##################################################
115: ##################################################
1.2 www 116: sub parmval {
1.187 www 117: my ($what,$id,$def,$uname,$udom,$csec)=@_;
1.198 www 118: # load caches
1.200 ! www 119:
1.198 www 120: &cacheparmhash();
1.200 ! www 121:
! 122: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
! 123: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
! 124: my $useropt=&Apache::lonnet::get_userresdata($uname,$udom);
! 125: my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom);
! 126:
1.198 www 127:
1.8 www 128: my $result='';
1.44 albertel 129: my @outpar=();
1.2 www 130: # ----------------------------------------------------- Cascading lookup scheme
1.10 www 131:
1.43 albertel 132: my $symbparm=$symbp{$id}.'.'.$what;
133: my $mapparm=$mapp{$id}.'___(all).'.$what;
1.10 www 134:
1.190 albertel 135: my $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$what;
136: my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm;
137: my $seclevelm=$env{'request.course.id'}.'.['.$csec.'].'.$mapparm;
138:
139: my $courselevel=$env{'request.course.id'}.'.'.$what;
140: my $courselevelr=$env{'request.course.id'}.'.'.$symbparm;
141: my $courselevelm=$env{'request.course.id'}.'.'.$mapparm;
1.2 www 142:
1.11 www 143:
144:
1.182 albertel 145: # --------------------------------------------------------- first, check course
1.11 www 146:
1.200 ! www 147: if (defined($$courseopt{$courselevel})) {
! 148: $outpar[11]=$$courseopt{$courselevel};
1.182 albertel 149: $result=11;
1.43 albertel 150: }
1.11 www 151:
1.200 ! www 152: if (defined($$courseopt{$courselevelm})) {
! 153: $outpar[10]=$$courseopt{$courselevelm};
1.182 albertel 154: $result=10;
1.43 albertel 155: }
1.11 www 156:
1.182 albertel 157: # ------------------------------------------------------- second, check default
158:
159: if (defined($def)) { $outpar[9]=$def; $result=9; }
160:
161: # ------------------------------------------------------ third, check map parms
162:
163: my $thisparm=$parmhash{$symbparm};
164: if (defined($thisparm)) { $outpar[8]=$thisparm; $result=8; }
165:
1.200 ! www 166: if (defined($$courseopt{$courselevelr})) {
! 167: $outpar[7]=$$courseopt{$courselevelr};
1.43 albertel 168: $result=7;
169: }
1.11 www 170:
1.182 albertel 171: # ------------------------------------------------------ fourth, back to course
1.71 albertel 172: if (defined($csec)) {
1.200 ! www 173: if (defined($$courseopt{$seclevel})) {
! 174: $outpar[6]=$$courseopt{$seclevel};
1.43 albertel 175: $result=6;
176: }
1.200 ! www 177: if (defined($$courseopt{$seclevelm})) {
! 178: $outpar[5]=$$courseopt{$seclevelm};
1.43 albertel 179: $result=5;
180: }
181:
1.200 ! www 182: if (defined($$courseopt{$seclevelr})) {
! 183: $outpar[4]=$$courseopt
! 184: {$seclevelr};
1.43 albertel 185: $result=4;
186: }
187: }
1.11 www 188:
1.182 albertel 189: # ---------------------------------------------------------- fifth, check user
1.11 www 190:
1.71 albertel 191: if (defined($uname)) {
1.200 ! www 192: if (defined($$useropt{$courselevel})) {
! 193: $outpar[3]=$$useropt{$courselevel};
1.43 albertel 194: $result=3;
195: }
1.10 www 196:
1.200 ! www 197: if (defined($$useropt{$courselevelm})) {
! 198: $outpar[2]=$$useropt{$courselevelm};
1.43 albertel 199: $result=2;
200: }
1.2 www 201:
1.200 ! www 202: if (defined($$useropt{$courselevelr})) {
! 203: $outpar[1]=$$useropt{$courselevelr};
1.43 albertel 204: $result=1;
205: }
206: }
1.44 albertel 207: return ($result,@outpar);
1.2 www 208: }
209:
1.198 www 210: sub resetparmhash {
211: $parmhashid='';
212: }
213:
214: sub cacheparmhash {
215: if ($parmhashid eq $env{'request.course.fn'}) { return; }
216: my %parmhashfile;
217: if (tie(%parmhashfile,'GDBM_File',
218: $env{'request.course.fn'}.'_parms.db',&GDBM_READER(),0640)) {
219: %parmhash=%parmhashfile;
220: untie %parmhashfile;
221: $parmhashid=$env{'request.course.fn'};
222: }
223: }
224:
1.186 www 225: ##################################################
226: ##################################################
227: #
1.197 www 228: # Store a parameter by ID
1.186 www 229: #
230: # Takes
231: # - resource id
232: # - name of parameter
233: # - level
234: # - new value
235: # - new type
1.187 www 236: # - username
237: # - userdomain
238:
1.186 www 239: sub storeparm {
1.187 www 240: my ($sresid,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec)=@_;
1.197 www 241: my $navmap = Apache::lonnavmaps::navmap->new();
242: if ($sresid=~/\./) {
243: my $resource=$navmap->getById($sresid);
244: &storeparm_by_symb($resource->symb(),$spnam,$snum,$nval,$ntype,$uname,$udom,$csec);
245: } else {
246: my $resource=$navmap->getByMapPc($sresid);
247: &storeparm_by_symb(&Apache::lonnet::declutter($resource->src()),$spnam,$snum,$nval,$ntype,$uname,$udom,$csec);
248: }
249: }
250:
251: #
252: # Store a parameter by symb
253: #
254: # Takes
255: # - symb
256: # - name of parameter
257: # - level
258: # - new value
259: # - new type
260: # - username
261: # - userdomain
262:
263: sub storeparm_by_symb {
264: # ---------------------------------------------------------- Get symb, map, etc
265: my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec)=@_;
266: # ---------------------------------------------------------- Construct prefixes
1.186 www 267: $spnam=~s/\_([^\_]+)$/\.$1/;
1.197 www 268: my $map=(&Apache::lonnet::decode_symb($symb))[0];
269: my $symbparm=$symb.'.'.$spnam;
270: my $mapparm=$map.'___(all).'.$spnam;
271:
1.190 albertel 272: my $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$spnam;
273: my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm;
274: my $seclevelm=$env{'request.course.id'}.'.['.$csec.'].'.$mapparm;
1.186 www 275:
1.190 albertel 276: my $courselevel=$env{'request.course.id'}.'.'.$spnam;
277: my $courselevelr=$env{'request.course.id'}.'.'.$symbparm;
278: my $courselevelm=$env{'request.course.id'}.'.'.$mapparm;
1.186 www 279:
280: my $storeunder='';
281: if (($snum==11) || ($snum==3)) { $storeunder=$courselevel; }
282: if (($snum==10) || ($snum==2)) { $storeunder=$courselevelm; }
283: if (($snum==7) || ($snum==1)) { $storeunder=$courselevelr; }
284: if ($snum==6) { $storeunder=$seclevel; }
285: if ($snum==5) { $storeunder=$seclevelm; }
286: if ($snum==4) { $storeunder=$seclevelr; }
287:
288: my $delete;
289: if ($nval eq '') { $delete=1;}
290: my %storecontent = ($storeunder => $nval,
291: $storeunder.'.type' => $ntype);
292: my $reply='';
293: if ($snum>3) {
294: # ---------------------------------------------------------------- Store Course
295: #
1.200 ! www 296: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
! 297: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.186 www 298: # Expire sheets
299: &Apache::lonnet::expirespread('','','studentcalc');
300: if (($snum==7) || ($snum==4)) {
1.197 www 301: &Apache::lonnet::expirespread('','','assesscalc',$symb);
1.186 www 302: } elsif (($snum==8) || ($snum==5)) {
1.197 www 303: &Apache::lonnet::expirespread('','','assesscalc',$map);
1.186 www 304: } else {
305: &Apache::lonnet::expirespread('','','assesscalc');
306: }
307: # Store parameter
308: if ($delete) {
309: $reply=&Apache::lonnet::del
1.200 ! www 310: ('resourcedata',[keys(%storecontent)],$cdom,$cnum);
1.186 www 311: } else {
312: $reply=&Apache::lonnet::cput
1.200 ! www 313: ('resourcedata',\%storecontent,$cdom,$cnum);
1.186 www 314: }
1.200 ! www 315: &Apache::lonnet::devalidatecourseresdata($cnum,$cdom);
1.186 www 316: } else {
317: # ------------------------------------------------------------------ Store User
318: #
319: # Expire sheets
320: &Apache::lonnet::expirespread($uname,$udom,'studentcalc');
321: if ($snum==1) {
322: &Apache::lonnet::expirespread
1.197 www 323: ($uname,$udom,'assesscalc',$symb);
1.186 www 324: } elsif ($snum==2) {
325: &Apache::lonnet::expirespread
1.197 www 326: ($uname,$udom,'assesscalc',$map);
1.186 www 327: } else {
328: &Apache::lonnet::expirespread($uname,$udom,'assesscalc');
329: }
330: # Store parameter
331: if ($delete) {
332: $reply=&Apache::lonnet::del
333: ('resourcedata',[keys(%storecontent)],$udom,$uname);
334: } else {
335: $reply=&Apache::lonnet::cput
336: ('resourcedata',\%storecontent,$udom,$uname);
337: }
1.191 albertel 338: &Apache::lonnet::devalidateuserresdata($uname,$udom);
1.186 www 339: }
340:
341: if ($reply=~/^error\:(.*)/) {
342: return "<font color=red>Write Error: $1</font>";
343: }
344: return '';
345: }
346:
1.59 matthew 347: ##################################################
348: ##################################################
349:
350: =pod
351:
352: =item valout
353:
354: Format a value for output.
355:
356: Inputs: $value, $type
357:
358: Returns: $value, formatted for output. If $type indicates it is a date,
359: localtime($value) is returned.
1.9 www 360:
1.59 matthew 361: =cut
362:
363: ##################################################
364: ##################################################
1.9 www 365: sub valout {
366: my ($value,$type)=@_;
1.59 matthew 367: my $result = '';
368: # Values of zero are valid.
369: if (! $value && $value ne '0') {
1.71 albertel 370: $result = ' ';
1.59 matthew 371: } else {
1.66 www 372: if ($type eq 'date_interval') {
373: my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($value);
374: $year=$year-70;
375: $mday--;
376: if ($year) {
377: $result.=$year.' yrs ';
378: }
379: if ($mon) {
380: $result.=$mon.' mths ';
381: }
382: if ($mday) {
383: $result.=$mday.' days ';
384: }
385: if ($hour) {
386: $result.=$hour.' hrs ';
387: }
388: if ($min) {
389: $result.=$min.' mins ';
390: }
391: if ($sec) {
392: $result.=$sec.' secs ';
393: }
394: $result=~s/\s+$//;
395: } elsif ($type=~/^date/) {
1.59 matthew 396: $result = localtime($value);
397: } else {
398: $result = $value;
399: }
400: }
401: return $result;
1.9 www 402: }
403:
1.59 matthew 404: ##################################################
405: ##################################################
406:
407: =pod
1.5 www 408:
1.59 matthew 409: =item plink
410:
411: Produces a link anchor.
412:
413: Inputs: $type,$dis,$value,$marker,$return,$call
414:
415: Returns: scalar with html code for a link which will envoke the
416: javascript function 'pjump'.
417:
418: =cut
419:
420: ##################################################
421: ##################################################
1.5 www 422: sub plink {
423: my ($type,$dis,$value,$marker,$return,$call)=@_;
1.23 www 424: my $winvalue=$value;
425: unless ($winvalue) {
426: if ($type=~/^date/) {
1.190 albertel 427: $winvalue=$env{'form.recent_'.$type};
1.23 www 428: } else {
1.190 albertel 429: $winvalue=$env{'form.recent_'.(split(/\_/,$type))[0]};
1.23 www 430: }
431: }
432: return
1.43 albertel 433: '<a href="javascript:pjump('."'".$type."','".$dis."','".$winvalue."','"
434: .$marker."','".$return."','".$call."'".');">'.
435: &valout($value,$type).'</a><a name="'.$marker.'"></a>';
1.5 www 436: }
437:
1.44 albertel 438:
439: sub startpage {
1.137 albertel 440: my ($r,$id,$udom,$csec,$uname,$have_assesments,$trimheader)=@_;
1.99 albertel 441:
1.120 www 442: my $bodytag=&Apache::loncommon::bodytag('Set/Modify Course Parameters','',
1.98 www 443: 'onUnload="pclose()"');
1.194 albertel 444: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Table');
1.81 www 445: my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '.
446: &Apache::loncommon::selectstudent_link('parmform','uname','udom');
447: my $selscript=&Apache::loncommon::studentbrowser_javascript();
1.88 matthew 448: my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
1.133 www 449: my %lt=&Apache::lonlocal::texthash(
450: 'cep' => "Course Environment Parameters",
451: 'scep' => "Set Course Environment Parameters",
452: 'smcap' => "Set/Modify Course Assessment Parameter",
453: 'mcap' => "Modify Course Assessment Parameters",
454: 'caphm' => "Course Assessment Parameter - Helper Mode",
455: 'capom' => "Course Assessment Parameters - Overview Mode",
456: 'captm' => "Course Assessments Parameters - Table Mode",
457: 'sg' => "Section/Group",
458: 'fu' => "For User",
459: 'oi' => "or ID",
460: 'ad' => "at Domain"
461: );
1.148 www 462: my $overallhelp=
1.166 albertel 463: &Apache::loncommon::help_open_menu('','Setting Parameters','Course_Setting_Parameters','',10,'Instructor Interface');
1.146 www 464: my $assessparmhelp=&Apache::loncommon::help_open_topic("Cascading_Parameters","Assessment Parameters");
1.183 albertel 465: my $html=&Apache::lonxml::xmlbegin();
1.44 albertel 466: $r->print(<<ENDHEAD);
1.183 albertel 467: $html
1.44 albertel 468: <head>
469: <title>LON-CAPA Course Parameters</title>
470: <script>
471:
472: function pclose() {
473: parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
474: "height=350,width=350,scrollbars=no,menubar=no");
475: parmwin.close();
476: }
477:
1.88 matthew 478: $pjump_def
1.44 albertel 479:
480: function psub() {
481: pclose();
482: if (document.parmform.pres_marker.value!='') {
483: document.parmform.action+='#'+document.parmform.pres_marker.value;
484: var typedef=new Array();
485: typedef=document.parmform.pres_type.value.split('_');
486: if (document.parmform.pres_type.value!='') {
487: if (typedef[0]=='date') {
488: eval('document.parmform.recent_'+
489: document.parmform.pres_type.value+
490: '.value=document.parmform.pres_value.value;');
491: } else {
492: eval('document.parmform.recent_'+typedef[0]+
493: '.value=document.parmform.pres_value.value;');
494: }
495: }
496: document.parmform.submit();
497: } else {
498: document.parmform.pres_value.value='';
499: document.parmform.pres_marker.value='';
500: }
501: }
502:
1.57 albertel 503: function openWindow(url, wdwName, w, h, toolbar,scrollbar) {
504: var options = "width=" + w + ",height=" + h + ",";
505: options += "resizable=yes,scrollbars="+scrollbar+",status=no,";
506: options += "menubar=no,toolbar="+toolbar+",location=no,directories=no";
507: var newWin = window.open(url, wdwName, options);
508: newWin.focus();
509: }
1.44 albertel 510: </script>
1.81 www 511: $selscript
1.44 albertel 512: </head>
1.64 www 513: $bodytag
1.193 albertel 514: $breadcrumbs
1.166 albertel 515: $overallhelp
1.137 albertel 516: ENDHEAD
1.91 bowersj2 517:
1.137 albertel 518: unless ($trimheader) {$r->print(<<ENDHEAD2);
1.44 albertel 519: <form method="post" action="/adm/parmset" name="envform">
1.133 www 520: <h4>$lt{'cep'}</h4>
521: <input type="submit" name="crsenv" value="$lt{'scep'}" />
1.120 www 522: </form>
523: <hr />
1.146 www 524: $assessparmhelp
1.120 www 525: <form method="post" action="/adm/helper/parameter.helper" name="helpform">
1.133 www 526: <h4>$lt{'caphm'}</h4>
527: <input type="submit" value="$lt{'smcap'}" />
1.120 www 528: </form>
529: <hr />
530: <form method="post" action="/adm/parmset" name="overview">
1.133 www 531: <h4>$lt{'capom'}</h4>
532: <input type="submit" name="overview" value="$lt{'mcap'}" />
1.44 albertel 533: </form>
1.101 www 534: <hr />
1.137 albertel 535: ENDHEAD2
1.189 www 536: }
537: my %sectionhash=();
538: my $sections='';
539: if (&Apache::loncommon::get_sections(
1.190 albertel 540: $env{'course.'.$env{'request.course.id'}.'.domain'},
541: $env{'course.'.$env{'request.course.id'}.'.num'},
1.189 www 542: \%sectionhash)) {
543: $sections=$lt{'sg'}.': <select name="csec">';
544: foreach ('',sort keys %sectionhash) {
545: $sections.='<option value="'.$_.'"'.
546: ($_ eq $csec?'selected="selected"':'').'>'.$_.'</option>';
547: }
548: $sections.='</select>';
549: }
550: $r->print(<<ENDHEAD3);
1.193 albertel 551: <form method="post" action="/adm/parmset?action=settable" name="parmform">
1.133 www 552: <h4>$lt{'captm'}</h4>
1.137 albertel 553: ENDHEAD3
1.99 albertel 554:
555: if (!$have_assesments) {
1.133 www 556: $r->print('<font color="red">'.&mt('There are no assesment parameters in this course to set.').'</font><br />');
1.99 albertel 557: } else {
558: $r->print(<<ENDHEAD);
1.44 albertel 559: <b>
1.189 www 560: $sections
1.188 www 561: <br />
1.133 www 562: $lt{'fu'}
1.188 www 563: <input type="text" value="$uname" size="12" name="uname" />
1.133 www 564: $lt{'oi'}
1.188 www 565: <input type="text" value="$id" size="12" name="id" />
1.133 www 566: $lt{'ad'}
1.81 www 567: $chooseopt
1.44 albertel 568: </b>
569: <input type="hidden" value='' name="pres_value">
570: <input type="hidden" value='' name="pres_type">
571: <input type="hidden" value='' name="pres_marker">
572: ENDHEAD
1.99 albertel 573: }
1.44 albertel 574: }
575:
576: sub print_row {
1.66 www 577: my ($r,$which,$part,$name,$rid,$default,$defaulttype,$display,$defbgone,
1.187 www 578: $defbgtwo,$parmlev,$uname,$udom,$csec)=@_;
1.66 www 579: # get the values for the parameter in cascading order
580: # empty levels will remain empty
1.44 albertel 581: my ($result,@outpar)=&parmval($$part{$which}.'.'.$$name{$which},
1.187 www 582: $rid,$$default{$which},$uname,$udom,$csec);
1.66 www 583: # get the type for the parameters
584: # problem: these may not be set for all levels
585: my ($typeresult,@typeoutpar)=&parmval($$part{$which}.'.'.
586: $$name{$which}.'.type',
1.187 www 587: $rid,$$defaulttype{$which},$uname,$udom,$csec);
1.66 www 588: # cascade down manually
1.182 albertel 589: my $cascadetype=$$defaulttype{$which};
590: for (my $i=11;$i>0;$i--) {
1.66 www 591: if ($typeoutpar[$i]) {
592: $cascadetype=$typeoutpar[$i];
593: } else {
594: $typeoutpar[$i]=$cascadetype;
595: }
596: }
1.57 albertel 597: my $parm=$$display{$which};
598:
599: if ($parmlev eq 'full' || $parmlev eq 'brief') {
600: $r->print('<td bgcolor='.$defbgtwo.' align="center">'
601: .$$part{$which}.'</td>');
602: } else {
603: $parm=~s|\[.*\]\s||g;
604: }
605:
1.159 albertel 606: $r->print('<td bgcolor='.$defbgone.'>'.$parm.'</td>');
1.57 albertel 607:
1.44 albertel 608: my $thismarker=$which;
609: $thismarker=~s/^parameter\_//;
610: my $mprefix=$rid.'&'.$thismarker.'&';
611:
1.57 albertel 612: if ($parmlev eq 'general') {
613:
614: if ($uname) {
1.66 www 615: &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 616: } elsif ($csec) {
1.66 www 617: &print_td($r,6,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 618: } else {
1.182 albertel 619: &print_td($r,11,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 620: }
621: } elsif ($parmlev eq 'map') {
622:
623: if ($uname) {
1.66 www 624: &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 625: } elsif ($csec) {
1.66 www 626: &print_td($r,5,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 627: } else {
1.182 albertel 628: &print_td($r,10,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 629: }
630: } else {
631:
1.182 albertel 632: &print_td($r,11,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 633:
634: if ($parmlev eq 'brief') {
635:
1.66 www 636: &print_td($r,7,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 637:
638: if ($csec) {
1.66 www 639: &print_td($r,4,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 640: }
641: if ($uname) {
1.66 www 642: &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 643: }
644: } else {
645:
1.182 albertel 646: &print_td($r,10,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
647: &print_td($r,9,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
648: &print_td($r,8,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.66 www 649: &print_td($r,7,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 650:
651: if ($csec) {
1.66 www 652: &print_td($r,6,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
653: &print_td($r,5,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
654: &print_td($r,4,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 655: }
656: if ($uname) {
1.66 www 657: &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
658: &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
659: &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 660: }
661: } # end of $brief if/else
662: } # end of $parmlev if/else
663:
1.136 albertel 664: $r->print('<td bgcolor=#CCCCFF align="center">'.
665: &valout($outpar[$result],$typeoutpar[$result]).'</td>');
666:
1.57 albertel 667: if ($parmlev eq 'full' || $parmlev eq 'brief') {
1.136 albertel 668: my $sessionval=&Apache::lonnet::EXT('resource.'.$$part{$which}.
1.57 albertel 669: '.'.$$name{$which},$symbp{$rid});
1.136 albertel 670:
1.70 albertel 671: # this doesn't seem to work, and I don't think is correct
672: # my $sessionvaltype=&Apache::lonnet::EXT('resource.'.$$part{$which}.
673: # '.'.$$name{$which}.'.type',$symbp{$rid});
674: # this seems to work
1.136 albertel 675: my $sessionvaltype=$typeoutpar[$result];
676: if (!defined($sessionvaltype)) { $sessionvaltype=$$defaulttype{$which}; }
677: $r->print('<td bgcolor=#999999 align="center"><font color=#FFFFFF>'.
1.66 www 678: &valout($sessionval,$sessionvaltype).' '.
1.57 albertel 679: '</font></td>');
1.136 albertel 680: }
1.44 albertel 681: $r->print('</tr>');
1.57 albertel 682: $r->print("\n");
1.44 albertel 683: }
1.59 matthew 684:
1.44 albertel 685: sub print_td {
1.66 www 686: my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display)=@_;
1.57 albertel 687: $r->print('<td bgcolor='.(($result==$which)?'"#AAFFAA"':$defbg).
1.114 www 688: ' align="center">');
1.182 albertel 689: if ($which<8 || $which > 9) {
1.114 www 690: $r->print(&plink($$typeoutpar[$which],
691: $$display{$value},$$outpar[$which],
692: $mprefix."$which",'parmform.pres','psub'));
693: } else {
694: $r->print(&valout($$outpar[$which],$$typeoutpar[$which]));
695: }
696: $r->print('</td>'."\n");
1.57 albertel 697: }
698:
1.63 bowersj2 699: =pod
700:
701: =item B<extractResourceInformation>: Given the course data hash, extractResourceInformation extracts lots of information about the course's resources into a variety of hashes.
702:
703: Input: See list below:
704:
705: =over 4
706:
707: =item B<ids>: An array that will contain all of the ids in the course.
708:
709: =item B<typep>: hash, id->type, where "type" contains the extension of the file, thus, I<problem exam quiz assess survey form>.
710:
1.171 www 711: =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 712:
713: =item B<allparms>: hash, name of parameter->display value (what is the display value?)
714:
715: =item B<allparts>: hash, part identification->text representation of part, where the text representation is "[Part $part]"
716:
717: =item B<allkeys>: hash, full key to part->display value (what's display value?)
718:
719: =item B<allmaps>: hash, ???
720:
721: =item B<fcat>: ???
722:
723: =item B<defp>: hash, ???
724:
725: =item B<mapp>: ??
726:
727: =item B<symbp>: hash, id->full sym?
728:
729: =back
730:
731: =cut
732:
733: sub extractResourceInformation {
734: my $ids = shift;
735: my $typep = shift;
736: my $keyp = shift;
737: my $allparms = shift;
738: my $allparts = shift;
739: my $allkeys = shift;
740: my $allmaps = shift;
741: my $fcat = shift;
742: my $defp = shift;
743: my $mapp = shift;
744: my $symbp = shift;
1.82 www 745: my $maptitles=shift;
1.196 www 746: my $uris=shift;
747:
1.63 bowersj2 748:
1.196 www 749: my $navmap = Apache::lonnavmaps::navmap->new();
750: my @allres=$navmap->retrieveResources(undef,undef,1,undef,1);
751: foreach my $resource (@allres) {
752: my $id=$resource->id();
753: my ($mapid,$resid)=split(/\./,$id);
754: if ($mapid eq '0') { next; }
755: $$ids[$#$ids+1]=$id;
756: my $srcf=$resource->src();
757: $srcf=~/\.(\w+)$/;
758: $$typep{$id}=$1;
759: $$keyp{$id}='';
760: $$uris{$id}=$srcf;
761: foreach (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) {
762: if ($_=~/^parameter\_(.*)/) {
763: my $key=$_;
764: my $allkey=$1;
765: $allkey=~s/\_/\./g;
766: if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq
767: 'parm') {
768: next; #hide hidden things
1.63 bowersj2 769: }
1.196 www 770: my $display= &Apache::lonnet::metadata($srcf,$key.'.display');
771: my $name=&Apache::lonnet::metadata($srcf,$key.'.name');
772: my $part= &Apache::lonnet::metadata($srcf,$key.'.part');
773: my $parmdis = $display;
774: $parmdis =~ s|(\[Part.*)$||g;
775: my $partkey = $part;
776: $partkey =~ tr|_|.|;
777: $$allparms{$name} = $parmdis;
778: $$allparts{$part} = "[Part $part]";
779: $$allkeys{$allkey}=$display;
780: if ($allkey eq $fcat) {
781: $$defp{$id}= &Apache::lonnet::metadata($srcf,$key);
782: }
783: if ($$keyp{$id}) {
784: $$keyp{$id}.=','.$key;
1.175 albertel 785: } else {
1.196 www 786: $$keyp{$id}=$key;
1.175 albertel 787: }
1.63 bowersj2 788: }
789: }
1.196 www 790: $$mapp{$id}=
791: &Apache::lonnet::declutter($resource->enclosing_map_src());
792: $$mapp{$mapid}=$$mapp{$id};
793: $$allmaps{$mapid}=$$mapp{$id};
794: if ($mapid eq '1') {
795: $$maptitles{$mapid}='Main Course Documents';
796: } else {
797: $$maptitles{$mapid}=&Apache::lonnet::gettitle(&Apache::lonnet::clutter($$mapp{$id}));
798: }
799: $$maptitles{$$mapp{$id}}=$$maptitles{$mapid};
800: $$symbp{$id}=&Apache::lonnet::encode_symb($$mapp{$id},$resid,$srcf);
801: $$symbp{$mapid}=$$mapp{$id}.'___(all)';
1.63 bowersj2 802: }
803: }
804:
1.59 matthew 805: ##################################################
806: ##################################################
807:
808: =pod
809:
810: =item assessparms
811:
812: Show assessment data and parameters. This is a large routine that should
813: be simplified and shortened... someday.
814:
815: Inputs: $r
816:
817: Returns: nothing
818:
1.63 bowersj2 819: Variables used (guessed by Jeremy):
820:
821: =over 4
822:
823: =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.
824:
825: =item B<psprt>: ParameterS PaRTs? a list of the parts of a problem that we are displaying? Used to display only selected parts?
826:
827: =item B<allmaps>:
828:
829: =back
830:
1.59 matthew 831: =cut
832:
833: ##################################################
834: ##################################################
1.30 www 835: sub assessparms {
1.1 www 836:
1.43 albertel 837: my $r=shift;
1.2 www 838: # -------------------------------------------------------- Variable declaration
1.129 www 839: my %allkeys=();
840: my %allmaps=();
841: my %alllevs=();
1.57 albertel 842:
1.187 www 843: my $uname;
844: my $udom;
845: my $uhome;
846: my $csec;
847:
1.190 albertel 848: my $coursename=$env{'course.'.$env{'request.course.id'}.'.description'};
1.187 www 849:
1.57 albertel 850: $alllevs{'Resource Level'}='full';
851: $alllevs{'Map Level'}='map';
852: $alllevs{'Course Level'}='general';
853:
854: my %allparms;
855: my %allparts;
856:
1.43 albertel 857: my %defp;
858:
859: @ids=();
860: %symbp=();
861: %typep=();
862:
863: my $message='';
864:
1.190 albertel 865: $csec=$env{'form.csec'};
1.188 www 866:
1.190 albertel 867: if ($udom=$env{'form.udom'}) {
868: } elsif ($udom=$env{'request.role.domain'}) {
869: } elsif ($udom=$env{'user.domain'}) {
1.172 albertel 870: } else {
871: $udom=$r->dir_config('lonDefDomain');
872: }
1.43 albertel 873:
1.134 albertel 874: my @pscat=&Apache::loncommon::get_env_multiple('form.pscat');
1.190 albertel 875: my $pschp=$env{'form.pschp'};
1.134 albertel 876: my @psprt=&Apache::loncommon::get_env_multiple('form.psprt');
1.76 www 877: if (!@psprt) { $psprt[0]='0'; }
1.190 albertel 878: my $showoptions=$env{'form.showoptions'};
1.57 albertel 879:
1.43 albertel 880: my $pssymb='';
1.57 albertel 881: my $parmlev='';
1.137 albertel 882: my $trimheader='';
1.190 albertel 883: my $prevvisit=$env{'form.prevvisit'};
1.57 albertel 884:
1.190 albertel 885: unless ($env{'form.parmlev'}) {
1.57 albertel 886: $parmlev = 'map';
887: } else {
1.190 albertel 888: $parmlev = $env{'form.parmlev'};
1.57 albertel 889: }
1.26 www 890:
1.29 www 891: # ----------------------------------------------- Was this started from grades?
892:
1.190 albertel 893: if (($env{'form.command'} eq 'set') && ($env{'form.url'})
894: && (!$env{'form.dis'})) {
895: my $url=$env{'form.url'};
1.194 albertel 896: $url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
1.43 albertel 897: $pssymb=&Apache::lonnet::symbread($url);
1.92 albertel 898: if (!@pscat) { @pscat=('all'); }
1.43 albertel 899: $pschp='';
1.57 albertel 900: $parmlev = 'full';
1.137 albertel 901: $trimheader='yes';
1.190 albertel 902: } elsif ($env{'form.symb'}) {
903: $pssymb=$env{'form.symb'};
1.92 albertel 904: if (!@pscat) { @pscat=('all'); }
1.43 albertel 905: $pschp='';
1.57 albertel 906: $parmlev = 'full';
1.137 albertel 907: $trimheader='yes';
1.43 albertel 908: } else {
1.190 albertel 909: $env{'form.url'}='';
1.43 albertel 910: }
911:
1.190 albertel 912: my $id=$env{'form.id'};
1.43 albertel 913: if (($id) && ($udom)) {
914: $uname=(&Apache::lonnet::idget($udom,$id))[1];
915: if ($uname) {
916: $id='';
917: } else {
918: $message=
1.133 www 919: "<font color=red>".&mt("Unknown ID")." '$id' ".
920: &mt('at domain')." '$udom'</font>";
1.43 albertel 921: }
922: } else {
1.190 albertel 923: $uname=$env{'form.uname'};
1.43 albertel 924: }
925: unless ($udom) { $uname=''; }
926: $uhome='';
927: if ($uname) {
928: $uhome=&Apache::lonnet::homeserver($uname,$udom);
929: if ($uhome eq 'no_host') {
930: $message=
1.133 www 931: "<font color=red>".&mt("Unknown user")." '$uname' ".
932: &mt("at domain")." '$udom'</font>";
1.43 albertel 933: $uname='';
1.12 www 934: } else {
1.103 albertel 935: $csec=&Apache::lonnet::getsection($udom,$uname,
1.190 albertel 936: $env{'request.course.id'});
1.43 albertel 937: if ($csec eq '-1') {
938: $message="<font color=red>".
1.133 www 939: &mt("User")." '$uname' ".&mt("at domain")." '$udom' ".
940: &mt("not in this course")."</font>";
1.43 albertel 941: $uname='';
1.190 albertel 942: $csec=$env{'form.csec'};
1.43 albertel 943: } else {
944: my %name=&Apache::lonnet::userenvironment($udom,$uname,
945: ('firstname','middlename','lastname','generation','id'));
1.133 www 946: $message="\n<p>\n".&mt("Full Name").": ".
1.43 albertel 947: $name{'firstname'}.' '.$name{'middlename'}.' '
948: .$name{'lastname'}.' '.$name{'generation'}.
1.133 www 949: "<br>\n".&mt('ID').": ".$name{'id'}.'<p>';
1.43 albertel 950: }
1.12 www 951: }
1.43 albertel 952: }
1.2 www 953:
1.43 albertel 954: unless ($csec) { $csec=''; }
1.12 www 955:
1.190 albertel 956: my $fcat=$env{'form.fcat'};
1.43 albertel 957: unless ($fcat) { $fcat=''; }
1.2 www 958:
1.14 www 959: # --------------------------------------------------------- Get all assessments
1.196 www 960: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allkeys, \%allmaps, $fcat, \%defp, \%mapp, \%symbp,\%maptitles,\%uris);
1.63 bowersj2 961:
1.57 albertel 962: $mapp{'0.0'} = '';
963: $symbp{'0.0'} = '';
1.99 albertel 964:
1.14 www 965: # ---------------------------------------------------------- Anything to store?
1.190 albertel 966: if ($env{'form.pres_marker'}) {
967: $message.=&storeparm(split(/\&/,$env{'form.pres_marker'}),
968: $env{'form.pres_value'},
969: $env{'form.pres_type'},
1.187 www 970: $uname,$udom,$csec);
1.68 www 971: # ---------------------------------------------------------------- Done storing
1.130 www 972: $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 973: }
1.2 www 974: # ------------------------------------------------------------------- Sort this
1.17 www 975:
1.44 albertel 976: @ids=sort {
977: if ($fcat eq '') {
978: $a<=>$b;
979: } else {
1.187 www 980: my ($result,@outpar)=&parmval($fcat,$a,$defp{$a},$uname,$udom,$csec);
1.44 albertel 981: my $aparm=$outpar[$result];
1.187 www 982: ($result,@outpar)=&parmval($fcat,$b,$defp{$b},$uname,$udom,$csec);
1.44 albertel 983: my $bparm=$outpar[$result];
984: 1*$aparm<=>1*$bparm;
985: }
986: } @ids;
1.57 albertel 987: #----------------------------------------------- if all selected, fill in array
988: if ($pscat[0] eq "all" || !@pscat) {@pscat = (keys %allparms);}
989: if ($psprt[0] eq "all" || !@psprt) {@psprt = (keys %allparts);}
1.2 www 990: # ------------------------------------------------------------------ Start page
1.63 bowersj2 991:
1.99 albertel 992: my $have_assesments=1;
993: if (scalar(keys(%allkeys)) eq 0) { $have_assesments=0; }
994:
1.193 albertel 995: $trimheader = 'yes';
1.137 albertel 996: &startpage($r,$id,$udom,$csec,$uname,$have_assesments,$trimheader);
1.99 albertel 997:
1.190 albertel 998: # if ($env{'form.url'}) {
999: # $r->print('<input type="hidden" value="'.$env{'form.url'}.
1.44 albertel 1000: # '" name="url"><input type="hidden" name="command" value="set">');
1001: # }
1.57 albertel 1002: $r->print('<input type="hidden" value="true" name="prevvisit">');
1003:
1.44 albertel 1004: foreach ('tolerance','date_default','date_start','date_end',
1005: 'date_interval','int','float','string') {
1006: $r->print('<input type="hidden" value="'.
1.190 albertel 1007: $env{'form.recent_'.$_}.'" name="recent_'.$_.'">');
1.44 albertel 1008: }
1009:
1.57 albertel 1010: $r->print('<h2>'.$message.'</h2><table>');
1011:
1.130 www 1012: my $submitmessage = &mt('Update Section or Specific User');
1.44 albertel 1013: if (!$pssymb) {
1.160 www 1014: $r->print('<tr><td>'.&mt('Select Parameter Level').
1015: &Apache::loncommon::help_open_topic('Course_Parameter_Levels').
1016: '</td><td colspan="2">');
1.57 albertel 1017: $r->print('<select name="parmlev">');
1018: foreach (reverse sort keys %alllevs) {
1019: $r->print('<option value="'.$alllevs{$_}.'"');
1020: if ($parmlev eq $alllevs{$_}) {
1021: $r->print(' selected');
1022: }
1023: $r->print('>'.$_.'</option>');
1024: }
1025: $r->print("</select></td>\n");
1026:
1.101 www 1027: $r->print('</tr>');
1.128 albertel 1028: if ($parmlev ne 'general') {
1.130 www 1029: $r->print('<tr><td>'.&mt('Select Enclosing Map or Folder').'</td>');
1.128 albertel 1030: $r->print('<td colspan="2"><select name="pschp">');
1.130 www 1031: $r->print('<option value="all">'.&mt('All Maps or Folders').'</option>');
1.128 albertel 1032: foreach (sort {$allmaps{$a} cmp $allmaps{$b}} keys %allmaps) {
1033: $r->print('<option value="'.$_.'"');
1034: if (($pschp eq $_)) { $r->print(' selected'); }
1035: $r->print('>'.$maptitles{$_}.($allmaps{$_}!~/^uploaded/?' ['.$allmaps{$_}.']':'').'</option>');
1036: }
1037: $r->print("</select></td></tr>\n");
1038: }
1.44 albertel 1039: } else {
1.125 www 1040: my ($map,$id,$resource)=&Apache::lonnet::decode_symb($pssymb);
1.130 www 1041: $r->print("<tr><td>".&mt('Specific Resource')."</td><td>$resource</td>");
1.57 albertel 1042: $r->print('<td><input type="submit" name="dis" value="'.$submitmessage.'"></td>');
1043: $r->print('</tr>');
1044: $r->print('<input type="hidden" value="'.$pssymb.'" name="symb">');
1045: }
1046:
1.185 albertel 1047: $r->print('<tr><td colspan="3"><hr /><label><input type="checkbox"');
1.57 albertel 1048: if ($showoptions eq 'show') {$r->print(" checked ");}
1.185 albertel 1049: $r->print(' name="showoptions" value="show" />'.&mt('Show More Options').'</label><hr /></td></tr>');
1.57 albertel 1050: # $r->print("<tr><td>Show: $showoptions</td></tr>");
1051: # $r->print("<tr><td>pscat: @pscat</td></tr>");
1052: # $r->print("<tr><td>psprt: @psprt</td></tr>");
1053: # $r->print("<tr><td>fcat: $fcat</td></tr>");
1054:
1055: if ($showoptions eq 'show') {
1056: my $tempkey;
1057:
1.130 www 1058: $r->print('<tr><td colspan="3" align="center">'.&mt('Select Parameters to View').'</td></tr>');
1.57 albertel 1059:
1.176 albertel 1060: $r->print('<tr><td colspan="2"><table><tr>');
1.57 albertel 1061: my $cnt=0;
1062: foreach $tempkey (sort { $allparms{$a} cmp $allparms{$b} }
1063: keys %allparms ) {
1064: ++$cnt;
1.176 albertel 1065: $r->print('</tr><tr>') if ($cnt%2);
1.57 albertel 1066: $r->print('<td><input type="checkbox" name="pscat" ');
1067: $r->print('value="'.$tempkey.'"');
1068: if ($pscat[0] eq "all" || grep $_ eq $tempkey, @pscat) {
1069: $r->print(' checked');
1070: }
1.176 albertel 1071: $r->print('>'.$allparms{$tempkey}.'</td>');
1072: }
1073: $r->print('
1074: </tr><tr><td>
1075: <script type="text/javascript">
1076: function checkall(value, checkName) {
1077: for (i=0; i<document.forms.parmform.elements.length; i++) {
1078: ele = document.forms.parmform.elements[i];
1079: if (ele.name == checkName) {
1080: document.forms.parmform.elements[i].checked=value;
1081: }
1.57 albertel 1082: }
1.176 albertel 1083: }
1084: </script>
1085: <input type="button" onclick="checkall(true, \'pscat\')" value="Select All" />
1086: </td><td>
1087: <input type="button" onclick="checkall(false, \'pscat\')" value="Unselect All" />
1088: </td>
1089: ');
1.57 albertel 1090: $r->print('</tr></table>');
1091:
1092: # $r->print('<tr><td>Select Parts</td><td>');
1093: $r->print('<td><select multiple name="psprt" size="5">');
1094: $r->print('<option value="all"');
1095: $r->print(' selected') unless (@psprt);
1.130 www 1096: $r->print('>'.&mt('All Parts').'</option>');
1.76 www 1097: my %temphash=();
1098: foreach (@psprt) { $temphash{$_}=1; }
1.57 albertel 1099: foreach $tempkey (sort keys %allparts) {
1100: unless ($tempkey =~ /\./) {
1101: $r->print('<option value="'.$tempkey.'"');
1.76 www 1102: if ($psprt[0] eq "all" || $temphash{$tempkey}) {
1.57 albertel 1103: $r->print(' selected');
1104: }
1105: $r->print('>'.$allparts{$tempkey}.'</option>');
1106: }
1107: }
1108: $r->print('</select></td></tr><tr><td colspan="3"><hr /></td></tr>');
1109:
1.130 www 1110: $r->print('<tr><td>'.&mt('Sort list by').'</td><td>');
1.57 albertel 1111: $r->print('<select name="fcat">');
1.130 www 1112: $r->print('<option value="">'.&mt('Enclosing Map or Folder').'</option>');
1.57 albertel 1113: foreach (sort keys %allkeys) {
1114: $r->print('<option value="'.$_.'"');
1115: if ($fcat eq $_) { $r->print(' selected'); }
1116: $r->print('>'.$allkeys{$_}.'</option>');
1117: }
1118: $r->print('</select></td>');
1119:
1120: $r->print('</tr><tr><td colspan="3"><hr /></td></tr>');
1121:
1122: } else { # hide options - include any necessary extras here
1123:
1124: $r->print('<input type="hidden" name="fcat" value="'.$fcat.'">'."\n");
1125:
1126: unless (@pscat) {
1127: foreach (keys %allparms ) {
1128: $r->print('<input type="hidden" name="pscat" value="'.$_.'">'."\n");
1129: }
1130: } else {
1131: foreach (@pscat) {
1132: $r->print('<input type="hidden" name="pscat" value="'.$_.'">'."\n");
1133: }
1134: }
1135:
1136: unless (@psprt) {
1137: foreach (keys %allparts ) {
1138: $r->print('<input type="hidden" name="psprt" value="'.$_.'">'."\n");
1139: }
1140: } else {
1141: foreach (@psprt) {
1142: $r->print('<input type="hidden" name="psprt" value="'.$_.'">'."\n");
1143: }
1144: }
1145:
1.44 albertel 1146: }
1.101 www 1147: $r->print('</table><br />');
1148: if (($prevvisit) || ($pschp) || ($pssymb)) {
1.130 www 1149: $submitmessage = &mt("Update Course Assessment Parameter Display");
1.101 www 1150: } else {
1.130 www 1151: $submitmessage = &mt("Set/Modify Course Assessment Parameters");
1.101 www 1152: }
1153: $r->print('<input type="submit" name="dis" value="'.$submitmessage.'">');
1.57 albertel 1154:
1.76 www 1155: # my @temp_psprt;
1156: # foreach my $t (@psprt) {
1157: # push(@temp_psprt, grep {eval (/^$t\./ || ($_ == $t))} (keys %allparts));
1158: # }
1.57 albertel 1159:
1.76 www 1160: # @psprt = @temp_psprt;
1.57 albertel 1161:
1162: my @temp_pscat;
1163: map {
1164: my $cat = $_;
1165: push(@temp_pscat, map { $_.'.'.$cat } @psprt);
1166: } @pscat;
1167:
1168: @pscat = @temp_pscat;
1169:
1170: if (($prevvisit) || ($pschp) || ($pssymb)) {
1.10 www 1171: # ----------------------------------------------------------------- Start Table
1.57 albertel 1172: my @catmarker=map { tr|.|_|; 'parameter_'.$_; } @pscat;
1.190 albertel 1173: my $csuname=$env{'user.name'};
1174: my $csudom=$env{'user.domain'};
1.57 albertel 1175:
1176: if ($parmlev eq 'full' || $parmlev eq 'brief') {
1177: my $coursespan=$csec?8:5;
1178: $r->print('<p><table border=2>');
1179: $r->print('<tr><td colspan=5></td>');
1.130 www 1180: $r->print('<th colspan='.($coursespan).'>'.&mt('Any User').'</th>');
1.57 albertel 1181: if ($uname) {
1182: $r->print("<th colspan=3 rowspan=2>");
1.130 www 1183: $r->print(&mt("User")." $uname ".&mt('at Domain')." $udom</th>");
1.57 albertel 1184: }
1.133 www 1185: my %lt=&Apache::lonlocal::texthash(
1186: 'pie' => "Parameter in Effect",
1187: 'csv' => "Current Session Value",
1188: 'at' => 'at',
1189: 'rl' => "Resource Level",
1190: 'ic' => 'in Course',
1191: 'aut' => "Assessment URL and Title",
1.143 albertel 1192: 'type' => 'Type',
1.133 www 1193: 'emof' => "Enclosing Map or Folder",
1.143 albertel 1194: 'part' => 'Part',
1.133 www 1195: 'pn' => 'Parameter Name',
1196: 'def' => 'default',
1197: 'femof' => 'from Enclosing Map or Folder',
1198: 'gen' => 'general',
1199: 'foremf' => 'for Enclosing Map or Folder',
1200: 'fr' => 'for Resource'
1201: );
1.57 albertel 1202: $r->print(<<ENDTABLETWO);
1.133 www 1203: <th rowspan=3>$lt{'pie'}</th>
1204: <th rowspan=3>$lt{'csv'}<br>($csuname $lt{'at'} $csudom)</th>
1.182 albertel 1205: </tr><tr><td colspan=5></td><th colspan=2>$lt{'ic'}</th><th colspan=2>$lt{'rl'}</th>
1206: <th colspan=1>$lt{'ic'}</th>
1207:
1.10 www 1208: ENDTABLETWO
1.57 albertel 1209: if ($csec) {
1.133 www 1210: $r->print("<th colspan=3>".
1211: &mt("in Section/Group")." $csec</th>");
1.57 albertel 1212: }
1213: $r->print(<<ENDTABLEHEADFOUR);
1.133 www 1214: </tr><tr><th>$lt{'aut'}</th><th>$lt{'type'}</th>
1215: <th>$lt{'emof'}</th><th>$lt{'part'}</th><th>$lt{'pn'}</th>
1.192 albertel 1216: <th>$lt{'gen'}</th><th>$lt{'foremf'}</th>
1217: <th>$lt{'def'}</th><th>$lt{'femof'}</th><th>$lt{'fr'}</th>
1.10 www 1218: ENDTABLEHEADFOUR
1.57 albertel 1219:
1220: if ($csec) {
1.130 www 1221: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
1.57 albertel 1222: }
1223:
1224: if ($uname) {
1.130 www 1225: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
1.57 albertel 1226: }
1227:
1228: $r->print('</tr>');
1229:
1230: my $defbgone='';
1231: my $defbgtwo='';
1232:
1233: foreach (@ids) {
1234:
1235: my $rid=$_;
1236: my ($inmapid)=($rid=~/\.(\d+)$/);
1237:
1.152 albertel 1238: if ((!$pssymb &&
1239: (($pschp eq 'all') || ($allmaps{$pschp} eq $mapp{$rid})))
1240: ||
1241: ($pssymb && $pssymb eq $symbp{$rid})) {
1.4 www 1242: # ------------------------------------------------------ Entry for one resource
1.184 albertel 1243: if ($defbgone eq '"#E0E099"') {
1244: $defbgone='"#E0E0DD"';
1.57 albertel 1245: } else {
1.184 albertel 1246: $defbgone='"#E0E099"';
1.57 albertel 1247: }
1.184 albertel 1248: if ($defbgtwo eq '"#FFFF99"') {
1249: $defbgtwo='"#FFFFDD"';
1.57 albertel 1250: } else {
1.184 albertel 1251: $defbgtwo='"#FFFF99"';
1.57 albertel 1252: }
1253: my $thistitle='';
1254: my %name= ();
1255: undef %name;
1256: my %part= ();
1257: my %display=();
1258: my %type= ();
1259: my %default=();
1.196 www 1260: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 1261:
1262: foreach (split(/\,/,$keyp{$rid})) {
1263: my $tempkeyp = $_;
1264: if (grep $_ eq $tempkeyp, @catmarker) {
1265: $part{$_}=&Apache::lonnet::metadata($uri,$_.'.part');
1266: $name{$_}=&Apache::lonnet::metadata($uri,$_.'.name');
1267: $display{$_}=&Apache::lonnet::metadata($uri,$_.'.display');
1268: unless ($display{$_}) { $display{$_}=''; }
1269: $display{$_}.=' ('.$name{$_}.')';
1270: $default{$_}=&Apache::lonnet::metadata($uri,$_);
1271: $type{$_}=&Apache::lonnet::metadata($uri,$_.'.type');
1272: $thistitle=&Apache::lonnet::metadata($uri,$_.'.title');
1273: }
1274: }
1275: my $totalparms=scalar keys %name;
1276: if ($totalparms>0) {
1277: my $firstrow=1;
1.180 albertel 1278: my $title=&Apache::lonnet::gettitle($uri);
1.57 albertel 1279: $r->print('<tr><td bgcolor='.$defbgone.
1280: ' rowspan='.$totalparms.
1281: '><tt><font size=-1>'.
1282: join(' / ',split(/\//,$uri)).
1283: '</font></tt><p><b>'.
1.154 albertel 1284: "<a href=\"javascript:openWindow('".
1285: &Apache::lonnet::clutter($uri).
1.57 albertel 1286: "', 'metadatafile', '450', '500', 'no', 'yes')\";".
1.127 albertel 1287: " TARGET=_self>$title");
1.57 albertel 1288:
1289: if ($thistitle) {
1290: $r->print(' ('.$thistitle.')');
1291: }
1292: $r->print('</a></b></td>');
1293: $r->print('<td bgcolor='.$defbgtwo.
1294: ' rowspan='.$totalparms.'>'.$typep{$rid}.
1295: '</td>');
1296:
1297: $r->print('<td bgcolor='.$defbgone.
1298: ' rowspan='.$totalparms.
1299: '><tt><font size=-1>');
1300:
1301: $r->print(' / res / ');
1302: $r->print(join(' / ', split(/\//,$mapp{$rid})));
1303:
1304: $r->print('</font></tt></td>');
1305:
1306: foreach (sort keys %name) {
1307: unless ($firstrow) {
1308: $r->print('<tr>');
1309: } else {
1310: undef $firstrow;
1311: }
1312:
1313: &print_row($r,$_,\%part,\%name,$rid,\%default,
1314: \%type,\%display,$defbgone,$defbgtwo,
1.187 www 1315: $parmlev,$uname,$udom,$csec);
1.57 albertel 1316: }
1317: }
1318: }
1319: } # end foreach ids
1.43 albertel 1320: # -------------------------------------------------- End entry for one resource
1.57 albertel 1321: $r->print('</table>');
1322: } # end of brief/full
1323: #--------------------------------------------------- Entry for parm level map
1324: if ($parmlev eq 'map') {
1325: my $defbgone = '"E0E099"';
1326: my $defbgtwo = '"FFFF99"';
1327:
1328: my %maplist;
1329:
1330: if ($pschp eq 'all') {
1331: %maplist = %allmaps;
1332: } else {
1333: %maplist = ($pschp => $mapp{$pschp});
1334: }
1335:
1336: #-------------------------------------------- for each map, gather information
1337: my $mapid;
1.60 albertel 1338: foreach $mapid (sort {$maplist{$a} cmp $maplist{$b}} keys %maplist) {
1339: my $maptitle = $maplist{$mapid};
1.57 albertel 1340:
1341: #----------------------- loop through ids and get all parameter types for map
1342: #----------------------------------------- and associated information
1343: my %name = ();
1344: my %part = ();
1345: my %display = ();
1346: my %type = ();
1347: my %default = ();
1348: my $map = 0;
1349:
1350: # $r->print("Catmarker: @catmarker<br />\n");
1351:
1352: foreach (@ids) {
1353: ($map)=(/([\d]*?)\./);
1354: my $rid = $_;
1355:
1356: # $r->print("$mapid:$map: $rid <br /> \n");
1357:
1358: if ($map eq $mapid) {
1.196 www 1359: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 1360: # $r->print("Keys: $keyp{$rid} <br />\n");
1361:
1362: #--------------------------------------------------------------------
1363: # @catmarker contains list of all possible parameters including part #s
1364: # $fullkeyp contains the full part/id # for the extraction of proper parameters
1365: # $tempkeyp contains part 0 only (no ids - ie, subparts)
1366: # When storing information, store as part 0
1367: # When requesting information, request from full part
1368: #-------------------------------------------------------------------
1369: foreach (split(/\,/,$keyp{$rid})) {
1370: my $tempkeyp = $_;
1371: my $fullkeyp = $tempkeyp;
1.73 albertel 1372: $tempkeyp =~ s/_\w+_/_0_/;
1.57 albertel 1373:
1374: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
1375: $part{$tempkeyp}="0";
1376: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
1377: $display{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
1378: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
1379: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
1.73 albertel 1380: $display{$tempkeyp} =~ s/_\w+_/_0_/;
1.57 albertel 1381: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
1382: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
1383: }
1384: } # end loop through keys
1385: }
1386: } # end loop through ids
1387:
1388: #---------------------------------------------------- print header information
1.133 www 1389: my $foldermap=&mt($maptitle=~/^uploaded/?'Folder':'Map');
1.82 www 1390: my $showtitle=$maptitles{$maptitle}.($maptitle!~/^uploaded/?' ['.$maptitle.']':'');
1.57 albertel 1391: $r->print(<<ENDMAPONE);
1392: <center><h4>
1.135 albertel 1393: Set Defaults for All Resources in $foldermap<br />
1394: <font color="red"><i>$showtitle</i></font><br />
1.57 albertel 1395: Specifically for
1396: ENDMAPONE
1397: if ($uname) {
1398: my %name=&Apache::lonnet::userenvironment($udom,$uname,
1399: ('firstname','middlename','lastname','generation', 'id'));
1400: my $person=$name{'firstname'}.' '.$name{'middlename'}.' '
1401: .$name{'lastname'}.' '.$name{'generation'};
1.135 albertel 1402: $r->print(&mt("User")." <font color=\"red\"><i>$uname \($person\) </i></font> ".
1.130 www 1403: &mt('in')." \n");
1.57 albertel 1404: } else {
1.135 albertel 1405: $r->print("<font color=\"red\"><i>".&mt('all').'</i></font> '.&mt('users in')." \n");
1.57 albertel 1406: }
1407:
1.135 albertel 1408: if ($csec) {$r->print(&mt("Section")." <font color=\"red\"><i>$csec</i></font> ".
1.130 www 1409: &mt('of')." \n")};
1.57 albertel 1410:
1.135 albertel 1411: $r->print("<font color=\"red\"><i>$coursename</i></font><br />");
1412: $r->print("</h4>\n");
1.57 albertel 1413: #---------------------------------------------------------------- print table
1414: $r->print('<p><table border="2">');
1.130 www 1415: $r->print('<tr><th>'.&mt('Parameter Name').'</th>');
1416: $r->print('<th>'.&mt('Default Value').'</th>');
1417: $r->print('<th>'.&mt('Parameter in Effect').'</th></tr>');
1.57 albertel 1418:
1419: foreach (sort keys %name) {
1.168 matthew 1420: $r->print('<tr>');
1.57 albertel 1421: &print_row($r,$_,\%part,\%name,$mapid,\%default,
1422: \%type,\%display,$defbgone,$defbgtwo,
1.187 www 1423: $parmlev,$uname,$udom,$csec);
1.57 albertel 1424: # $r->print("<tr><td>resource.$part{$_}.$name{$_},$symbp{$mapid}</td></tr>\n");
1425: }
1426: $r->print("</table></center>");
1427: } # end each map
1428: } # end of $parmlev eq map
1429: #--------------------------------- Entry for parm level general (Course level)
1430: if ($parmlev eq 'general') {
1431: my $defbgone = '"E0E099"';
1432: my $defbgtwo = '"FFFF99"';
1433:
1434: #-------------------------------------------- for each map, gather information
1435: my $mapid="0.0";
1436: #----------------------- loop through ids and get all parameter types for map
1437: #----------------------------------------- and associated information
1438: my %name = ();
1439: my %part = ();
1440: my %display = ();
1441: my %type = ();
1442: my %default = ();
1443:
1444: foreach (@ids) {
1445: my $rid = $_;
1446:
1.196 www 1447: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 1448:
1449: #--------------------------------------------------------------------
1450: # @catmarker contains list of all possible parameters including part #s
1451: # $fullkeyp contains the full part/id # for the extraction of proper parameters
1452: # $tempkeyp contains part 0 only (no ids - ie, subparts)
1453: # When storing information, store as part 0
1454: # When requesting information, request from full part
1455: #-------------------------------------------------------------------
1456: foreach (split(/\,/,$keyp{$rid})) {
1457: my $tempkeyp = $_;
1458: my $fullkeyp = $tempkeyp;
1.73 albertel 1459: $tempkeyp =~ s/_\w+_/_0_/;
1.57 albertel 1460: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
1461: $part{$tempkeyp}="0";
1462: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
1463: $display{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
1464: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
1465: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
1.73 albertel 1466: $display{$tempkeyp} =~ s/_\w+_/_0_/;
1.57 albertel 1467: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
1468: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
1469: }
1470: } # end loop through keys
1471: } # end loop through ids
1472:
1473: #---------------------------------------------------- print header information
1.133 www 1474: my $setdef=&mt("Set Defaults for All Resources in Course");
1.57 albertel 1475: $r->print(<<ENDMAPONE);
1.133 www 1476: <center><h4>$setdef
1.135 albertel 1477: <font color="red"><i>$coursename</i></font><br />
1.57 albertel 1478: ENDMAPONE
1479: if ($uname) {
1480: my %name=&Apache::lonnet::userenvironment($udom,$uname,
1481: ('firstname','middlename','lastname','generation', 'id'));
1482: my $person=$name{'firstname'}.' '.$name{'middlename'}.' '
1483: .$name{'lastname'}.' '.$name{'generation'};
1.135 albertel 1484: $r->print(" ".&mt("User")."<font color=\"red\"> <i>$uname \($person\) </i></font> \n");
1.57 albertel 1485: } else {
1.135 albertel 1486: $r->print("<i><font color=\"red\"> ".&mt("ALL")."</i> ".&mt("USERS")."</font> \n");
1.57 albertel 1487: }
1488:
1.135 albertel 1489: if ($csec) {$r->print(&mt("Section")."<font color=\"red\"> <i>$csec</i></font>\n")};
1490: $r->print("</h4>\n");
1.57 albertel 1491: #---------------------------------------------------------------- print table
1492: $r->print('<p><table border="2">');
1.130 www 1493: $r->print('<tr><th>'.&mt('Parameter Name').'</th>');
1494: $r->print('<th>'.&mt('Default Value').'</th>');
1495: $r->print('<th>'.&mt('Parameter in Effect').'</th></tr>');
1.57 albertel 1496:
1497: foreach (sort keys %name) {
1.168 matthew 1498: $r->print('<tr>');
1.57 albertel 1499: &print_row($r,$_,\%part,\%name,$mapid,\%default,
1.187 www 1500: \%type,\%display,$defbgone,$defbgtwo,$parmlev,$uname,$udom,$csec);
1.57 albertel 1501: # $r->print("<tr><td>resource.$part{$_}.$name{$_},$symbp{$mapid}</td></tr>\n");
1502: }
1503: $r->print("</table></center>");
1504: } # end of $parmlev eq general
1.43 albertel 1505: }
1.44 albertel 1506: $r->print('</form></body></html>');
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:
2189:
1.132 albertel 2190: @ids=();
2191: %symbp=();
2192: %mapp=();
2193: %typep=();
2194: %keyp=();
1.131 www 2195:
1.132 albertel 2196: %maptitles=();
1.83 bowersj2 2197:
1.193 albertel 2198: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.194 albertel 2199: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset",
2200: text=>"Parameter Manager",
2201: faq=>9,
2202: bug=>'Instructor Interface'});
1.30 www 2203: # ----------------------------------------------------- Needs to be in a course
1.194 albertel 2204: my $parm_permission =
2205: (&Apache::lonnet::allowed('opa',$env{'request.course.id'}) ||
1.190 albertel 2206: &Apache::lonnet::allowed('opa',$env{'request.course.id'}.'/'.
1.193 albertel 2207: $env{'request.course.sec'}));
1.194 albertel 2208: if ($env{'request.course.id'} && $parm_permission) {
1.193 albertel 2209:
2210: # Start Page
1.126 www 2211: &Apache::loncommon::content_type($r,'text/html');
1.106 www 2212: $r->send_http_header;
1.30 www 2213:
1.193 albertel 2214: #
2215: # Main switch on form.action and form.state, as appropriate
2216: #
2217: # Check first if coming from someone else headed directly for
2218: # the table mode
2219: if ((($env{'form.command'} eq 'set') && ($env{'form.url'})
2220: && (!$env{'form.dis'})) || ($env{'form.symb'})) {
2221: &assessparms($r);
2222:
2223: } elsif (! exists($env{'form.action'})) {
2224: $r->print(&header());
1.194 albertel 2225: $r->print(&Apache::lonhtmlcommon::breadcrumbs(undef,
2226: 'Parameter Manager'));
1.193 albertel 2227: &print_main_menu($r,$parm_permission);
2228: } elsif ($env{'form.action'} eq 'crsenv' && $parm_permission) {
1.194 albertel 2229: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=crsenv',
2230: text=>"Course Environment"});
2231: $r->print(&Apache::lonhtmlcommon::breadcrumbs(undef,
2232: 'Edit Course Environment'));
1.193 albertel 2233: &crsenv($r);
2234: } elsif ($env{'form.action'} eq 'setoverview' && $parm_permission) {
1.194 albertel 2235: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
2236: text=>"Overview Mode"});
1.121 www 2237: &overview($r);
1.193 albertel 2238: } elsif ($env{'form.action'} eq 'settable' && $parm_permission) {
1.194 albertel 2239: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
2240: text=>"Table Mode"});
1.121 www 2241: &assessparms($r);
1.193 albertel 2242: }
2243:
1.43 albertel 2244: } else {
1.1 www 2245: # ----------------------------- Not in a course, or not allowed to modify parms
1.190 albertel 2246: $env{'user.error.msg'}=
1.43 albertel 2247: "/adm/parmset:opa:0:0:Cannot modify assessment parameters";
2248: return HTTP_NOT_ACCEPTABLE;
2249: }
2250: return OK;
1.1 www 2251: }
2252:
2253: 1;
2254: __END__
2255:
1.59 matthew 2256: =pod
1.38 harris41 2257:
2258: =back
2259:
2260: =cut
1.1 www 2261:
2262:
2263:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>