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