Annotation of loncom/interface/loncommon.pm, revision 1.948.2.32
1.10 albertel 1: # The LearningOnline Network with CAPA
1.1 albertel 2: # a pile of common routines
1.10 albertel 3: #
1.948.2.32! raeburn 4: # $Id: loncommon.pm,v 1.948.2.31 2011/10/03 12:39:41 raeburn Exp $
1.10 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.1 albertel 28:
29: # Makes a table out of the previous attempts
1.2 albertel 30: # Inputs result_from_symbread, user, domain, course_id
1.16 harris41 31: # Reads in non-network-related .tab files
1.1 albertel 32:
1.35 matthew 33: # POD header:
34:
1.45 matthew 35: =pod
36:
1.35 matthew 37: =head1 NAME
38:
39: Apache::loncommon - pile of common routines
40:
41: =head1 SYNOPSIS
42:
1.112 bowersj2 43: Common routines for manipulating connections, student answers,
44: domains, common Javascript fragments, etc.
1.35 matthew 45:
1.112 bowersj2 46: =head1 OVERVIEW
1.35 matthew 47:
1.112 bowersj2 48: A collection of commonly used subroutines that don't have a natural
49: home anywhere else. This collection helps remove
1.35 matthew 50: redundancy from other modules and increase efficiency of memory usage.
51:
52: =cut
53:
54: # End of POD header
1.1 albertel 55: package Apache::loncommon;
56:
57: use strict;
1.258 albertel 58: use Apache::lonnet;
1.46 matthew 59: use GDBM_File;
1.51 www 60: use POSIX qw(strftime mktime);
1.82 www 61: use Apache::lonmenu();
1.498 albertel 62: use Apache::lonenc();
1.117 www 63: use Apache::lonlocal;
1.685 tempelho 64: use Apache::lonnet();
1.139 matthew 65: use HTML::Entities;
1.334 albertel 66: use Apache::lonhtmlcommon();
67: use Apache::loncoursedata();
1.344 albertel 68: use Apache::lontexconvert();
1.444 albertel 69: use Apache::lonclonecourse();
1.479 albertel 70: use LONCAPA qw(:DEFAULT :match);
1.657 raeburn 71: use DateTime::TimeZone;
1.687 raeburn 72: use DateTime::Locale::Catalog;
1.117 www 73:
1.517 raeburn 74: # ---------------------------------------------- Designs
75: use vars qw(%defaultdesign);
76:
1.22 www 77: my $readit;
78:
1.517 raeburn 79:
1.157 matthew 80: ##
81: ## Global Variables
82: ##
1.46 matthew 83:
1.643 foxr 84:
85: # ----------------------------------------------- SSI with retries:
86: #
87:
88: =pod
89:
1.648 raeburn 90: =head1 Server Side include with retries:
1.643 foxr 91:
92: =over 4
93:
1.648 raeburn 94: =item * &ssi_with_retries(resource,retries form)
1.643 foxr 95:
96: Performs an ssi with some number of retries. Retries continue either
97: until the result is ok or until the retry count supplied by the
98: caller is exhausted.
99:
100: Inputs:
1.648 raeburn 101:
102: =over 4
103:
1.643 foxr 104: resource - Identifies the resource to insert.
1.648 raeburn 105:
1.643 foxr 106: retries - Count of the number of retries allowed.
1.648 raeburn 107:
1.643 foxr 108: form - Hash that identifies the rendering options.
109:
1.648 raeburn 110: =back
111:
112: Returns:
113:
114: =over 4
115:
1.643 foxr 116: content - The content of the response. If retries were exhausted this is empty.
1.648 raeburn 117:
1.643 foxr 118: response - The response from the last attempt (which may or may not have been successful.
119:
1.648 raeburn 120: =back
121:
122: =back
123:
1.643 foxr 124: =cut
125:
126: sub ssi_with_retries {
127: my ($resource, $retries, %form) = @_;
128:
129:
130: my $ok = 0; # True if we got a good response.
131: my $content;
132: my $response;
133:
134: # Try to get the ssi done. within the retries count:
135:
136: do {
137: ($content, $response) = &Apache::lonnet::ssi($resource, %form);
138: $ok = $response->is_success;
1.650 www 139: if (!$ok) {
140: &Apache::lonnet::logthis("Failed ssi_with_retries on $resource: ".$response->is_success.', '.$response->code.', '.$response->message);
141: }
1.643 foxr 142: $retries--;
143: } while (!$ok && ($retries > 0));
144:
145: if (!$ok) {
146: $content = ''; # On error return an empty content.
147: }
148: return ($content, $response);
149:
150: }
151:
152:
153:
1.20 www 154: # ----------------------------------------------- Filetypes/Languages/Copyright
1.12 harris41 155: my %language;
1.124 www 156: my %supported_language;
1.12 harris41 157: my %cprtag;
1.192 taceyjo1 158: my %scprtag;
1.351 www 159: my %fe; my %fd; my %fm;
1.41 ng 160: my %category_extensions;
1.12 harris41 161:
1.46 matthew 162: # ---------------------------------------------- Thesaurus variables
1.144 matthew 163: #
164: # %Keywords:
165: # A hash used by &keyword to determine if a word is considered a keyword.
166: # $thesaurus_db_file
167: # Scalar containing the full path to the thesaurus database.
1.46 matthew 168:
169: my %Keywords;
170: my $thesaurus_db_file;
171:
1.144 matthew 172: #
173: # Initialize values from language.tab, copyright.tab, filetypes.tab,
174: # thesaurus.tab, and filecategories.tab.
175: #
1.18 www 176: BEGIN {
1.46 matthew 177: # Variable initialization
178: $thesaurus_db_file = $Apache::lonnet::perlvar{'lonTabDir'}."/thesaurus.db";
179: #
1.22 www 180: unless ($readit) {
1.12 harris41 181: # ------------------------------------------------------------------- languages
182: {
1.158 raeburn 183: my $langtabfile = $Apache::lonnet::perlvar{'lonTabDir'}.
184: '/language.tab';
185: if ( open(my $fh,"<$langtabfile") ) {
1.356 albertel 186: while (my $line = <$fh>) {
187: next if ($line=~/^\#/);
188: chomp($line);
189: my ($key,$two,$country,$three,$enc,$val,$sup)=(split(/\t/,$line));
1.158 raeburn 190: $language{$key}=$val.' - '.$enc;
191: if ($sup) {
192: $supported_language{$key}=$sup;
193: }
194: }
195: close($fh);
196: }
1.12 harris41 197: }
198: # ------------------------------------------------------------------ copyrights
199: {
1.158 raeburn 200: my $copyrightfile = $Apache::lonnet::perlvar{'lonIncludes'}.
201: '/copyright.tab';
202: if ( open (my $fh,"<$copyrightfile") ) {
1.356 albertel 203: while (my $line = <$fh>) {
204: next if ($line=~/^\#/);
205: chomp($line);
206: my ($key,$val)=(split(/\s+/,$line,2));
1.158 raeburn 207: $cprtag{$key}=$val;
208: }
209: close($fh);
210: }
1.12 harris41 211: }
1.351 www 212: # ----------------------------------------------------------- source copyrights
1.192 taceyjo1 213: {
214: my $sourcecopyrightfile = $Apache::lonnet::perlvar{'lonIncludes'}.
215: '/source_copyright.tab';
216: if ( open (my $fh,"<$sourcecopyrightfile") ) {
1.356 albertel 217: while (my $line = <$fh>) {
218: next if ($line =~ /^\#/);
219: chomp($line);
220: my ($key,$val)=(split(/\s+/,$line,2));
1.192 taceyjo1 221: $scprtag{$key}=$val;
222: }
223: close($fh);
224: }
225: }
1.63 www 226:
1.517 raeburn 227: # -------------------------------------------------------------- default domain designs
1.63 www 228: my $designdir=$Apache::lonnet::perlvar{'lonTabDir'}.'/lonDomColors';
1.517 raeburn 229: my $designfile = $designdir.'/default.tab';
230: if ( open (my $fh,"<$designfile") ) {
231: while (my $line = <$fh>) {
232: next if ($line =~ /^\#/);
233: chomp($line);
234: my ($key,$val)=(split(/\=/,$line));
235: if ($val) { $defaultdesign{$key}=$val; }
236: }
237: close($fh);
1.63 www 238: }
239:
1.15 harris41 240: # ------------------------------------------------------------- file categories
241: {
1.158 raeburn 242: my $categoryfile = $Apache::lonnet::perlvar{'lonTabDir'}.
243: '/filecategories.tab';
244: if ( open (my $fh,"<$categoryfile") ) {
1.356 albertel 245: while (my $line = <$fh>) {
246: next if ($line =~ /^\#/);
247: chomp($line);
248: my ($extension,$category)=(split(/\s+/,$line,2));
1.158 raeburn 249: push @{$category_extensions{lc($category)}},$extension;
250: }
251: close($fh);
252: }
253:
1.15 harris41 254: }
1.12 harris41 255: # ------------------------------------------------------------------ file types
256: {
1.158 raeburn 257: my $typesfile = $Apache::lonnet::perlvar{'lonTabDir'}.
258: '/filetypes.tab';
259: if ( open (my $fh,"<$typesfile") ) {
1.356 albertel 260: while (my $line = <$fh>) {
261: next if ($line =~ /^\#/);
262: chomp($line);
263: my ($ending,$emb,$mime,$descr)=split(/\s+/,$line,4);
1.158 raeburn 264: if ($descr ne '') {
265: $fe{$ending}=lc($emb);
266: $fd{$ending}=$descr;
1.351 www 267: if ($mime ne 'unk') { $fm{$ending}=$mime; }
1.158 raeburn 268: }
269: }
270: close($fh);
271: }
1.12 harris41 272: }
1.22 www 273: &Apache::lonnet::logthis(
1.705 tempelho 274: "<span style='color:yellow;'>INFO: Read file types</span>");
1.22 www 275: $readit=1;
1.46 matthew 276: } # end of unless($readit)
1.32 matthew 277:
278: }
1.112 bowersj2 279:
1.42 matthew 280: ###############################################################
281: ## HTML and Javascript Helper Functions ##
282: ###############################################################
283:
284: =pod
285:
1.112 bowersj2 286: =head1 HTML and Javascript Functions
1.42 matthew 287:
1.112 bowersj2 288: =over 4
289:
1.648 raeburn 290: =item * &browser_and_searcher_javascript()
1.112 bowersj2 291:
292: X<browsing, javascript>X<searching, javascript>Returns a string
293: containing javascript with two functions, C<openbrowser> and
294: C<opensearcher>. Returned string does not contain E<lt>scriptE<gt>
295: tags.
1.42 matthew 296:
1.648 raeburn 297: =item * &openbrowser(formname,elementname,only,omit) [javascript]
1.42 matthew 298:
299: inputs: formname, elementname, only, omit
300:
301: formname and elementname indicate the name of the html form and name of
302: the element that the results of the browsing selection are to be placed in.
303:
304: Specifying 'only' will restrict the browser to displaying only files
1.185 www 305: with the given extension. Can be a comma separated list.
1.42 matthew 306:
307: Specifying 'omit' will restrict the browser to NOT displaying files
1.185 www 308: with the given extension. Can be a comma separated list.
1.42 matthew 309:
1.648 raeburn 310: =item * &opensearcher(formname,elementname) [javascript]
1.42 matthew 311:
312: Inputs: formname, elementname
313:
314: formname and elementname specify the name of the html form and the name
315: of the element the selection from the search results will be placed in.
1.542 raeburn 316:
1.42 matthew 317: =cut
318:
319: sub browser_and_searcher_javascript {
1.199 albertel 320: my ($mode)=@_;
321: if (!defined($mode)) { $mode='edit'; }
1.453 albertel 322: my $resurl=&escape_single(&lastresurl());
1.42 matthew 323: return <<END;
1.219 albertel 324: // <!-- BEGIN LON-CAPA Internal
1.50 matthew 325: var editbrowser = null;
1.135 albertel 326: function openbrowser(formname,elementname,only,omit,titleelement) {
1.170 www 327: var url = '$resurl/?';
1.42 matthew 328: if (editbrowser == null) {
329: url += 'launch=1&';
330: }
331: url += 'catalogmode=interactive&';
1.199 albertel 332: url += 'mode=$mode&';
1.611 albertel 333: url += 'inhibitmenu=yes&';
1.42 matthew 334: url += 'form=' + formname + '&';
335: if (only != null) {
336: url += 'only=' + only + '&';
1.217 albertel 337: } else {
338: url += 'only=&';
339: }
1.42 matthew 340: if (omit != null) {
341: url += 'omit=' + omit + '&';
1.217 albertel 342: } else {
343: url += 'omit=&';
344: }
1.135 albertel 345: if (titleelement != null) {
346: url += 'titleelement=' + titleelement + '&';
1.217 albertel 347: } else {
348: url += 'titleelement=&';
349: }
1.42 matthew 350: url += 'element=' + elementname + '';
351: var title = 'Browser';
1.435 albertel 352: var options = 'scrollbars=1,resizable=1,menubar=0,toolbar=1,location=1';
1.42 matthew 353: options += ',width=700,height=600';
354: editbrowser = open(url,title,options,'1');
355: editbrowser.focus();
356: }
357: var editsearcher;
1.135 albertel 358: function opensearcher(formname,elementname,titleelement) {
1.42 matthew 359: var url = '/adm/searchcat?';
360: if (editsearcher == null) {
361: url += 'launch=1&';
362: }
363: url += 'catalogmode=interactive&';
1.199 albertel 364: url += 'mode=$mode&';
1.42 matthew 365: url += 'form=' + formname + '&';
1.135 albertel 366: if (titleelement != null) {
367: url += 'titleelement=' + titleelement + '&';
1.217 albertel 368: } else {
369: url += 'titleelement=&';
370: }
1.42 matthew 371: url += 'element=' + elementname + '';
372: var title = 'Search';
1.435 albertel 373: var options = 'scrollbars=1,resizable=1,menubar=0,toolbar=1,location=1';
1.42 matthew 374: options += ',width=700,height=600';
375: editsearcher = open(url,title,options,'1');
376: editsearcher.focus();
377: }
1.219 albertel 378: // END LON-CAPA Internal -->
1.42 matthew 379: END
1.170 www 380: }
381:
382: sub lastresurl {
1.258 albertel 383: if ($env{'environment.lastresurl'}) {
384: return $env{'environment.lastresurl'}
1.170 www 385: } else {
386: return '/res';
387: }
388: }
389:
390: sub storeresurl {
391: my $resurl=&Apache::lonnet::clutter(shift);
392: unless ($resurl=~/^\/res/) { return 0; }
393: $resurl=~s/\/$//;
394: &Apache::lonnet::put('environment',{'lastresurl' => $resurl});
1.646 raeburn 395: &Apache::lonnet::appenv({'environment.lastresurl' => $resurl});
1.170 www 396: return 1;
1.42 matthew 397: }
398:
1.74 www 399: sub studentbrowser_javascript {
1.111 www 400: unless (
1.258 albertel 401: (($env{'request.course.id'}) &&
1.302 albertel 402: (&Apache::lonnet::allowed('srm',$env{'request.course.id'})
403: || &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
404: '/'.$env{'request.course.sec'})
405: ))
1.258 albertel 406: || ($env{'request.role'}=~/^(au|dc|su)/)
1.111 www 407: ) { return ''; }
1.74 www 408: return (<<'ENDSTDBRW');
1.776 bisitz 409: <script type="text/javascript" language="Javascript">
1.824 bisitz 410: // <![CDATA[
1.74 www 411: var stdeditbrowser;
1.948.2.32! raeburn 412: function openstdbrowser(formname,uname,udom,clicker,roleflag,ignorefilter,courseadvonly) {
1.74 www 413: var url = '/adm/pickstudent?';
414: var filter;
1.558 albertel 415: if (!ignorefilter) {
416: eval('filter=document.'+formname+'.'+uname+'.value;');
417: }
1.74 www 418: if (filter != null) {
419: if (filter != '') {
420: url += 'filter='+filter+'&';
421: }
422: }
423: url += 'form=' + formname + '&unameelement='+uname+
1.948.2.32! raeburn 424: '&udomelement='+udom+
! 425: '&clicker='+clicker;
1.111 www 426: if (roleflag) { url+="&roles=1"; }
1.793 raeburn 427: if (courseadvonly) { url+="&courseadvonly=1"; }
1.102 www 428: var title = 'Student_Browser';
1.74 www 429: var options = 'scrollbars=1,resizable=1,menubar=0';
430: options += ',width=700,height=600';
431: stdeditbrowser = open(url,title,options,'1');
432: stdeditbrowser.focus();
433: }
1.824 bisitz 434: // ]]>
1.74 www 435: </script>
436: ENDSTDBRW
437: }
1.42 matthew 438:
1.74 www 439: sub selectstudent_link {
1.948.2.32! raeburn 440: my ($form,$unameele,$udomele,$courseadvonly,$clickerid)=@_;
! 441: my $callargs = "'".&Apache::lonhtmlcommon::entity_encode($form)."','".
! 442: &Apache::lonhtmlcommon::entity_encode($unameele)."','".
! 443: &Apache::lonhtmlcommon::entity_encode($udomele)."'";
1.258 albertel 444: if ($env{'request.course.id'}) {
1.302 albertel 445: if (!&Apache::lonnet::allowed('srm',$env{'request.course.id'})
446: && !&Apache::lonnet::allowed('srm',$env{'request.course.id'}.
447: '/'.$env{'request.course.sec'})) {
1.111 www 448: return '';
449: }
1.948.2.32! raeburn 450: $callargs.=",'".&Apache::lonhtmlcommon::entity_encode($clickerid)."'";
1.793 raeburn 451: if ($courseadvonly) {
452: $callargs .= ",'',1,1";
453: }
454: return '<span class="LC_nobreak">'.
455: '<a href="javascript:openstdbrowser('.$callargs.');">'.
456: &mt('Select User').'</a></span>';
1.74 www 457: }
1.258 albertel 458: if ($env{'request.role'}=~/^(au|dc|su)/) {
1.948.2.31 raeburn 459: $callargs .= ",'',1";
1.793 raeburn 460: return '<span class="LC_nobreak">'.
461: '<a href="javascript:openstdbrowser('.$callargs.');">'.
462: &mt('Select User').'</a></span>';
1.111 www 463: }
464: return '';
1.91 www 465: }
466:
1.653 raeburn 467: sub authorbrowser_javascript {
468: return <<"ENDAUTHORBRW";
1.776 bisitz 469: <script type="text/javascript" language="JavaScript">
1.824 bisitz 470: // <![CDATA[
1.653 raeburn 471: var stdeditbrowser;
472:
473: function openauthorbrowser(formname,udom) {
474: var url = '/adm/pickauthor?';
475: url += 'form='+formname+'&roledom='+udom;
476: var title = 'Author_Browser';
477: var options = 'scrollbars=1,resizable=1,menubar=0';
478: options += ',width=700,height=600';
479: stdeditbrowser = open(url,title,options,'1');
480: stdeditbrowser.focus();
481: }
482:
1.824 bisitz 483: // ]]>
1.653 raeburn 484: </script>
485: ENDAUTHORBRW
486: }
487:
1.91 www 488: sub coursebrowser_javascript {
1.909 raeburn 489: my ($domainfilter,$sec_element,$formname,$role_element,$crstype) = @_;
1.932 raeburn 490: my $wintitle = 'Course_Browser';
1.931 raeburn 491: if ($crstype eq 'Community') {
1.932 raeburn 492: $wintitle = 'Community_Browser';
1.909 raeburn 493: }
1.876 raeburn 494: my $id_functions = &javascript_index_functions();
495: my $output = '
1.776 bisitz 496: <script type="text/javascript" language="JavaScript">
1.824 bisitz 497: // <![CDATA[
1.468 raeburn 498: var stdeditbrowser;'."\n";
1.876 raeburn 499:
500: $output .= <<"ENDSTDBRW";
1.909 raeburn 501: function opencrsbrowser(formname,uname,udom,desc,extra_element,multflag,type,type_elem) {
1.91 www 502: var url = '/adm/pickcourse?';
1.895 raeburn 503: var formid = getFormIdByName(formname);
1.876 raeburn 504: var domainfilter = getDomainFromSelectbox(formname,udom);
1.128 albertel 505: if (domainfilter != null) {
506: if (domainfilter != '') {
507: url += 'domainfilter='+domainfilter+'&';
508: }
509: }
1.91 www 510: url += 'form=' + formname + '&cnumelement='+uname+
1.187 albertel 511: '&cdomelement='+udom+
512: '&cnameelement='+desc;
1.468 raeburn 513: if (extra_element !=null && extra_element != '') {
1.594 raeburn 514: if (formname == 'rolechoice' || formname == 'studentform') {
1.468 raeburn 515: url += '&roleelement='+extra_element;
516: if (domainfilter == null || domainfilter == '') {
517: url += '&domainfilter='+extra_element;
518: }
1.234 raeburn 519: }
1.468 raeburn 520: else {
521: if (formname == 'portform') {
522: url += '&setroles='+extra_element;
1.800 raeburn 523: } else {
524: if (formname == 'rules') {
525: url += '&fixeddom='+extra_element;
526: }
1.468 raeburn 527: }
528: }
1.230 raeburn 529: }
1.909 raeburn 530: if (type != null && type != '') {
531: url += '&type='+type;
532: }
533: if (type_elem != null && type_elem != '') {
534: url += '&typeelement='+type_elem;
535: }
1.872 raeburn 536: if (formname == 'ccrs') {
537: var ownername = document.forms[formid].ccuname.value;
538: var ownerdom = document.forms[formid].ccdomain.options[document.forms[formid].ccdomain.selectedIndex].value;
539: url += '&cloner='+ownername+':'+ownerdom;
540: }
1.293 raeburn 541: if (multflag !=null && multflag != '') {
542: url += '&multiple='+multflag;
543: }
1.909 raeburn 544: var title = '$wintitle';
1.91 www 545: var options = 'scrollbars=1,resizable=1,menubar=0';
546: options += ',width=700,height=600';
547: stdeditbrowser = open(url,title,options,'1');
548: stdeditbrowser.focus();
549: }
1.876 raeburn 550: $id_functions
551: ENDSTDBRW
1.905 raeburn 552: if (($sec_element ne '') || ($role_element ne '')) {
553: $output .= &setsec_javascript($sec_element,$formname,$role_element);
1.876 raeburn 554: }
555: $output .= '
556: // ]]>
557: </script>';
558: return $output;
559: }
560:
561: sub javascript_index_functions {
562: return <<"ENDJS";
563:
564: function getFormIdByName(formname) {
565: for (var i=0;i<document.forms.length;i++) {
566: if (document.forms[i].name == formname) {
567: return i;
568: }
569: }
570: return -1;
571: }
572:
573: function getIndexByName(formid,item) {
574: for (var i=0;i<document.forms[formid].elements.length;i++) {
575: if (document.forms[formid].elements[i].name == item) {
576: return i;
577: }
578: }
579: return -1;
580: }
1.468 raeburn 581:
1.876 raeburn 582: function getDomainFromSelectbox(formname,udom) {
583: var userdom;
584: var formid = getFormIdByName(formname);
585: if (formid > -1) {
586: var domid = getIndexByName(formid,udom);
587: if (domid > -1) {
588: if (document.forms[formid].elements[domid].type == 'select-one') {
589: userdom=document.forms[formid].elements[domid].options[document.forms[formid].elements[domid].selectedIndex].value;
590: }
591: if (document.forms[formid].elements[domid].type == 'hidden') {
592: userdom=document.forms[formid].elements[domid].value;
1.468 raeburn 593: }
594: }
595: }
1.876 raeburn 596: return userdom;
597: }
598:
599: ENDJS
1.468 raeburn 600:
1.876 raeburn 601: }
602:
1.948.2.31 raeburn 603: sub javascript_array_indexof {
604: return <<ENDJS;
605: <script type="text/javascript" language="JavaScript">
606: // <![CDATA[
607:
608: if (!Array.prototype.indexOf) {
609: Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) {
610: "use strict";
611: if (this === void 0 || this === null) {
612: throw new TypeError();
613: }
614: var t = Object(this);
615: var len = t.length >>> 0;
616: if (len === 0) {
617: return -1;
618: }
619: var n = 0;
620: if (arguments.length > 0) {
621: n = Number(arguments[1]);
622: if (n !== n) { // shortcut for verifying if it's NaN
623: n = 0;
624: } else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) {
625: n = (n > 0 || -1) * Math.floor(Math.abs(n));
626: }
627: }
628: if (n >= len) {
629: return -1;
630: }
631: var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0);
632: for (; k < len; k++) {
633: if (k in t && t[k] === searchElement) {
634: return k;
635: }
636: }
637: return -1;
638: }
639: }
640:
641: // ]]>
642: </script>
643:
644: ENDJS
645:
646: }
647:
1.876 raeburn 648: sub userbrowser_javascript {
649: my $id_functions = &javascript_index_functions();
650: return <<"ENDUSERBRW";
651:
1.888 raeburn 652: function openuserbrowser(formname,uname,udom,ulast,ufirst,uemail,hideudom,crsdom,caller) {
1.876 raeburn 653: var url = '/adm/pickuser?';
654: var userdom = getDomainFromSelectbox(formname,udom);
655: if (userdom != null) {
656: if (userdom != '') {
657: url += 'srchdom='+userdom+'&';
658: }
659: }
660: url += 'form=' + formname + '&unameelement='+uname+
661: '&udomelement='+udom+
662: '&ulastelement='+ulast+
663: '&ufirstelement='+ufirst+
664: '&uemailelement='+uemail+
1.881 raeburn 665: '&hideudomelement='+hideudom+
666: '&coursedom='+crsdom;
1.888 raeburn 667: if ((caller != null) && (caller != undefined)) {
668: url += '&caller='+caller;
669: }
1.876 raeburn 670: var title = 'User_Browser';
671: var options = 'scrollbars=1,resizable=1,menubar=0';
672: options += ',width=700,height=600';
673: var stdeditbrowser = open(url,title,options,'1');
674: stdeditbrowser.focus();
675: }
676:
1.888 raeburn 677: function fix_domain (formname,udom,origdom,uname) {
1.876 raeburn 678: var formid = getFormIdByName(formname);
679: if (formid > -1) {
1.888 raeburn 680: var unameid = getIndexByName(formid,uname);
1.876 raeburn 681: var domid = getIndexByName(formid,udom);
682: var hidedomid = getIndexByName(formid,origdom);
683: if (hidedomid > -1) {
684: var fixeddom = document.forms[formid].elements[hidedomid].value;
1.888 raeburn 685: var unameval = document.forms[formid].elements[unameid].value;
686: if ((fixeddom != '') && (fixeddom != undefined) && (fixeddom != null) && (unameval != '') && (unameval != undefined) && (unameval != null)) {
687: if (domid > -1) {
688: var slct = document.forms[formid].elements[domid];
689: if (slct.type == 'select-one') {
690: var i;
691: for (i=0;i<slct.length;i++) {
692: if (slct.options[i].value==fixeddom) { slct.selectedIndex=i; }
693: }
694: }
695: if (slct.type == 'hidden') {
696: slct.value = fixeddom;
1.876 raeburn 697: }
698: }
1.468 raeburn 699: }
700: }
701: }
1.876 raeburn 702: return;
703: }
704:
705: $id_functions
706: ENDUSERBRW
1.468 raeburn 707: }
708:
709: sub setsec_javascript {
1.905 raeburn 710: my ($sec_element,$formname,$role_element) = @_;
711: my (@courserolenames,@communityrolenames,$rolestr,$courserolestr,
712: $communityrolestr);
713: if ($role_element ne '') {
714: my @allroles = ('st','ta','ep','in','ad');
715: foreach my $crstype ('Course','Community') {
716: if ($crstype eq 'Community') {
717: foreach my $role (@allroles) {
718: push(@communityrolenames,&Apache::lonnet::plaintext($role,$crstype));
719: }
720: push(@communityrolenames,&Apache::lonnet::plaintext('co'));
721: } else {
722: foreach my $role (@allroles) {
723: push(@courserolenames,&Apache::lonnet::plaintext($role,$crstype));
724: }
725: push(@courserolenames,&Apache::lonnet::plaintext('cc'));
726: }
727: }
728: $rolestr = '"'.join('","',@allroles).'"';
729: $courserolestr = '"'.join('","',@courserolenames).'"';
730: $communityrolestr = '"'.join('","',@communityrolenames).'"';
731: }
1.468 raeburn 732: my $setsections = qq|
733: function setSect(sectionlist) {
1.629 raeburn 734: var sectionsArray = new Array();
735: if ((sectionlist != '') && (typeof sectionlist != "undefined")) {
736: sectionsArray = sectionlist.split(",");
737: }
1.468 raeburn 738: var numSections = sectionsArray.length;
739: document.$formname.$sec_element.length = 0;
740: if (numSections == 0) {
741: document.$formname.$sec_element.multiple=false;
742: document.$formname.$sec_element.size=1;
743: document.$formname.$sec_element.options[0] = new Option('No existing sections','',false,false)
744: } else {
745: if (numSections == 1) {
746: document.$formname.$sec_element.multiple=false;
747: document.$formname.$sec_element.size=1;
748: document.$formname.$sec_element.options[0] = new Option('Select','',true,true);
749: document.$formname.$sec_element.options[1] = new Option('No section','',false,false)
750: document.$formname.$sec_element.options[2] = new Option(sectionsArray[0],sectionsArray[0],false,false);
751: } else {
752: for (var i=0; i<numSections; i++) {
753: document.$formname.$sec_element.options[i] = new Option(sectionsArray[i],sectionsArray[i],false,false)
754: }
755: document.$formname.$sec_element.multiple=true
756: if (numSections < 3) {
757: document.$formname.$sec_element.size=numSections;
758: } else {
759: document.$formname.$sec_element.size=3;
760: }
761: document.$formname.$sec_element.options[0].selected = false
762: }
763: }
1.91 www 764: }
1.905 raeburn 765:
766: function setRole(crstype) {
1.468 raeburn 767: |;
1.905 raeburn 768: if ($role_element eq '') {
769: $setsections .= ' return;
770: }
771: ';
772: } else {
773: $setsections .= qq|
774: var elementLength = document.$formname.$role_element.length;
775: var allroles = Array($rolestr);
776: var courserolenames = Array($courserolestr);
777: var communityrolenames = Array($communityrolestr);
778: if (elementLength != undefined) {
779: if (document.$formname.$role_element.options[5].value == 'cc') {
780: if (crstype == 'Course') {
781: return;
782: } else {
783: allroles[5] = 'co';
784: for (var i=0; i<6; i++) {
785: document.$formname.$role_element.options[i].value = allroles[i];
786: document.$formname.$role_element.options[i].text = communityrolenames[i];
787: }
788: }
789: } else {
790: if (crstype == 'Community') {
791: return;
792: } else {
793: allroles[5] = 'cc';
794: for (var i=0; i<6; i++) {
795: document.$formname.$role_element.options[i].value = allroles[i];
796: document.$formname.$role_element.options[i].text = courserolenames[i];
797: }
798: }
799: }
800: }
801: return;
802: }
803: |;
804: }
1.468 raeburn 805: return $setsections;
806: }
807:
1.91 www 808: sub selectcourse_link {
1.909 raeburn 809: my ($form,$unameele,$udomele,$desc,$extra_element,$multflag,$selecttype,
810: $typeelement) = @_;
811: my $type = $selecttype;
1.871 raeburn 812: my $linktext = &mt('Select Course');
813: if ($selecttype eq 'Community') {
1.909 raeburn 814: $linktext = &mt('Select Community');
1.906 raeburn 815: } elsif ($selecttype eq 'Course/Community') {
816: $linktext = &mt('Select Course/Community');
1.909 raeburn 817: $type = '';
1.948.2.31 raeburn 818: } elsif ($selecttype eq 'Select') {
819: $linktext = &mt('Select');
820: $type = '';
1.871 raeburn 821: }
1.787 bisitz 822: return '<span class="LC_nobreak">'
823: ."<a href='"
824: .'javascript:opencrsbrowser("'.$form.'","'.$unameele
825: .'","'.$udomele.'","'.$desc.'","'.$extra_element
1.909 raeburn 826: .'","'.$multflag.'","'.$type.'","'.$typeelement.'");'
1.871 raeburn 827: ."'>".$linktext.'</a>'
1.787 bisitz 828: .'</span>';
1.74 www 829: }
1.42 matthew 830:
1.653 raeburn 831: sub selectauthor_link {
832: my ($form,$udom)=@_;
833: return '<a href="javascript:openauthorbrowser('."'$form','$udom'".');">'.
834: &mt('Select Author').'</a>';
835: }
836:
1.876 raeburn 837: sub selectuser_link {
1.881 raeburn 838: my ($form,$unameelem,$domelem,$lastelem,$firstelem,$emailelem,$hdomelem,
1.888 raeburn 839: $coursedom,$linktext,$caller) = @_;
1.876 raeburn 840: return '<a href="javascript:openuserbrowser('."'$form','$unameelem','$domelem',".
1.888 raeburn 841: "'$lastelem','$firstelem','$emailelem','$hdomelem','$coursedom','$caller'".
1.881 raeburn 842: ');">'.$linktext.'</a>';
1.876 raeburn 843: }
844:
1.273 raeburn 845: sub check_uncheck_jscript {
846: my $jscript = <<"ENDSCRT";
847: function checkAll(field) {
848: if (field.length > 0) {
849: for (i = 0; i < field.length; i++) {
850: field[i].checked = true ;
851: }
852: } else {
853: field.checked = true
854: }
855: }
856:
857: function uncheckAll(field) {
858: if (field.length > 0) {
859: for (i = 0; i < field.length; i++) {
860: field[i].checked = false ;
1.543 albertel 861: }
862: } else {
1.273 raeburn 863: field.checked = false ;
864: }
865: }
866: ENDSCRT
867: return $jscript;
868: }
869:
1.656 www 870: sub select_timezone {
1.659 raeburn 871: my ($name,$selected,$onchange,$includeempty)=@_;
872: my $output='<select name="'.$name.'" '.$onchange.'>'."\n";
873: if ($includeempty) {
874: $output .= '<option value=""';
875: if (($selected eq '') || ($selected eq 'local')) {
876: $output .= ' selected="selected" ';
877: }
878: $output .= '> </option>';
879: }
1.657 raeburn 880: my @timezones = DateTime::TimeZone->all_names;
881: foreach my $tzone (@timezones) {
882: $output.= '<option value="'.$tzone.'"';
883: if ($tzone eq $selected) {
884: $output.=' selected="selected"';
885: }
886: $output.=">$tzone</option>\n";
1.656 www 887: }
888: $output.="</select>";
889: return $output;
890: }
1.273 raeburn 891:
1.687 raeburn 892: sub select_datelocale {
893: my ($name,$selected,$onchange,$includeempty)=@_;
894: my $output='<select name="'.$name.'" '.$onchange.'>'."\n";
895: if ($includeempty) {
896: $output .= '<option value=""';
897: if ($selected eq '') {
898: $output .= ' selected="selected" ';
899: }
900: $output .= '> </option>';
901: }
902: my (@possibles,%locale_names);
903: my @locales = DateTime::Locale::Catalog::Locales;
904: foreach my $locale (@locales) {
905: if (ref($locale) eq 'HASH') {
906: my $id = $locale->{'id'};
907: if ($id ne '') {
908: my $en_terr = $locale->{'en_territory'};
909: my $native_terr = $locale->{'native_territory'};
1.695 raeburn 910: my @languages = &Apache::lonlocal::preferred_languages();
1.687 raeburn 911: if (grep(/^en$/,@languages) || !@languages) {
912: if ($en_terr ne '') {
913: $locale_names{$id} = '('.$en_terr.')';
914: } elsif ($native_terr ne '') {
915: $locale_names{$id} = $native_terr;
916: }
917: } else {
918: if ($native_terr ne '') {
919: $locale_names{$id} = $native_terr.' ';
920: } elsif ($en_terr ne '') {
921: $locale_names{$id} = '('.$en_terr.')';
922: }
923: }
924: push (@possibles,$id);
925: }
926: }
927: }
928: foreach my $item (sort(@possibles)) {
929: $output.= '<option value="'.$item.'"';
930: if ($item eq $selected) {
931: $output.=' selected="selected"';
932: }
933: $output.=">$item";
934: if ($locale_names{$item} ne '') {
935: $output.=" $locale_names{$item}</option>\n";
936: }
937: $output.="</option>\n";
938: }
939: $output.="</select>";
940: return $output;
941: }
942:
1.792 raeburn 943: sub select_language {
944: my ($name,$selected,$includeempty) = @_;
945: my %langchoices;
946: if ($includeempty) {
947: %langchoices = ('' => 'No language preference');
948: }
949: foreach my $id (&languageids()) {
950: my $code = &supportedlanguagecode($id);
951: if ($code) {
952: $langchoices{$code} = &plainlanguagedescription($id);
953: }
954: }
1.948.2.7 raeburn 955: return &select_form($selected,$name,\%langchoices);
1.792 raeburn 956: }
957:
1.42 matthew 958: =pod
1.36 matthew 959:
1.648 raeburn 960: =item * &linked_select_forms(...)
1.36 matthew 961:
962: linked_select_forms returns a string containing a <script></script> block
963: and html for two <select> menus. The select menus will be linked in that
964: changing the value of the first menu will result in new values being placed
965: in the second menu. The values in the select menu will appear in alphabetical
1.609 raeburn 966: order unless a defined order is provided.
1.36 matthew 967:
968: linked_select_forms takes the following ordered inputs:
969:
970: =over 4
971:
1.112 bowersj2 972: =item * $formname, the name of the <form> tag
1.36 matthew 973:
1.112 bowersj2 974: =item * $middletext, the text which appears between the <select> tags
1.36 matthew 975:
1.112 bowersj2 976: =item * $firstdefault, the default value for the first menu
1.36 matthew 977:
1.112 bowersj2 978: =item * $firstselectname, the name of the first <select> tag
1.36 matthew 979:
1.112 bowersj2 980: =item * $secondselectname, the name of the second <select> tag
1.36 matthew 981:
1.112 bowersj2 982: =item * $hashref, a reference to a hash containing the data for the menus.
1.36 matthew 983:
1.609 raeburn 984: =item * $menuorder, the order of values in the first menu
985:
1.41 ng 986: =back
987:
1.36 matthew 988: Below is an example of such a hash. Only the 'text', 'default', and
989: 'select2' keys must appear as stated. keys(%menu) are the possible
990: values for the first select menu. The text that coincides with the
1.41 ng 991: first menu value is given in $menu{$choice1}->{'text'}. The values
1.36 matthew 992: and text for the second menu are given in the hash pointed to by
993: $menu{$choice1}->{'select2'}.
994:
1.112 bowersj2 995: my %menu = ( A1 => { text =>"Choice A1" ,
996: default => "B3",
997: select2 => {
998: B1 => "Choice B1",
999: B2 => "Choice B2",
1000: B3 => "Choice B3",
1001: B4 => "Choice B4"
1.609 raeburn 1002: },
1003: order => ['B4','B3','B1','B2'],
1.112 bowersj2 1004: },
1005: A2 => { text =>"Choice A2" ,
1006: default => "C2",
1007: select2 => {
1008: C1 => "Choice C1",
1009: C2 => "Choice C2",
1010: C3 => "Choice C3"
1.609 raeburn 1011: },
1012: order => ['C2','C1','C3'],
1.112 bowersj2 1013: },
1014: A3 => { text =>"Choice A3" ,
1015: default => "D6",
1016: select2 => {
1017: D1 => "Choice D1",
1018: D2 => "Choice D2",
1019: D3 => "Choice D3",
1020: D4 => "Choice D4",
1021: D5 => "Choice D5",
1022: D6 => "Choice D6",
1023: D7 => "Choice D7"
1.609 raeburn 1024: },
1025: order => ['D4','D3','D2','D1','D7','D6','D5'],
1.112 bowersj2 1026: }
1027: );
1.36 matthew 1028:
1029: =cut
1030:
1031: sub linked_select_forms {
1032: my ($formname,
1033: $middletext,
1034: $firstdefault,
1035: $firstselectname,
1036: $secondselectname,
1.609 raeburn 1037: $hashref,
1038: $menuorder,
1.36 matthew 1039: ) = @_;
1040: my $second = "document.$formname.$secondselectname";
1041: my $first = "document.$formname.$firstselectname";
1042: # output the javascript to do the changing
1043: my $result = '';
1.776 bisitz 1044: $result.='<script type="text/javascript" language="JavaScript">'."\n";
1.824 bisitz 1045: $result.="// <![CDATA[\n";
1.36 matthew 1046: $result.="var select2data = new Object();\n";
1047: $" = '","';
1048: my $debug = '';
1049: foreach my $s1 (sort(keys(%$hashref))) {
1050: $result.="select2data.d_$s1 = new Object();\n";
1051: $result.="select2data.d_$s1.def = new String('".
1052: $hashref->{$s1}->{'default'}."');\n";
1.609 raeburn 1053: $result.="select2data.d_$s1.values = new Array(";
1.36 matthew 1054: my @s2values = sort(keys( %{ $hashref->{$s1}->{'select2'} } ));
1.609 raeburn 1055: if (ref($hashref->{$s1}->{'order'}) eq 'ARRAY') {
1056: @s2values = @{$hashref->{$s1}->{'order'}};
1057: }
1.36 matthew 1058: $result.="\"@s2values\");\n";
1059: $result.="select2data.d_$s1.texts = new Array(";
1060: my @s2texts;
1061: foreach my $value (@s2values) {
1062: push @s2texts, $hashref->{$s1}->{'select2'}->{$value};
1063: }
1064: $result.="\"@s2texts\");\n";
1065: }
1066: $"=' ';
1067: $result.= <<"END";
1068:
1069: function select1_changed() {
1070: // Determine new choice
1071: var newvalue = "d_" + $first.value;
1072: // update select2
1073: var values = select2data[newvalue].values;
1074: var texts = select2data[newvalue].texts;
1075: var select2def = select2data[newvalue].def;
1076: var i;
1077: // out with the old
1078: for (i = 0; i < $second.options.length; i++) {
1079: $second.options[i] = null;
1080: }
1081: // in with the nuclear
1082: for (i=0;i<values.length; i++) {
1083: $second.options[i] = new Option(values[i]);
1.143 matthew 1084: $second.options[i].value = values[i];
1.36 matthew 1085: $second.options[i].text = texts[i];
1086: if (values[i] == select2def) {
1087: $second.options[i].selected = true;
1088: }
1089: }
1090: }
1.824 bisitz 1091: // ]]>
1.36 matthew 1092: </script>
1093: END
1094: # output the initial values for the selection lists
1095: $result .= "<select size=\"1\" name=\"$firstselectname\" onchange=\"select1_changed()\">\n";
1.609 raeburn 1096: my @order = sort(keys(%{$hashref}));
1097: if (ref($menuorder) eq 'ARRAY') {
1098: @order = @{$menuorder};
1099: }
1100: foreach my $value (@order) {
1.36 matthew 1101: $result.=" <option value=\"$value\" ";
1.253 albertel 1102: $result.=" selected=\"selected\" " if ($value eq $firstdefault);
1.119 www 1103: $result.=">".&mt($hashref->{$value}->{'text'})."</option>\n";
1.36 matthew 1104: }
1105: $result .= "</select>\n";
1106: my %select2 = %{$hashref->{$firstdefault}->{'select2'}};
1107: $result .= $middletext;
1108: $result .= "<select size=\"1\" name=\"$secondselectname\">\n";
1109: my $seconddefault = $hashref->{$firstdefault}->{'default'};
1.609 raeburn 1110:
1111: my @secondorder = sort(keys(%select2));
1112: if (ref($hashref->{$firstdefault}->{'order'}) eq 'ARRAY') {
1113: @secondorder = @{$hashref->{$firstdefault}->{'order'}};
1114: }
1115: foreach my $value (@secondorder) {
1.36 matthew 1116: $result.=" <option value=\"$value\" ";
1.253 albertel 1117: $result.=" selected=\"selected\" " if ($value eq $seconddefault);
1.119 www 1118: $result.=">".&mt($select2{$value})."</option>\n";
1.36 matthew 1119: }
1120: $result .= "</select>\n";
1121: # return $debug;
1122: return $result;
1123: } # end of sub linked_select_forms {
1124:
1.45 matthew 1125: =pod
1.44 bowersj2 1126:
1.948.2.7 raeburn 1127: =item * &help_open_topic($topic,$text,$stayOnPage,$width,$height,$imgid)
1.44 bowersj2 1128:
1.112 bowersj2 1129: Returns a string corresponding to an HTML link to the given help
1130: $topic, where $topic corresponds to the name of a .tex file in
1131: /home/httpd/html/adm/help/tex, with underscores replaced by
1132: spaces.
1133:
1134: $text will optionally be linked to the same topic, allowing you to
1135: link text in addition to the graphic. If you do not want to link
1136: text, but wish to specify one of the later parameters, pass an
1137: empty string.
1138:
1139: $stayOnPage is a value that will be interpreted as a boolean. If true,
1140: the link will not open a new window. If false, the link will open
1141: a new window using Javascript. (Default is false.)
1142:
1143: $width and $height are optional numerical parameters that will
1144: override the width and height of the popped up window, which may
1145: be useful for certain help topics with big pictures included.
1.44 bowersj2 1146:
1147: =cut
1148:
1149: sub help_open_topic {
1.948.2.7 raeburn 1150: my ($topic, $text, $stayOnPage, $width, $height, $imgid) = @_;
1.48 bowersj2 1151: $text = "" if (not defined $text);
1.44 bowersj2 1152: $stayOnPage = 0 if (not defined $stayOnPage);
1153: $width = 350 if (not defined $width);
1154: $height = 400 if (not defined $height);
1155: my $filename = $topic;
1156: $filename =~ s/ /_/g;
1157:
1.48 bowersj2 1158: my $template = "";
1159: my $link;
1.572 banghart 1160:
1.159 www 1161: $topic=~s/\W/\_/g;
1.44 bowersj2 1162:
1.572 banghart 1163: if (!$stayOnPage) {
1.72 bowersj2 1164: $link = "javascript:void(open('/adm/help/${filename}.hlp', 'Help_for_$topic', 'menubar=0,toolbar=1,scrollbars=1,width=$width,height=$height,resizable=yes'))";
1.572 banghart 1165: } else {
1.48 bowersj2 1166: $link = "/adm/help/${filename}.hlp";
1167: }
1168:
1169: # Add the text
1.755 neumanie 1170: if ($text ne "") {
1.763 bisitz 1171: $template.='<span class="LC_help_open_topic">'
1172: .'<a target="_top" href="'.$link.'">'
1173: .$text.'</a>';
1.48 bowersj2 1174: }
1175:
1.763 bisitz 1176: # (Always) Add the graphic
1.179 matthew 1177: my $title = &mt('Online Help');
1.667 raeburn 1178: my $helpicon=&lonhttpdurl("/adm/help/help.png");
1.948.2.7 raeburn 1179: if ($imgid ne '') {
1180: $imgid = ' id="'.$imgid.'"';
1181: }
1.763 bisitz 1182: $template.=' <a target="_top" href="'.$link.'" title="'.$title.'">'
1183: .'<img src="'.$helpicon.'" border="0"'
1184: .' alt="'.&mt('Help: [_1]',$topic).'"'
1.948.2.7 raeburn 1185: .' title="'.$title.'" style="vertical-align:middle;"'.$imgid
1.763 bisitz 1186: .' /></a>';
1.948.2.7 raeburn 1187: if ($text ne "") {
1.763 bisitz 1188: $template.='</span>';
1189: }
1.44 bowersj2 1190: return $template;
1191:
1.106 bowersj2 1192: }
1193:
1194: # This is a quicky function for Latex cheatsheet editing, since it
1195: # appears in at least four places
1196: sub helpLatexCheatsheet {
1.732 raeburn 1197: my ($topic,$text,$not_author) = @_;
1198: my $out;
1.106 bowersj2 1199: my $addOther = '';
1.732 raeburn 1200: if ($topic) {
1.763 bisitz 1201: $addOther = '<span>'.&Apache::loncommon::help_open_topic($topic,&mt($text),
1202: undef, undef, 600).
1203: '</span> ';
1204: }
1205: $out = '<span>' # Start cheatsheet
1206: .$addOther
1207: .'<span>'
1208: .&Apache::loncommon::help_open_topic('Greek_Symbols',&mt('Greek Symbols'),
1209: undef,undef,600)
1210: .'</span> <span>'
1211: .&Apache::loncommon::help_open_topic('Other_Symbols',&mt('Other Symbols'),
1212: undef,undef,600)
1213: .'</span>';
1.732 raeburn 1214: unless ($not_author) {
1.763 bisitz 1215: $out .= ' <span>'
1216: .&Apache::loncommon::help_open_topic('Authoring_Output_Tags',&mt('Output Tags'),
1217: undef,undef,600)
1218: .'</span>';
1.732 raeburn 1219: }
1.763 bisitz 1220: $out .= '</span>'; # End cheatsheet
1.732 raeburn 1221: return $out;
1.172 www 1222: }
1223:
1.430 albertel 1224: sub general_help {
1225: my $helptopic='Student_Intro';
1226: if ($env{'request.role'}=~/^(ca|au)/) {
1227: $helptopic='Authoring_Intro';
1.907 raeburn 1228: } elsif ($env{'request.role'}=~/^(cc|co)/) {
1.430 albertel 1229: $helptopic='Course_Coordination_Intro';
1.672 raeburn 1230: } elsif ($env{'request.role'}=~/^dc/) {
1231: $helptopic='Domain_Coordination_Intro';
1.430 albertel 1232: }
1233: return $helptopic;
1234: }
1235:
1236: sub update_help_link {
1237: my ($topic,$component_help,$faq,$bug,$stayOnPage) = @_;
1238: my $origurl = $ENV{'REQUEST_URI'};
1239: $origurl=~s|^/~|/priv/|;
1240: my $timestamp = time;
1241: foreach my $datum (\$topic,\$component_help,\$faq,\$bug,\$origurl) {
1242: $$datum = &escape($$datum);
1243: }
1244:
1245: my $banner_link = "/adm/helpmenu?page=banner&topic=$topic&component_help=$component_help&faq=$faq&bug=$bug&origurl=$origurl&stamp=$timestamp&stayonpage=$stayOnPage";
1246: my $output .= <<"ENDOUTPUT";
1247: <script type="text/javascript">
1.824 bisitz 1248: // <![CDATA[
1.430 albertel 1249: banner_link = '$banner_link';
1.824 bisitz 1250: // ]]>
1.430 albertel 1251: </script>
1252: ENDOUTPUT
1253: return $output;
1254: }
1255:
1256: # now just updates the help link and generates a blue icon
1.193 raeburn 1257: sub help_open_menu {
1.430 albertel 1258: my ($topic,$component_help,$faq,$bug,$stayOnPage,$width,$height,$text)
1.552 banghart 1259: = @_;
1.430 albertel 1260: $stayOnPage = 0 if (not defined $stayOnPage);
1.572 banghart 1261: # only use pop-up help (stayOnPage == 0)
1.552 banghart 1262: # if environment.remote is on (using remote control UI)
1.798 tempelho 1263: if ($env{'environment.remote'} eq 'off' ) {
1.552 banghart 1264: $stayOnPage=1;
1.430 albertel 1265: }
1266: my $output;
1267: if ($component_help) {
1268: if (!$text) {
1269: $output=&help_open_topic($component_help,undef,$stayOnPage,
1270: $width,$height);
1271: } else {
1272: my $help_text;
1273: $help_text=&unescape($topic);
1274: $output='<table><tr><td>'.
1275: &help_open_topic($component_help,$help_text,$stayOnPage,
1276: $width,$height).'</td></tr></table>';
1277: }
1278: }
1279: my $banner_link = &update_help_link($topic,$component_help,$faq,$bug,$stayOnPage);
1280: return $output.$banner_link;
1281: }
1282:
1283: sub top_nav_help {
1284: my ($text) = @_;
1.436 albertel 1285: $text = &mt($text);
1.572 banghart 1286: my $stay_on_page =
1.798 tempelho 1287: ($env{'environment.remote'} eq 'off' );
1.572 banghart 1288: my $link = ($stay_on_page) ? "javascript:helpMenu('display')"
1.436 albertel 1289: : "javascript:helpMenu('open')";
1.572 banghart 1290: my $banner_link = &update_help_link(undef,undef,undef,undef,$stay_on_page);
1.436 albertel 1291:
1.201 raeburn 1292: my $title = &mt('Get help');
1.436 albertel 1293:
1294: return <<"END";
1295: $banner_link
1296: <a href="$link" title="$title">$text</a>
1297: END
1298: }
1299:
1300: sub help_menu_js {
1301: my ($text) = @_;
1302:
1303: my $stayOnPage =
1.798 tempelho 1304: ($env{'environment.remote'} eq 'off' );
1.436 albertel 1305:
1306: my $width = 620;
1307: my $height = 600;
1.430 albertel 1308: my $helptopic=&general_help();
1309: my $details_link = '/adm/help/'.$helptopic.'.hlp';
1.261 albertel 1310: my $nothing=&Apache::lonhtmlcommon::javascript_nothing();
1.331 albertel 1311: my $start_page =
1312: &Apache::loncommon::start_page('Help Menu', undef,
1313: {'frameset' => 1,
1314: 'js_ready' => 1,
1315: 'add_entries' => {
1316: 'border' => '0',
1.579 raeburn 1317: 'rows' => "110,*",},});
1.331 albertel 1318: my $end_page =
1319: &Apache::loncommon::end_page({'frameset' => 1,
1320: 'js_ready' => 1,});
1321:
1.436 albertel 1322: my $template .= <<"ENDTEMPLATE";
1323: <script type="text/javascript">
1.877 bisitz 1324: // <![CDATA[
1.253 albertel 1325: // <!-- BEGIN LON-CAPA Internal
1.430 albertel 1326: var banner_link = '';
1.243 raeburn 1327: function helpMenu(target) {
1328: var caller = this;
1329: if (target == 'open') {
1330: var newWindow = null;
1331: try {
1.262 albertel 1332: newWindow = window.open($nothing,"helpmenu","HEIGHT=$height,WIDTH=$width,resizable=yes,scrollbars=yes" )
1.243 raeburn 1333: }
1334: catch(error) {
1335: writeHelp(caller);
1336: return;
1337: }
1338: if (newWindow) {
1339: caller = newWindow;
1340: }
1.193 raeburn 1341: }
1.243 raeburn 1342: writeHelp(caller);
1343: return;
1344: }
1345: function writeHelp(caller) {
1.430 albertel 1346: caller.document.writeln('$start_page<frame name="bannerframe" src="'+banner_link+'" /><frame name="bodyframe" src="$details_link" /> $end_page')
1.243 raeburn 1347: caller.document.close()
1348: caller.focus()
1.193 raeburn 1349: }
1.877 bisitz 1350: // END LON-CAPA Internal -->
1.253 albertel 1351: // ]]>
1.436 albertel 1352: </script>
1.193 raeburn 1353: ENDTEMPLATE
1354: return $template;
1355: }
1356:
1.172 www 1357: sub help_open_bug {
1358: my ($topic, $text, $stayOnPage, $width, $height) = @_;
1.258 albertel 1359: unless ($env{'user.adv'}) { return ''; }
1.172 www 1360: unless ($Apache::lonnet::perlvar{'BugzillaHost'}) { return ''; }
1361: $text = "" if (not defined $text);
1362: $stayOnPage = 0 if (not defined $stayOnPage);
1.798 tempelho 1363: if ($env{'environment.remote'} eq 'off' ) {
1.172 www 1364: $stayOnPage=1;
1365: }
1.184 albertel 1366: $width = 600 if (not defined $width);
1367: $height = 600 if (not defined $height);
1.172 www 1368:
1369: $topic=~s/\W+/\+/g;
1370: my $link='';
1371: my $template='';
1.379 albertel 1372: my $url=$Apache::lonnet::perlvar{'BugzillaHost'}.'enter_bug.cgi?product=LON-CAPA&bug_file_loc='.
1373: &escape($ENV{'REQUEST_URI'}).'&component='.$topic;
1.172 www 1374: if (!$stayOnPage)
1375: {
1376: $link = "javascript:void(open('$url', 'Bugzilla', 'menubar=0,toolbar=1,scrollbars=1,width=$width,height=$height,resizable=yes'))";
1377: }
1378: else
1379: {
1380: $link = $url;
1381: }
1382: # Add the text
1383: if ($text ne "")
1384: {
1385: $template .=
1386: "<table bgcolor='#AA3333' cellspacing='1' cellpadding='1' border='0'><tr>".
1.705 tempelho 1387: "<td bgcolor='#FF5555'><a target=\"_top\" href=\"$link\"><span style=\"color:#FFFFFF;font-size:10pt;\">$text</span></a>";
1.172 www 1388: }
1389:
1390: # Add the graphic
1.179 matthew 1391: my $title = &mt('Report a Bug');
1.215 albertel 1392: my $bugicon=&lonhttpdurl("/adm/lonMisc/smallBug.gif");
1.172 www 1393: $template .= <<"ENDTEMPLATE";
1.436 albertel 1394: <a target="_top" href="$link" title="$title"><img src="$bugicon" border="0" alt="(Bug: $topic)" /></a>
1.172 www 1395: ENDTEMPLATE
1396: if ($text ne '') { $template.='</td></tr></table>' };
1397: return $template;
1398:
1399: }
1400:
1401: sub help_open_faq {
1402: my ($topic, $text, $stayOnPage, $width, $height) = @_;
1.258 albertel 1403: unless ($env{'user.adv'}) { return ''; }
1.172 www 1404: unless ($Apache::lonnet::perlvar{'FAQHost'}) { return ''; }
1405: $text = "" if (not defined $text);
1406: $stayOnPage = 0 if (not defined $stayOnPage);
1.798 tempelho 1407: if ($env{'environment.remote'} eq 'off' ) {
1.172 www 1408: $stayOnPage=1;
1409: }
1410: $width = 350 if (not defined $width);
1411: $height = 400 if (not defined $height);
1412:
1413: $topic=~s/\W+/\+/g;
1414: my $link='';
1415: my $template='';
1416: my $url=$Apache::lonnet::perlvar{'FAQHost'}.'/fom/cache/'.$topic.'.html';
1417: if (!$stayOnPage)
1418: {
1419: $link = "javascript:void(open('$url', 'FAQ-O-Matic', 'menubar=0,toolbar=1,scrollbars=1,width=$width,height=$height,resizable=yes'))";
1420: }
1421: else
1422: {
1423: $link = $url;
1424: }
1425:
1426: # Add the text
1427: if ($text ne "")
1428: {
1429: $template .=
1.173 www 1430: "<table bgcolor='#337733' cellspacing='1' cellpadding='1' border='0'><tr>".
1.705 tempelho 1431: "<td bgcolor='#448844'><a target=\"_top\" href=\"$link\"><span style=\"color:#FFFFFF; font-size:10pt;\">$text</span></a>";
1.172 www 1432: }
1433:
1434: # Add the graphic
1.179 matthew 1435: my $title = &mt('View the FAQ');
1.215 albertel 1436: my $faqicon=&lonhttpdurl("/adm/lonMisc/smallFAQ.gif");
1.172 www 1437: $template .= <<"ENDTEMPLATE";
1.436 albertel 1438: <a target="_top" href="$link" title="$title"><img src="$faqicon" border="0" alt="(FAQ: $topic)" /></a>
1.172 www 1439: ENDTEMPLATE
1440: if ($text ne '') { $template.='</td></tr></table>' };
1441: return $template;
1442:
1.44 bowersj2 1443: }
1.37 matthew 1444:
1.180 matthew 1445: ###############################################################
1446: ###############################################################
1447:
1.45 matthew 1448: =pod
1449:
1.648 raeburn 1450: =item * &change_content_javascript():
1.256 matthew 1451:
1452: This and the next function allow you to create small sections of an
1453: otherwise static HTML page that you can update on the fly with
1454: Javascript, even in Netscape 4.
1455:
1456: The Javascript fragment returned by this function (no E<lt>scriptE<gt> tag)
1457: must be written to the HTML page once. It will prove the Javascript
1458: function "change(name, content)". Calling the change function with the
1459: name of the section
1460: you want to update, matching the name passed to C<changable_area>, and
1461: the new content you want to put in there, will put the content into
1462: that area.
1463:
1464: B<Note>: Netscape 4 only reserves enough space for the changable area
1465: to contain room for the original contents. You need to "make space"
1466: for whatever changes you wish to make, and be B<sure> to check your
1467: code in Netscape 4. This feature in Netscape 4 is B<not> powerful;
1468: it's adequate for updating a one-line status display, but little more.
1469: This script will set the space to 100% width, so you only need to
1470: worry about height in Netscape 4.
1471:
1472: Modern browsers are much less limiting, and if you can commit to the
1473: user not using Netscape 4, this feature may be used freely with
1474: pretty much any HTML.
1475:
1476: =cut
1477:
1478: sub change_content_javascript {
1479: # If we're on Netscape 4, we need to use Layer-based code
1.258 albertel 1480: if ($env{'browser.type'} eq 'netscape' &&
1481: $env{'browser.version'} =~ /^4\./) {
1.256 matthew 1482: return (<<NETSCAPE4);
1483: function change(name, content) {
1484: doc = document.layers[name+"___escape"].layers[0].document;
1485: doc.open();
1486: doc.write(content);
1487: doc.close();
1488: }
1489: NETSCAPE4
1490: } else {
1491: # Otherwise, we need to use semi-standards-compliant code
1492: # (technically, "innerHTML" isn't standard but the equivalent
1493: # is really scary, and every useful browser supports it
1494: return (<<DOMBASED);
1495: function change(name, content) {
1496: element = document.getElementById(name);
1497: element.innerHTML = content;
1498: }
1499: DOMBASED
1500: }
1501: }
1502:
1503: =pod
1504:
1.648 raeburn 1505: =item * &changable_area($name,$origContent):
1.256 matthew 1506:
1507: This provides a "changable area" that can be modified on the fly via
1508: the Javascript code provided in C<change_content_javascript>. $name is
1509: the name you will use to reference the area later; do not repeat the
1510: same name on a given HTML page more then once. $origContent is what
1511: the area will originally contain, which can be left blank.
1512:
1513: =cut
1514:
1515: sub changable_area {
1516: my ($name, $origContent) = @_;
1517:
1.258 albertel 1518: if ($env{'browser.type'} eq 'netscape' &&
1519: $env{'browser.version'} =~ /^4\./) {
1.256 matthew 1520: # If this is netscape 4, we need to use the Layer tag
1521: return "<ilayer width='100%' id='${name}___escape' overflow='none'><layer width='100%' id='$name' overflow='none'>$origContent</layer></ilayer>";
1522: } else {
1523: return "<span id='$name'>$origContent</span>";
1524: }
1525: }
1526:
1527: =pod
1528:
1.648 raeburn 1529: =item * &viewport_geometry_js
1.590 raeburn 1530:
1531: Provides javascript object (Geometry) which can provide information about the viewport geometry for the client browser.
1532:
1533: =cut
1534:
1535:
1536: sub viewport_geometry_js {
1537: return <<"GEOMETRY";
1538: var Geometry = {};
1539: function init_geometry() {
1540: if (Geometry.init) { return };
1541: Geometry.init=1;
1542: if (window.innerHeight) {
1543: Geometry.getViewportHeight = function() { return window.innerHeight; };
1544: Geometry.getViewportWidth = function() { return window.innerWidth; };
1545: Geometry.getHorizontalScroll = function() { return window.pageXOffset; };
1546: Geometry.getVerticalScroll = function() { return window.pageYOffset; };
1547: }
1548: else if (document.documentElement && document.documentElement.clientHeight) {
1549: Geometry.getViewportHeight =
1550: function() { return document.documentElement.clientHeight; };
1551: Geometry.getViewportWidth =
1552: function() { return document.documentElement.clientWidth; };
1553:
1554: Geometry.getHorizontalScroll =
1555: function() { return document.documentElement.scrollLeft; };
1556: Geometry.getVerticalScroll =
1557: function() { return document.documentElement.scrollTop; };
1558: }
1559: else if (document.body.clientHeight) {
1560: Geometry.getViewportHeight =
1561: function() { return document.body.clientHeight; };
1562: Geometry.getViewportWidth =
1563: function() { return document.body.clientWidth; };
1564: Geometry.getHorizontalScroll =
1565: function() { return document.body.scrollLeft; };
1566: Geometry.getVerticalScroll =
1567: function() { return document.body.scrollTop; };
1568: }
1569: }
1570:
1571: GEOMETRY
1572: }
1573:
1574: =pod
1575:
1.648 raeburn 1576: =item * &viewport_size_js()
1.590 raeburn 1577:
1578: Provides a javascript function to set values of two form elements - width and height (elements are passed in as arguments to the javascript function) to the dimensions of the user's browser window.
1579:
1580: =cut
1581:
1582: sub viewport_size_js {
1583: my $geometry = &viewport_geometry_js();
1584: return <<"DIMS";
1585:
1586: $geometry
1587:
1588: function getViewportDims(width,height) {
1589: init_geometry();
1590: width.value = Geometry.getViewportWidth();
1591: height.value = Geometry.getViewportHeight();
1592: return;
1593: }
1594:
1595: DIMS
1596: }
1597:
1598: =pod
1599:
1.648 raeburn 1600: =item * &resize_textarea_js()
1.565 albertel 1601:
1602: emits the needed javascript to resize a textarea to be as big as possible
1603:
1604: creates a function resize_textrea that takes two IDs first should be
1605: the id of the element to resize, second should be the id of a div that
1606: surrounds everything that comes after the textarea, this routine needs
1607: to be attached to the <body> for the onload and onresize events.
1608:
1.648 raeburn 1609: =back
1.565 albertel 1610:
1611: =cut
1612:
1613: sub resize_textarea_js {
1.590 raeburn 1614: my $geometry = &viewport_geometry_js();
1.565 albertel 1615: return <<"RESIZE";
1616: <script type="text/javascript">
1.824 bisitz 1617: // <![CDATA[
1.590 raeburn 1618: $geometry
1.565 albertel 1619:
1.588 albertel 1620: function getX(element) {
1621: var x = 0;
1622: while (element) {
1623: x += element.offsetLeft;
1624: element = element.offsetParent;
1625: }
1626: return x;
1627: }
1628: function getY(element) {
1629: var y = 0;
1630: while (element) {
1631: y += element.offsetTop;
1632: element = element.offsetParent;
1633: }
1634: return y;
1635: }
1636:
1637:
1.565 albertel 1638: function resize_textarea(textarea_id,bottom_id) {
1639: init_geometry();
1640: var textarea = document.getElementById(textarea_id);
1641: //alert(textarea);
1642:
1.588 albertel 1643: var textarea_top = getY(textarea);
1.565 albertel 1644: var textarea_height = textarea.offsetHeight;
1645: var bottom = document.getElementById(bottom_id);
1.588 albertel 1646: var bottom_top = getY(bottom);
1.565 albertel 1647: var bottom_height = bottom.offsetHeight;
1648: var window_height = Geometry.getViewportHeight();
1.588 albertel 1649: var fudge = 23;
1.565 albertel 1650: var new_height = window_height-fudge-textarea_top-bottom_height;
1651: if (new_height < 300) {
1652: new_height = 300;
1653: }
1654: textarea.style.height=new_height+'px';
1655: }
1.824 bisitz 1656: // ]]>
1.565 albertel 1657: </script>
1658: RESIZE
1659:
1660: }
1661:
1662: =pod
1663:
1.256 matthew 1664: =head1 Excel and CSV file utility routines
1665:
1666: =over 4
1667:
1668: =cut
1669:
1670: ###############################################################
1671: ###############################################################
1672:
1673: =pod
1674:
1.648 raeburn 1675: =item * &csv_translate($text)
1.37 matthew 1676:
1.185 www 1677: Translate $text to allow it to be output as a 'comma separated values'
1.37 matthew 1678: format.
1679:
1680: =cut
1681:
1.180 matthew 1682: ###############################################################
1683: ###############################################################
1.37 matthew 1684: sub csv_translate {
1685: my $text = shift;
1686: $text =~ s/\"/\"\"/g;
1.209 albertel 1687: $text =~ s/\n/ /g;
1.37 matthew 1688: return $text;
1689: }
1.180 matthew 1690:
1691: ###############################################################
1692: ###############################################################
1693:
1694: =pod
1695:
1.648 raeburn 1696: =item * &define_excel_formats()
1.180 matthew 1697:
1698: Define some commonly used Excel cell formats.
1699:
1700: Currently supported formats:
1701:
1702: =over 4
1703:
1704: =item header
1705:
1706: =item bold
1707:
1708: =item h1
1709:
1710: =item h2
1711:
1712: =item h3
1713:
1.256 matthew 1714: =item h4
1715:
1716: =item i
1717:
1.180 matthew 1718: =item date
1719:
1720: =back
1721:
1722: Inputs: $workbook
1723:
1724: Returns: $format, a hash reference.
1725:
1726: =cut
1727:
1728: ###############################################################
1729: ###############################################################
1730: sub define_excel_formats {
1731: my ($workbook) = @_;
1732: my $format;
1733: $format->{'header'} = $workbook->add_format(bold => 1,
1734: bottom => 1,
1735: align => 'center');
1736: $format->{'bold'} = $workbook->add_format(bold=>1);
1737: $format->{'h1'} = $workbook->add_format(bold=>1, size=>18);
1738: $format->{'h2'} = $workbook->add_format(bold=>1, size=>16);
1739: $format->{'h3'} = $workbook->add_format(bold=>1, size=>14);
1.255 matthew 1740: $format->{'h4'} = $workbook->add_format(bold=>1, size=>12);
1.246 matthew 1741: $format->{'i'} = $workbook->add_format(italic=>1);
1.180 matthew 1742: $format->{'date'} = $workbook->add_format(num_format=>
1.207 matthew 1743: 'mm/dd/yyyy hh:mm:ss');
1.180 matthew 1744: return $format;
1745: }
1746:
1747: ###############################################################
1748: ###############################################################
1.113 bowersj2 1749:
1750: =pod
1751:
1.648 raeburn 1752: =item * &create_workbook()
1.255 matthew 1753:
1754: Create an Excel worksheet. If it fails, output message on the
1755: request object and return undefs.
1756:
1757: Inputs: Apache request object
1758:
1759: Returns (undef) on failure,
1760: Excel worksheet object, scalar with filename, and formats
1761: from &Apache::loncommon::define_excel_formats on success
1762:
1763: =cut
1764:
1765: ###############################################################
1766: ###############################################################
1767: sub create_workbook {
1768: my ($r) = @_;
1769: #
1770: # Create the excel spreadsheet
1771: my $filename = '/prtspool/'.
1.258 albertel 1772: $env{'user.name'}.'_'.$env{'user.domain'}.'_'.
1.255 matthew 1773: time.'_'.rand(1000000000).'.xls';
1774: my $workbook = Spreadsheet::WriteExcel->new('/home/httpd'.$filename);
1775: if (! defined($workbook)) {
1776: $r->log_error("Error creating excel spreadsheet $filename: $!");
1.928 bisitz 1777: $r->print(
1778: '<p class="LC_error">'
1779: .&mt('Problems occurred in creating the new Excel file.')
1780: .' '.&mt('This error has been logged.')
1781: .' '.&mt('Please alert your LON-CAPA administrator.')
1782: .'</p>'
1783: );
1.255 matthew 1784: return (undef);
1785: }
1786: #
1787: $workbook->set_tempdir('/home/httpd/perl/tmp');
1788: #
1789: my $format = &Apache::loncommon::define_excel_formats($workbook);
1790: return ($workbook,$filename,$format);
1791: }
1792:
1793: ###############################################################
1794: ###############################################################
1795:
1796: =pod
1797:
1.648 raeburn 1798: =item * &create_text_file()
1.113 bowersj2 1799:
1.542 raeburn 1800: Create a file to write to and eventually make available to the user.
1.256 matthew 1801: If file creation fails, outputs an error message on the request object and
1802: return undefs.
1.113 bowersj2 1803:
1.256 matthew 1804: Inputs: Apache request object, and file suffix
1.113 bowersj2 1805:
1.256 matthew 1806: Returns (undef) on failure,
1807: Filehandle and filename on success.
1.113 bowersj2 1808:
1809: =cut
1810:
1.256 matthew 1811: ###############################################################
1812: ###############################################################
1813: sub create_text_file {
1814: my ($r,$suffix) = @_;
1815: if (! defined($suffix)) { $suffix = 'txt'; };
1816: my $fh;
1817: my $filename = '/prtspool/'.
1.258 albertel 1818: $env{'user.name'}.'_'.$env{'user.domain'}.'_'.
1.256 matthew 1819: time.'_'.rand(1000000000).'.'.$suffix;
1820: $fh = Apache::File->new('>/home/httpd'.$filename);
1821: if (! defined($fh)) {
1822: $r->log_error("Couldn't open $filename for output $!");
1.928 bisitz 1823: $r->print(
1824: '<p class="LC_error">'
1825: .&mt('Problems occurred in creating the output file.')
1826: .' '.&mt('This error has been logged.')
1827: .' '.&mt('Please alert your LON-CAPA administrator.')
1828: .'</p>'
1829: );
1.113 bowersj2 1830: }
1.256 matthew 1831: return ($fh,$filename)
1.113 bowersj2 1832: }
1833:
1834:
1.256 matthew 1835: =pod
1.113 bowersj2 1836:
1837: =back
1838:
1839: =cut
1.37 matthew 1840:
1841: ###############################################################
1.33 matthew 1842: ## Home server <option> list generating code ##
1843: ###############################################################
1.35 matthew 1844:
1.169 www 1845: # ------------------------------------------
1846:
1847: sub domain_select {
1848: my ($name,$value,$multiple)=@_;
1849: my %domains=map {
1.514 albertel 1850: $_ => $_.' '. &Apache::lonnet::domain($_,'description')
1.512 albertel 1851: } &Apache::lonnet::all_domains();
1.169 www 1852: if ($multiple) {
1853: $domains{''}=&mt('Any domain');
1.550 albertel 1854: $domains{'select_form_order'} = [sort {lc($a) cmp lc($b) } (keys(%domains))];
1.287 albertel 1855: return &multiple_select_form($name,$value,4,\%domains);
1.169 www 1856: } else {
1.550 albertel 1857: $domains{'select_form_order'} = [sort {lc($a) cmp lc($b) } (keys(%domains))];
1.948.2.7 raeburn 1858: return &select_form($name,$value,\%domains);
1.169 www 1859: }
1860: }
1861:
1.282 albertel 1862: #-------------------------------------------
1863:
1864: =pod
1865:
1.519 raeburn 1866: =head1 Routines for form select boxes
1867:
1868: =over 4
1869:
1.648 raeburn 1870: =item * &multiple_select_form($name,$value,$size,$hash,$order)
1.282 albertel 1871:
1872: Returns a string containing a <select> element int multiple mode
1873:
1874:
1875: Args:
1876: $name - name of the <select> element
1.506 raeburn 1877: $value - scalar or array ref of values that should already be selected
1.282 albertel 1878: $size - number of rows long the select element is
1.283 albertel 1879: $hash - the elements should be 'option' => 'shown text'
1.282 albertel 1880: (shown text should already have been &mt())
1.506 raeburn 1881: $order - (optional) array ref of the order to show the elements in
1.283 albertel 1882:
1.282 albertel 1883: =cut
1884:
1885: #-------------------------------------------
1.169 www 1886: sub multiple_select_form {
1.284 albertel 1887: my ($name,$value,$size,$hash,$order)=@_;
1.169 www 1888: my %selected = map { $_ => 1 } ref($value)?@{$value}:($value);
1889: my $output='';
1.191 matthew 1890: if (! defined($size)) {
1891: $size = 4;
1.283 albertel 1892: if (scalar(keys(%$hash))<4) {
1893: $size = scalar(keys(%$hash));
1.191 matthew 1894: }
1895: }
1.734 bisitz 1896: $output.="\n".'<select name="'.$name.'" size="'.$size.'" multiple="multiple">';
1.501 banghart 1897: my @order;
1.506 raeburn 1898: if (ref($order) eq 'ARRAY') {
1899: @order = @{$order};
1900: } else {
1901: @order = sort(keys(%$hash));
1.501 banghart 1902: }
1903: if (exists($$hash{'select_form_order'})) {
1904: @order = @{$$hash{'select_form_order'}};
1905: }
1906:
1.284 albertel 1907: foreach my $key (@order) {
1.356 albertel 1908: $output.='<option value="'.&HTML::Entities::encode($key,'"<>&').'" ';
1.284 albertel 1909: $output.='selected="selected" ' if ($selected{$key});
1910: $output.='>'.$hash->{$key}."</option>\n";
1.169 www 1911: }
1912: $output.="</select>\n";
1913: return $output;
1914: }
1915:
1.88 www 1916: #-------------------------------------------
1917:
1918: =pod
1919:
1.948.2.7 raeburn 1920: =item * &select_form($defdom,$name,$hashref,$onchange)
1.88 www 1921:
1922: Returns a string containing a <select name='$name' size='1'> form to
1.948.2.7 raeburn 1923: allow a user to select options from a ref to a hash containing:
1924: option_name => displayed text. An optional $onchange can include
1925: a javascript onchange item, e.g., onchange="this.form.submit();"
1926:
1.88 www 1927: See lonrights.pm for an example invocation and use.
1928:
1929: =cut
1930:
1931: #-------------------------------------------
1932: sub select_form {
1.948.2.7 raeburn 1933: my ($def,$name,$hashref,$onchange) = @_;
1934: return unless (ref($hashref) eq 'HASH');
1935: if ($onchange) {
1936: $onchange = ' onchange="'.$onchange.'"';
1937: }
1938: my $selectform = "<select name=\"$name\" size=\"1\"$onchange>\n";
1.128 albertel 1939: my @keys;
1.948.2.7 raeburn 1940: if (exists($hashref->{'select_form_order'})) {
1941: @keys=@{$hashref->{'select_form_order'}};
1.128 albertel 1942: } else {
1.948.2.7 raeburn 1943: @keys=sort(keys(%{$hashref}));
1.128 albertel 1944: }
1.356 albertel 1945: foreach my $key (@keys) {
1946: $selectform.=
1947: '<option value="'.&HTML::Entities::encode($key,'"<>&').'" '.
1948: ($key eq $def ? 'selected="selected" ' : '').
1.948.2.7 raeburn 1949: ">".$hashref->{$key}."</option>\n";
1.88 www 1950: }
1951: $selectform.="</select>";
1952: return $selectform;
1953: }
1954:
1.475 www 1955: # For display filters
1956:
1957: sub display_filter {
1958: if (!$env{'form.show'}) { $env{'form.show'}=10; }
1.477 www 1959: if (!$env{'form.displayfilter'}) { $env{'form.displayfilter'}='currentfolder'; }
1.714 bisitz 1960: return '<span class="LC_nobreak"><label>'.&mt('Records [_1]',
1.475 www 1961: &Apache::lonmeta::selectbox('show',$env{'form.show'},undef,
1962: (&mt('all'),10,20,50,100,1000,10000))).
1.714 bisitz 1963: '</label></span> <span class="LC_nobreak">'.
1.475 www 1964: &mt('Filter [_1]',
1.477 www 1965: &select_form($env{'form.displayfilter'},
1966: 'displayfilter',
1.948.2.7 raeburn 1967: {'currentfolder' => 'Current folder/page',
1.477 www 1968: 'containing' => 'Containing phrase',
1.948.2.7 raeburn 1969: 'none' => 'None'})).
1.714 bisitz 1970: '<input type="text" name="containingphrase" size="30" value="'.&HTML::Entities::encode($env{'form.containingphrase'}).'" /></span>';
1.475 www 1971: }
1972:
1.167 www 1973: sub gradeleveldescription {
1974: my $gradelevel=shift;
1975: my %gradelevels=(0 => 'Not specified',
1976: 1 => 'Grade 1',
1977: 2 => 'Grade 2',
1978: 3 => 'Grade 3',
1979: 4 => 'Grade 4',
1980: 5 => 'Grade 5',
1981: 6 => 'Grade 6',
1982: 7 => 'Grade 7',
1983: 8 => 'Grade 8',
1984: 9 => 'Grade 9',
1985: 10 => 'Grade 10',
1986: 11 => 'Grade 11',
1987: 12 => 'Grade 12',
1988: 13 => 'Grade 13',
1989: 14 => '100 Level',
1990: 15 => '200 Level',
1991: 16 => '300 Level',
1992: 17 => '400 Level',
1993: 18 => 'Graduate Level');
1994: return &mt($gradelevels{$gradelevel});
1995: }
1996:
1.163 www 1997: sub select_level_form {
1998: my ($deflevel,$name)=@_;
1999: unless ($deflevel) { $deflevel=0; }
1.167 www 2000: my $selectform = "<select name=\"$name\" size=\"1\">\n";
2001: for (my $i=0; $i<=18; $i++) {
2002: $selectform.="<option value=\"$i\" ".
1.253 albertel 2003: ($i==$deflevel ? 'selected="selected" ' : '').
1.167 www 2004: ">".&gradeleveldescription($i)."</option>\n";
2005: }
2006: $selectform.="</select>";
2007: return $selectform;
1.163 www 2008: }
1.167 www 2009:
1.35 matthew 2010: #-------------------------------------------
2011:
1.45 matthew 2012: =pod
2013:
1.910 raeburn 2014: =item * &select_dom_form($defdom,$name,$includeempty,$showdomdesc,$onchange,$incdoms)
1.35 matthew 2015:
2016: Returns a string containing a <select name='$name' size='1'> form to
2017: allow a user to select the domain to preform an operation in.
2018: See loncreateuser.pm for an example invocation and use.
2019:
1.90 www 2020: If the $includeempty flag is set, it also includes an empty choice ("no domain
2021: selected");
2022:
1.743 raeburn 2023: If the $showdomdesc flag is set, the domain name is followed by the domain description.
2024:
1.910 raeburn 2025: The optional $onchange argument specifies what should occur if the domain selector is changed, e.g., 'this.form.submit()' if the form is to be automatically submitted.
2026:
2027: The optional $incdoms is a reference to an array of domains which will be the only available options.
1.563 raeburn 2028:
1.35 matthew 2029: =cut
2030:
2031: #-------------------------------------------
1.34 matthew 2032: sub select_dom_form {
1.910 raeburn 2033: my ($defdom,$name,$includeempty,$showdomdesc,$onchange,$incdoms) = @_;
1.872 raeburn 2034: if ($onchange) {
1.874 raeburn 2035: $onchange = ' onchange="'.$onchange.'"';
1.743 raeburn 2036: }
1.910 raeburn 2037: my @domains;
2038: if (ref($incdoms) eq 'ARRAY') {
2039: @domains = sort {lc($a) cmp lc($b)} (@{$incdoms});
2040: } else {
2041: @domains = sort {lc($a) cmp lc($b)} (&Apache::lonnet::all_domains());
2042: }
1.90 www 2043: if ($includeempty) { @domains=('',@domains); }
1.743 raeburn 2044: my $selectdomain = "<select name=\"$name\" size=\"1\"$onchange>\n";
1.356 albertel 2045: foreach my $dom (@domains) {
2046: $selectdomain.="<option value=\"$dom\" ".
1.563 raeburn 2047: ($dom eq $defdom ? 'selected="selected" ' : '').'>'.$dom;
2048: if ($showdomdesc) {
2049: if ($dom ne '') {
2050: my $domdesc = &Apache::lonnet::domain($dom,'description');
2051: if ($domdesc ne '') {
2052: $selectdomain .= ' ('.$domdesc.')';
2053: }
2054: }
2055: }
2056: $selectdomain .= "</option>\n";
1.34 matthew 2057: }
2058: $selectdomain.="</select>";
2059: return $selectdomain;
2060: }
2061:
1.35 matthew 2062: #-------------------------------------------
2063:
1.45 matthew 2064: =pod
2065:
1.648 raeburn 2066: =item * &home_server_form_item($domain,$name,$defaultflag)
1.35 matthew 2067:
1.586 raeburn 2068: input: 4 arguments (two required, two optional) -
2069: $domain - domain of new user
2070: $name - name of form element
2071: $default - Value of 'default' causes a default item to be first
2072: option, and selected by default.
2073: $hide - Value of 'hide' causes hiding of the name of the server,
2074: if 1 server found, or default, if 0 found.
1.594 raeburn 2075: output: returns 2 items:
1.586 raeburn 2076: (a) form element which contains either:
2077: (i) <select name="$name">
2078: <option value="$hostid1">$hostid $servers{$hostid}</option>
2079: <option value="$hostid2">$hostid $servers{$hostid}</option>
2080: </select>
2081: form item if there are multiple library servers in $domain, or
2082: (ii) an <input type="hidden" name="$name" value="$hostid" /> form item
2083: if there is only one library server in $domain.
2084:
2085: (b) number of library servers found.
2086:
2087: See loncreateuser.pm for example of use.
1.35 matthew 2088:
2089: =cut
2090:
2091: #-------------------------------------------
1.586 raeburn 2092: sub home_server_form_item {
2093: my ($domain,$name,$default,$hide) = @_;
1.513 albertel 2094: my %servers = &Apache::lonnet::get_servers($domain,'library');
1.586 raeburn 2095: my $result;
2096: my $numlib = keys(%servers);
2097: if ($numlib > 1) {
2098: $result .= '<select name="'.$name.'" />'."\n";
2099: if ($default) {
1.804 bisitz 2100: $result .= '<option value="default" selected="selected">'.&mt('default').
1.586 raeburn 2101: '</option>'."\n";
2102: }
2103: foreach my $hostid (sort(keys(%servers))) {
2104: $result.= '<option value="'.$hostid.'">'.
2105: $hostid.' '.$servers{$hostid}."</option>\n";
2106: }
2107: $result .= '</select>'."\n";
2108: } elsif ($numlib == 1) {
2109: my $hostid;
2110: foreach my $item (keys(%servers)) {
2111: $hostid = $item;
2112: }
2113: $result .= '<input type="hidden" name="'.$name.'" value="'.
2114: $hostid.'" />';
2115: if (!$hide) {
2116: $result .= $hostid.' '.$servers{$hostid};
2117: }
2118: $result .= "\n";
2119: } elsif ($default) {
2120: $result .= '<input type="hidden" name="'.$name.
2121: '" value="default" />';
2122: if (!$hide) {
2123: $result .= &mt('default');
2124: }
2125: $result .= "\n";
1.33 matthew 2126: }
1.586 raeburn 2127: return ($result,$numlib);
1.33 matthew 2128: }
1.112 bowersj2 2129:
2130: =pod
2131:
1.534 albertel 2132: =back
2133:
1.112 bowersj2 2134: =cut
1.87 matthew 2135:
2136: ###############################################################
1.112 bowersj2 2137: ## Decoding User Agent ##
1.87 matthew 2138: ###############################################################
2139:
2140: =pod
2141:
1.112 bowersj2 2142: =head1 Decoding the User Agent
2143:
2144: =over 4
2145:
2146: =item * &decode_user_agent()
1.87 matthew 2147:
2148: Inputs: $r
2149:
2150: Outputs:
2151:
2152: =over 4
2153:
1.112 bowersj2 2154: =item * $httpbrowser
1.87 matthew 2155:
1.112 bowersj2 2156: =item * $clientbrowser
1.87 matthew 2157:
1.112 bowersj2 2158: =item * $clientversion
1.87 matthew 2159:
1.112 bowersj2 2160: =item * $clientmathml
1.87 matthew 2161:
1.112 bowersj2 2162: =item * $clientunicode
1.87 matthew 2163:
1.112 bowersj2 2164: =item * $clientos
1.87 matthew 2165:
2166: =back
2167:
1.157 matthew 2168: =back
2169:
1.87 matthew 2170: =cut
2171:
2172: ###############################################################
2173: ###############################################################
2174: sub decode_user_agent {
1.247 albertel 2175: my ($r)=@_;
1.87 matthew 2176: my @browsertype=split(/\&/,$Apache::lonnet::perlvar{"lonBrowsDet"});
2177: my %mathcap=split(/\&/,$$Apache::lonnet::perlvar{"lonMathML"});
2178: my $httpbrowser=$ENV{"HTTP_USER_AGENT"};
1.247 albertel 2179: if (!$httpbrowser && $r) { $httpbrowser=$r->header_in('User-Agent'); }
1.87 matthew 2180: my $clientbrowser='unknown';
2181: my $clientversion='0';
2182: my $clientmathml='';
2183: my $clientunicode='0';
2184: for (my $i=0;$i<=$#browsertype;$i++) {
2185: my ($bname,$match,$notmatch,$vreg,$minv,$univ)=split(/\:/,$browsertype[$i]);
2186: if (($httpbrowser=~/$match/i) && ($httpbrowser!~/$notmatch/i)) {
2187: $clientbrowser=$bname;
2188: $httpbrowser=~/$vreg/i;
2189: $clientversion=$1;
2190: $clientmathml=($clientversion>=$minv);
2191: $clientunicode=($clientversion>=$univ);
2192: }
2193: }
2194: my $clientos='unknown';
2195: if (($httpbrowser=~/linux/i) ||
2196: ($httpbrowser=~/unix/i) ||
2197: ($httpbrowser=~/ux/i) ||
2198: ($httpbrowser=~/solaris/i)) { $clientos='unix'; }
2199: if (($httpbrowser=~/vax/i) ||
2200: ($httpbrowser=~/vms/i)) { $clientos='vms'; }
2201: if ($httpbrowser=~/next/i) { $clientos='next'; }
2202: if (($httpbrowser=~/mac/i) ||
2203: ($httpbrowser=~/powerpc/i)) { $clientos='mac'; }
2204: if ($httpbrowser=~/win/i) { $clientos='win'; }
2205: if ($httpbrowser=~/embed/i) { $clientos='pda'; }
2206: return ($httpbrowser,$clientbrowser,$clientversion,$clientmathml,
2207: $clientunicode,$clientos,);
2208: }
2209:
1.32 matthew 2210: ###############################################################
2211: ## Authentication changing form generation subroutines ##
2212: ###############################################################
2213: ##
2214: ## All of the authform_xxxxxxx subroutines take their inputs in a
2215: ## hash, and have reasonable default values.
2216: ##
2217: ## formname = the name given in the <form> tag.
1.35 matthew 2218: #-------------------------------------------
2219:
1.45 matthew 2220: =pod
2221:
1.112 bowersj2 2222: =head1 Authentication Routines
2223:
2224: =over 4
2225:
1.648 raeburn 2226: =item * &authform_xxxxxx()
1.35 matthew 2227:
2228: The authform_xxxxxx subroutines provide javascript and html forms which
2229: handle some of the conveniences required for authentication forms.
2230: This is not an optimal method, but it works.
2231:
2232: =over 4
2233:
1.112 bowersj2 2234: =item * authform_header
1.35 matthew 2235:
1.112 bowersj2 2236: =item * authform_authorwarning
1.35 matthew 2237:
1.112 bowersj2 2238: =item * authform_nochange
1.35 matthew 2239:
1.112 bowersj2 2240: =item * authform_kerberos
1.35 matthew 2241:
1.112 bowersj2 2242: =item * authform_internal
1.35 matthew 2243:
1.112 bowersj2 2244: =item * authform_filesystem
1.35 matthew 2245:
2246: =back
2247:
1.648 raeburn 2248: See loncreateuser.pm for invocation and use examples.
1.157 matthew 2249:
1.35 matthew 2250: =cut
2251:
2252: #-------------------------------------------
1.32 matthew 2253: sub authform_header{
2254: my %in = (
2255: formname => 'cu',
1.80 albertel 2256: kerb_def_dom => '',
1.32 matthew 2257: @_,
2258: );
2259: $in{'formname'} = 'document.' . $in{'formname'};
2260: my $result='';
1.80 albertel 2261:
2262: #---------------------------------------------- Code for upper case translation
2263: my $Javascript_toUpperCase;
2264: unless ($in{kerb_def_dom}) {
2265: $Javascript_toUpperCase =<<"END";
2266: switch (choice) {
2267: case 'krb': currentform.elements[choicearg].value =
2268: currentform.elements[choicearg].value.toUpperCase();
2269: break;
2270: default:
2271: }
2272: END
2273: } else {
2274: $Javascript_toUpperCase = "";
2275: }
2276:
1.165 raeburn 2277: my $radioval = "'nochange'";
1.591 raeburn 2278: if (defined($in{'curr_authtype'})) {
2279: if ($in{'curr_authtype'} ne '') {
2280: $radioval = "'".$in{'curr_authtype'}."arg'";
2281: }
1.174 matthew 2282: }
1.165 raeburn 2283: my $argfield = 'null';
1.591 raeburn 2284: if (defined($in{'mode'})) {
1.165 raeburn 2285: if ($in{'mode'} eq 'modifycourse') {
1.591 raeburn 2286: if (defined($in{'curr_autharg'})) {
2287: if ($in{'curr_autharg'} ne '') {
1.165 raeburn 2288: $argfield = "'$in{'curr_autharg'}'";
2289: }
2290: }
2291: }
2292: }
2293:
1.32 matthew 2294: $result.=<<"END";
2295: var current = new Object();
1.165 raeburn 2296: current.radiovalue = $radioval;
2297: current.argfield = $argfield;
1.32 matthew 2298:
2299: function changed_radio(choice,currentform) {
2300: var choicearg = choice + 'arg';
2301: // If a radio button in changed, we need to change the argfield
2302: if (current.radiovalue != choice) {
2303: current.radiovalue = choice;
2304: if (current.argfield != null) {
2305: currentform.elements[current.argfield].value = '';
2306: }
2307: if (choice == 'nochange') {
2308: current.argfield = null;
2309: } else {
2310: current.argfield = choicearg;
2311: switch(choice) {
2312: case 'krb':
2313: currentform.elements[current.argfield].value =
2314: "$in{'kerb_def_dom'}";
2315: break;
2316: default:
2317: break;
2318: }
2319: }
2320: }
2321: return;
2322: }
1.22 www 2323:
1.32 matthew 2324: function changed_text(choice,currentform) {
2325: var choicearg = choice + 'arg';
2326: if (currentform.elements[choicearg].value !='') {
1.80 albertel 2327: $Javascript_toUpperCase
1.32 matthew 2328: // clear old field
2329: if ((current.argfield != choicearg) && (current.argfield != null)) {
2330: currentform.elements[current.argfield].value = '';
2331: }
2332: current.argfield = choicearg;
2333: }
2334: set_auth_radio_buttons(choice,currentform);
2335: return;
1.20 www 2336: }
1.32 matthew 2337:
2338: function set_auth_radio_buttons(newvalue,currentform) {
1.948.2.13 raeburn 2339: var numauthchoices = currentform.login.length;
2340: if (typeof numauthchoices == "undefined") {
2341: return;
2342: }
1.32 matthew 2343: var i=0;
1.948.2.17 raeburn 2344: while (i < numauthchoices) {
1.32 matthew 2345: if (currentform.login[i].value == newvalue) { break; }
2346: i++;
2347: }
1.948.2.13 raeburn 2348: if (i == numauthchoices) {
1.32 matthew 2349: return;
2350: }
2351: current.radiovalue = newvalue;
2352: currentform.login[i].checked = true;
2353: return;
2354: }
2355: END
2356: return $result;
2357: }
2358:
2359: sub authform_authorwarning{
2360: my $result='';
1.144 matthew 2361: $result='<i>'.
2362: &mt('As a general rule, only authors or co-authors should be '.
2363: 'filesystem authenticated '.
2364: '(which allows access to the server filesystem).')."</i>\n";
1.32 matthew 2365: return $result;
2366: }
2367:
2368: sub authform_nochange{
2369: my %in = (
2370: formname => 'document.cu',
2371: kerb_def_dom => 'MSU.EDU',
2372: @_,
2373: );
1.586 raeburn 2374: my ($authnum,%can_assign) = &get_assignable_auth($in{'domain'});
2375: my $result;
2376: if (keys(%can_assign) == 0) {
2377: $result = &mt('Under you current role you are not permitted to change login settings for this user');
2378: } else {
2379: $result = '<label>'.&mt('[_1] Do not change login data',
2380: '<input type="radio" name="login" value="nochange" '.
2381: 'checked="checked" onclick="'.
1.281 albertel 2382: "javascript:changed_radio('nochange',$in{'formname'});".'" />').
2383: '</label>';
1.586 raeburn 2384: }
1.32 matthew 2385: return $result;
2386: }
2387:
1.591 raeburn 2388: sub authform_kerberos {
1.32 matthew 2389: my %in = (
2390: formname => 'document.cu',
2391: kerb_def_dom => 'MSU.EDU',
1.80 albertel 2392: kerb_def_auth => 'krb4',
1.32 matthew 2393: @_,
2394: );
1.586 raeburn 2395: my ($check4,$check5,$krbcheck,$krbarg,$krbver,$result,$authtype,
2396: $autharg,$jscall);
2397: my ($authnum,%can_assign) = &get_assignable_auth($in{'domain'});
1.80 albertel 2398: if ($in{'kerb_def_auth'} eq 'krb5') {
1.772 bisitz 2399: $check5 = ' checked="checked"';
1.80 albertel 2400: } else {
1.772 bisitz 2401: $check4 = ' checked="checked"';
1.80 albertel 2402: }
1.165 raeburn 2403: $krbarg = $in{'kerb_def_dom'};
1.591 raeburn 2404: if (defined($in{'curr_authtype'})) {
2405: if ($in{'curr_authtype'} eq 'krb') {
1.772 bisitz 2406: $krbcheck = ' checked="checked"';
1.623 raeburn 2407: if (defined($in{'mode'})) {
2408: if ($in{'mode'} eq 'modifyuser') {
2409: $krbcheck = '';
2410: }
2411: }
1.591 raeburn 2412: if (defined($in{'curr_kerb_ver'})) {
2413: if ($in{'curr_krb_ver'} eq '5') {
1.772 bisitz 2414: $check5 = ' checked="checked"';
1.591 raeburn 2415: $check4 = '';
2416: } else {
1.772 bisitz 2417: $check4 = ' checked="checked"';
1.591 raeburn 2418: $check5 = '';
2419: }
1.586 raeburn 2420: }
1.591 raeburn 2421: if (defined($in{'curr_autharg'})) {
1.165 raeburn 2422: $krbarg = $in{'curr_autharg'};
2423: }
1.586 raeburn 2424: if (!$can_assign{'krb4'} && !$can_assign{'krb5'}) {
1.591 raeburn 2425: if (defined($in{'curr_autharg'})) {
1.586 raeburn 2426: $result =
2427: &mt('Currently Kerberos authenticated with domain [_1] Version [_2].',
2428: $in{'curr_autharg'},$krbver);
2429: } else {
2430: $result =
2431: &mt('Currently Kerberos authenticated, Version [_1].',$krbver);
2432: }
2433: return $result;
2434: }
2435: }
2436: } else {
2437: if ($authnum == 1) {
1.784 bisitz 2438: $authtype = '<input type="hidden" name="login" value="krb" />';
1.165 raeburn 2439: }
2440: }
1.586 raeburn 2441: if (!$can_assign{'krb4'} && !$can_assign{'krb5'}) {
2442: return;
1.587 raeburn 2443: } elsif ($authtype eq '') {
1.591 raeburn 2444: if (defined($in{'mode'})) {
1.587 raeburn 2445: if ($in{'mode'} eq 'modifycourse') {
2446: if ($authnum == 1) {
1.784 bisitz 2447: $authtype = '<input type="hidden" name="login" value="krb" />';
1.587 raeburn 2448: }
2449: }
2450: }
1.586 raeburn 2451: }
2452: $jscall = "javascript:changed_radio('krb',$in{'formname'});";
2453: if ($authtype eq '') {
2454: $authtype = '<input type="radio" name="login" value="krb" '.
2455: 'onclick="'.$jscall.'" onchange="'.$jscall.'"'.
2456: $krbcheck.' />';
2457: }
2458: if (($can_assign{'krb4'} && $can_assign{'krb5'}) ||
2459: ($can_assign{'krb4'} && !$can_assign{'krb5'} &&
2460: $in{'curr_authtype'} eq 'krb5') ||
2461: (!$can_assign{'krb4'} && $can_assign{'krb5'} &&
2462: $in{'curr_authtype'} eq 'krb4')) {
2463: $result .= &mt
1.144 matthew 2464: ('[_1] Kerberos authenticated with domain [_2] '.
1.281 albertel 2465: '[_3] Version 4 [_4] Version 5 [_5]',
1.586 raeburn 2466: '<label>'.$authtype,
1.281 albertel 2467: '</label><input type="text" size="10" name="krbarg" '.
1.165 raeburn 2468: 'value="'.$krbarg.'" '.
1.144 matthew 2469: 'onchange="'.$jscall.'" />',
1.281 albertel 2470: '<label><input type="radio" name="krbver" value="4" '.$check4.' />',
2471: '</label><label><input type="radio" name="krbver" value="5" '.$check5.' />',
2472: '</label>');
1.586 raeburn 2473: } elsif ($can_assign{'krb4'}) {
2474: $result .= &mt
2475: ('[_1] Kerberos authenticated with domain [_2] '.
2476: '[_3] Version 4 [_4]',
2477: '<label>'.$authtype,
2478: '</label><input type="text" size="10" name="krbarg" '.
2479: 'value="'.$krbarg.'" '.
2480: 'onchange="'.$jscall.'" />',
2481: '<label><input type="hidden" name="krbver" value="4" />',
2482: '</label>');
2483: } elsif ($can_assign{'krb5'}) {
2484: $result .= &mt
2485: ('[_1] Kerberos authenticated with domain [_2] '.
2486: '[_3] Version 5 [_4]',
2487: '<label>'.$authtype,
2488: '</label><input type="text" size="10" name="krbarg" '.
2489: 'value="'.$krbarg.'" '.
2490: 'onchange="'.$jscall.'" />',
2491: '<label><input type="hidden" name="krbver" value="5" />',
2492: '</label>');
2493: }
1.32 matthew 2494: return $result;
2495: }
2496:
2497: sub authform_internal{
1.586 raeburn 2498: my %in = (
1.32 matthew 2499: formname => 'document.cu',
2500: kerb_def_dom => 'MSU.EDU',
2501: @_,
2502: );
1.586 raeburn 2503: my ($intcheck,$intarg,$result,$authtype,$autharg,$jscall);
2504: my ($authnum,%can_assign) = &get_assignable_auth($in{'domain'});
1.591 raeburn 2505: if (defined($in{'curr_authtype'})) {
2506: if ($in{'curr_authtype'} eq 'int') {
1.586 raeburn 2507: if ($can_assign{'int'}) {
1.772 bisitz 2508: $intcheck = 'checked="checked" ';
1.623 raeburn 2509: if (defined($in{'mode'})) {
2510: if ($in{'mode'} eq 'modifyuser') {
2511: $intcheck = '';
2512: }
2513: }
1.591 raeburn 2514: if (defined($in{'curr_autharg'})) {
1.586 raeburn 2515: $intarg = $in{'curr_autharg'};
2516: }
2517: } else {
2518: $result = &mt('Currently internally authenticated.');
2519: return $result;
1.165 raeburn 2520: }
2521: }
1.586 raeburn 2522: } else {
2523: if ($authnum == 1) {
1.784 bisitz 2524: $authtype = '<input type="hidden" name="login" value="int" />';
1.586 raeburn 2525: }
2526: }
2527: if (!$can_assign{'int'}) {
2528: return;
1.587 raeburn 2529: } elsif ($authtype eq '') {
1.591 raeburn 2530: if (defined($in{'mode'})) {
1.587 raeburn 2531: if ($in{'mode'} eq 'modifycourse') {
2532: if ($authnum == 1) {
1.784 bisitz 2533: $authtype = '<input type="hidden" name="login" value="int" />';
1.587 raeburn 2534: }
2535: }
2536: }
1.165 raeburn 2537: }
1.586 raeburn 2538: $jscall = "javascript:changed_radio('int',$in{'formname'});";
2539: if ($authtype eq '') {
2540: $authtype = '<input type="radio" name="login" value="int" '.$intcheck.
2541: ' onchange="'.$jscall.'" onclick="'.$jscall.'" />';
2542: }
1.605 bisitz 2543: $autharg = '<input type="password" size="10" name="intarg" value="'.
1.586 raeburn 2544: $intarg.'" onchange="'.$jscall.'" />';
2545: $result = &mt
1.144 matthew 2546: ('[_1] Internally authenticated (with initial password [_2])',
1.586 raeburn 2547: '<label>'.$authtype,'</label>'.$autharg);
1.824 bisitz 2548: $result.="<label><input type=\"checkbox\" name=\"visible\" onclick='if (this.checked) { this.form.intarg.type=\"text\" } else { this.form.intarg.type=\"password\" }' />".&mt('Visible input').'</label>';
1.32 matthew 2549: return $result;
2550: }
2551:
2552: sub authform_local{
2553: my %in = (
2554: formname => 'document.cu',
2555: kerb_def_dom => 'MSU.EDU',
2556: @_,
2557: );
1.586 raeburn 2558: my ($loccheck,$locarg,$result,$authtype,$autharg,$jscall);
2559: my ($authnum,%can_assign) = &get_assignable_auth($in{'domain'});
1.591 raeburn 2560: if (defined($in{'curr_authtype'})) {
2561: if ($in{'curr_authtype'} eq 'loc') {
1.586 raeburn 2562: if ($can_assign{'loc'}) {
1.772 bisitz 2563: $loccheck = 'checked="checked" ';
1.623 raeburn 2564: if (defined($in{'mode'})) {
2565: if ($in{'mode'} eq 'modifyuser') {
2566: $loccheck = '';
2567: }
2568: }
1.591 raeburn 2569: if (defined($in{'curr_autharg'})) {
1.586 raeburn 2570: $locarg = $in{'curr_autharg'};
2571: }
2572: } else {
2573: $result = &mt('Currently using local (institutional) authentication.');
2574: return $result;
1.165 raeburn 2575: }
2576: }
1.586 raeburn 2577: } else {
2578: if ($authnum == 1) {
1.784 bisitz 2579: $authtype = '<input type="hidden" name="login" value="loc" />';
1.586 raeburn 2580: }
2581: }
2582: if (!$can_assign{'loc'}) {
2583: return;
1.587 raeburn 2584: } elsif ($authtype eq '') {
1.591 raeburn 2585: if (defined($in{'mode'})) {
1.587 raeburn 2586: if ($in{'mode'} eq 'modifycourse') {
2587: if ($authnum == 1) {
1.784 bisitz 2588: $authtype = '<input type="hidden" name="login" value="loc" />';
1.587 raeburn 2589: }
2590: }
2591: }
1.165 raeburn 2592: }
1.586 raeburn 2593: $jscall = "javascript:changed_radio('loc',$in{'formname'});";
2594: if ($authtype eq '') {
2595: $authtype = '<input type="radio" name="login" value="loc" '.
2596: $loccheck.' onchange="'.$jscall.'" onclick="'.
2597: $jscall.'" />';
2598: }
2599: $autharg = '<input type="text" size="10" name="locarg" value="'.
2600: $locarg.'" onchange="'.$jscall.'" />';
2601: $result = &mt('[_1] Local Authentication with argument [_2]',
2602: '<label>'.$authtype,'</label>'.$autharg);
1.32 matthew 2603: return $result;
2604: }
2605:
2606: sub authform_filesystem{
2607: my %in = (
2608: formname => 'document.cu',
2609: kerb_def_dom => 'MSU.EDU',
2610: @_,
2611: );
1.586 raeburn 2612: my ($fsyscheck,$result,$authtype,$autharg,$jscall);
2613: my ($authnum,%can_assign) = &get_assignable_auth($in{'domain'});
1.591 raeburn 2614: if (defined($in{'curr_authtype'})) {
2615: if ($in{'curr_authtype'} eq 'fsys') {
1.586 raeburn 2616: if ($can_assign{'fsys'}) {
1.772 bisitz 2617: $fsyscheck = 'checked="checked" ';
1.623 raeburn 2618: if (defined($in{'mode'})) {
2619: if ($in{'mode'} eq 'modifyuser') {
2620: $fsyscheck = '';
2621: }
2622: }
1.586 raeburn 2623: } else {
2624: $result = &mt('Currently Filesystem Authenticated.');
2625: return $result;
2626: }
2627: }
2628: } else {
2629: if ($authnum == 1) {
1.784 bisitz 2630: $authtype = '<input type="hidden" name="login" value="fsys" />';
1.586 raeburn 2631: }
2632: }
2633: if (!$can_assign{'fsys'}) {
2634: return;
1.587 raeburn 2635: } elsif ($authtype eq '') {
1.591 raeburn 2636: if (defined($in{'mode'})) {
1.587 raeburn 2637: if ($in{'mode'} eq 'modifycourse') {
2638: if ($authnum == 1) {
1.784 bisitz 2639: $authtype = '<input type="hidden" name="login" value="fsys" />';
1.587 raeburn 2640: }
2641: }
2642: }
1.586 raeburn 2643: }
2644: $jscall = "javascript:changed_radio('fsys',$in{'formname'});";
2645: if ($authtype eq '') {
2646: $authtype = '<input type="radio" name="login" value="fsys" '.
2647: $fsyscheck.' onchange="'.$jscall.'" onclick="'.
2648: $jscall.'" />';
2649: }
2650: $autharg = '<input type="text" size="10" name="fsysarg" value=""'.
2651: ' onchange="'.$jscall.'" />';
2652: $result = &mt
1.144 matthew 2653: ('[_1] Filesystem Authenticated (with initial password [_2])',
1.281 albertel 2654: '<label><input type="radio" name="login" value="fsys" '.
1.586 raeburn 2655: $fsyscheck.'onchange="'.$jscall.'" onclick="'.$jscall.'" />',
1.605 bisitz 2656: '</label><input type="password" size="10" name="fsysarg" value="" '.
1.144 matthew 2657: 'onchange="'.$jscall.'" />');
1.32 matthew 2658: return $result;
2659: }
2660:
1.586 raeburn 2661: sub get_assignable_auth {
2662: my ($dom) = @_;
2663: if ($dom eq '') {
2664: $dom = $env{'request.role.domain'};
2665: }
2666: my %can_assign = (
2667: krb4 => 1,
2668: krb5 => 1,
2669: int => 1,
2670: loc => 1,
2671: );
2672: my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom);
2673: if (ref($domconfig{'usercreation'}) eq 'HASH') {
2674: if (ref($domconfig{'usercreation'}{'authtypes'}) eq 'HASH') {
2675: my $authhash = $domconfig{'usercreation'}{'authtypes'};
2676: my $context;
2677: if ($env{'request.role'} =~ /^au/) {
2678: $context = 'author';
2679: } elsif ($env{'request.role'} =~ /^dc/) {
2680: $context = 'domain';
2681: } elsif ($env{'request.course.id'}) {
2682: $context = 'course';
2683: }
2684: if ($context) {
2685: if (ref($authhash->{$context}) eq 'HASH') {
2686: %can_assign = %{$authhash->{$context}};
2687: }
2688: }
2689: }
2690: }
2691: my $authnum = 0;
2692: foreach my $key (keys(%can_assign)) {
2693: if ($can_assign{$key}) {
2694: $authnum ++;
2695: }
2696: }
2697: if ($can_assign{'krb4'} && $can_assign{'krb5'}) {
2698: $authnum --;
2699: }
2700: return ($authnum,%can_assign);
2701: }
2702:
1.80 albertel 2703: ###############################################################
2704: ## Get Kerberos Defaults for Domain ##
2705: ###############################################################
2706: ##
2707: ## Returns default kerberos version and an associated argument
2708: ## as listed in file domain.tab. If not listed, provides
2709: ## appropriate default domain and kerberos version.
2710: ##
2711: #-------------------------------------------
2712:
2713: =pod
2714:
1.648 raeburn 2715: =item * &get_kerberos_defaults()
1.80 albertel 2716:
2717: get_kerberos_defaults($target_domain) returns the default kerberos
1.641 raeburn 2718: version and domain. If not found, it defaults to version 4 and the
2719: domain of the server.
1.80 albertel 2720:
1.648 raeburn 2721: =over 4
2722:
1.80 albertel 2723: ($def_version, $def_krb_domain) = &get_kerberos_defaults($target_domain);
2724:
1.648 raeburn 2725: =back
2726:
2727: =back
2728:
1.80 albertel 2729: =cut
2730:
2731: #-------------------------------------------
2732: sub get_kerberos_defaults {
2733: my $domain=shift;
1.641 raeburn 2734: my ($krbdef,$krbdefdom);
2735: my %domdefaults = &Apache::lonnet::get_domain_defaults($domain);
2736: if (($domdefaults{'auth_def'} =~/^krb(4|5)$/) && ($domdefaults{'auth_arg_def'} ne '')) {
2737: $krbdef = $domdefaults{'auth_def'};
2738: $krbdefdom = $domdefaults{'auth_arg_def'};
2739: } else {
1.80 albertel 2740: $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/;
2741: my $krbdefdom=$1;
2742: $krbdefdom=~tr/a-z/A-Z/;
2743: $krbdef = "krb4";
2744: }
2745: return ($krbdef,$krbdefdom);
2746: }
1.112 bowersj2 2747:
1.32 matthew 2748:
1.46 matthew 2749: ###############################################################
2750: ## Thesaurus Functions ##
2751: ###############################################################
1.20 www 2752:
1.46 matthew 2753: =pod
1.20 www 2754:
1.112 bowersj2 2755: =head1 Thesaurus Functions
2756:
2757: =over 4
2758:
1.648 raeburn 2759: =item * &initialize_keywords()
1.46 matthew 2760:
2761: Initializes the package variable %Keywords if it is empty. Uses the
2762: package variable $thesaurus_db_file.
2763:
2764: =cut
2765:
2766: ###################################################
2767:
2768: sub initialize_keywords {
2769: return 1 if (scalar keys(%Keywords));
2770: # If we are here, %Keywords is empty, so fill it up
2771: # Make sure the file we need exists...
2772: if (! -e $thesaurus_db_file) {
2773: &Apache::lonnet::logthis("Attempt to access $thesaurus_db_file".
2774: " failed because it does not exist");
2775: return 0;
2776: }
2777: # Set up the hash as a database
2778: my %thesaurus_db;
2779: if (! tie(%thesaurus_db,'GDBM_File',
1.53 albertel 2780: $thesaurus_db_file,&GDBM_READER(),0640)){
1.46 matthew 2781: &Apache::lonnet::logthis("Could not tie \%thesaurus_db to ".
2782: $thesaurus_db_file);
2783: return 0;
2784: }
2785: # Get the average number of appearances of a word.
2786: my $avecount = $thesaurus_db{'average.count'};
2787: # Put keywords (those that appear > average) into %Keywords
2788: while (my ($word,$data)=each (%thesaurus_db)) {
2789: my ($count,undef) = split /:/,$data;
2790: $Keywords{$word}++ if ($count > $avecount);
2791: }
2792: untie %thesaurus_db;
2793: # Remove special values from %Keywords.
1.356 albertel 2794: foreach my $value ('total.count','average.count') {
2795: delete($Keywords{$value}) if (exists($Keywords{$value}));
1.586 raeburn 2796: }
1.46 matthew 2797: return 1;
2798: }
2799:
2800: ###################################################
2801:
2802: =pod
2803:
1.648 raeburn 2804: =item * &keyword($word)
1.46 matthew 2805:
2806: Returns true if $word is a keyword. A keyword is a word that appears more
2807: than the average number of times in the thesaurus database. Calls
2808: &initialize_keywords
2809:
2810: =cut
2811:
2812: ###################################################
1.20 www 2813:
2814: sub keyword {
1.46 matthew 2815: return if (!&initialize_keywords());
2816: my $word=lc(shift());
2817: $word=~s/\W//g;
2818: return exists($Keywords{$word});
1.20 www 2819: }
1.46 matthew 2820:
2821: ###############################################################
2822:
2823: =pod
1.20 www 2824:
1.648 raeburn 2825: =item * &get_related_words()
1.46 matthew 2826:
1.160 matthew 2827: Look up a word in the thesaurus. Takes a scalar argument and returns
1.46 matthew 2828: an array of words. If the keyword is not in the thesaurus, an empty array
2829: will be returned. The order of the words returned is determined by the
2830: database which holds them.
2831:
2832: Uses global $thesaurus_db_file.
2833:
2834: =cut
2835:
2836: ###############################################################
2837: sub get_related_words {
2838: my $keyword = shift;
2839: my %thesaurus_db;
2840: if (! -e $thesaurus_db_file) {
2841: &Apache::lonnet::logthis("Attempt to access $thesaurus_db_file ".
2842: "failed because the file does not exist");
2843: return ();
2844: }
2845: if (! tie(%thesaurus_db,'GDBM_File',
1.53 albertel 2846: $thesaurus_db_file,&GDBM_READER(),0640)){
1.46 matthew 2847: return ();
2848: }
2849: my @Words=();
1.429 www 2850: my $count=0;
1.46 matthew 2851: if (exists($thesaurus_db{$keyword})) {
1.356 albertel 2852: # The first element is the number of times
2853: # the word appears. We do not need it now.
1.429 www 2854: my (undef,@RelatedWords) = (split(/:/,$thesaurus_db{$keyword}));
2855: my (undef,$mostfrequentcount)=split(/\,/,$RelatedWords[0]);
2856: my $threshold=$mostfrequentcount/10;
2857: foreach my $possibleword (@RelatedWords) {
2858: my ($word,$wordcount)=split(/\,/,$possibleword);
2859: if ($wordcount>$threshold) {
2860: push(@Words,$word);
2861: $count++;
2862: if ($count>10) { last; }
2863: }
1.20 www 2864: }
2865: }
1.46 matthew 2866: untie %thesaurus_db;
2867: return @Words;
1.14 harris41 2868: }
1.46 matthew 2869:
1.112 bowersj2 2870: =pod
2871:
2872: =back
2873:
2874: =cut
1.61 www 2875:
2876: # -------------------------------------------------------------- Plaintext name
1.81 albertel 2877: =pod
2878:
1.112 bowersj2 2879: =head1 User Name Functions
2880:
2881: =over 4
2882:
1.648 raeburn 2883: =item * &plainname($uname,$udom,$first)
1.81 albertel 2884:
1.112 bowersj2 2885: Takes a users logon name and returns it as a string in
1.226 albertel 2886: "first middle last generation" form
2887: if $first is set to 'lastname' then it returns it as
2888: 'lastname generation, firstname middlename' if their is a lastname
1.81 albertel 2889:
2890: =cut
1.61 www 2891:
1.295 www 2892:
1.81 albertel 2893: ###############################################################
1.61 www 2894: sub plainname {
1.226 albertel 2895: my ($uname,$udom,$first)=@_;
1.537 albertel 2896: return if (!defined($uname) || !defined($udom));
1.295 www 2897: my %names=&getnames($uname,$udom);
1.226 albertel 2898: my $name=&Apache::lonnet::format_name($names{'firstname'},
2899: $names{'middlename'},
2900: $names{'lastname'},
2901: $names{'generation'},$first);
2902: $name=~s/^\s+//;
1.62 www 2903: $name=~s/\s+$//;
2904: $name=~s/\s+/ /g;
1.353 albertel 2905: if ($name !~ /\S/) { $name=$uname.':'.$udom; }
1.62 www 2906: return $name;
1.61 www 2907: }
1.66 www 2908:
2909: # -------------------------------------------------------------------- Nickname
1.81 albertel 2910: =pod
2911:
1.648 raeburn 2912: =item * &nickname($uname,$udom)
1.81 albertel 2913:
2914: Gets a users name and returns it as a string as
2915:
2916: ""nickname""
1.66 www 2917:
1.81 albertel 2918: if the user has a nickname or
2919:
2920: "first middle last generation"
2921:
2922: if the user does not
2923:
2924: =cut
1.66 www 2925:
2926: sub nickname {
2927: my ($uname,$udom)=@_;
1.537 albertel 2928: return if (!defined($uname) || !defined($udom));
1.295 www 2929: my %names=&getnames($uname,$udom);
1.68 albertel 2930: my $name=$names{'nickname'};
1.66 www 2931: if ($name) {
2932: $name='"'.$name.'"';
2933: } else {
2934: $name=$names{'firstname'}.' '.$names{'middlename'}.' '.
2935: $names{'lastname'}.' '.$names{'generation'};
2936: $name=~s/\s+$//;
2937: $name=~s/\s+/ /g;
2938: }
2939: return $name;
2940: }
2941:
1.295 www 2942: sub getnames {
2943: my ($uname,$udom)=@_;
1.537 albertel 2944: return if (!defined($uname) || !defined($udom));
1.433 albertel 2945: if ($udom eq 'public' && $uname eq 'public') {
2946: return ('lastname' => &mt('Public'));
2947: }
1.295 www 2948: my $id=$uname.':'.$udom;
2949: my ($names,$cached)=&Apache::lonnet::is_cached_new('namescache',$id);
2950: if ($cached) {
2951: return %{$names};
2952: } else {
2953: my %loadnames=&Apache::lonnet::get('environment',
2954: ['firstname','middlename','lastname','generation','nickname'],
2955: $udom,$uname);
2956: &Apache::lonnet::do_cache_new('namescache',$id,\%loadnames);
2957: return %loadnames;
2958: }
2959: }
1.61 www 2960:
1.542 raeburn 2961: # -------------------------------------------------------------------- getemails
1.648 raeburn 2962:
1.542 raeburn 2963: =pod
2964:
1.648 raeburn 2965: =item * &getemails($uname,$udom)
1.542 raeburn 2966:
2967: Gets a user's email information and returns it as a hash with keys:
2968: notification, critnotification, permanentemail
2969:
2970: For notification and critnotification, values are comma-separated lists
1.648 raeburn 2971: of e-mail addresses; for permanentemail, value is a single e-mail address.
1.542 raeburn 2972:
1.648 raeburn 2973:
1.542 raeburn 2974: =cut
2975:
1.648 raeburn 2976:
1.466 albertel 2977: sub getemails {
2978: my ($uname,$udom)=@_;
2979: if ($udom eq 'public' && $uname eq 'public') {
2980: return;
2981: }
1.467 www 2982: if (!$udom) { $udom=$env{'user.domain'}; }
2983: if (!$uname) { $uname=$env{'user.name'}; }
1.466 albertel 2984: my $id=$uname.':'.$udom;
2985: my ($names,$cached)=&Apache::lonnet::is_cached_new('emailscache',$id);
2986: if ($cached) {
2987: return %{$names};
2988: } else {
2989: my %loadnames=&Apache::lonnet::get('environment',
2990: ['notification','critnotification',
2991: 'permanentemail'],
2992: $udom,$uname);
2993: &Apache::lonnet::do_cache_new('emailscache',$id,\%loadnames);
2994: return %loadnames;
2995: }
2996: }
2997:
1.551 albertel 2998: sub flush_email_cache {
2999: my ($uname,$udom)=@_;
3000: if (!$udom) { $udom =$env{'user.domain'}; }
3001: if (!$uname) { $uname=$env{'user.name'}; }
3002: return if ($udom eq 'public' && $uname eq 'public');
3003: my $id=$uname.':'.$udom;
3004: &Apache::lonnet::devalidate_cache_new('emailscache',$id);
3005: }
3006:
1.728 raeburn 3007: # -------------------------------------------------------------------- getlangs
3008:
3009: =pod
3010:
3011: =item * &getlangs($uname,$udom)
3012:
3013: Gets a user's language preference and returns it as a hash with key:
3014: language.
3015:
3016: =cut
3017:
3018:
3019: sub getlangs {
3020: my ($uname,$udom) = @_;
3021: if (!$udom) { $udom =$env{'user.domain'}; }
3022: if (!$uname) { $uname=$env{'user.name'}; }
3023: my $id=$uname.':'.$udom;
3024: my ($langs,$cached)=&Apache::lonnet::is_cached_new('userlangs',$id);
3025: if ($cached) {
3026: return %{$langs};
3027: } else {
3028: my %loadlangs=&Apache::lonnet::get('environment',['languages'],
3029: $udom,$uname);
3030: &Apache::lonnet::do_cache_new('userlangs',$id,\%loadlangs);
3031: return %loadlangs;
3032: }
3033: }
3034:
3035: sub flush_langs_cache {
3036: my ($uname,$udom)=@_;
3037: if (!$udom) { $udom =$env{'user.domain'}; }
3038: if (!$uname) { $uname=$env{'user.name'}; }
3039: return if ($udom eq 'public' && $uname eq 'public');
3040: my $id=$uname.':'.$udom;
3041: &Apache::lonnet::devalidate_cache_new('userlangs',$id);
3042: }
3043:
1.61 www 3044: # ------------------------------------------------------------------ Screenname
1.81 albertel 3045:
3046: =pod
3047:
1.648 raeburn 3048: =item * &screenname($uname,$udom)
1.81 albertel 3049:
3050: Gets a users screenname and returns it as a string
3051:
3052: =cut
1.61 www 3053:
3054: sub screenname {
3055: my ($uname,$udom)=@_;
1.258 albertel 3056: if ($uname eq $env{'user.name'} &&
3057: $udom eq $env{'user.domain'}) {return $env{'environment.screenname'};}
1.212 albertel 3058: my %names=&Apache::lonnet::get('environment',['screenname'],$udom,$uname);
1.68 albertel 3059: return $names{'screenname'};
1.62 www 3060: }
3061:
1.212 albertel 3062:
1.802 bisitz 3063: # ------------------------------------------------------------- Confirm Wrapper
3064: =pod
3065:
3066: =item confirmwrapper
3067:
3068: Wrap messages about completion of operation in box
3069:
3070: =cut
3071:
3072: sub confirmwrapper {
3073: my ($message)=@_;
3074: if ($message) {
3075: return "\n".'<div class="LC_confirm_box">'."\n"
3076: .$message."\n"
3077: .'</div>'."\n";
3078: } else {
3079: return $message;
3080: }
3081: }
3082:
1.62 www 3083: # ------------------------------------------------------------- Message Wrapper
3084:
3085: sub messagewrapper {
1.369 www 3086: my ($link,$username,$domain,$subject,$text)=@_;
1.62 www 3087: return
1.441 albertel 3088: '<a href="/adm/email?compose=individual&'.
3089: 'recname='.$username.'&recdom='.$domain.
3090: '&subject='.&escape($subject).'&text='.&escape($text).'" '.
1.200 matthew 3091: 'title="'.&mt('Send message').'">'.$link.'</a>';
1.74 www 3092: }
1.802 bisitz 3093:
1.74 www 3094: # --------------------------------------------------------------- Notes Wrapper
3095:
3096: sub noteswrapper {
3097: my ($link,$un,$do)=@_;
3098: return
1.896 amueller 3099: "<a href='/adm/email?recordftf=retrieve&recname=$un&recdom=$do'>$link</a>";
1.62 www 3100: }
1.802 bisitz 3101:
1.62 www 3102: # ------------------------------------------------------------- Aboutme Wrapper
3103:
3104: sub aboutmewrapper {
1.166 www 3105: my ($link,$username,$domain,$target)=@_;
1.447 raeburn 3106: if (!defined($username) && !defined($domain)) {
3107: return;
3108: }
1.892 amueller 3109: return '<a href="/adm/'.$domain.'/'.$username.'/aboutme?forcestudent=1"'.
1.756 weissno 3110: ($target?' target="$target"':'').' title="'.&mt("View this user's personal information page").'">'.$link.'</a>';
1.62 www 3111: }
3112:
3113: # ------------------------------------------------------------ Syllabus Wrapper
3114:
3115: sub syllabuswrapper {
1.707 bisitz 3116: my ($linktext,$coursedir,$domain)=@_;
1.208 matthew 3117: return qq{<a href="/public/$domain/$coursedir/syllabus">$linktext</a>};
1.61 www 3118: }
1.14 harris41 3119:
1.802 bisitz 3120: # -----------------------------------------------------------------------------
3121:
1.208 matthew 3122: sub track_student_link {
1.887 raeburn 3123: my ($linktext,$sname,$sdom,$target,$start,$only_body) = @_;
1.268 albertel 3124: my $link ="/adm/trackstudent?";
1.208 matthew 3125: my $title = 'View recent activity';
3126: if (defined($sname) && $sname !~ /^\s*$/ &&
3127: defined($sdom) && $sdom !~ /^\s*$/) {
1.268 albertel 3128: $link .= "selected_student=$sname:$sdom";
1.208 matthew 3129: $title .= ' of this student';
1.268 albertel 3130: }
1.208 matthew 3131: if (defined($target) && $target !~ /^\s*$/) {
3132: $target = qq{target="$target"};
3133: } else {
3134: $target = '';
3135: }
1.268 albertel 3136: if ($start) { $link.='&start='.$start; }
1.887 raeburn 3137: if ($only_body) { $link .= '&only_body=1'; }
1.554 albertel 3138: $title = &mt($title);
3139: $linktext = &mt($linktext);
1.448 albertel 3140: return qq{<a href="$link" title="$title" $target>$linktext</a>}.
3141: &help_open_topic('View_recent_activity');
1.208 matthew 3142: }
3143:
1.781 raeburn 3144: sub slot_reservations_link {
3145: my ($linktext,$sname,$sdom,$target) = @_;
3146: my $link ="/adm/slotrequest?command=showresv&origin=aboutme";
3147: my $title = 'View slot reservation history';
3148: if (defined($sname) && $sname !~ /^\s*$/ &&
3149: defined($sdom) && $sdom !~ /^\s*$/) {
3150: $link .= "&uname=$sname&udom=$sdom";
3151: $title .= ' of this student';
3152: }
3153: if (defined($target) && $target !~ /^\s*$/) {
3154: $target = qq{target="$target"};
3155: } else {
3156: $target = '';
3157: }
3158: $title = &mt($title);
3159: $linktext = &mt($linktext);
3160: return qq{<a href="$link" title="$title" $target>$linktext</a>};
3161: # FIXME uncomment when help item created: &help_open_topic('Slot_Reservation_History');
3162:
3163: }
3164:
1.508 www 3165: # ===================================================== Display a student photo
3166:
3167:
1.509 albertel 3168: sub student_image_tag {
1.508 www 3169: my ($domain,$user)=@_;
3170: my $imgsrc=&Apache::lonnet::studentphoto($domain,$user,'jpg');
3171: if (($imgsrc) && ($imgsrc ne '/adm/lonKaputt/lonlogo_broken.gif')) {
3172: return '<img src="'.$imgsrc.'" align="right" />';
3173: } else {
3174: return '';
3175: }
3176: }
3177:
1.112 bowersj2 3178: =pod
3179:
3180: =back
3181:
3182: =head1 Access .tab File Data
3183:
3184: =over 4
3185:
1.648 raeburn 3186: =item * &languageids()
1.112 bowersj2 3187:
3188: returns list of all language ids
3189:
3190: =cut
3191:
1.14 harris41 3192: sub languageids {
1.16 harris41 3193: return sort(keys(%language));
1.14 harris41 3194: }
3195:
1.112 bowersj2 3196: =pod
3197:
1.648 raeburn 3198: =item * &languagedescription()
1.112 bowersj2 3199:
3200: returns description of a specified language id
3201:
3202: =cut
3203:
1.14 harris41 3204: sub languagedescription {
1.125 www 3205: my $code=shift;
3206: return ($supported_language{$code}?'* ':'').
3207: $language{$code}.
1.126 www 3208: ($supported_language{$code}?' ('.&mt('interface available').')':'');
1.145 www 3209: }
3210:
3211: sub plainlanguagedescription {
3212: my $code=shift;
3213: return $language{$code};
3214: }
3215:
3216: sub supportedlanguagecode {
3217: my $code=shift;
3218: return $supported_language{$code};
1.97 www 3219: }
3220:
1.112 bowersj2 3221: =pod
3222:
1.648 raeburn 3223: =item * ©rightids()
1.112 bowersj2 3224:
3225: returns list of all copyrights
3226:
3227: =cut
3228:
3229: sub copyrightids {
3230: return sort(keys(%cprtag));
3231: }
3232:
3233: =pod
3234:
1.648 raeburn 3235: =item * ©rightdescription()
1.112 bowersj2 3236:
3237: returns description of a specified copyright id
3238:
3239: =cut
3240:
3241: sub copyrightdescription {
1.166 www 3242: return &mt($cprtag{shift(@_)});
1.112 bowersj2 3243: }
1.197 matthew 3244:
3245: =pod
3246:
1.648 raeburn 3247: =item * &source_copyrightids()
1.192 taceyjo1 3248:
3249: returns list of all source copyrights
3250:
3251: =cut
3252:
3253: sub source_copyrightids {
3254: return sort(keys(%scprtag));
3255: }
3256:
3257: =pod
3258:
1.648 raeburn 3259: =item * &source_copyrightdescription()
1.192 taceyjo1 3260:
3261: returns description of a specified source copyright id
3262:
3263: =cut
3264:
3265: sub source_copyrightdescription {
3266: return &mt($scprtag{shift(@_)});
3267: }
1.112 bowersj2 3268:
3269: =pod
3270:
1.648 raeburn 3271: =item * &filecategories()
1.112 bowersj2 3272:
3273: returns list of all file categories
3274:
3275: =cut
3276:
3277: sub filecategories {
3278: return sort(keys(%category_extensions));
3279: }
3280:
3281: =pod
3282:
1.648 raeburn 3283: =item * &filecategorytypes()
1.112 bowersj2 3284:
3285: returns list of file types belonging to a given file
3286: category
3287:
3288: =cut
3289:
3290: sub filecategorytypes {
1.356 albertel 3291: my ($cat) = @_;
3292: return @{$category_extensions{lc($cat)}};
1.112 bowersj2 3293: }
3294:
3295: =pod
3296:
1.648 raeburn 3297: =item * &fileembstyle()
1.112 bowersj2 3298:
3299: returns embedding style for a specified file type
3300:
3301: =cut
3302:
3303: sub fileembstyle {
3304: return $fe{lc(shift(@_))};
1.169 www 3305: }
3306:
1.351 www 3307: sub filemimetype {
3308: return $fm{lc(shift(@_))};
3309: }
3310:
1.169 www 3311:
3312: sub filecategoryselect {
3313: my ($name,$value)=@_;
1.189 matthew 3314: return &select_form($value,$name,
1.948.2.7 raeburn 3315: {'' => &mt('Any category'), map { $_,$_ } sort(keys(%category_extensions))});
1.112 bowersj2 3316: }
3317:
3318: =pod
3319:
1.648 raeburn 3320: =item * &filedescription()
1.112 bowersj2 3321:
3322: returns description for a specified file type
3323:
3324: =cut
3325:
3326: sub filedescription {
1.188 matthew 3327: my $file_description = $fd{lc(shift())};
3328: $file_description =~ s:([\[\]]):~$1:g;
3329: return &mt($file_description);
1.112 bowersj2 3330: }
3331:
3332: =pod
3333:
1.648 raeburn 3334: =item * &filedescriptionex()
1.112 bowersj2 3335:
3336: returns description for a specified file type with
3337: extra formatting
3338:
3339: =cut
3340:
3341: sub filedescriptionex {
3342: my $ex=shift;
1.188 matthew 3343: my $file_description = $fd{lc($ex)};
3344: $file_description =~ s:([\[\]]):~$1:g;
3345: return '.'.$ex.' '.&mt($file_description);
1.112 bowersj2 3346: }
3347:
3348: # End of .tab access
3349: =pod
3350:
3351: =back
3352:
3353: =cut
3354:
3355: # ------------------------------------------------------------------ File Types
3356: sub fileextensions {
3357: return sort(keys(%fe));
3358: }
3359:
1.97 www 3360: # ----------------------------------------------------------- Display Languages
3361: # returns a hash with all desired display languages
3362: #
3363:
3364: sub display_languages {
3365: my %languages=();
1.695 raeburn 3366: foreach my $lang (&Apache::lonlocal::preferred_languages()) {
1.356 albertel 3367: $languages{$lang}=1;
1.97 www 3368: }
3369: &get_unprocessed_cgi($ENV{'QUERY_STRING'},['displaylanguage']);
1.258 albertel 3370: if ($env{'form.displaylanguage'}) {
1.356 albertel 3371: foreach my $lang (split(/\s*(\,|\;|\:)\s*/,$env{'form.displaylanguage'})) {
3372: $languages{$lang}=1;
1.97 www 3373: }
3374: }
3375: return %languages;
1.14 harris41 3376: }
3377:
1.582 albertel 3378: sub languages {
3379: my ($possible_langs) = @_;
1.695 raeburn 3380: my @preferred_langs = &Apache::lonlocal::preferred_languages();
1.582 albertel 3381: if (!ref($possible_langs)) {
3382: if( wantarray ) {
3383: return @preferred_langs;
3384: } else {
3385: return $preferred_langs[0];
3386: }
3387: }
3388: my %possibilities = map { $_ => 1 } (@$possible_langs);
3389: my @preferred_possibilities;
3390: foreach my $preferred_lang (@preferred_langs) {
3391: if (exists($possibilities{$preferred_lang})) {
3392: push(@preferred_possibilities, $preferred_lang);
3393: }
3394: }
3395: if( wantarray ) {
3396: return @preferred_possibilities;
3397: }
3398: return $preferred_possibilities[0];
3399: }
3400:
1.742 raeburn 3401: sub user_lang {
3402: my ($touname,$toudom,$fromcid) = @_;
3403: my @userlangs;
3404: if (($fromcid ne '') && ($env{'course.'.$fromcid.'.languages'} ne '')) {
3405: @userlangs=(@userlangs,split(/\s*(\,|\;|\:)\s*/,
3406: $env{'course.'.$fromcid.'.languages'}));
3407: } else {
3408: my %langhash = &getlangs($touname,$toudom);
3409: if ($langhash{'languages'} ne '') {
3410: @userlangs = split(/\s*(\,|\;|\:)\s*/,$langhash{'languages'});
3411: } else {
3412: my %domdefs = &Apache::lonnet::get_domain_defaults($toudom);
3413: if ($domdefs{'lang_def'} ne '') {
3414: @userlangs = ($domdefs{'lang_def'});
3415: }
3416: }
3417: }
3418: my @languages=&Apache::lonlocal::get_genlanguages(@userlangs);
3419: my $user_lh = Apache::localize->get_handle(@languages);
3420: return $user_lh;
3421: }
3422:
3423:
1.112 bowersj2 3424: ###############################################################
3425: ## Student Answer Attempts ##
3426: ###############################################################
3427:
3428: =pod
3429:
3430: =head1 Alternate Problem Views
3431:
3432: =over 4
3433:
1.648 raeburn 3434: =item * &get_previous_attempt($symb, $username, $domain, $course,
1.112 bowersj2 3435: $getattempt, $regexp, $gradesub)
3436:
3437: Return string with previous attempt on problem. Arguments:
3438:
3439: =over 4
3440:
3441: =item * $symb: Problem, including path
3442:
3443: =item * $username: username of the desired student
3444:
3445: =item * $domain: domain of the desired student
1.14 harris41 3446:
1.112 bowersj2 3447: =item * $course: Course ID
1.14 harris41 3448:
1.112 bowersj2 3449: =item * $getattempt: Leave blank for all attempts, otherwise put
3450: something
1.14 harris41 3451:
1.112 bowersj2 3452: =item * $regexp: if string matches this regexp, the string will be
3453: sent to $gradesub
1.14 harris41 3454:
1.112 bowersj2 3455: =item * $gradesub: routine that processes the string if it matches $regexp
1.14 harris41 3456:
1.112 bowersj2 3457: =back
1.14 harris41 3458:
1.112 bowersj2 3459: The output string is a table containing all desired attempts, if any.
1.16 harris41 3460:
1.112 bowersj2 3461: =cut
1.1 albertel 3462:
3463: sub get_previous_attempt {
1.43 ng 3464: my ($symb,$username,$domain,$course,$getattempt,$regexp,$gradesub)=@_;
1.1 albertel 3465: my $prevattempts='';
1.43 ng 3466: no strict 'refs';
1.1 albertel 3467: if ($symb) {
1.3 albertel 3468: my (%returnhash)=
3469: &Apache::lonnet::restore($symb,$course,$domain,$username);
1.1 albertel 3470: if ($returnhash{'version'}) {
3471: my %lasthash=();
3472: my $version;
3473: for ($version=1;$version<=$returnhash{'version'};$version++) {
1.356 albertel 3474: foreach my $key (sort(split(/\:/,$returnhash{$version.':keys'}))) {
3475: $lasthash{$key}=$returnhash{$version.':'.$key};
1.19 harris41 3476: }
1.1 albertel 3477: }
1.596 albertel 3478: $prevattempts=&start_data_table().&start_data_table_header_row();
3479: $prevattempts.='<th>'.&mt('History').'</th>';
1.948.2.8 raeburn 3480: my (%typeparts,%lasthidden);
1.945 raeburn 3481: my $showsurv=&Apache::lonnet::allowed('vas',$env{'request.course.id'});
1.356 albertel 3482: foreach my $key (sort(keys(%lasthash))) {
3483: my ($ign,@parts) = split(/\./,$key);
1.41 ng 3484: if ($#parts > 0) {
1.31 albertel 3485: my $data=$parts[-1];
1.948.2.15 raeburn 3486: next if ($data eq 'foilorder');
1.31 albertel 3487: pop(@parts);
1.945 raeburn 3488: if ($data eq 'type') {
3489: unless ($showsurv) {
3490: my $id = join(',',@parts);
3491: $typeparts{$ign.'.'.$id} = $lasthash{$key};
1.948.2.8 raeburn 3492: if (($lasthash{$key} eq 'anonsurvey') || ($lasthash{$key} eq 'anonsurveycred')) {
3493: $lasthidden{$ign.'.'.$id} = 1;
3494: }
1.945 raeburn 3495: }
3496: delete($lasthash{$key});
3497: } else {
3498: $prevattempts.='<th>'.&mt('Part ').join('.',@parts).'<br />'.$data.' </th>';
3499: }
1.31 albertel 3500: } else {
1.41 ng 3501: if ($#parts == 0) {
3502: $prevattempts.='<th>'.$parts[0].'</th>';
3503: } else {
3504: $prevattempts.='<th>'.$ign.'</th>';
3505: }
1.31 albertel 3506: }
1.16 harris41 3507: }
1.596 albertel 3508: $prevattempts.=&end_data_table_header_row();
1.40 ng 3509: if ($getattempt eq '') {
3510: for ($version=1;$version<=$returnhash{'version'};$version++) {
1.945 raeburn 3511: my @hidden;
3512: if (%typeparts) {
3513: foreach my $id (keys(%typeparts)) {
3514: if (($returnhash{$version.':'.$id.'.type'} eq 'anonsurvey') || ($returnhash{$version.':'.$id.'.type'} eq 'anonsurveycred')) {
3515: push(@hidden,$id);
3516: }
3517: }
3518: }
3519: $prevattempts.=&start_data_table_row().
3520: '<td>'.&mt('Transaction [_1]',$version).'</td>';
3521: if (@hidden) {
3522: foreach my $key (sort(keys(%lasthash))) {
1.948.2.15 raeburn 3523: next if ($key =~ /\.foilorder$/);
1.945 raeburn 3524: my $hide;
3525: foreach my $id (@hidden) {
3526: if ($key =~ /^\Q$id\E/) {
3527: $hide = 1;
3528: last;
3529: }
3530: }
3531: if ($hide) {
3532: my ($id,$data) = ($key =~ /^(.+)\.([^.]+)$/);
3533: if (($data eq 'award') || ($data eq 'awarddetail')) {
3534: my $value = &format_previous_attempt_value($key,
3535: $returnhash{$version.':'.$key});
3536: $prevattempts.='<td>'.$value.' </td>';
3537: } else {
3538: $prevattempts.='<td> </td>';
3539: }
3540: } else {
3541: if ($key =~ /\./) {
3542: my $value = &format_previous_attempt_value($key,
3543: $returnhash{$version.':'.$key});
3544: $prevattempts.='<td>'.$value.' </td>';
3545: } else {
3546: $prevattempts.='<td> </td>';
3547: }
3548: }
3549: }
3550: } else {
3551: foreach my $key (sort(keys(%lasthash))) {
1.948.2.15 raeburn 3552: next if ($key =~ /\.foilorder$/);
1.945 raeburn 3553: my $value = &format_previous_attempt_value($key,
3554: $returnhash{$version.':'.$key});
3555: $prevattempts.='<td>'.$value.' </td>';
3556: }
3557: }
3558: $prevattempts.=&end_data_table_row();
1.40 ng 3559: }
1.1 albertel 3560: }
1.945 raeburn 3561: my @currhidden = keys(%lasthidden);
1.596 albertel 3562: $prevattempts.=&start_data_table_row().'<td>'.&mt('Current').'</td>';
1.356 albertel 3563: foreach my $key (sort(keys(%lasthash))) {
1.948.2.15 raeburn 3564: next if ($key =~ /\.foilorder$/);
1.945 raeburn 3565: if (%typeparts) {
3566: my $hidden;
3567: foreach my $id (@currhidden) {
3568: if ($key =~ /^\Q$id\E/) {
3569: $hidden = 1;
3570: last;
3571: }
3572: }
3573: if ($hidden) {
3574: my ($id,$data) = ($key =~ /^(.+)\.([^.]+)$/);
3575: if (($data eq 'award') || ($data eq 'awarddetail')) {
3576: my $value = &format_previous_attempt_value($key,$lasthash{$key});
3577: if ($key =~/$regexp$/ && (defined &$gradesub)) {
3578: $value = &$gradesub($value);
3579: }
3580: $prevattempts.='<td>'.$value.' </td>';
3581: } else {
3582: $prevattempts.='<td> </td>';
3583: }
3584: } else {
3585: my $value = &format_previous_attempt_value($key,$lasthash{$key});
3586: if ($key =~/$regexp$/ && (defined &$gradesub)) {
3587: $value = &$gradesub($value);
3588: }
3589: $prevattempts.='<td>'.$value.' </td>';
3590: }
3591: } else {
3592: my $value = &format_previous_attempt_value($key,$lasthash{$key});
3593: if ($key =~/$regexp$/ && (defined &$gradesub)) {
3594: $value = &$gradesub($value);
3595: }
3596: $prevattempts.='<td>'.$value.' </td>';
3597: }
1.16 harris41 3598: }
1.596 albertel 3599: $prevattempts.= &end_data_table_row().&end_data_table();
1.1 albertel 3600: } else {
1.596 albertel 3601: $prevattempts=
3602: &start_data_table().&start_data_table_row().
3603: '<td>'.&mt('Nothing submitted - no attempts.').'</td>'.
3604: &end_data_table_row().&end_data_table();
1.1 albertel 3605: }
3606: } else {
1.596 albertel 3607: $prevattempts=
3608: &start_data_table().&start_data_table_row().
3609: '<td>'.&mt('No data.').'</td>'.
3610: &end_data_table_row().&end_data_table();
1.1 albertel 3611: }
1.10 albertel 3612: }
3613:
1.581 albertel 3614: sub format_previous_attempt_value {
3615: my ($key,$value) = @_;
3616: if ($key =~ /timestamp/) {
3617: $value = &Apache::lonlocal::locallocaltime($value);
3618: } elsif (ref($value) eq 'ARRAY') {
3619: $value = '('.join(', ', @{ $value }).')';
1.948.2.14 raeburn 3620: } elsif ($key =~ /answerstring$/) {
3621: my %answers = &Apache::lonnet::str2hash($value);
3622: my @anskeys = sort(keys(%answers));
3623: if (@anskeys == 1) {
3624: my $answer = $answers{$anskeys[0]};
1.948.2.27 raeburn 3625: if ($answer =~ m{\0}) {
3626: $answer =~ s{\0}{,}g;
1.948.2.14 raeburn 3627: }
3628: my $tag_internal_answer_name = 'INTERNAL';
3629: if ($anskeys[0] eq $tag_internal_answer_name) {
3630: $value = $answer;
3631: } else {
3632: $value = $anskeys[0].'='.$answer;
3633: }
3634: } else {
3635: foreach my $ans (@anskeys) {
3636: my $answer = $answers{$ans};
1.948.2.27 raeburn 3637: if ($answer =~ m{\0}) {
3638: $answer =~ s{\0}{,}g;
1.948.2.14 raeburn 3639: }
3640: $value .= $ans.'='.$answer.'<br />';;
3641: }
3642: }
1.581 albertel 3643: } else {
3644: $value = &unescape($value);
3645: }
3646: return $value;
3647: }
3648:
3649:
1.107 albertel 3650: sub relative_to_absolute {
3651: my ($url,$output)=@_;
3652: my $parser=HTML::TokeParser->new(\$output);
3653: my $token;
3654: my $thisdir=$url;
3655: my @rlinks=();
3656: while ($token=$parser->get_token) {
3657: if ($token->[0] eq 'S') {
3658: if ($token->[1] eq 'a') {
3659: if ($token->[2]->{'href'}) {
3660: $rlinks[$#rlinks+1]=$token->[2]->{'href'};
3661: }
3662: } elsif ($token->[1] eq 'img' || $token->[1] eq 'embed' ) {
3663: $rlinks[$#rlinks+1]=$token->[2]->{'src'};
3664: } elsif ($token->[1] eq 'base') {
3665: $thisdir=$token->[2]->{'href'};
3666: }
3667: }
3668: }
3669: $thisdir=~s-/[^/]*$--;
1.356 albertel 3670: foreach my $link (@rlinks) {
1.726 raeburn 3671: unless (($link=~/^https?\:\/\//i) ||
1.356 albertel 3672: ($link=~/^\//) ||
3673: ($link=~/^javascript:/i) ||
3674: ($link=~/^mailto:/i) ||
3675: ($link=~/^\#/)) {
3676: my $newlocation=&Apache::lonnet::hreflocation($thisdir,$link);
3677: $output=~s/(\"|\'|\=\s*)\Q$link\E(\"|\'|\s|\>)/$1$newlocation$2/;
1.107 albertel 3678: }
3679: }
3680: # -------------------------------------------------- Deal with Applet codebases
3681: $output=~s/(\<applet[^\>]+)(codebase\=[^\S\>]+)*([^\>]*)\>/$1.($2?$2:' codebase="'.$thisdir.'"').$3.'>'/gei;
3682: return $output;
3683: }
3684:
1.112 bowersj2 3685: =pod
3686:
1.648 raeburn 3687: =item * &get_student_view()
1.112 bowersj2 3688:
3689: show a snapshot of what student was looking at
3690:
3691: =cut
3692:
1.10 albertel 3693: sub get_student_view {
1.186 albertel 3694: my ($symb,$username,$domain,$courseid,$target,$moreenv) = @_;
1.114 www 3695: my ($map,$id,$feedurl) = &Apache::lonnet::decode_symb($symb);
1.186 albertel 3696: my (%form);
1.10 albertel 3697: my @elements=('symb','courseid','domain','username');
3698: foreach my $element (@elements) {
1.186 albertel 3699: $form{'grade_'.$element}=eval '$'.$element #'
1.10 albertel 3700: }
1.186 albertel 3701: if (defined($moreenv)) {
3702: %form=(%form,%{$moreenv});
3703: }
1.236 albertel 3704: if (defined($target)) { $form{'grade_target'} = $target; }
1.107 albertel 3705: $feedurl=&Apache::lonnet::clutter($feedurl);
1.650 www 3706: my ($userview,$response)=&Apache::lonnet::ssi_body($feedurl,%form);
1.11 albertel 3707: $userview=~s/\<body[^\>]*\>//gi;
3708: $userview=~s/\<\/body\>//gi;
3709: $userview=~s/\<html\>//gi;
3710: $userview=~s/\<\/html\>//gi;
3711: $userview=~s/\<head\>//gi;
3712: $userview=~s/\<\/head\>//gi;
3713: $userview=~s/action\s*\=/would_be_action\=/gi;
1.107 albertel 3714: $userview=&relative_to_absolute($feedurl,$userview);
1.650 www 3715: if (wantarray) {
3716: return ($userview,$response);
3717: } else {
3718: return $userview;
3719: }
3720: }
3721:
3722: sub get_student_view_with_retries {
3723: my ($symb,$retries,$username,$domain,$courseid,$target,$moreenv) = @_;
3724:
3725: my $ok = 0; # True if we got a good response.
3726: my $content;
3727: my $response;
3728:
3729: # Try to get the student_view done. within the retries count:
3730:
3731: do {
3732: ($content, $response) = &get_student_view($symb,$username,$domain,$courseid,$target,$moreenv);
3733: $ok = $response->is_success;
3734: if (!$ok) {
3735: &Apache::lonnet::logthis("Failed get_student_view_with_retries on $symb: ".$response->is_success.', '.$response->code.', '.$response->message);
3736: }
3737: $retries--;
3738: } while (!$ok && ($retries > 0));
3739:
3740: if (!$ok) {
3741: $content = ''; # On error return an empty content.
3742: }
1.651 www 3743: if (wantarray) {
3744: return ($content, $response);
3745: } else {
3746: return $content;
3747: }
1.11 albertel 3748: }
3749:
1.112 bowersj2 3750: =pod
3751:
1.648 raeburn 3752: =item * &get_student_answers()
1.112 bowersj2 3753:
3754: show a snapshot of how student was answering problem
3755:
3756: =cut
3757:
1.11 albertel 3758: sub get_student_answers {
1.100 sakharuk 3759: my ($symb,$username,$domain,$courseid,%form) = @_;
1.114 www 3760: my ($map,$id,$feedurl) = &Apache::lonnet::decode_symb($symb);
1.186 albertel 3761: my (%moreenv);
1.11 albertel 3762: my @elements=('symb','courseid','domain','username');
3763: foreach my $element (@elements) {
1.186 albertel 3764: $moreenv{'grade_'.$element}=eval '$'.$element #'
1.10 albertel 3765: }
1.186 albertel 3766: $moreenv{'grade_target'}='answer';
3767: %moreenv=(%form,%moreenv);
1.497 raeburn 3768: $feedurl = &Apache::lonnet::clutter($feedurl);
3769: my $userview=&Apache::lonnet::ssi($feedurl,%moreenv);
1.10 albertel 3770: return $userview;
1.1 albertel 3771: }
1.116 albertel 3772:
3773: =pod
3774:
3775: =item * &submlink()
3776:
1.242 albertel 3777: Inputs: $text $uname $udom $symb $target
1.116 albertel 3778:
3779: Returns: A link to grades.pm such as to see the SUBM view of a student
3780:
3781: =cut
3782:
3783: ###############################################
3784: sub submlink {
1.242 albertel 3785: my ($text,$uname,$udom,$symb,$target)=@_;
1.116 albertel 3786: if (!($uname && $udom)) {
3787: (my $cursymb, my $courseid,$udom,$uname)=
1.463 albertel 3788: &Apache::lonnet::whichuser($symb);
1.116 albertel 3789: if (!$symb) { $symb=$cursymb; }
3790: }
1.254 matthew 3791: if (!$symb) { $symb=&Apache::lonnet::symbread(); }
1.369 www 3792: $symb=&escape($symb);
1.948.2.4 raeburn 3793: if ($target) { $target=" target=\"$target\""; }
3794: return
3795: '<a href="/adm/grades?command=submission'.
3796: '&symb='.$symb.
3797: '&student='.$uname.
3798: '&userdom='.$udom.'"'.
3799: $target.'>'.$text.'</a>';
1.242 albertel 3800: }
3801: ##############################################
3802:
3803: =pod
3804:
3805: =item * &pgrdlink()
3806:
3807: Inputs: $text $uname $udom $symb $target
3808:
3809: Returns: A link to grades.pm such as to see the PGRD view of a student
3810:
3811: =cut
3812:
3813: ###############################################
3814: sub pgrdlink {
3815: my $link=&submlink(@_);
3816: $link=~s/(&command=submission)/$1&showgrading=yes/;
3817: return $link;
3818: }
3819: ##############################################
3820:
3821: =pod
3822:
3823: =item * &pprmlink()
3824:
3825: Inputs: $text $uname $udom $symb $target
3826:
3827: Returns: A link to parmset.pm such as to see the PPRM view of a
1.283 albertel 3828: student and a specific resource
1.242 albertel 3829:
3830: =cut
3831:
3832: ###############################################
3833: sub pprmlink {
3834: my ($text,$uname,$udom,$symb,$target)=@_;
3835: if (!($uname && $udom)) {
3836: (my $cursymb, my $courseid,$udom,$uname)=
1.463 albertel 3837: &Apache::lonnet::whichuser($symb);
1.242 albertel 3838: if (!$symb) { $symb=$cursymb; }
3839: }
1.254 matthew 3840: if (!$symb) { $symb=&Apache::lonnet::symbread(); }
1.369 www 3841: $symb=&escape($symb);
1.242 albertel 3842: if ($target) { $target="target=\"$target\""; }
1.595 albertel 3843: return '<a href="/adm/parmset?command=set&'.
3844: 'symb='.$symb.'&uname='.$uname.
3845: '&udom='.$udom.'" '.$target.'>'.$text.'</a>';
1.116 albertel 3846: }
3847: ##############################################
1.37 matthew 3848:
1.112 bowersj2 3849: =pod
3850:
3851: =back
3852:
3853: =cut
3854:
1.37 matthew 3855: ###############################################
1.51 www 3856:
3857:
3858: sub timehash {
1.687 raeburn 3859: my ($thistime) = @_;
3860: my $timezone = &Apache::lonlocal::gettimezone();
3861: my $dt = DateTime->from_epoch(epoch => $thistime)
3862: ->set_time_zone($timezone);
3863: my $wday = $dt->day_of_week();
3864: if ($wday == 7) { $wday = 0; }
3865: return ( 'second' => $dt->second(),
3866: 'minute' => $dt->minute(),
3867: 'hour' => $dt->hour(),
3868: 'day' => $dt->day_of_month(),
3869: 'month' => $dt->month(),
3870: 'year' => $dt->year(),
3871: 'weekday' => $wday,
3872: 'dayyear' => $dt->day_of_year(),
3873: 'dlsav' => $dt->is_dst() );
1.51 www 3874: }
3875:
1.370 www 3876: sub utc_string {
3877: my ($date)=@_;
1.371 www 3878: return strftime("%Y%m%dT%H%M%SZ",gmtime($date));
1.370 www 3879: }
3880:
1.51 www 3881: sub maketime {
3882: my %th=@_;
1.687 raeburn 3883: my ($epoch_time,$timezone,$dt);
3884: $timezone = &Apache::lonlocal::gettimezone();
3885: eval {
3886: $dt = DateTime->new( year => $th{'year'},
3887: month => $th{'month'},
3888: day => $th{'day'},
3889: hour => $th{'hour'},
3890: minute => $th{'minute'},
3891: second => $th{'second'},
3892: time_zone => $timezone,
3893: );
3894: };
3895: if (!$@) {
3896: $epoch_time = $dt->epoch;
3897: if ($epoch_time) {
3898: return $epoch_time;
3899: }
3900: }
1.51 www 3901: return POSIX::mktime(
3902: ($th{'seconds'},$th{'minutes'},$th{'hours'},
1.210 www 3903: $th{'day'},$th{'month'}-1,$th{'year'}-1900,0,0,-1));
1.70 www 3904: }
3905:
3906: #########################################
1.51 www 3907:
3908: sub findallcourses {
1.482 raeburn 3909: my ($roles,$uname,$udom) = @_;
1.355 albertel 3910: my %roles;
3911: if (ref($roles)) { %roles = map { $_ => 1 } @{$roles}; }
1.348 albertel 3912: my %courses;
1.51 www 3913: my $now=time;
1.482 raeburn 3914: if (!defined($uname)) {
3915: $uname = $env{'user.name'};
3916: }
3917: if (!defined($udom)) {
3918: $udom = $env{'user.domain'};
3919: }
3920: if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {
1.948.2.11 raeburn 3921: my $extra = &Apache::lonnet::freeze_escape({'skipcheck' => 1});
3922: my %roleshash = &Apache::lonnet::dump('roles',$udom,$uname,'.',undef,
3923: $extra);
1.482 raeburn 3924: if (!%roles) {
3925: %roles = (
3926: cc => 1,
1.907 raeburn 3927: co => 1,
1.482 raeburn 3928: in => 1,
3929: ep => 1,
3930: ta => 1,
3931: cr => 1,
3932: st => 1,
3933: );
3934: }
3935: foreach my $entry (keys(%roleshash)) {
3936: my ($trole,$tend,$tstart) = split(/_/,$roleshash{$entry});
3937: if ($trole =~ /^cr/) {
3938: next if (!exists($roles{$trole}) && !exists($roles{'cr'}));
3939: } else {
3940: next if (!exists($roles{$trole}));
3941: }
3942: if ($tend) {
3943: next if ($tend < $now);
3944: }
3945: if ($tstart) {
3946: next if ($tstart > $now);
3947: }
3948: my ($cdom,$cnum,$sec,$cnumpart,$secpart,$role,$realsec);
3949: (undef,$cdom,$cnumpart,$secpart) = split(/\//,$entry);
3950: if ($secpart eq '') {
3951: ($cnum,$role) = split(/_/,$cnumpart);
3952: $sec = 'none';
3953: $realsec = '';
3954: } else {
3955: $cnum = $cnumpart;
3956: ($sec,$role) = split(/_/,$secpart);
3957: $realsec = $sec;
1.490 raeburn 3958: }
1.482 raeburn 3959: $courses{$cdom.'_'.$cnum}{$sec} = $trole.'/'.$cdom.'/'.$cnum.'/'.$realsec;
3960: }
3961: } else {
3962: foreach my $key (keys(%env)) {
1.483 albertel 3963: if ( $key=~m{^user\.role\.(\w+)\./($match_domain)/($match_courseid)/?(\w*)$} ||
3964: $key=~m{^user\.role\.(cr/$match_domain/$match_username/\w+)\./($match_domain)/($match_courseid)/?(\w*)$}) {
1.482 raeburn 3965: my ($role,$cdom,$cnum,$sec) = ($1,$2,$3,$4);
3966: next if ($role eq 'ca' || $role eq 'aa');
3967: next if (%roles && !exists($roles{$role}));
3968: my ($starttime,$endtime)=split(/\./,$env{$key});
3969: my $active=1;
3970: if ($starttime) {
3971: if ($now<$starttime) { $active=0; }
3972: }
3973: if ($endtime) {
3974: if ($now>$endtime) { $active=0; }
3975: }
3976: if ($active) {
3977: if ($sec eq '') {
3978: $sec = 'none';
3979: }
3980: $courses{$cdom.'_'.$cnum}{$sec} =
3981: $role.'/'.$cdom.'/'.$cnum.'/'.$sec;
1.474 raeburn 3982: }
3983: }
1.51 www 3984: }
3985: }
1.474 raeburn 3986: return %courses;
1.51 www 3987: }
1.37 matthew 3988:
1.54 www 3989: ###############################################
1.474 raeburn 3990:
3991: sub blockcheck {
1.482 raeburn 3992: my ($setters,$activity,$uname,$udom) = @_;
1.490 raeburn 3993:
3994: if (!defined($udom)) {
3995: $udom = $env{'user.domain'};
3996: }
3997: if (!defined($uname)) {
3998: $uname = $env{'user.name'};
3999: }
4000:
4001: # If uname and udom are for a course, check for blocks in the course.
4002:
4003: if (&Apache::lonnet::is_course($udom,$uname)) {
4004: my %records = &Apache::lonnet::dump('comm_block',$udom,$uname);
1.502 raeburn 4005: my ($startblock,$endblock)=&get_blocks($setters,$activity,$udom,$uname);
1.490 raeburn 4006: return ($startblock,$endblock);
4007: }
1.474 raeburn 4008:
1.502 raeburn 4009: my $startblock = 0;
4010: my $endblock = 0;
1.482 raeburn 4011: my %live_courses = &findallcourses(undef,$uname,$udom);
1.474 raeburn 4012:
1.490 raeburn 4013: # If uname is for a user, and activity is course-specific, i.e.,
4014: # boards, chat or groups, check for blocking in current course only.
1.474 raeburn 4015:
1.490 raeburn 4016: if (($activity eq 'boards' || $activity eq 'chat' ||
4017: $activity eq 'groups') && ($env{'request.course.id'})) {
4018: foreach my $key (keys(%live_courses)) {
4019: if ($key ne $env{'request.course.id'}) {
4020: delete($live_courses{$key});
4021: }
4022: }
4023: }
4024:
4025: my $otheruser = 0;
4026: my %own_courses;
4027: if ((($uname ne $env{'user.name'})) || ($udom ne $env{'user.domain'})) {
4028: # Resource belongs to user other than current user.
4029: $otheruser = 1;
4030: # Gather courses for current user
4031: %own_courses =
4032: &findallcourses(undef,$env{'user.name'},$env{'user.domain'});
4033: }
4034:
4035: # Gather active course roles - course coordinator, instructor,
4036: # exam proctor, ta, student, or custom role.
1.474 raeburn 4037:
4038: foreach my $course (keys(%live_courses)) {
1.482 raeburn 4039: my ($cdom,$cnum);
4040: if ((defined($env{'course.'.$course.'.domain'})) && (defined($env{'course.'.$course.'.num'}))) {
4041: $cdom = $env{'course.'.$course.'.domain'};
4042: $cnum = $env{'course.'.$course.'.num'};
4043: } else {
1.490 raeburn 4044: ($cdom,$cnum) = split(/_/,$course);
1.482 raeburn 4045: }
4046: my $no_ownblock = 0;
4047: my $no_userblock = 0;
1.533 raeburn 4048: if ($otheruser && $activity ne 'com') {
1.490 raeburn 4049: # Check if current user has 'evb' priv for this
4050: if (defined($own_courses{$course})) {
4051: foreach my $sec (keys(%{$own_courses{$course}})) {
4052: my $checkrole = 'cm./'.$cdom.'/'.$cnum;
4053: if ($sec ne 'none') {
4054: $checkrole .= '/'.$sec;
4055: }
4056: if (&Apache::lonnet::allowed('evb',undef,undef,$checkrole)) {
4057: $no_ownblock = 1;
4058: last;
4059: }
4060: }
4061: }
4062: # if they have 'evb' priv and are currently not playing student
4063: next if (($no_ownblock) &&
4064: ($env{'request.role'} !~ m{^st\./$cdom/$cnum}));
4065: }
1.474 raeburn 4066: foreach my $sec (keys(%{$live_courses{$course}})) {
1.482 raeburn 4067: my $checkrole = 'cm./'.$cdom.'/'.$cnum;
1.474 raeburn 4068: if ($sec ne 'none') {
1.482 raeburn 4069: $checkrole .= '/'.$sec;
1.474 raeburn 4070: }
1.490 raeburn 4071: if ($otheruser) {
4072: # Resource belongs to user other than current user.
4073: # Assemble privs for that user, and check for 'evb' priv.
1.482 raeburn 4074: my ($trole,$tdom,$tnum,$tsec);
4075: my $entry = $live_courses{$course}{$sec};
4076: if ($entry =~ /^cr/) {
4077: ($trole,$tdom,$tnum,$tsec) =
4078: ($entry =~ m|^(cr/$match_domain/$match_username/\w+)\./($match_domain)/($match_username)/?(\w*)$|);
4079: } else {
4080: ($trole,$tdom,$tnum,$tsec) = split(/\//,$entry);
4081: }
4082: my ($spec,$area,$trest,%allroles,%userroles);
4083: $area = '/'.$tdom.'/'.$tnum;
4084: $trest = $tnum;
4085: if ($tsec ne '') {
4086: $area .= '/'.$tsec;
4087: $trest .= '/'.$tsec;
4088: }
4089: $spec = $trole.'.'.$area;
4090: if ($trole =~ /^cr/) {
4091: &Apache::lonnet::custom_roleprivs(\%allroles,$trole,
4092: $tdom,$spec,$trest,$area);
4093: } else {
4094: &Apache::lonnet::standard_roleprivs(\%allroles,$trole,
4095: $tdom,$spec,$trest,$area);
4096: }
4097: my ($author,$adv) = &Apache::lonnet::set_userprivs(\%userroles,\%allroles);
1.486 raeburn 4098: if ($userroles{'user.priv.'.$checkrole} =~ /evb\&([^\:]*)/) {
4099: if ($1) {
4100: $no_userblock = 1;
4101: last;
4102: }
4103: }
1.490 raeburn 4104: } else {
4105: # Resource belongs to current user
4106: # Check for 'evb' priv via lonnet::allowed().
1.482 raeburn 4107: if (&Apache::lonnet::allowed('evb',undef,undef,$checkrole)) {
4108: $no_ownblock = 1;
4109: last;
4110: }
1.474 raeburn 4111: }
4112: }
4113: # if they have the evb priv and are currently not playing student
1.482 raeburn 4114: next if (($no_ownblock) &&
1.491 albertel 4115: ($env{'request.role'} !~ m{^st\./\Q$cdom\E/\Q$cnum\E}));
1.482 raeburn 4116: next if ($no_userblock);
1.474 raeburn 4117:
1.866 kalberla 4118: # Retrieve blocking times and identity of locker for course
1.490 raeburn 4119: # of specified user, unless user has 'evb' privilege.
1.502 raeburn 4120:
4121: my ($start,$end)=&get_blocks($setters,$activity,$cdom,$cnum);
4122: if (($start != 0) &&
4123: (($startblock == 0) || ($startblock > $start))) {
4124: $startblock = $start;
4125: }
4126: if (($end != 0) &&
4127: (($endblock == 0) || ($endblock < $end))) {
4128: $endblock = $end;
4129: }
1.490 raeburn 4130: }
4131: return ($startblock,$endblock);
4132: }
4133:
4134: sub get_blocks {
4135: my ($setters,$activity,$cdom,$cnum) = @_;
4136: my $startblock = 0;
4137: my $endblock = 0;
4138: my $course = $cdom.'_'.$cnum;
4139: $setters->{$course} = {};
4140: $setters->{$course}{'staff'} = [];
4141: $setters->{$course}{'times'} = [];
4142: my %records = &Apache::lonnet::dump('comm_block',$cdom,$cnum);
4143: foreach my $record (keys(%records)) {
4144: my ($start,$end) = ($record =~ m/^(\d+)____(\d+)$/);
4145: if ($start <= time && $end >= time) {
4146: my ($staff_name,$staff_dom,$title,$blocks) =
4147: &parse_block_record($records{$record});
4148: if ($blocks->{$activity} eq 'on') {
4149: push(@{$$setters{$course}{'staff'}},[$staff_name,$staff_dom]);
4150: push(@{$$setters{$course}{'times'}}, [$start,$end]);
1.491 albertel 4151: if ( ($startblock == 0) || ($startblock > $start) ) {
4152: $startblock = $start;
1.490 raeburn 4153: }
1.491 albertel 4154: if ( ($endblock == 0) || ($endblock < $end) ) {
4155: $endblock = $end;
1.474 raeburn 4156: }
4157: }
4158: }
4159: }
4160: return ($startblock,$endblock);
4161: }
4162:
4163: sub parse_block_record {
4164: my ($record) = @_;
4165: my ($setuname,$setudom,$title,$blocks);
4166: if (ref($record) eq 'HASH') {
4167: ($setuname,$setudom) = split(/:/,$record->{'setter'});
4168: $title = &unescape($record->{'event'});
4169: $blocks = $record->{'blocks'};
4170: } else {
4171: my @data = split(/:/,$record,3);
4172: if (scalar(@data) eq 2) {
4173: $title = $data[1];
4174: ($setuname,$setudom) = split(/@/,$data[0]);
4175: } else {
4176: ($setuname,$setudom,$title) = @data;
4177: }
4178: $blocks = { 'com' => 'on' };
4179: }
4180: return ($setuname,$setudom,$title,$blocks);
4181: }
4182:
1.854 kalberla 4183: sub blocking_status {
4184: my ($activity,$uname,$udom) = @_;
1.867 kalberla 4185: my %setters;
1.890 droeschl 4186:
4187: # check for active blocking
1.867 kalberla 4188: my ($startblock,$endblock)=&blockcheck(\%setters,$activity,$uname,$udom);
1.854 kalberla 4189:
1.890 droeschl 4190: my $blocked = $startblock && $endblock ? 1 : 0;
4191:
4192: # caller just wants to know whether a block is active
4193: if (!wantarray) { return $blocked; }
4194:
4195: # build a link to a popup window containing the details
4196: my $querystring = "?activity=$activity";
4197: # $uname and $udom decide whose portfolio the user is trying to look at
4198: $querystring .= "&udom=$udom" if $udom;
4199: $querystring .= "&uname=$uname" if $uname;
4200:
4201: my $output .= <<'END_MYBLOCK';
1.854 kalberla 4202: function openWindow(url, wdwName, w, h, toolbar,scrollbar) {
4203: var options = "width=" + w + ",height=" + h + ",";
4204: options += "resizable=yes,scrollbars="+scrollbar+",status=no,";
4205: options += "menubar=no,toolbar="+toolbar+",location=no,directories=no";
4206: var newWin = window.open(url, wdwName, options);
4207: newWin.focus();
4208: }
1.890 droeschl 4209: END_MYBLOCK
1.854 kalberla 4210:
1.890 droeschl 4211: $output = Apache::lonhtmlcommon::scripttag($output);
4212:
1.854 kalberla 4213: my $popupUrl = "/adm/blockingstatus/$querystring";
1.890 droeschl 4214: my $text = mt('Communication Blocked');
4215:
1.867 kalberla 4216: $output .= <<"END_BLOCK";
4217: <div class='LC_comblock'>
1.869 kalberla 4218: <a onclick='openWindow("$popupUrl","Blocking Table",600,300,"no","no");return false;' href='/adm/blockingstatus/$querystring'
1.890 droeschl 4219: title='$text'>
4220: <img class='LC_noBorder LC_middle' title='$text' src='/res/adm/pages/comblock.png' alt='$text'/></a>
1.869 kalberla 4221: <a onclick='openWindow("$popupUrl","Blocking Table",600,300,"no","no");return false;' href='/adm/blockingstatus/$querystring'
1.890 droeschl 4222: title='$text'>$text</a>
1.867 kalberla 4223: </div>
4224:
4225: END_BLOCK
1.474 raeburn 4226:
1.854 kalberla 4227: return ($blocked, $output);
4228: }
1.490 raeburn 4229:
1.60 matthew 4230: ###############################################
4231:
1.682 raeburn 4232: sub check_ip_acc {
4233: my ($acc)=@_;
4234: &Apache::lonxml::debug("acc is $acc");
4235: if (!defined($acc) || $acc =~ /^\s*$/ || $acc =~/^\s*no\s*$/i) {
4236: return 1;
4237: }
4238: my $allowed=0;
4239: my $ip=$env{'request.host'} || $ENV{'REMOTE_ADDR'};
4240:
4241: my $name;
4242: foreach my $pattern (split(',',$acc)) {
4243: $pattern =~ s/^\s*//;
4244: $pattern =~ s/\s*$//;
4245: if ($pattern =~ /\*$/) {
4246: #35.8.*
4247: $pattern=~s/\*//;
4248: if ($ip =~ /^\Q$pattern\E/) { $allowed=1; }
4249: } elsif ($pattern =~ /(\d+\.\d+\.\d+)\.\[(\d+)-(\d+)\]$/) {
4250: #35.8.3.[34-56]
4251: my $low=$2;
4252: my $high=$3;
4253: $pattern=$1;
4254: if ($ip =~ /^\Q$pattern\E/) {
4255: my $last=(split(/\./,$ip))[3];
4256: if ($last <=$high && $last >=$low) { $allowed=1; }
4257: }
4258: } elsif ($pattern =~ /^\*/) {
4259: #*.msu.edu
4260: $pattern=~s/\*//;
4261: if (!defined($name)) {
4262: use Socket;
4263: my $netaddr=inet_aton($ip);
4264: ($name)=gethostbyaddr($netaddr,AF_INET);
4265: }
4266: if ($name =~ /\Q$pattern\E$/i) { $allowed=1; }
4267: } elsif ($pattern =~ /\d+\.\d+\.\d+\.\d+/) {
4268: #127.0.0.1
4269: if ($ip =~ /^\Q$pattern\E/) { $allowed=1; }
4270: } else {
4271: #some.name.com
4272: if (!defined($name)) {
4273: use Socket;
4274: my $netaddr=inet_aton($ip);
4275: ($name)=gethostbyaddr($netaddr,AF_INET);
4276: }
4277: if ($name =~ /\Q$pattern\E$/i) { $allowed=1; }
4278: }
4279: if ($allowed) { last; }
4280: }
4281: return $allowed;
4282: }
4283:
4284: ###############################################
4285:
1.60 matthew 4286: =pod
4287:
1.112 bowersj2 4288: =head1 Domain Template Functions
4289:
4290: =over 4
4291:
4292: =item * &determinedomain()
1.60 matthew 4293:
4294: Inputs: $domain (usually will be undef)
4295:
1.63 www 4296: Returns: Determines which domain should be used for designs
1.60 matthew 4297:
4298: =cut
1.54 www 4299:
1.60 matthew 4300: ###############################################
1.63 www 4301: sub determinedomain {
4302: my $domain=shift;
1.531 albertel 4303: if (! $domain) {
1.60 matthew 4304: # Determine domain if we have not been given one
1.893 raeburn 4305: $domain = &Apache::lonnet::default_login_domain();
1.258 albertel 4306: if ($env{'user.domain'}) { $domain=$env{'user.domain'}; }
4307: if ($env{'request.role.domain'}) {
4308: $domain=$env{'request.role.domain'};
1.60 matthew 4309: }
4310: }
1.63 www 4311: return $domain;
4312: }
4313: ###############################################
1.517 raeburn 4314:
1.518 albertel 4315: sub devalidate_domconfig_cache {
4316: my ($udom)=@_;
4317: &Apache::lonnet::devalidate_cache_new('domainconfig',$udom);
4318: }
4319:
4320: # ---------------------- Get domain configuration for a domain
4321: sub get_domainconf {
4322: my ($udom) = @_;
4323: my $cachetime=1800;
4324: my ($result,$cached)=&Apache::lonnet::is_cached_new('domainconfig',$udom);
4325: if (defined($cached)) { return %{$result}; }
4326:
4327: my %domconfig = &Apache::lonnet::get_dom('configuration',
1.948 raeburn 4328: ['login','rolecolors','autoenroll'],$udom);
1.632 raeburn 4329: my (%designhash,%legacy);
1.518 albertel 4330: if (keys(%domconfig) > 0) {
4331: if (ref($domconfig{'login'}) eq 'HASH') {
1.632 raeburn 4332: if (keys(%{$domconfig{'login'}})) {
4333: foreach my $key (keys(%{$domconfig{'login'}})) {
1.699 raeburn 4334: if (ref($domconfig{'login'}{$key}) eq 'HASH') {
1.946 raeburn 4335: if ($key eq 'loginvia') {
4336: if (ref($domconfig{'login'}{'loginvia'}) eq 'HASH') {
1.948.2.30 raeburn 4337: foreach my $hostname (keys(%{$domconfig{'login'}{'loginvia'}})) {
1.948 raeburn 4338: if (ref($domconfig{'login'}{'loginvia'}{$hostname}) eq 'HASH') {
4339: if ($domconfig{'login'}{'loginvia'}{$hostname}{'server'}) {
4340: my $server = $domconfig{'login'}{'loginvia'}{$hostname}{'server'};
4341: $designhash{$udom.'.login.loginvia'} = $server;
4342: if ($domconfig{'login'}{'loginvia'}{$hostname}{'serverpath'} eq 'custom') {
4343:
4344: $designhash{$udom.'.login.loginvia_'.$hostname} = $server.':'.$domconfig{'login'}{'loginvia'}{$hostname}{'custompath'};
4345: } else {
1.948.2.30 raeburn 4346: $designhash{$udom.'.login.loginvia_'.$hostname} = $server.':'.$domconfig{'login'}{'loginvia'}{$hostname}{'serverpath'};
1.948 raeburn 4347: }
4348: if ($domconfig{'login'}{'loginvia'}{$hostname}{'exempt'}) {
4349: $designhash{$udom.'.login.loginvia_exempt_'.$hostname} = $domconfig{'login'}{'loginvia'}{$hostname}{'exempt'};
4350: }
1.946 raeburn 4351: }
4352: }
4353: }
4354: }
4355: } else {
4356: foreach my $img (keys(%{$domconfig{'login'}{$key}})) {
4357: $designhash{$udom.'.login.'.$key.'_'.$img} =
4358: $domconfig{'login'}{$key}{$img};
4359: }
1.699 raeburn 4360: }
4361: } else {
4362: $designhash{$udom.'.login.'.$key}=$domconfig{'login'}{$key};
4363: }
1.632 raeburn 4364: }
4365: } else {
4366: $legacy{'login'} = 1;
1.518 albertel 4367: }
1.632 raeburn 4368: } else {
4369: $legacy{'login'} = 1;
1.518 albertel 4370: }
4371: if (ref($domconfig{'rolecolors'}) eq 'HASH') {
1.632 raeburn 4372: if (keys(%{$domconfig{'rolecolors'}})) {
4373: foreach my $role (keys(%{$domconfig{'rolecolors'}})) {
4374: if (ref($domconfig{'rolecolors'}{$role}) eq 'HASH') {
4375: foreach my $item (keys(%{$domconfig{'rolecolors'}{$role}})) {
4376: $designhash{$udom.'.'.$role.'.'.$item}=$domconfig{'rolecolors'}{$role}{$item};
4377: }
1.518 albertel 4378: }
4379: }
1.632 raeburn 4380: } else {
4381: $legacy{'rolecolors'} = 1;
1.518 albertel 4382: }
1.632 raeburn 4383: } else {
4384: $legacy{'rolecolors'} = 1;
1.518 albertel 4385: }
1.948 raeburn 4386: if (ref($domconfig{'autoenroll'}) eq 'HASH') {
4387: if ($domconfig{'autoenroll'}{'co-owners'}) {
4388: $designhash{$udom.'.autoassign.co-owners'}=$domconfig{'autoenroll'}{'co-owners'};
4389: }
4390: }
1.632 raeburn 4391: if (keys(%legacy) > 0) {
4392: my %legacyhash = &get_legacy_domconf($udom);
4393: foreach my $item (keys(%legacyhash)) {
4394: if ($item =~ /^\Q$udom\E\.login/) {
4395: if ($legacy{'login'}) {
4396: $designhash{$item} = $legacyhash{$item};
4397: }
4398: } else {
4399: if ($legacy{'rolecolors'}) {
4400: $designhash{$item} = $legacyhash{$item};
4401: }
1.518 albertel 4402: }
4403: }
4404: }
1.632 raeburn 4405: } else {
4406: %designhash = &get_legacy_domconf($udom);
1.518 albertel 4407: }
4408: &Apache::lonnet::do_cache_new('domainconfig',$udom,\%designhash,
4409: $cachetime);
4410: return %designhash;
4411: }
4412:
1.632 raeburn 4413: sub get_legacy_domconf {
4414: my ($udom) = @_;
4415: my %legacyhash;
4416: my $designdir=$Apache::lonnet::perlvar{'lonTabDir'}.'/lonDomColors';
4417: my $designfile = $designdir.'/'.$udom.'.tab';
4418: if (-e $designfile) {
4419: if ( open (my $fh,"<$designfile") ) {
4420: while (my $line = <$fh>) {
4421: next if ($line =~ /^\#/);
4422: chomp($line);
4423: my ($key,$val)=(split(/\=/,$line));
4424: if ($val) { $legacyhash{$udom.'.'.$key}=$val; }
4425: }
4426: close($fh);
4427: }
4428: }
4429: if (-e '/home/httpd/html/adm/lonDomLogos/'.$udom.'.gif') {
4430: $legacyhash{$udom.'.login.domlogo'} = "/adm/lonDomLogos/$udom.gif";
4431: }
4432: return %legacyhash;
4433: }
4434:
1.63 www 4435: =pod
4436:
1.112 bowersj2 4437: =item * &domainlogo()
1.63 www 4438:
4439: Inputs: $domain (usually will be undef)
4440:
4441: Returns: A link to a domain logo, if the domain logo exists.
4442: If the domain logo does not exist, a description of the domain.
4443:
4444: =cut
1.112 bowersj2 4445:
1.63 www 4446: ###############################################
4447: sub domainlogo {
1.517 raeburn 4448: my $domain = &determinedomain(shift);
1.518 albertel 4449: my %designhash = &get_domainconf($domain);
1.517 raeburn 4450: # See if there is a logo
4451: if ($designhash{$domain.'.login.domlogo'} ne '') {
1.519 raeburn 4452: my $imgsrc = $designhash{$domain.'.login.domlogo'};
1.538 albertel 4453: if ($imgsrc =~ m{^/(adm|res)/}) {
4454: if ($imgsrc =~ m{^/res/}) {
4455: my $local_name = &Apache::lonnet::filelocation('',$imgsrc);
4456: &Apache::lonnet::repcopy($local_name);
4457: }
4458: $imgsrc = &lonhttpdurl($imgsrc);
1.519 raeburn 4459: }
4460: return '<img src="'.$imgsrc.'" alt="'.$domain.'" />';
1.514 albertel 4461: } elsif (defined(&Apache::lonnet::domain($domain,'description'))) {
4462: return &Apache::lonnet::domain($domain,'description');
1.59 www 4463: } else {
1.60 matthew 4464: return '';
1.59 www 4465: }
4466: }
1.63 www 4467: ##############################################
4468:
4469: =pod
4470:
1.112 bowersj2 4471: =item * &designparm()
1.63 www 4472:
4473: Inputs: $which parameter; $domain (usually will be undef)
4474:
4475: Returns: value of designparamter $which
4476:
4477: =cut
1.112 bowersj2 4478:
1.397 albertel 4479:
1.400 albertel 4480: ##############################################
1.397 albertel 4481: sub designparm {
4482: my ($which,$domain)=@_;
4483: if (exists($env{'environment.color.'.$which})) {
1.817 bisitz 4484: return $env{'environment.color.'.$which};
1.96 www 4485: }
1.63 www 4486: $domain=&determinedomain($domain);
1.948.2.31 raeburn 4487: my %domdesign;
4488: unless ($domain eq 'public') {
4489: %domdesign = &get_domainconf($domain);
4490: }
1.520 raeburn 4491: my $output;
1.517 raeburn 4492: if ($domdesign{$domain.'.'.$which} ne '') {
1.817 bisitz 4493: $output = $domdesign{$domain.'.'.$which};
1.63 www 4494: } else {
1.520 raeburn 4495: $output = $defaultdesign{$which};
4496: }
4497: if (($which =~ /^(student|coordinator|author|admin)\.img$/) ||
1.635 raeburn 4498: ($which =~ /login\.(img|logo|domlogo|login)/)) {
1.538 albertel 4499: if ($output =~ m{^/(adm|res)/}) {
1.817 bisitz 4500: if ($output =~ m{^/res/}) {
4501: my $local_name = &Apache::lonnet::filelocation('',$output);
4502: &Apache::lonnet::repcopy($local_name);
4503: }
1.520 raeburn 4504: $output = &lonhttpdurl($output);
4505: }
1.63 www 4506: }
1.520 raeburn 4507: return $output;
1.63 www 4508: }
1.59 www 4509:
1.822 bisitz 4510: ##############################################
4511: =pod
4512:
1.832 bisitz 4513: =item * &authorspace()
4514:
4515: Inputs: ./.
4516:
4517: Returns: Path to the Construction Space of the current user's
4518: accessed author space
4519: The author space will be that of the current user
4520: when accessing the own author space
4521: and that of the co-author/assistent co-author
4522: when accessing the co-author's/assistent co-author's
4523: space
4524:
4525: =cut
4526:
4527: sub authorspace {
4528: my $caname = '';
4529: if ($env{'request.role'} =~ /^ca|^aa/) {
4530: (undef,$caname) =
4531: ($env{'request.role'}=~/($match_domain)\/($match_username)$/);
4532: } else {
4533: $caname = $env{'user.name'};
4534: }
4535: return '/priv/'.$caname.'/';
4536: }
4537:
4538: ##############################################
4539: =pod
4540:
1.822 bisitz 4541: =item * &head_subbox()
4542:
4543: Inputs: $content (contains HTML code with page functions, etc.)
4544:
4545: Returns: HTML div with $content
4546: To be included in page header
4547:
4548: =cut
4549:
4550: sub head_subbox {
4551: my ($content)=@_;
4552: my $output =
1.948.2.22 raeburn 4553: '<div class="LC_head_subbox">'
1.822 bisitz 4554: .$content
4555: .'</div>'
4556: }
4557:
4558: ##############################################
4559: =pod
4560:
4561: =item * &CSTR_pageheader()
4562:
4563: Inputs: ./.
4564:
4565: Returns: HTML div with CSTR path and recent box
4566: To be included on Construction Space pages
4567:
4568: =cut
4569:
4570: sub CSTR_pageheader {
4571: # this is for resources; directories have customtitle, and crumbs
4572: # and select recent are created in lonpubdir.pm
4573: my ($uname,$thisdisfn)=
4574: ($env{'request.filename'} =~ m|^/home/([^/]+)/public_html/(.*)|);
4575: my $formaction='/priv/'.$uname.'/'.$thisdisfn;
4576: $formaction=~s/\/+/\//g;
4577:
4578: my $parentpath = '';
4579: my $lastitem = '';
4580: if ($thisdisfn =~ m-(.+/)([^/]*)$-) {
4581: $parentpath = $1;
4582: $lastitem = $2;
4583: } else {
4584: $lastitem = $thisdisfn;
4585: }
1.921 bisitz 4586:
4587: my $output =
1.822 bisitz 4588: '<div>'
4589: .&Apache::loncommon::help_open_menu('','',3,'Authoring') #FIXME: Broken? Where is it?
4590: .'<b>'.&mt('Construction Space:').'</b> '
4591: .'<form name="dirs" method="post" action="'.$formaction
1.921 bisitz 4592: .'" target="_top">' #FIXME lonpubdir: target="_parent"
4593: .&Apache::lonhtmlcommon::crumbs($uname.'/'.$parentpath,'_top','/priv',undef,undef);
4594:
4595: if ($lastitem) {
4596: $output .=
4597: '<span class="LC_filename">'
4598: .$lastitem
4599: .'</span>';
4600: }
4601: $output .=
4602: '<br />'
1.822 bisitz 4603: #FIXME lonpubdir: &Apache::lonhtmlcommon::crumbs($uname.$thisdisfn.'/','_top','/priv','','+1',1)."</b></tt><br />"
4604: .&Apache::lonhtmlcommon::select_recent('construct','recent','this.form.action=this.form.recent.value;this.form.submit()')
4605: .'</form>'
4606: .&Apache::lonmenu::constspaceform()
4607: .'</div>';
1.921 bisitz 4608:
4609: return $output;
1.822 bisitz 4610: }
4611:
1.60 matthew 4612: ###############################################
4613: ###############################################
4614:
4615: =pod
4616:
1.112 bowersj2 4617: =back
4618:
1.549 albertel 4619: =head1 HTML Helpers
1.112 bowersj2 4620:
4621: =over 4
4622:
4623: =item * &bodytag()
1.60 matthew 4624:
4625: Returns a uniform header for LON-CAPA web pages.
4626:
4627: Inputs:
4628:
1.112 bowersj2 4629: =over 4
4630:
4631: =item * $title, A title to be displayed on the page.
4632:
4633: =item * $function, the current role (can be undef).
4634:
4635: =item * $addentries, extra parameters for the <body> tag.
4636:
4637: =item * $bodyonly, if defined, only return the <body> tag.
4638:
4639: =item * $domain, if defined, force a given domain.
4640:
4641: =item * $forcereg, if page should register as content page (relevant for
1.86 www 4642: text interface only)
1.60 matthew 4643:
1.814 bisitz 4644: =item * $no_nav_bar, if true, keep the 'what is this' info but remove the
4645: navigational links
1.317 albertel 4646:
1.338 albertel 4647: =item * $bgcolor, used to override the bgcolor on a webpage to a specific value
4648:
1.361 albertel 4649: =item * $no_inline_link, if true and in remote mode, don't show the
4650: 'Switch To Inline Menu' link
4651:
1.460 albertel 4652: =item * $args, optional argument valid values are
4653: no_auto_mt_title -> prevents &mt()ing the title arg
1.562 albertel 4654: inherit_jsmath -> when creating popup window in a page,
4655: should it have jsmath forced on by the
4656: current page
1.460 albertel 4657:
1.112 bowersj2 4658: =back
4659:
1.60 matthew 4660: Returns: A uniform header for LON-CAPA web pages.
4661: If $bodyonly is nonzero, a string containing a <body> tag will be returned.
4662: If $bodyonly is undef or zero, an html string containing a <body> tag and
4663: other decorations will be returned.
4664:
4665: =cut
4666:
1.54 www 4667: sub bodytag {
1.831 bisitz 4668: my ($title,$function,$addentries,$bodyonly,$domain,$forcereg,
1.816 bisitz 4669: $no_nav_bar,$bgcolor,$no_inline_link,$args)=@_;
1.339 albertel 4670:
1.948.2.2 raeburn 4671: my $public;
4672: if ((($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public'))
4673: || ($env{'user.name'} eq '') && ($env{'user.domain'} eq '')) {
4674: $public = 1;
4675: }
1.460 albertel 4676: if (!$args->{'no_auto_mt_title'}) { $title = &mt($title); }
1.339 albertel 4677:
1.183 matthew 4678: $function = &get_users_function() if (!$function);
1.339 albertel 4679: my $img = &designparm($function.'.img',$domain);
4680: my $font = &designparm($function.'.font',$domain);
4681: my $pgbg = $bgcolor || &designparm($function.'.pgbg',$domain);
4682:
1.803 bisitz 4683: my %design = ( 'style' => 'margin-top: 0',
1.535 albertel 4684: 'bgcolor' => $pgbg,
1.339 albertel 4685: 'text' => $font,
4686: 'alink' => &designparm($function.'.alink',$domain),
4687: 'vlink' => &designparm($function.'.vlink',$domain),
4688: 'link' => &designparm($function.'.link',$domain),);
1.438 albertel 4689: @design{keys(%$addentries)} = @$addentries{keys(%$addentries)};
1.339 albertel 4690:
1.63 www 4691: # role and realm
1.378 raeburn 4692: my ($role,$realm) = split(/\./,$env{'request.role'},2);
4693: if ($role eq 'ca') {
1.479 albertel 4694: my ($rdom,$rname) = ($realm =~ m{^/($match_domain)/($match_username)$});
1.500 albertel 4695: $realm = &plainname($rname,$rdom);
1.378 raeburn 4696: }
1.55 www 4697: # realm
1.258 albertel 4698: if ($env{'request.course.id'}) {
1.378 raeburn 4699: if ($env{'request.role'} !~ /^cr/) {
4700: $role = &Apache::lonnet::plaintext($role,&course_type());
4701: }
1.898 raeburn 4702: if ($env{'request.course.sec'}) {
4703: $role .= (' 'x2).'- '.&mt('section:').' '.$env{'request.course.sec'};
4704: }
1.359 albertel 4705: $realm = $env{'course.'.$env{'request.course.id'}.'.description'};
1.378 raeburn 4706: } else {
4707: $role = &Apache::lonnet::plaintext($role);
1.54 www 4708: }
1.433 albertel 4709:
1.359 albertel 4710: if (!$realm) { $realm=' '; }
1.55 www 4711: # Set messages
1.60 matthew 4712: my $messages=&domainlogo($domain);
1.330 albertel 4713:
1.438 albertel 4714: my $extra_body_attr = &make_attr_string($forcereg,\%design);
1.329 albertel 4715:
1.101 www 4716: # construct main body tag
1.359 albertel 4717: my $bodytag = "<body $extra_body_attr>".
1.562 albertel 4718: &Apache::lontexconvert::init_math_support($args->{'inherit_jsmath'});
1.252 albertel 4719:
1.530 albertel 4720: if ($bodyonly) {
1.60 matthew 4721: return $bodytag;
1.798 tempelho 4722: }
1.359 albertel 4723:
1.410 albertel 4724: my $name = &plainname($env{'user.name'},$env{'user.domain'});
1.948.2.2 raeburn 4725: if ($public) {
1.433 albertel 4726: undef($role);
1.434 albertel 4727: } else {
4728: $name = &aboutmewrapper($name,$env{'user.name'},$env{'user.domain'});
1.433 albertel 4729: }
1.948.2.2 raeburn 4730:
1.762 bisitz 4731: my $titleinfo = '<h1>'.$title.'</h1>';
1.359 albertel 4732: #
4733: # Extra info if you are the DC
4734: my $dc_info = '';
4735: if ($env{'user.adv'} && exists($env{'user.role.dc./'.
4736: $env{'course.'.$env{'request.course.id'}.
4737: '.domain'}.'/'})) {
4738: my $cid = $env{'request.course.id'};
1.917 raeburn 4739: $dc_info = $cid.' '.$env{'course.'.$cid.'.internal.coursecode'};
1.380 www 4740: $dc_info =~ s/\s+$//;
1.359 albertel 4741: }
4742:
1.898 raeburn 4743: $role = '<span class="LC_nobreak">('.$role.')</span>' if $role;
1.853 droeschl 4744: &get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['inhibitmenu']);
4745:
1.948.2.19 raeburn 4746: if ($env{'environment.remote'} ne 'on') {
1.359 albertel 4747: # No Remote
1.916 droeschl 4748: if ($no_nav_bar || $env{'form.inhibitmenu'} eq 'yes') {
1.948.2.19 raeburn 4749: return $bodytag;
4750: }
1.903 droeschl 4751:
4752: if ($env{'request.state'} eq 'construct') { $forcereg=1; }
4753:
4754: # if ($env{'request.state'} eq 'construct') {
4755: # $titleinfo = &CSTR_pageheader(); #FIXME: Will be removed once all scripts have their own calls
4756: # }
4757:
1.359 albertel 4758:
4759:
1.916 droeschl 4760: if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) {
1.917 raeburn 4761: if ($dc_info) {
4762: $dc_info = qq|<span class="LC_cusr_subheading">$dc_info</span>|;
4763: }
1.916 droeschl 4764: $bodytag .= qq|<div id="LC_nav_bar">$name $role<br />
4765: <em>$realm</em> $dc_info</div>|;
1.903 droeschl 4766: return $bodytag;
4767: }
1.948.2.19 raeburn 4768: if (($env{'request.noversionuri'} =~ m{^/adm/navmaps}) &&
4769: ($env{'environment.remotenavmap'} eq 'on')) {
4770: return $bodytag;
4771: }
1.894 droeschl 4772:
1.927 raeburn 4773: unless ($env{'request.symb'} =~ m/\.page___\d+___/) {
4774: $bodytag .= qq|<div id="LC_nav_bar">$name $role</div>|;
4775: }
1.916 droeschl 4776:
1.903 droeschl 4777: $bodytag .= Apache::lonhtmlcommon::scripttag(
4778: Apache::lonmenu::utilityfunctions(), 'start');
1.816 bisitz 4779:
1.903 droeschl 4780: $bodytag .= Apache::lonmenu::primary_menu();
1.852 droeschl 4781:
1.917 raeburn 4782: if ($dc_info) {
4783: $dc_info = &dc_courseid_toggle($dc_info);
4784: }
4785: $bodytag .= qq|<div id="LC_realm">$realm $dc_info</div>|;
1.916 droeschl 4786:
1.903 droeschl 4787: #don't show menus for public users
1.948.2.2 raeburn 4788: if (!$public){
1.903 droeschl 4789: $bodytag .= Apache::lonmenu::secondary_menu();
4790: $bodytag .= Apache::lonmenu::serverform();
1.920 raeburn 4791: $bodytag .= Apache::lonhtmlcommon::scripttag('', 'end');
4792: if ($env{'request.state'} eq 'construct') {
4793: $bodytag .= &Apache::lonmenu::innerregister($forcereg,'',
4794: $args->{'bread_crumbs'});
4795: } elsif ($forcereg) {
4796: $bodytag .= &Apache::lonmenu::innerregister($forcereg);
4797: }
1.903 droeschl 4798: }else{
4799: # this is to seperate menu from content when there's no secondary
4800: # menu. Especially needed for public accessible ressources.
4801: $bodytag .= '<hr style="clear:both" />';
4802: $bodytag .= Apache::lonhtmlcommon::scripttag('', 'end');
1.235 raeburn 4803: }
1.903 droeschl 4804:
1.235 raeburn 4805: return $bodytag;
1.94 www 4806: }
1.95 www 4807:
1.93 www 4808: #
1.95 www 4809: # Top frame rendering, Remote is up
1.93 www 4810: #
1.359 albertel 4811:
1.517 raeburn 4812: my $imgsrc = $img;
4813: if ($img =~ /^\/adm/) {
1.575 albertel 4814: $imgsrc = &lonhttpdurl($img);
1.517 raeburn 4815: }
4816: my $upperleft='<img src="'.$imgsrc.'" alt="'.$function.'" />';
1.359 albertel 4817:
1.305 www 4818: # Explicit link to get inline menu
1.361 albertel 4819: my $menu= ($no_inline_link?''
1.883 droeschl 4820: :'<a href="/adm/remote?action=collapse" target="_top">'.&mt('Switch to Inline Menu Mode').'</a>');
1.917 raeburn 4821:
4822: if ($dc_info) {
4823: $dc_info = qq|<span class="LC_cusr_subheading">($dc_info)</span>|;
4824: }
4825:
1.948.2.25 raeburn 4826: unless ($env{'form.inhibitmenu'}) {
4827: $bodytag .= qq|<div id="LC_nav_bar">$name $role</div>
4828: <ol class="LC_primary_menu LC_right">
4829: <li>$menu</li>
4830: </ol><div id="LC_realm"> $realm $dc_info</div>|;
4831: }
4832:
1.94 www 4833: return(<<ENDBODY);
1.60 matthew 4834: $bodytag
1.359 albertel 4835: <table id="LC_title_bar" class="LC_with_remote">
1.791 tempelho 4836: <tr><td>$upperleft</td>
4837: <td>$messages </td>
1.54 www 4838: </tr>
1.359 albertel 4839: <tr><td>$titleinfo $dc_info $menu</td>
1.368 albertel 4840: </tr>
1.356 albertel 4841: </table>
1.54 www 4842: ENDBODY
1.182 matthew 4843: }
4844:
1.917 raeburn 4845: sub dc_courseid_toggle {
4846: my ($dc_info) = @_;
1.948.2.10 raeburn 4847: return ' <span id="dccidtext" class="LC_cusr_subheading LC_nobreak">'.
1.917 raeburn 4848: '<a href="javascript:showCourseID();">'.
4849: &mt('(More ...)').'</a></span>'.
4850: '<div id="dccid" class="LC_dccid">'.$dc_info.'</div>';
4851: }
4852:
1.330 albertel 4853: sub make_attr_string {
4854: my ($register,$attr_ref) = @_;
4855:
4856: if ($attr_ref && !ref($attr_ref)) {
4857: die("addentries Must be a hash ref ".
4858: join(':',caller(1))." ".
4859: join(':',caller(0))." ");
4860: }
4861:
4862: if ($register) {
1.339 albertel 4863: my ($on_load,$on_unload);
4864: foreach my $key (keys(%{$attr_ref})) {
4865: if (lc($key) eq 'onload') {
4866: $on_load.=$attr_ref->{$key}.';';
4867: delete($attr_ref->{$key});
4868:
4869: } elsif (lc($key) eq 'onunload') {
4870: $on_unload.=$attr_ref->{$key}.';';
4871: delete($attr_ref->{$key});
4872: }
4873: }
4874: $attr_ref->{'onload'} =
4875: &Apache::lonmenu::loadevents(). $on_load;
4876: $attr_ref->{'onunload'}=
4877: &Apache::lonmenu::unloadevents().$on_unload;
4878: }
4879:
4880: # Accessibility font enhance
4881: if ($env{'browser.fontenhance'} eq 'on') {
4882: my $style;
4883: foreach my $key (keys(%{$attr_ref})) {
4884: if (lc($key) eq 'style') {
4885: $style.=$attr_ref->{$key}.';';
4886: delete($attr_ref->{$key});
4887: }
4888: }
4889: $attr_ref->{'style'}=$style.'; font-size: x-large;';
1.330 albertel 4890: }
1.339 albertel 4891:
1.330 albertel 4892: my $attr_string;
4893: foreach my $attr (keys(%$attr_ref)) {
4894: $attr_string .= " $attr=\"".$attr_ref->{$attr}.'" ';
4895: }
4896: return $attr_string;
4897: }
4898:
4899:
1.182 matthew 4900: ###############################################
1.251 albertel 4901: ###############################################
4902:
4903: =pod
4904:
4905: =item * &endbodytag()
4906:
4907: Returns a uniform footer for LON-CAPA web pages.
4908:
1.635 raeburn 4909: Inputs: 1 - optional reference to an args hash
4910: If in the hash, key for noredirectlink has a value which evaluates to true,
4911: a 'Continue' link is not displayed if the page contains an
4912: internal redirect in the <head></head> section,
4913: i.e., $env{'internal.head.redirect'} exists
1.251 albertel 4914:
4915: =cut
4916:
4917: sub endbodytag {
1.635 raeburn 4918: my ($args) = @_;
1.251 albertel 4919: my $endbodytag='</body>';
1.269 albertel 4920: $endbodytag=&Apache::lontexconvert::jsMath_process()."\n".$endbodytag;
1.315 albertel 4921: if ( exists( $env{'internal.head.redirect'} ) ) {
1.635 raeburn 4922: if (!(ref($args) eq 'HASH' && $args->{'noredirectlink'})) {
4923: $endbodytag=
4924: "<br /><a href=\"$env{'internal.head.redirect'}\">".
4925: &mt('Continue').'</a>'.
4926: $endbodytag;
4927: }
1.315 albertel 4928: }
1.251 albertel 4929: return $endbodytag;
4930: }
4931:
1.352 albertel 4932: =pod
4933:
4934: =item * &standard_css()
4935:
4936: Returns a style sheet
4937:
4938: Inputs: (all optional)
4939: domain -> force to color decorate a page for a specific
4940: domain
4941: function -> force usage of a specific rolish color scheme
4942: bgcolor -> override the default page bgcolor
4943:
4944: =cut
4945:
1.343 albertel 4946: sub standard_css {
1.345 albertel 4947: my ($function,$domain,$bgcolor) = @_;
1.352 albertel 4948: $function = &get_users_function() if (!$function);
4949: my $img = &designparm($function.'.img', $domain);
4950: my $tabbg = &designparm($function.'.tabbg', $domain);
4951: my $font = &designparm($function.'.font', $domain);
1.801 tempelho 4952: my $fontmenu = &designparm($function.'.fontmenu', $domain);
1.791 tempelho 4953: #second colour for later usage
1.345 albertel 4954: my $sidebg = &designparm($function.'.sidebg',$domain);
1.382 albertel 4955: my $pgbg_or_bgcolor =
4956: $bgcolor ||
1.352 albertel 4957: &designparm($function.'.pgbg', $domain);
1.382 albertel 4958: my $pgbg = &designparm($function.'.pgbg', $domain);
1.352 albertel 4959: my $alink = &designparm($function.'.alink', $domain);
4960: my $vlink = &designparm($function.'.vlink', $domain);
4961: my $link = &designparm($function.'.link', $domain);
4962:
1.602 albertel 4963: my $sans = 'Verdana,Arial,Helvetica,sans-serif';
1.395 albertel 4964: my $mono = 'monospace';
1.850 bisitz 4965: my $data_table_head = $sidebg;
4966: my $data_table_light = '#FAFAFA';
4967: my $data_table_dark = '#F0F0F0';
1.470 banghart 4968: my $data_table_darker = '#CCCCCC';
1.349 albertel 4969: my $data_table_highlight = '#FFFF00';
1.352 albertel 4970: my $mail_new = '#FFBB77';
4971: my $mail_new_hover = '#DD9955';
4972: my $mail_read = '#BBBB77';
4973: my $mail_read_hover = '#999944';
4974: my $mail_replied = '#AAAA88';
4975: my $mail_replied_hover = '#888855';
4976: my $mail_other = '#99BBBB';
4977: my $mail_other_hover = '#669999';
1.391 albertel 4978: my $table_header = '#DDDDDD';
1.489 raeburn 4979: my $feedback_link_bg = '#BBBBBB';
1.911 bisitz 4980: my $lg_border_color = '#C8C8C8';
1.948.2.1 raeburn 4981: my $button_hover = '#BF2317';
1.392 albertel 4982:
1.608 albertel 4983: my $border = ($env{'browser.type'} eq 'explorer' ||
1.911 bisitz 4984: $env{'browser.type'} eq 'safari' ) ? '0 2px 0 2px'
4985: : '0 3px 0 4px';
1.448 albertel 4986:
1.343 albertel 4987: return <<END;
1.947 droeschl 4988:
4989: /* needed for iframe to allow 100% height in FF */
4990: body, html {
4991: margin: 0;
4992: padding: 0 0.5%;
4993: height: 99%; /* to avoid scrollbars */
4994: }
4995:
1.795 www 4996: body {
1.911 bisitz 4997: font-family: $sans;
4998: line-height:130%;
4999: font-size:0.83em;
5000: color:$font;
1.795 www 5001: }
5002:
1.948.2.9 raeburn 5003: a:focus,
5004: a:focus img {
1.795 www 5005: color: red;
1.911 bisitz 5006: background: yellow;
1.795 www 5007: }
1.698 harmsja 5008:
1.911 bisitz 5009: form, .inline {
5010: display: inline;
1.795 www 5011: }
1.721 harmsja 5012:
1.795 www 5013: .LC_right {
1.911 bisitz 5014: text-align:right;
1.795 www 5015: }
5016:
5017: .LC_middle {
1.911 bisitz 5018: vertical-align:middle;
1.795 www 5019: }
1.721 harmsja 5020:
1.911 bisitz 5021: .LC_400Box {
5022: width:400px;
5023: }
1.721 harmsja 5024:
1.947 droeschl 5025: .LC_iframecontainer {
5026: width: 98%;
5027: margin: 0;
5028: position: fixed;
5029: top: 8.5em;
5030: bottom: 0;
5031: }
5032:
5033: .LC_iframecontainer iframe{
5034: border: none;
5035: width: 100%;
5036: height: 100%;
5037: }
5038:
1.778 bisitz 5039: .LC_filename {
5040: font-family: $mono;
5041: white-space:pre;
1.921 bisitz 5042: font-size: 120%;
1.778 bisitz 5043: }
5044:
5045: .LC_fileicon {
5046: border: none;
5047: height: 1.3em;
5048: vertical-align: text-bottom;
5049: margin-right: 0.3em;
5050: text-decoration:none;
5051: }
5052:
1.350 albertel 5053: .LC_error {
5054: color: red;
5055: font-size: larger;
5056: }
1.795 www 5057:
1.457 albertel 5058: .LC_warning,
5059: .LC_diff_removed {
1.733 bisitz 5060: color: red;
1.394 albertel 5061: }
1.532 albertel 5062:
5063: .LC_info,
1.457 albertel 5064: .LC_success,
5065: .LC_diff_added {
1.350 albertel 5066: color: green;
5067: }
1.795 www 5068:
1.802 bisitz 5069: div.LC_confirm_box {
5070: background-color: #FAFAFA;
5071: border: 1px solid $lg_border_color;
5072: margin-right: 0;
5073: padding: 5px;
5074: }
5075:
5076: div.LC_confirm_box .LC_error img,
5077: div.LC_confirm_box .LC_success img {
5078: vertical-align: middle;
5079: }
5080:
1.440 albertel 5081: .LC_icon {
1.771 droeschl 5082: border: none;
1.790 droeschl 5083: vertical-align: middle;
1.771 droeschl 5084: }
5085:
1.543 albertel 5086: .LC_docs_spacer {
5087: width: 25px;
5088: height: 1px;
1.771 droeschl 5089: border: none;
1.543 albertel 5090: }
1.346 albertel 5091:
1.532 albertel 5092: .LC_internal_info {
1.735 bisitz 5093: color: #999999;
1.532 albertel 5094: }
5095:
1.794 www 5096: .LC_discussion {
1.911 bisitz 5097: background: $tabbg;
5098: border: 1px solid black;
5099: margin: 2px;
1.794 www 5100: }
5101:
5102: .LC_disc_action_links_bar {
1.911 bisitz 5103: background: $tabbg;
5104: border: none;
5105: margin: 4px;
1.794 www 5106: }
5107:
5108: .LC_disc_action_left {
1.911 bisitz 5109: text-align: left;
1.794 www 5110: }
5111:
5112: .LC_disc_action_right {
1.911 bisitz 5113: text-align: right;
1.794 www 5114: }
5115:
5116: .LC_disc_new_item {
1.911 bisitz 5117: background: white;
5118: border: 2px solid red;
5119: margin: 2px;
1.794 www 5120: }
5121:
5122: .LC_disc_old_item {
1.911 bisitz 5123: background: white;
5124: border: 1px solid black;
5125: margin: 2px;
1.794 www 5126: }
5127:
1.458 albertel 5128: table.LC_pastsubmission {
5129: border: 1px solid black;
5130: margin: 2px;
5131: }
5132:
1.924 bisitz 5133: table#LC_menubuttons {
1.345 albertel 5134: width: 100%;
5135: background: $pgbg;
1.392 albertel 5136: border: 2px;
1.402 albertel 5137: border-collapse: separate;
1.803 bisitz 5138: padding: 0;
1.345 albertel 5139: }
1.392 albertel 5140:
1.801 tempelho 5141: table#LC_title_bar a {
5142: color: $fontmenu;
5143: }
1.836 bisitz 5144:
1.807 droeschl 5145: table#LC_title_bar {
1.819 tempelho 5146: clear: both;
1.836 bisitz 5147: display: none;
1.807 droeschl 5148: }
5149:
1.795 www 5150: table#LC_title_bar,
1.933 droeschl 5151: table.LC_breadcrumbs, /* obsolete? */
1.393 albertel 5152: table#LC_title_bar.LC_with_remote {
1.359 albertel 5153: width: 100%;
1.392 albertel 5154: border-color: $pgbg;
5155: border-style: solid;
5156: border-width: $border;
1.379 albertel 5157: background: $pgbg;
1.801 tempelho 5158: color: $fontmenu;
1.392 albertel 5159: border-collapse: collapse;
1.803 bisitz 5160: padding: 0;
1.819 tempelho 5161: margin: 0;
1.359 albertel 5162: }
1.795 www 5163:
1.933 droeschl 5164: ul.LC_breadcrumb_tools_outerlist {
1.913 droeschl 5165: margin: 0;
5166: padding: 0;
1.933 droeschl 5167: position: relative;
5168: list-style: none;
1.913 droeschl 5169: }
1.933 droeschl 5170: ul.LC_breadcrumb_tools_outerlist li {
1.913 droeschl 5171: display: inline;
5172: }
1.933 droeschl 5173:
5174: .LC_breadcrumb_tools_navigation {
1.913 droeschl 5175: padding: 0;
1.933 droeschl 5176: margin: 0;
5177: float: left;
1.913 droeschl 5178: }
1.933 droeschl 5179: .LC_breadcrumb_tools_tools {
5180: padding: 0;
5181: margin: 0;
1.913 droeschl 5182: float: right;
5183: }
5184:
1.359 albertel 5185: table#LC_title_bar td {
5186: background: $tabbg;
5187: }
1.795 www 5188:
1.911 bisitz 5189: table#LC_menubuttons img {
1.803 bisitz 5190: border: none;
1.346 albertel 5191: }
1.795 www 5192:
1.842 droeschl 5193: .LC_breadcrumbs_component {
1.911 bisitz 5194: float: right;
5195: margin: 0 1em;
1.357 albertel 5196: }
1.842 droeschl 5197: .LC_breadcrumbs_component img {
1.911 bisitz 5198: vertical-align: middle;
1.777 tempelho 5199: }
1.795 www 5200:
1.383 albertel 5201: td.LC_table_cell_checkbox {
5202: text-align: center;
5203: }
1.795 www 5204:
5205: .LC_fontsize_small {
1.911 bisitz 5206: font-size: 70%;
1.705 tempelho 5207: }
5208:
1.844 bisitz 5209: #LC_breadcrumbs {
1.911 bisitz 5210: clear:both;
5211: background: $sidebg;
5212: border-bottom: 1px solid $lg_border_color;
5213: line-height: 2.5em;
1.933 droeschl 5214: overflow: hidden;
1.911 bisitz 5215: margin: 0;
5216: padding: 0;
1.948.2.24 raeburn 5217: text-align: left;
1.819 tempelho 5218: }
1.862 bisitz 5219:
1.839 droeschl 5220: /* Preliminary fix to hide breadcrumbs inside remote control window */
1.844 bisitz 5221: #LC_remote #LC_breadcrumbs {
1.911 bisitz 5222: display:none;
1.839 droeschl 5223: }
1.819 tempelho 5224:
1.948.2.22 raeburn 5225: .LC_head_subbox {
1.911 bisitz 5226: clear:both;
5227: background: #F8F8F8; /* $sidebg; */
1.915 droeschl 5228: border: 1px solid $sidebg;
5229: margin: 0 0 10px 0;
1.948.2.6 raeburn 5230: padding: 3px;
1.948.2.24 raeburn 5231: text-align: left;
1.822 bisitz 5232: }
5233:
1.795 www 5234: .LC_fontsize_medium {
1.911 bisitz 5235: font-size: 85%;
1.705 tempelho 5236: }
5237:
1.795 www 5238: .LC_fontsize_large {
1.911 bisitz 5239: font-size: 120%;
1.705 tempelho 5240: }
5241:
1.346 albertel 5242: .LC_menubuttons_inline_text {
5243: color: $font;
1.698 harmsja 5244: font-size: 90%;
1.701 harmsja 5245: padding-left:3px;
1.346 albertel 5246: }
5247:
1.934 droeschl 5248: .LC_menubuttons_inline_text img{
5249: vertical-align: middle;
5250: }
5251:
1.948.2.1 raeburn 5252: li.LC_menubuttons_inline_text img,a {
5253: cursor:pointer;
1.948.2.27 raeburn 5254: text-decoration: none;
1.948.2.1 raeburn 5255: }
5256:
1.526 www 5257: .LC_menubuttons_link {
5258: text-decoration: none;
5259: }
1.795 www 5260:
1.522 albertel 5261: .LC_menubuttons_category {
1.521 www 5262: color: $font;
1.526 www 5263: background: $pgbg;
1.521 www 5264: font-size: larger;
5265: font-weight: bold;
5266: }
5267:
1.346 albertel 5268: td.LC_menubuttons_text {
1.911 bisitz 5269: color: $font;
1.346 albertel 5270: }
1.706 harmsja 5271:
1.346 albertel 5272: .LC_current_location {
5273: background: $tabbg;
5274: }
1.795 www 5275:
1.938 bisitz 5276: table.LC_data_table {
1.347 albertel 5277: border: 1px solid #000000;
1.402 albertel 5278: border-collapse: separate;
1.426 albertel 5279: border-spacing: 1px;
1.610 albertel 5280: background: $pgbg;
1.347 albertel 5281: }
1.795 www 5282:
1.422 albertel 5283: .LC_data_table_dense {
5284: font-size: small;
5285: }
1.795 www 5286:
1.507 raeburn 5287: table.LC_nested_outer {
5288: border: 1px solid #000000;
1.589 raeburn 5289: border-collapse: collapse;
1.803 bisitz 5290: border-spacing: 0;
1.507 raeburn 5291: width: 100%;
5292: }
1.795 www 5293:
1.879 raeburn 5294: table.LC_innerpickbox,
1.507 raeburn 5295: table.LC_nested {
1.803 bisitz 5296: border: none;
1.589 raeburn 5297: border-collapse: collapse;
1.803 bisitz 5298: border-spacing: 0;
1.507 raeburn 5299: width: 100%;
5300: }
1.795 www 5301:
1.930 faziophi 5302: .ui-accordion,
5303: .ui-accordion table.LC_data_table,
5304: .ui-accordion table.LC_nested_outer{
5305: border: 0px;
5306: border-spacing: 0px;
5307: margin: 3px;
5308: }
5309:
1.911 bisitz 5310: table.LC_data_table tr th,
5311: table.LC_calendar tr th,
1.879 raeburn 5312: table.LC_prior_tries tr th,
5313: table.LC_innerpickbox tr th {
1.349 albertel 5314: font-weight: bold;
5315: background-color: $data_table_head;
1.801 tempelho 5316: color:$fontmenu;
1.701 harmsja 5317: font-size:90%;
1.347 albertel 5318: }
1.795 www 5319:
1.879 raeburn 5320: table.LC_innerpickbox tr th,
5321: table.LC_innerpickbox tr td {
5322: vertical-align: top;
5323: }
5324:
1.711 raeburn 5325: table.LC_data_table tr.LC_info_row > td {
1.735 bisitz 5326: background-color: #CCCCCC;
1.711 raeburn 5327: font-weight: bold;
5328: text-align: left;
5329: }
1.795 www 5330:
1.912 bisitz 5331: table.LC_data_table tr.LC_odd_row > td {
5332: background-color: $data_table_light;
5333: padding: 2px;
5334: vertical-align: top;
5335: }
5336:
1.809 bisitz 5337: table.LC_pick_box tr > td.LC_odd_row {
1.349 albertel 5338: background-color: $data_table_light;
1.912 bisitz 5339: vertical-align: top;
5340: }
5341:
5342: table.LC_data_table tr.LC_even_row > td {
5343: background-color: $data_table_dark;
1.425 albertel 5344: padding: 2px;
1.900 bisitz 5345: vertical-align: top;
1.347 albertel 5346: }
1.795 www 5347:
1.809 bisitz 5348: table.LC_pick_box tr > td.LC_even_row {
1.349 albertel 5349: background-color: $data_table_dark;
1.900 bisitz 5350: vertical-align: top;
1.347 albertel 5351: }
1.795 www 5352:
1.425 albertel 5353: table.LC_data_table tr.LC_data_table_highlight td {
5354: background-color: $data_table_darker;
5355: }
1.795 www 5356:
1.639 raeburn 5357: table.LC_data_table tr td.LC_leftcol_header {
5358: background-color: $data_table_head;
5359: font-weight: bold;
5360: }
1.795 www 5361:
1.451 albertel 5362: table.LC_data_table tr.LC_empty_row td,
1.507 raeburn 5363: table.LC_nested tr.LC_empty_row td {
1.421 albertel 5364: font-weight: bold;
5365: font-style: italic;
5366: text-align: center;
5367: padding: 8px;
1.347 albertel 5368: }
1.795 www 5369:
1.940 bisitz 5370: table.LC_data_table tr.LC_empty_row td {
5371: background-color: $sidebg;
5372: }
5373:
5374: table.LC_nested tr.LC_empty_row td {
5375: background-color: #FFFFFF;
5376: }
5377:
1.890 droeschl 5378: table.LC_caption {
5379: }
5380:
1.507 raeburn 5381: table.LC_nested tr.LC_empty_row td {
1.465 albertel 5382: padding: 4ex
5383: }
1.795 www 5384:
1.507 raeburn 5385: table.LC_nested_outer tr th {
5386: font-weight: bold;
1.801 tempelho 5387: color:$fontmenu;
1.507 raeburn 5388: background-color: $data_table_head;
1.701 harmsja 5389: font-size: small;
1.507 raeburn 5390: border-bottom: 1px solid #000000;
5391: }
1.795 www 5392:
1.507 raeburn 5393: table.LC_nested_outer tr td.LC_subheader {
5394: background-color: $data_table_head;
5395: font-weight: bold;
5396: font-size: small;
5397: border-bottom: 1px solid #000000;
5398: text-align: right;
1.451 albertel 5399: }
1.795 www 5400:
1.507 raeburn 5401: table.LC_nested tr.LC_info_row td {
1.735 bisitz 5402: background-color: #CCCCCC;
1.451 albertel 5403: font-weight: bold;
5404: font-size: small;
1.507 raeburn 5405: text-align: center;
5406: }
1.795 www 5407:
1.589 raeburn 5408: table.LC_nested tr.LC_info_row td.LC_left_item,
5409: table.LC_nested_outer tr th.LC_left_item {
1.507 raeburn 5410: text-align: left;
1.451 albertel 5411: }
1.795 www 5412:
1.507 raeburn 5413: table.LC_nested td {
1.735 bisitz 5414: background-color: #FFFFFF;
1.451 albertel 5415: font-size: small;
1.507 raeburn 5416: }
1.795 www 5417:
1.507 raeburn 5418: table.LC_nested_outer tr th.LC_right_item,
5419: table.LC_nested tr.LC_info_row td.LC_right_item,
5420: table.LC_nested tr.LC_odd_row td.LC_right_item,
5421: table.LC_nested tr td.LC_right_item {
1.451 albertel 5422: text-align: right;
5423: }
5424:
1.930 faziophi 5425: .ui-accordion table.LC_nested tr.LC_odd_row td.LC_left_item,
5426: .ui-accordion table.LC_nested tr.LC_even_row td.LC_left_item {
5427: text-align: right;
5428: width: 40%;
5429: padding-right:10px;
5430: vertical-align: top;
5431: padding: 5px;
5432: }
5433:
5434: .ui-accordion table.LC_nested tr.LC_odd_row td.LC_right_item,
5435: .ui-accordion table.LC_nested tr.LC_even_row td.LC_right_item {
5436: text-align: left;
5437: width: 60%;
5438: padding: 2px 4px;
5439: }
5440:
1.507 raeburn 5441: table.LC_nested tr.LC_odd_row td {
1.735 bisitz 5442: background-color: #EEEEEE;
1.451 albertel 5443: }
5444:
1.473 raeburn 5445: table.LC_createuser {
5446: }
5447:
5448: table.LC_createuser tr.LC_section_row td {
1.701 harmsja 5449: font-size: small;
1.473 raeburn 5450: }
5451:
5452: table.LC_createuser tr.LC_info_row td {
1.735 bisitz 5453: background-color: #CCCCCC;
1.473 raeburn 5454: font-weight: bold;
5455: text-align: center;
5456: }
5457:
1.349 albertel 5458: table.LC_calendar {
5459: border: 1px solid #000000;
5460: border-collapse: collapse;
1.917 raeburn 5461: width: 98%;
1.349 albertel 5462: }
1.795 www 5463:
1.349 albertel 5464: table.LC_calendar_pickdate {
5465: font-size: xx-small;
5466: }
1.795 www 5467:
1.349 albertel 5468: table.LC_calendar tr td {
5469: border: 1px solid #000000;
5470: vertical-align: top;
1.917 raeburn 5471: width: 14%;
1.349 albertel 5472: }
1.795 www 5473:
1.349 albertel 5474: table.LC_calendar tr td.LC_calendar_day_empty {
5475: background-color: $data_table_dark;
5476: }
1.795 www 5477:
1.779 bisitz 5478: table.LC_calendar tr td.LC_calendar_day_current {
5479: background-color: $data_table_highlight;
1.777 tempelho 5480: }
1.795 www 5481:
1.938 bisitz 5482: table.LC_data_table tr td.LC_mail_new {
1.349 albertel 5483: background-color: $mail_new;
5484: }
1.795 www 5485:
1.938 bisitz 5486: table.LC_data_table tr.LC_mail_new:hover {
1.349 albertel 5487: background-color: $mail_new_hover;
5488: }
1.795 www 5489:
1.938 bisitz 5490: table.LC_data_table tr td.LC_mail_read {
1.349 albertel 5491: background-color: $mail_read;
5492: }
1.795 www 5493:
1.938 bisitz 5494: /*
5495: table.LC_data_table tr.LC_mail_read:hover {
1.349 albertel 5496: background-color: $mail_read_hover;
5497: }
1.938 bisitz 5498: */
1.795 www 5499:
1.938 bisitz 5500: table.LC_data_table tr td.LC_mail_replied {
1.349 albertel 5501: background-color: $mail_replied;
5502: }
1.795 www 5503:
1.938 bisitz 5504: /*
5505: table.LC_data_table tr.LC_mail_replied:hover {
1.349 albertel 5506: background-color: $mail_replied_hover;
5507: }
1.938 bisitz 5508: */
1.795 www 5509:
1.938 bisitz 5510: table.LC_data_table tr td.LC_mail_other {
1.349 albertel 5511: background-color: $mail_other;
5512: }
1.795 www 5513:
1.938 bisitz 5514: /*
5515: table.LC_data_table tr.LC_mail_other:hover {
1.349 albertel 5516: background-color: $mail_other_hover;
5517: }
1.938 bisitz 5518: */
1.494 raeburn 5519:
1.777 tempelho 5520: table.LC_data_table tr > td.LC_browser_file,
5521: table.LC_data_table tr > td.LC_browser_file_published {
1.899 bisitz 5522: background: #AAEE77;
1.389 albertel 5523: }
1.795 www 5524:
1.777 tempelho 5525: table.LC_data_table tr > td.LC_browser_file_locked,
5526: table.LC_data_table tr > td.LC_browser_file_unpublished {
1.389 albertel 5527: background: #FFAA99;
1.387 albertel 5528: }
1.795 www 5529:
1.777 tempelho 5530: table.LC_data_table tr > td.LC_browser_file_obsolete {
1.899 bisitz 5531: background: #888888;
1.779 bisitz 5532: }
1.795 www 5533:
1.777 tempelho 5534: table.LC_data_table tr > td.LC_browser_file_modified,
1.779 bisitz 5535: table.LC_data_table tr > td.LC_browser_file_metamodified {
1.899 bisitz 5536: background: #F8F866;
1.777 tempelho 5537: }
1.795 www 5538:
1.696 bisitz 5539: table.LC_data_table tr.LC_browser_folder > td {
1.899 bisitz 5540: background: #E0E8FF;
1.387 albertel 5541: }
1.696 bisitz 5542:
1.707 bisitz 5543: table.LC_data_table tr > td.LC_roles_is {
1.911 bisitz 5544: /* background: #77FF77; */
1.707 bisitz 5545: }
1.795 www 5546:
1.707 bisitz 5547: table.LC_data_table tr > td.LC_roles_future {
1.939 bisitz 5548: border-right: 8px solid #FFFF77;
1.707 bisitz 5549: }
1.795 www 5550:
1.707 bisitz 5551: table.LC_data_table tr > td.LC_roles_will {
1.939 bisitz 5552: border-right: 8px solid #FFAA77;
1.707 bisitz 5553: }
1.795 www 5554:
1.707 bisitz 5555: table.LC_data_table tr > td.LC_roles_expired {
1.939 bisitz 5556: border-right: 8px solid #FF7777;
1.707 bisitz 5557: }
1.795 www 5558:
1.707 bisitz 5559: table.LC_data_table tr > td.LC_roles_will_not {
1.939 bisitz 5560: border-right: 8px solid #AAFF77;
1.707 bisitz 5561: }
1.795 www 5562:
1.707 bisitz 5563: table.LC_data_table tr > td.LC_roles_selected {
1.939 bisitz 5564: border-right: 8px solid #11CC55;
1.707 bisitz 5565: }
5566:
1.388 albertel 5567: span.LC_current_location {
1.701 harmsja 5568: font-size:larger;
1.388 albertel 5569: background: $pgbg;
5570: }
1.387 albertel 5571:
1.395 albertel 5572: span.LC_parm_menu_item {
5573: font-size: larger;
5574: }
1.795 www 5575:
1.395 albertel 5576: span.LC_parm_scope_all {
5577: color: red;
5578: }
1.795 www 5579:
1.395 albertel 5580: span.LC_parm_scope_folder {
5581: color: green;
5582: }
1.795 www 5583:
1.395 albertel 5584: span.LC_parm_scope_resource {
5585: color: orange;
5586: }
1.795 www 5587:
1.395 albertel 5588: span.LC_parm_part {
5589: color: blue;
5590: }
1.795 www 5591:
1.911 bisitz 5592: span.LC_parm_folder,
5593: span.LC_parm_symb {
1.395 albertel 5594: font-size: x-small;
5595: font-family: $mono;
5596: color: #AAAAAA;
5597: }
5598:
1.948.2.8 raeburn 5599: ul.LC_parm_parmlist li {
5600: display: inline-block;
5601: padding: 0.3em 0.8em;
5602: vertical-align: top;
5603: width: 150px;
5604: border-top:1px solid $lg_border_color;
5605: }
5606:
1.795 www 5607: td.LC_parm_overview_level_menu,
5608: td.LC_parm_overview_map_menu,
5609: td.LC_parm_overview_parm_selectors,
5610: td.LC_parm_overview_restrictions {
1.396 albertel 5611: border: 1px solid black;
5612: border-collapse: collapse;
5613: }
1.795 www 5614:
1.396 albertel 5615: table.LC_parm_overview_restrictions td {
5616: border-width: 1px 4px 1px 4px;
5617: border-style: solid;
5618: border-color: $pgbg;
5619: text-align: center;
5620: }
1.795 www 5621:
1.396 albertel 5622: table.LC_parm_overview_restrictions th {
5623: background: $tabbg;
5624: border-width: 1px 4px 1px 4px;
5625: border-style: solid;
5626: border-color: $pgbg;
5627: }
1.795 www 5628:
1.398 albertel 5629: table#LC_helpmenu {
1.803 bisitz 5630: border: none;
1.398 albertel 5631: height: 55px;
1.803 bisitz 5632: border-spacing: 0;
1.398 albertel 5633: }
5634:
5635: table#LC_helpmenu fieldset legend {
5636: font-size: larger;
5637: }
1.795 www 5638:
1.397 albertel 5639: table#LC_helpmenu_links {
5640: width: 100%;
5641: border: 1px solid black;
5642: background: $pgbg;
1.803 bisitz 5643: padding: 0;
1.397 albertel 5644: border-spacing: 1px;
5645: }
1.795 www 5646:
1.397 albertel 5647: table#LC_helpmenu_links tr td {
5648: padding: 1px;
5649: background: $tabbg;
1.399 albertel 5650: text-align: center;
5651: font-weight: bold;
1.397 albertel 5652: }
1.396 albertel 5653:
1.795 www 5654: table#LC_helpmenu_links a:link,
5655: table#LC_helpmenu_links a:visited,
1.397 albertel 5656: table#LC_helpmenu_links a:active {
5657: text-decoration: none;
5658: color: $font;
5659: }
1.795 www 5660:
1.397 albertel 5661: table#LC_helpmenu_links a:hover {
5662: text-decoration: underline;
5663: color: $vlink;
5664: }
1.396 albertel 5665:
1.417 albertel 5666: .LC_chrt_popup_exists {
5667: border: 1px solid #339933;
5668: margin: -1px;
5669: }
1.795 www 5670:
1.417 albertel 5671: .LC_chrt_popup_up {
5672: border: 1px solid yellow;
5673: margin: -1px;
5674: }
1.795 www 5675:
1.417 albertel 5676: .LC_chrt_popup {
5677: border: 1px solid #8888FF;
5678: background: #CCCCFF;
5679: }
1.795 www 5680:
1.421 albertel 5681: table.LC_pick_box {
5682: border-collapse: separate;
5683: background: white;
5684: border: 1px solid black;
5685: border-spacing: 1px;
5686: }
1.795 www 5687:
1.421 albertel 5688: table.LC_pick_box td.LC_pick_box_title {
1.850 bisitz 5689: background: $sidebg;
1.421 albertel 5690: font-weight: bold;
1.900 bisitz 5691: text-align: left;
1.740 bisitz 5692: vertical-align: top;
1.421 albertel 5693: width: 184px;
5694: padding: 8px;
5695: }
1.795 www 5696:
1.579 raeburn 5697: table.LC_pick_box td.LC_pick_box_value {
5698: text-align: left;
5699: padding: 8px;
5700: }
1.795 www 5701:
1.579 raeburn 5702: table.LC_pick_box td.LC_pick_box_select {
5703: text-align: left;
5704: padding: 8px;
5705: }
1.795 www 5706:
1.424 albertel 5707: table.LC_pick_box td.LC_pick_box_separator {
1.803 bisitz 5708: padding: 0;
1.421 albertel 5709: height: 1px;
5710: background: black;
5711: }
1.795 www 5712:
1.421 albertel 5713: table.LC_pick_box td.LC_pick_box_submit {
5714: text-align: right;
5715: }
1.795 www 5716:
1.579 raeburn 5717: table.LC_pick_box td.LC_evenrow_value {
5718: text-align: left;
5719: padding: 8px;
5720: background-color: $data_table_light;
5721: }
1.795 www 5722:
1.579 raeburn 5723: table.LC_pick_box td.LC_oddrow_value {
5724: text-align: left;
5725: padding: 8px;
5726: background-color: $data_table_light;
5727: }
1.795 www 5728:
1.579 raeburn 5729: span.LC_helpform_receipt_cat {
5730: font-weight: bold;
5731: }
1.795 www 5732:
1.424 albertel 5733: table.LC_group_priv_box {
5734: background: white;
5735: border: 1px solid black;
5736: border-spacing: 1px;
5737: }
1.795 www 5738:
1.424 albertel 5739: table.LC_group_priv_box td.LC_pick_box_title {
5740: background: $tabbg;
5741: font-weight: bold;
5742: text-align: right;
5743: width: 184px;
5744: }
1.795 www 5745:
1.424 albertel 5746: table.LC_group_priv_box td.LC_groups_fixed {
5747: background: $data_table_light;
5748: text-align: center;
5749: }
1.795 www 5750:
1.424 albertel 5751: table.LC_group_priv_box td.LC_groups_optional {
5752: background: $data_table_dark;
5753: text-align: center;
5754: }
1.795 www 5755:
1.424 albertel 5756: table.LC_group_priv_box td.LC_groups_functionality {
5757: background: $data_table_darker;
5758: text-align: center;
5759: font-weight: bold;
5760: }
1.795 www 5761:
1.424 albertel 5762: table.LC_group_priv td {
5763: text-align: left;
1.803 bisitz 5764: padding: 0;
1.424 albertel 5765: }
5766:
1.421 albertel 5767: table.LC_notify_front_page {
5768: background: white;
5769: border: 1px solid black;
5770: padding: 8px;
5771: }
1.795 www 5772:
1.421 albertel 5773: table.LC_notify_front_page td {
5774: padding: 8px;
5775: }
1.795 www 5776:
1.424 albertel 5777: .LC_navbuttons {
5778: margin: 2ex 0ex 2ex 0ex;
5779: }
1.795 www 5780:
1.423 albertel 5781: .LC_topic_bar {
5782: font-weight: bold;
5783: background: $tabbg;
1.918 wenzelju 5784: margin: 1em 0em 1em 2em;
1.805 bisitz 5785: padding: 3px;
1.918 wenzelju 5786: font-size: 1.2em;
1.423 albertel 5787: }
1.795 www 5788:
1.423 albertel 5789: .LC_topic_bar span {
1.918 wenzelju 5790: left: 0.5em;
5791: position: absolute;
1.423 albertel 5792: vertical-align: middle;
1.918 wenzelju 5793: font-size: 1.2em;
1.423 albertel 5794: }
1.795 www 5795:
1.423 albertel 5796: table.LC_course_group_status {
5797: margin: 20px;
5798: }
1.795 www 5799:
1.423 albertel 5800: table.LC_status_selector td {
5801: vertical-align: top;
5802: text-align: center;
1.424 albertel 5803: padding: 4px;
5804: }
1.795 www 5805:
1.599 albertel 5806: div.LC_feedback_link {
1.616 albertel 5807: clear: both;
1.829 kalberla 5808: background: $sidebg;
1.779 bisitz 5809: width: 100%;
1.829 kalberla 5810: padding-bottom: 10px;
5811: border: 1px $tabbg solid;
1.833 kalberla 5812: height: 22px;
5813: line-height: 22px;
5814: padding-top: 5px;
5815: }
5816:
5817: div.LC_feedback_link img {
5818: height: 22px;
1.867 kalberla 5819: vertical-align:middle;
1.829 kalberla 5820: }
5821:
1.911 bisitz 5822: div.LC_feedback_link a {
1.829 kalberla 5823: text-decoration: none;
1.489 raeburn 5824: }
1.795 www 5825:
1.867 kalberla 5826: div.LC_comblock {
1.911 bisitz 5827: display:inline;
1.867 kalberla 5828: color:$font;
5829: font-size:90%;
5830: }
5831:
5832: div.LC_feedback_link div.LC_comblock {
5833: padding-left:5px;
5834: }
5835:
5836: div.LC_feedback_link div.LC_comblock a {
5837: color:$font;
5838: }
5839:
1.489 raeburn 5840: span.LC_feedback_link {
1.858 bisitz 5841: /* background: $feedback_link_bg; */
1.599 albertel 5842: font-size: larger;
5843: }
1.795 www 5844:
1.599 albertel 5845: span.LC_message_link {
1.858 bisitz 5846: /* background: $feedback_link_bg; */
1.599 albertel 5847: font-size: larger;
5848: position: absolute;
5849: right: 1em;
1.489 raeburn 5850: }
1.421 albertel 5851:
1.515 albertel 5852: table.LC_prior_tries {
1.524 albertel 5853: border: 1px solid #000000;
5854: border-collapse: separate;
5855: border-spacing: 1px;
1.515 albertel 5856: }
1.523 albertel 5857:
1.515 albertel 5858: table.LC_prior_tries td {
1.524 albertel 5859: padding: 2px;
1.515 albertel 5860: }
1.523 albertel 5861:
5862: .LC_answer_correct {
1.795 www 5863: background: lightgreen;
5864: color: darkgreen;
5865: padding: 6px;
1.523 albertel 5866: }
1.795 www 5867:
1.523 albertel 5868: .LC_answer_charged_try {
1.797 www 5869: background: #FFAAAA;
1.795 www 5870: color: darkred;
5871: padding: 6px;
1.523 albertel 5872: }
1.795 www 5873:
1.779 bisitz 5874: .LC_answer_not_charged_try,
1.523 albertel 5875: .LC_answer_no_grade,
5876: .LC_answer_late {
1.795 www 5877: background: lightyellow;
1.523 albertel 5878: color: black;
1.795 www 5879: padding: 6px;
1.523 albertel 5880: }
1.795 www 5881:
1.523 albertel 5882: .LC_answer_previous {
1.795 www 5883: background: lightblue;
5884: color: darkblue;
5885: padding: 6px;
1.523 albertel 5886: }
1.795 www 5887:
1.779 bisitz 5888: .LC_answer_no_message {
1.777 tempelho 5889: background: #FFFFFF;
5890: color: black;
1.795 www 5891: padding: 6px;
1.779 bisitz 5892: }
1.795 www 5893:
1.779 bisitz 5894: .LC_answer_unknown {
5895: background: orange;
5896: color: black;
1.795 www 5897: padding: 6px;
1.777 tempelho 5898: }
1.795 www 5899:
1.529 albertel 5900: span.LC_prior_numerical,
5901: span.LC_prior_string,
5902: span.LC_prior_custom,
5903: span.LC_prior_reaction,
5904: span.LC_prior_math {
1.925 bisitz 5905: font-family: $mono;
1.523 albertel 5906: white-space: pre;
5907: }
5908:
1.525 albertel 5909: span.LC_prior_string {
1.925 bisitz 5910: font-family: $mono;
1.525 albertel 5911: white-space: pre;
5912: }
5913:
1.523 albertel 5914: table.LC_prior_option {
5915: width: 100%;
5916: border-collapse: collapse;
5917: }
1.795 www 5918:
1.911 bisitz 5919: table.LC_prior_rank,
1.795 www 5920: table.LC_prior_match {
1.528 albertel 5921: border-collapse: collapse;
5922: }
1.795 www 5923:
1.528 albertel 5924: table.LC_prior_option tr td,
5925: table.LC_prior_rank tr td,
5926: table.LC_prior_match tr td {
1.524 albertel 5927: border: 1px solid #000000;
1.515 albertel 5928: }
5929:
1.855 bisitz 5930: .LC_nobreak {
1.544 albertel 5931: white-space: nowrap;
1.519 raeburn 5932: }
5933:
1.576 raeburn 5934: span.LC_cusr_emph {
5935: font-style: italic;
5936: }
5937:
1.633 raeburn 5938: span.LC_cusr_subheading {
5939: font-weight: normal;
5940: font-size: 85%;
5941: }
5942:
1.861 bisitz 5943: div.LC_docs_entry_move {
1.859 bisitz 5944: border: 1px solid #BBBBBB;
1.545 albertel 5945: background: #DDDDDD;
1.861 bisitz 5946: width: 22px;
1.859 bisitz 5947: padding: 1px;
5948: margin: 0;
1.545 albertel 5949: }
5950:
1.861 bisitz 5951: table.LC_data_table tr > td.LC_docs_entry_commands,
5952: table.LC_data_table tr > td.LC_docs_entry_parameter {
1.545 albertel 5953: background: #DDDDDD;
5954: font-size: x-small;
5955: }
1.795 www 5956:
1.861 bisitz 5957: .LC_docs_entry_parameter {
5958: white-space: nowrap;
5959: }
5960:
1.544 albertel 5961: .LC_docs_copy {
1.545 albertel 5962: color: #000099;
1.544 albertel 5963: }
1.795 www 5964:
1.544 albertel 5965: .LC_docs_cut {
1.545 albertel 5966: color: #550044;
1.544 albertel 5967: }
1.795 www 5968:
1.544 albertel 5969: .LC_docs_rename {
1.545 albertel 5970: color: #009900;
1.544 albertel 5971: }
1.795 www 5972:
1.544 albertel 5973: .LC_docs_remove {
1.545 albertel 5974: color: #990000;
5975: }
5976:
1.547 albertel 5977: .LC_docs_reinit_warn,
5978: .LC_docs_ext_edit {
5979: font-size: x-small;
5980: }
5981:
1.545 albertel 5982: table.LC_docs_adddocs td,
5983: table.LC_docs_adddocs th {
5984: border: 1px solid #BBBBBB;
5985: padding: 4px;
5986: background: #DDDDDD;
1.543 albertel 5987: }
5988:
1.584 albertel 5989: table.LC_sty_begin {
5990: background: #BBFFBB;
5991: }
1.795 www 5992:
1.584 albertel 5993: table.LC_sty_end {
5994: background: #FFBBBB;
5995: }
5996:
1.589 raeburn 5997: table.LC_double_column {
1.803 bisitz 5998: border-width: 0;
1.589 raeburn 5999: border-collapse: collapse;
6000: width: 100%;
6001: padding: 2px;
6002: }
6003:
6004: table.LC_double_column tr td.LC_left_col {
1.590 raeburn 6005: top: 2px;
1.589 raeburn 6006: left: 2px;
6007: width: 47%;
6008: vertical-align: top;
6009: }
6010:
6011: table.LC_double_column tr td.LC_right_col {
6012: top: 2px;
1.779 bisitz 6013: right: 2px;
1.589 raeburn 6014: width: 47%;
6015: vertical-align: top;
6016: }
6017:
1.591 raeburn 6018: div.LC_left_float {
6019: float: left;
6020: padding-right: 5%;
1.597 albertel 6021: padding-bottom: 4px;
1.591 raeburn 6022: }
6023:
6024: div.LC_clear_float_header {
1.597 albertel 6025: padding-bottom: 2px;
1.591 raeburn 6026: }
6027:
6028: div.LC_clear_float_footer {
1.597 albertel 6029: padding-top: 10px;
1.591 raeburn 6030: clear: both;
6031: }
6032:
1.597 albertel 6033: div.LC_grade_show_user {
1.941 bisitz 6034: /* border-left: 5px solid $sidebg; */
6035: border-top: 5px solid #000000;
6036: margin: 50px 0 0 0;
1.936 bisitz 6037: padding: 15px 0 5px 10px;
1.597 albertel 6038: }
1.795 www 6039:
1.936 bisitz 6040: div.LC_grade_show_user_odd_row {
1.941 bisitz 6041: /* border-left: 5px solid #000000; */
6042: }
6043:
6044: div.LC_grade_show_user div.LC_Box {
6045: margin-right: 50px;
1.597 albertel 6046: }
6047:
6048: div.LC_grade_submissions,
6049: div.LC_grade_message_center,
1.936 bisitz 6050: div.LC_grade_info_links {
1.597 albertel 6051: margin: 5px;
6052: width: 99%;
6053: background: #FFFFFF;
6054: }
1.795 www 6055:
1.597 albertel 6056: div.LC_grade_submissions_header,
1.936 bisitz 6057: div.LC_grade_message_center_header {
1.705 tempelho 6058: font-weight: bold;
6059: font-size: large;
1.597 albertel 6060: }
1.795 www 6061:
1.597 albertel 6062: div.LC_grade_submissions_body,
1.936 bisitz 6063: div.LC_grade_message_center_body {
1.597 albertel 6064: border: 1px solid black;
6065: width: 99%;
6066: background: #FFFFFF;
6067: }
1.795 www 6068:
1.613 albertel 6069: table.LC_scantron_action {
6070: width: 100%;
6071: }
1.795 www 6072:
1.613 albertel 6073: table.LC_scantron_action tr th {
1.698 harmsja 6074: font-weight:bold;
6075: font-style:normal;
1.613 albertel 6076: }
1.795 www 6077:
1.779 bisitz 6078: .LC_edit_problem_header,
1.614 albertel 6079: div.LC_edit_problem_footer {
1.705 tempelho 6080: font-weight: normal;
6081: font-size: medium;
1.602 albertel 6082: margin: 2px;
1.600 albertel 6083: }
1.795 www 6084:
1.600 albertel 6085: div.LC_edit_problem_header,
1.602 albertel 6086: div.LC_edit_problem_header div,
1.614 albertel 6087: div.LC_edit_problem_footer,
6088: div.LC_edit_problem_footer div,
1.602 albertel 6089: div.LC_edit_problem_editxml_header,
6090: div.LC_edit_problem_editxml_header div {
1.600 albertel 6091: margin-top: 5px;
6092: }
1.795 www 6093:
1.600 albertel 6094: div.LC_edit_problem_header_title {
1.705 tempelho 6095: font-weight: bold;
6096: font-size: larger;
1.602 albertel 6097: background: $tabbg;
6098: padding: 3px;
6099: }
1.795 www 6100:
1.602 albertel 6101: table.LC_edit_problem_header_title {
6102: width: 100%;
1.600 albertel 6103: background: $tabbg;
1.602 albertel 6104: }
6105:
6106: div.LC_edit_problem_discards {
6107: float: left;
6108: padding-bottom: 5px;
6109: }
1.795 www 6110:
1.602 albertel 6111: div.LC_edit_problem_saves {
6112: float: right;
6113: padding-bottom: 5px;
1.600 albertel 6114: }
1.795 www 6115:
1.911 bisitz 6116: img.stift {
1.803 bisitz 6117: border-width: 0;
6118: vertical-align: middle;
1.677 riegler 6119: }
1.680 riegler 6120:
1.923 bisitz 6121: table td.LC_mainmenu_col_fieldset {
1.680 riegler 6122: vertical-align: top;
1.777 tempelho 6123: }
1.795 www 6124:
1.716 raeburn 6125: div.LC_createcourse {
1.911 bisitz 6126: margin: 10px 10px 10px 10px;
1.716 raeburn 6127: }
6128:
1.917 raeburn 6129: .LC_dccid {
6130: margin: 0.2em 0 0 0;
6131: padding: 0;
6132: font-size: 90%;
6133: display:none;
6134: }
6135:
1.698 harmsja 6136: a:hover,
1.897 wenzelju 6137: ol.LC_primary_menu a:hover,
1.721 harmsja 6138: ol#LC_MenuBreadcrumbs a:hover,
6139: ol#LC_PathBreadcrumbs a:hover,
1.897 wenzelju 6140: ul#LC_secondary_menu a:hover,
1.721 harmsja 6141: .LC_FormSectionClearButton input:hover
1.795 www 6142: ul.LC_TabContent li:hover a {
1.948.2.1 raeburn 6143: color:$button_hover;
1.911 bisitz 6144: text-decoration:none;
1.693 droeschl 6145: }
6146:
1.779 bisitz 6147: h1 {
1.911 bisitz 6148: padding: 0;
6149: line-height:130%;
1.693 droeschl 6150: }
1.698 harmsja 6151:
1.911 bisitz 6152: h2,
6153: h3,
6154: h4,
6155: h5,
6156: h6 {
6157: margin: 5px 0 5px 0;
6158: padding: 0;
6159: line-height:130%;
1.693 droeschl 6160: }
1.795 www 6161:
6162: .LC_hcell {
1.911 bisitz 6163: padding:3px 15px 3px 15px;
6164: margin: 0;
6165: background-color:$tabbg;
6166: color:$fontmenu;
6167: border-bottom:solid 1px $lg_border_color;
1.693 droeschl 6168: }
1.795 www 6169:
1.840 bisitz 6170: .LC_Box > .LC_hcell {
1.911 bisitz 6171: margin: 0 -10px 10px -10px;
1.835 bisitz 6172: }
6173:
1.721 harmsja 6174: .LC_noBorder {
1.911 bisitz 6175: border: 0;
1.698 harmsja 6176: }
1.693 droeschl 6177:
1.721 harmsja 6178: .LC_FormSectionClearButton input {
1.911 bisitz 6179: background-color:transparent;
6180: border: none;
6181: cursor:pointer;
6182: text-decoration:underline;
1.693 droeschl 6183: }
1.763 bisitz 6184:
6185: .LC_help_open_topic {
1.911 bisitz 6186: color: #FFFFFF;
6187: background-color: #EEEEFF;
6188: margin: 1px;
6189: padding: 4px;
6190: border: 1px solid #000033;
6191: white-space: nowrap;
6192: /* vertical-align: middle; */
1.759 neumanie 6193: }
1.693 droeschl 6194:
1.911 bisitz 6195: dl,
6196: ul,
6197: div,
6198: fieldset {
6199: margin: 10px 10px 10px 0;
6200: /* overflow: hidden; */
1.693 droeschl 6201: }
1.795 www 6202:
1.838 bisitz 6203: fieldset > legend {
1.911 bisitz 6204: font-weight: bold;
6205: padding: 0 5px 0 5px;
1.838 bisitz 6206: }
6207:
1.813 bisitz 6208: #LC_nav_bar {
1.911 bisitz 6209: float: left;
1.948.2.24 raeburn 6210: background-color: $pgbg_or_bgcolor;
1.948.2.6 raeburn 6211: margin: 0 0 2px 0;
1.807 droeschl 6212: }
6213:
1.916 droeschl 6214: #LC_realm {
6215: margin: 0.2em 0 0 0;
6216: padding: 0;
6217: font-weight: bold;
6218: text-align: center;
1.948.2.24 raeburn 6219: background-color: $pgbg_or_bgcolor;
1.916 droeschl 6220: }
6221:
1.911 bisitz 6222: #LC_nav_bar em {
6223: font-weight: bold;
6224: font-style: normal;
1.807 droeschl 6225: }
6226:
1.948.2.6 raeburn 6227: /* Preliminary fix to hide nav_bar inside bookmarks window */
6228: #LC_bookmarks #LC_nav_bar {
6229: display:none;
6230: }
6231:
1.897 wenzelju 6232: ol.LC_primary_menu {
1.911 bisitz 6233: float: right;
1.934 droeschl 6234: margin: 0;
1.948.2.24 raeburn 6235: background-color: $pgbg_or_bgcolor;
1.807 droeschl 6236: }
6237:
1.948.2.26 raeburn 6238: ol.LC_primary_menu a.LC_new_message {
1.929 wenzelju 6239: font-weight:bold;
6240: color: darkred;
6241: }
6242:
1.852 droeschl 6243: ol#LC_PathBreadcrumbs {
1.911 bisitz 6244: margin: 0;
1.693 droeschl 6245: }
6246:
1.897 wenzelju 6247: ol.LC_primary_menu li {
1.911 bisitz 6248: display: inline;
6249: padding: 5px 5px 0 10px;
6250: vertical-align: top;
1.693 droeschl 6251: }
6252:
1.897 wenzelju 6253: ol.LC_primary_menu li img {
1.911 bisitz 6254: vertical-align: bottom;
1.934 droeschl 6255: height: 1.1em;
1.693 droeschl 6256: }
6257:
1.897 wenzelju 6258: ol.LC_primary_menu a {
1.911 bisitz 6259: color: RGB(80, 80, 80);
6260: text-decoration: none;
1.693 droeschl 6261: }
1.795 www 6262:
1.948.2.7 raeburn 6263: ol.LC_docs_parameters {
6264: margin-left: 0;
6265: padding: 0;
6266: list-style: none;
6267: }
6268:
6269: ol.LC_docs_parameters li {
6270: margin: 0;
6271: padding-right: 20px;
6272: display: inline;
6273: }
6274:
6275: ol.LC_docs_parameters li:before {
6276: content: "\\002022 \\0020";
6277: }
6278:
6279: li.LC_docs_parameters_title {
6280: font-weight: bold;
6281: }
6282:
6283: ol.LC_docs_parameters li.LC_docs_parameters_title:before {
6284: content: "";
6285: }
6286:
1.897 wenzelju 6287: ul#LC_secondary_menu {
1.911 bisitz 6288: clear: both;
6289: color: $fontmenu;
6290: background: $tabbg;
6291: list-style: none;
6292: padding: 0;
6293: margin: 0;
6294: width: 100%;
1.948.2.24 raeburn 6295: text-align: left;
1.808 droeschl 6296: }
6297:
1.897 wenzelju 6298: ul#LC_secondary_menu li {
1.911 bisitz 6299: font-weight: bold;
6300: line-height: 1.8em;
6301: padding: 0 0.8em;
6302: border-right: 1px solid black;
6303: display: inline;
6304: vertical-align: middle;
1.807 droeschl 6305: }
6306:
1.847 tempelho 6307: ul.LC_TabContent {
1.911 bisitz 6308: display:block;
6309: background: $sidebg;
6310: border-bottom: solid 1px $lg_border_color;
6311: list-style:none;
6312: margin: 0 -10px;
6313: padding: 0;
1.693 droeschl 6314: }
6315:
1.795 www 6316: ul.LC_TabContent li,
6317: ul.LC_TabContentBigger li {
1.911 bisitz 6318: float:left;
1.741 harmsja 6319: }
1.795 www 6320:
1.897 wenzelju 6321: ul#LC_secondary_menu li a {
1.911 bisitz 6322: color: $fontmenu;
6323: text-decoration: none;
1.693 droeschl 6324: }
1.795 www 6325:
1.721 harmsja 6326: ul.LC_TabContent {
1.948.2.1 raeburn 6327: min-height:20px;
1.721 harmsja 6328: }
1.795 www 6329:
6330: ul.LC_TabContent li {
1.911 bisitz 6331: vertical-align:middle;
1.948.2.3 raeburn 6332: padding: 0 16px 0 10px;
1.911 bisitz 6333: background-color:$tabbg;
6334: border-bottom:solid 1px $lg_border_color;
1.948.2.1 raeburn 6335: border-right: solid 1px $font;
1.721 harmsja 6336: }
1.795 www 6337:
1.847 tempelho 6338: ul.LC_TabContent .right {
1.911 bisitz 6339: float:right;
1.847 tempelho 6340: }
6341:
1.911 bisitz 6342: ul.LC_TabContent li a,
6343: ul.LC_TabContent li {
6344: color:rgb(47,47,47);
6345: text-decoration:none;
6346: font-size:95%;
6347: font-weight:bold;
1.948.2.1 raeburn 6348: min-height:20px;
6349: }
6350:
1.948.2.3 raeburn 6351: ul.LC_TabContent li a:hover,
6352: ul.LC_TabContent li a:focus {
1.948.2.1 raeburn 6353: color: $button_hover;
1.948.2.3 raeburn 6354: background:none;
6355: outline:none;
1.948.2.1 raeburn 6356: }
6357:
6358: ul.LC_TabContent li:hover {
6359: color: $button_hover;
6360: cursor:pointer;
1.721 harmsja 6361: }
1.795 www 6362:
1.911 bisitz 6363: ul.LC_TabContent li.active {
1.948.2.1 raeburn 6364: color: $font;
1.911 bisitz 6365: background:#FFFFFF url(/adm/lonIcons/open.gif) no-repeat scroll right center;
1.948.2.1 raeburn 6366: border-bottom:solid 1px #FFFFFF;
6367: cursor: default;
1.744 ehlerst 6368: }
1.795 www 6369:
1.948.2.3 raeburn 6370: ul.LC_TabContent li.active a {
6371: color:$font;
6372: background:#FFFFFF;
6373: outline: none;
6374: }
1.870 tempelho 6375: #maincoursedoc {
1.911 bisitz 6376: clear:both;
1.870 tempelho 6377: }
6378:
6379: ul.LC_TabContentBigger {
1.911 bisitz 6380: display:block;
6381: list-style:none;
6382: padding: 0;
1.870 tempelho 6383: }
6384:
1.795 www 6385: ul.LC_TabContentBigger li {
1.911 bisitz 6386: vertical-align:bottom;
6387: height: 30px;
6388: font-size:110%;
6389: font-weight:bold;
6390: color: #737373;
1.841 tempelho 6391: }
6392:
1.948.2.3 raeburn 6393: ul.LC_TabContentBigger li.active {
6394: position: relative;
6395: top: 1px;
6396: }
1.870 tempelho 6397:
6398: ul.LC_TabContentBigger li a {
1.911 bisitz 6399: background:url('/adm/lonIcons/tabbgleft.gif') left bottom no-repeat;
6400: height: 30px;
6401: line-height: 30px;
6402: text-align: center;
6403: display: block;
6404: text-decoration: none;
1.948.2.3 raeburn 6405: outline: none;
1.741 harmsja 6406: }
1.795 www 6407:
1.870 tempelho 6408: ul.LC_TabContentBigger li.active a {
1.911 bisitz 6409: background:url('/adm/lonIcons/tabbgleft.gif') left top no-repeat;
6410: color:$font;
1.744 ehlerst 6411: }
1.795 www 6412:
1.870 tempelho 6413: ul.LC_TabContentBigger li b {
1.911 bisitz 6414: background: url('/adm/lonIcons/tabbgright.gif') no-repeat right bottom;
6415: display: block;
6416: float: left;
6417: padding: 0 30px;
1.948.2.3 raeburn 6418: border-bottom: 1px solid $lg_border_color;
6419: }
6420:
6421: ul.LC_TabContentBigger li:hover b {
6422: color:$button_hover;
1.870 tempelho 6423: }
6424:
6425: ul.LC_TabContentBigger li.active b {
1.911 bisitz 6426: background:url('/adm/lonIcons/tabbgright.gif') right top no-repeat;
6427: color:$font;
1.948.2.3 raeburn 6428: border: 0;
6429: cursor:default;
1.741 harmsja 6430: }
1.693 droeschl 6431:
1.862 bisitz 6432: ul.LC_CourseBreadcrumbs {
6433: background: $sidebg;
6434: line-height: 32px;
6435: padding-left: 10px;
6436: margin: 0 0 10px 0;
6437: list-style-position: inside;
6438:
6439: }
6440:
1.911 bisitz 6441: ol#LC_MenuBreadcrumbs,
1.862 bisitz 6442: ol#LC_PathBreadcrumbs {
1.911 bisitz 6443: padding-left: 10px;
6444: margin: 0;
1.933 droeschl 6445: height: 2.5em; /* equal to #LC_breadcrumbs line-height */
1.693 droeschl 6446: }
6447:
1.911 bisitz 6448: ol#LC_MenuBreadcrumbs li,
6449: ol#LC_PathBreadcrumbs li,
1.862 bisitz 6450: ul.LC_CourseBreadcrumbs li {
1.911 bisitz 6451: display: inline;
1.933 droeschl 6452: white-space: normal;
1.693 droeschl 6453: }
6454:
1.823 bisitz 6455: ol#LC_MenuBreadcrumbs li a,
1.862 bisitz 6456: ul.LC_CourseBreadcrumbs li a {
1.911 bisitz 6457: text-decoration: none;
6458: font-size:90%;
1.693 droeschl 6459: }
1.795 www 6460:
1.948.2.7 raeburn 6461: ol#LC_MenuBreadcrumbs h1 {
6462: display: inline;
6463: font-size: 90%;
6464: line-height: 2.5em;
6465: margin: 0;
6466: padding: 0;
6467: }
6468:
1.795 www 6469: ol#LC_PathBreadcrumbs li a {
1.911 bisitz 6470: text-decoration:none;
6471: font-size:100%;
6472: font-weight:bold;
1.693 droeschl 6473: }
1.795 www 6474:
1.840 bisitz 6475: .LC_Box {
1.911 bisitz 6476: border: solid 1px $lg_border_color;
6477: padding: 0 10px 10px 10px;
1.746 neumanie 6478: }
1.795 www 6479:
6480: .LC_AboutMe_Image {
1.911 bisitz 6481: float:left;
6482: margin-right:10px;
1.747 neumanie 6483: }
1.795 www 6484:
6485: .LC_Clear_AboutMe_Image {
1.911 bisitz 6486: clear:left;
1.747 neumanie 6487: }
1.795 www 6488:
1.721 harmsja 6489: dl.LC_ListStyleClean dt {
1.911 bisitz 6490: padding-right: 5px;
6491: display: table-header-group;
1.693 droeschl 6492: }
6493:
1.721 harmsja 6494: dl.LC_ListStyleClean dd {
1.911 bisitz 6495: display: table-row;
1.693 droeschl 6496: }
6497:
1.721 harmsja 6498: .LC_ListStyleClean,
6499: .LC_ListStyleSimple,
6500: .LC_ListStyleNormal,
1.795 www 6501: .LC_ListStyleSpecial {
1.911 bisitz 6502: /* display:block; */
6503: list-style-position: inside;
6504: list-style-type: none;
6505: overflow: hidden;
6506: padding: 0;
1.693 droeschl 6507: }
6508:
1.721 harmsja 6509: .LC_ListStyleSimple li,
6510: .LC_ListStyleSimple dd,
6511: .LC_ListStyleNormal li,
6512: .LC_ListStyleNormal dd,
6513: .LC_ListStyleSpecial li,
1.795 www 6514: .LC_ListStyleSpecial dd {
1.911 bisitz 6515: margin: 0;
6516: padding: 5px 5px 5px 10px;
6517: clear: both;
1.693 droeschl 6518: }
6519:
1.721 harmsja 6520: .LC_ListStyleClean li,
6521: .LC_ListStyleClean dd {
1.911 bisitz 6522: padding-top: 0;
6523: padding-bottom: 0;
1.693 droeschl 6524: }
6525:
1.721 harmsja 6526: .LC_ListStyleSimple dd,
1.795 www 6527: .LC_ListStyleSimple li {
1.911 bisitz 6528: border-bottom: solid 1px $lg_border_color;
1.693 droeschl 6529: }
6530:
1.721 harmsja 6531: .LC_ListStyleSpecial li,
6532: .LC_ListStyleSpecial dd {
1.911 bisitz 6533: list-style-type: none;
6534: background-color: RGB(220, 220, 220);
6535: margin-bottom: 4px;
1.693 droeschl 6536: }
6537:
1.721 harmsja 6538: table.LC_SimpleTable {
1.911 bisitz 6539: margin:5px;
6540: border:solid 1px $lg_border_color;
1.795 www 6541: }
1.693 droeschl 6542:
1.721 harmsja 6543: table.LC_SimpleTable tr {
1.911 bisitz 6544: padding: 0;
6545: border:solid 1px $lg_border_color;
1.693 droeschl 6546: }
1.795 www 6547:
6548: table.LC_SimpleTable thead {
1.911 bisitz 6549: background:rgb(220,220,220);
1.693 droeschl 6550: }
6551:
1.721 harmsja 6552: div.LC_columnSection {
1.911 bisitz 6553: display: block;
6554: clear: both;
6555: overflow: hidden;
6556: margin: 0;
1.693 droeschl 6557: }
6558:
1.721 harmsja 6559: div.LC_columnSection>* {
1.911 bisitz 6560: float: left;
6561: margin: 10px 20px 10px 0;
6562: overflow:hidden;
1.693 droeschl 6563: }
1.721 harmsja 6564:
1.795 www 6565: table em {
1.911 bisitz 6566: font-weight: bold;
6567: font-style: normal;
1.748 schulted 6568: }
1.795 www 6569:
1.779 bisitz 6570: table.LC_tableBrowseRes,
1.795 www 6571: table.LC_tableOfContent {
1.911 bisitz 6572: border:none;
6573: border-spacing: 1px;
6574: padding: 3px;
6575: background-color: #FFFFFF;
6576: font-size: 90%;
1.753 droeschl 6577: }
1.789 droeschl 6578:
1.911 bisitz 6579: table.LC_tableOfContent {
6580: border-collapse: collapse;
1.789 droeschl 6581: }
6582:
1.771 droeschl 6583: table.LC_tableBrowseRes a,
1.768 schulted 6584: table.LC_tableOfContent a {
1.911 bisitz 6585: background-color: transparent;
6586: text-decoration: none;
1.753 droeschl 6587: }
6588:
1.795 www 6589: table.LC_tableOfContent img {
1.911 bisitz 6590: border: none;
6591: height: 1.3em;
6592: vertical-align: text-bottom;
6593: margin-right: 0.3em;
1.753 droeschl 6594: }
1.757 schulted 6595:
1.795 www 6596: a#LC_content_toolbar_firsthomework {
1.911 bisitz 6597: background-image:url(/res/adm/pages/open-first-problem.gif);
1.774 ehlerst 6598: }
6599:
1.795 www 6600: a#LC_content_toolbar_launchnav {
1.911 bisitz 6601: background-image:url(/res/adm/pages/start-navigation.gif);
1.774 ehlerst 6602: }
6603:
1.795 www 6604: a#LC_content_toolbar_closenav {
1.911 bisitz 6605: background-image:url(/res/adm/pages/close-navigation.gif);
1.774 ehlerst 6606: }
6607:
1.795 www 6608: a#LC_content_toolbar_everything {
1.911 bisitz 6609: background-image:url(/res/adm/pages/show-all.gif);
1.774 ehlerst 6610: }
6611:
1.795 www 6612: a#LC_content_toolbar_uncompleted {
1.911 bisitz 6613: background-image:url(/res/adm/pages/show-incomplete-problems.gif);
1.774 ehlerst 6614: }
6615:
1.795 www 6616: #LC_content_toolbar_clearbubbles {
1.911 bisitz 6617: background-image:url(/res/adm/pages/mark-discussionentries-read.gif);
1.774 ehlerst 6618: }
6619:
1.795 www 6620: a#LC_content_toolbar_changefolder {
1.911 bisitz 6621: background : url(/res/adm/pages/close-all-folders.gif) top center ;
1.757 schulted 6622: }
6623:
1.795 www 6624: a#LC_content_toolbar_changefolder_toggled {
1.911 bisitz 6625: background-image:url(/res/adm/pages/open-all-folders.gif);
1.757 schulted 6626: }
6627:
1.795 www 6628: ul#LC_toolbar li a:hover {
1.911 bisitz 6629: background-position: bottom center;
1.757 schulted 6630: }
6631:
1.795 www 6632: ul#LC_toolbar {
1.911 bisitz 6633: padding: 0;
6634: margin: 2px;
6635: list-style:none;
6636: position:relative;
6637: background-color:white;
1.757 schulted 6638: }
6639:
1.795 www 6640: ul#LC_toolbar li {
1.911 bisitz 6641: border:1px solid white;
6642: padding: 0;
6643: margin: 0;
6644: float: left;
6645: display:inline;
6646: vertical-align:middle;
6647: }
1.757 schulted 6648:
1.783 amueller 6649:
1.795 www 6650: a.LC_toolbarItem {
1.911 bisitz 6651: display:block;
6652: padding: 0;
6653: margin: 0;
6654: height: 32px;
6655: width: 32px;
6656: color:white;
6657: border: none;
6658: background-repeat:no-repeat;
6659: background-color:transparent;
1.757 schulted 6660: }
6661:
1.915 droeschl 6662: ul.LC_funclist {
6663: margin: 0;
6664: padding: 0.5em 1em 0.5em 0;
6665: }
6666:
1.933 droeschl 6667: ul.LC_funclist > li:first-child {
6668: font-weight:bold;
6669: margin-left:0.8em;
6670: }
6671:
1.915 droeschl 6672: ul.LC_funclist + ul.LC_funclist {
6673: /*
6674: left border as a seperator if we have more than
6675: one list
6676: */
6677: border-left: 1px solid $sidebg;
6678: /*
6679: this hides the left border behind the border of the
6680: outer box if element is wrapped to the next 'line'
6681: */
6682: margin-left: -1px;
6683: }
6684:
1.843 bisitz 6685: ul.LC_funclist li {
1.915 droeschl 6686: display: inline;
1.782 bisitz 6687: white-space: nowrap;
1.915 droeschl 6688: margin: 0 0 0 25px;
6689: line-height: 150%;
1.782 bisitz 6690: }
6691:
1.930 faziophi 6692: .ui-accordion .LC_advanced_toggle {
6693: float: right;
6694: font-size: 90%;
6695: padding: 0px 4px
6696: }
1.757 schulted 6697:
1.343 albertel 6698: END
6699: }
6700:
1.306 albertel 6701: =pod
6702:
6703: =item * &headtag()
6704:
6705: Returns a uniform footer for LON-CAPA web pages.
6706:
1.307 albertel 6707: Inputs: $title - optional title for the head
6708: $head_extra - optional extra HTML to put inside the <head>
1.315 albertel 6709: $args - optional arguments
1.319 albertel 6710: force_register - if is true call registerurl so the remote is
6711: informed
1.415 albertel 6712: redirect -> array ref of
6713: 1- seconds before redirect occurs
6714: 2- url to redirect to
6715: 3- whether the side effect should occur
1.315 albertel 6716: (side effect of setting
6717: $env{'internal.head.redirect'} to the url
6718: redirected too)
1.352 albertel 6719: domain -> force to color decorate a page for a specific
6720: domain
6721: function -> force usage of a specific rolish color scheme
6722: bgcolor -> override the default page bgcolor
1.460 albertel 6723: no_auto_mt_title
6724: -> prevent &mt()ing the title arg
1.464 albertel 6725:
1.306 albertel 6726: =cut
6727:
6728: sub headtag {
1.313 albertel 6729: my ($title,$head_extra,$args) = @_;
1.306 albertel 6730:
1.363 albertel 6731: my $function = $args->{'function'} || &get_users_function();
6732: my $domain = $args->{'domain'} || &determinedomain();
6733: my $bgcolor = $args->{'bgcolor'} || &designparm($function.'.pgbg',$domain);
1.418 albertel 6734: my $url = join(':',$env{'user.name'},$env{'user.domain'},
1.458 albertel 6735: $Apache::lonnet::perlvar{'lonVersion'},
1.531 albertel 6736: #time(),
1.418 albertel 6737: $env{'environment.color.timestamp'},
1.363 albertel 6738: $function,$domain,$bgcolor);
6739:
1.369 www 6740: $url = '/adm/css/'.&escape($url).'.css';
1.363 albertel 6741:
1.308 albertel 6742: my $result =
6743: '<head>'.
1.461 albertel 6744: &font_settings();
1.319 albertel 6745:
1.461 albertel 6746: if (!$args->{'frameset'}) {
6747: $result .= &Apache::lonhtmlcommon::htmlareaheaders();
6748: }
1.319 albertel 6749: if ($args->{'force_register'}) {
6750: $result .= &Apache::lonmenu::registerurl(1);
6751: }
1.436 albertel 6752: if (!$args->{'no_nav_bar'}
6753: && !$args->{'only_body'}
6754: && !$args->{'frameset'}) {
6755: $result .= &help_menu_js();
6756: }
1.319 albertel 6757:
1.314 albertel 6758: if (ref($args->{'redirect'})) {
1.414 albertel 6759: my ($time,$url,$inhibit_continue) = @{$args->{'redirect'}};
1.315 albertel 6760: $url = &Apache::lonenc::check_encrypt($url);
1.414 albertel 6761: if (!$inhibit_continue) {
6762: $env{'internal.head.redirect'} = $url;
6763: }
1.313 albertel 6764: $result.=<<ADDMETA
6765: <meta http-equiv="pragma" content="no-cache" />
1.344 albertel 6766: <meta http-equiv="Refresh" content="$time; url=$url" />
1.313 albertel 6767: ADDMETA
6768: }
1.306 albertel 6769: if (!defined($title)) {
6770: $title = 'The LearningOnline Network with CAPA';
6771: }
1.460 albertel 6772: if (!$args->{'no_auto_mt_title'}) { $title = &mt($title); }
6773: $result .= '<title> LON-CAPA '.$title.'</title>'
1.414 albertel 6774: .'<link rel="stylesheet" type="text/css" href="'.$url.'" />'
6775: .$head_extra;
1.306 albertel 6776: return $result;
6777: }
6778:
6779: =pod
6780:
1.340 albertel 6781: =item * &font_settings()
6782:
6783: Returns neccessary <meta> to set the proper encoding
6784:
6785: Inputs: none
6786:
6787: =cut
6788:
6789: sub font_settings {
6790: my $headerstring='';
1.647 www 6791: if (!$env{'browser.mathml'} && $env{'browser.unicode'}) {
1.340 albertel 6792: $headerstring.=
6793: '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
6794: }
6795: return $headerstring;
6796: }
6797:
1.341 albertel 6798: =pod
6799:
6800: =item * &xml_begin()
6801:
6802: Returns the needed doctype and <html>
6803:
6804: Inputs: none
6805:
6806: =cut
6807:
6808: sub xml_begin {
6809: my $output='';
6810:
6811: if ($env{'browser.mathml'}) {
6812: $output='<?xml version="1.0"?>'
6813: #.'<?xml-stylesheet type="text/css" href="/adm/MathML/mathml.css"?>'."\n"
6814: # .'<!DOCTYPE html SYSTEM "/adm/MathML/mathml.dtd" '
6815:
6816: # .'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" [<!ENTITY mathns "http://www.w3.org/1998/Math/MathML">] >'
6817: .'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">'
6818: .'<html xmlns:math="http://www.w3.org/1998/Math/MathML" '
6819: .'xmlns="http://www.w3.org/1999/xhtml">';
6820: } else {
1.849 bisitz 6821: $output='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
6822: .'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">';
1.341 albertel 6823: }
6824: return $output;
6825: }
1.340 albertel 6826:
6827: =pod
6828:
1.306 albertel 6829: =item * &endheadtag()
6830:
6831: Returns a uniform </head> for LON-CAPA web pages.
6832:
6833: Inputs: none
6834:
6835: =cut
6836:
6837: sub endheadtag {
6838: return '</head>';
6839: }
6840:
6841: =pod
6842:
6843: =item * &head()
6844:
6845: Returns a uniform complete <head>..</head> section for LON-CAPA web pages.
6846:
1.648 raeburn 6847: Inputs:
6848:
6849: =over 4
6850:
6851: $title - optional title for the page
6852:
6853: $head_extra - optional extra HTML to put inside the <head>
6854:
6855: =back
1.405 albertel 6856:
1.306 albertel 6857: =cut
6858:
6859: sub head {
1.325 albertel 6860: my ($title,$head_extra,$args) = @_;
6861: return &headtag($title,$head_extra,$args).&endheadtag();
1.306 albertel 6862: }
6863:
6864: =pod
6865:
6866: =item * &start_page()
6867:
6868: Returns a complete <html> .. <body> section for LON-CAPA web pages.
6869:
1.648 raeburn 6870: Inputs:
6871:
6872: =over 4
6873:
6874: $title - optional title for the page
6875:
6876: $head_extra - optional extra HTML to incude inside the <head>
6877:
6878: $args - additional optional args supported are:
6879:
6880: =over 8
6881:
6882: only_body -> is true will set &bodytag() onlybodytag
1.317 albertel 6883: arg on
1.814 bisitz 6884: no_nav_bar -> is true will set &bodytag() no_nav_bar arg on
1.648 raeburn 6885: add_entries -> additional attributes to add to the <body>
6886: domain -> force to color decorate a page for a
1.317 albertel 6887: specific domain
1.648 raeburn 6888: function -> force usage of a specific rolish color
1.317 albertel 6889: scheme
1.648 raeburn 6890: redirect -> see &headtag()
6891: bgcolor -> override the default page bg color
6892: js_ready -> return a string ready for being used in
1.317 albertel 6893: a javascript writeln
1.648 raeburn 6894: html_encode -> return a string ready for being used in
1.320 albertel 6895: a html attribute
1.648 raeburn 6896: force_register -> if is true will turn on the &bodytag()
1.317 albertel 6897: $forcereg arg
1.648 raeburn 6898: frameset -> if true will start with a <frameset>
1.330 albertel 6899: rather than <body>
1.648 raeburn 6900: skip_phases -> hash ref of
1.338 albertel 6901: head -> skip the <html><head> generation
6902: body -> skip all <body> generation
1.648 raeburn 6903: no_inline_link -> if true and in remote mode, don't show the
1.361 albertel 6904: 'Switch To Inline Menu' link
1.648 raeburn 6905: no_auto_mt_title -> prevent &mt()ing the title arg
6906: inherit_jsmath -> when creating popup window in a page,
6907: should it have jsmath forced on by the
6908: current page
1.867 kalberla 6909: bread_crumbs -> Array containing breadcrumbs
1.948.2.12 raeburn 6910: bread_crumbs_component -> if exists show it as headline else show only the breadcrumbs
1.361 albertel 6911:
1.648 raeburn 6912: =back
1.460 albertel 6913:
1.648 raeburn 6914: =back
1.562 albertel 6915:
1.306 albertel 6916: =cut
6917:
6918: sub start_page {
1.309 albertel 6919: my ($title,$head_extra,$args) = @_;
1.318 albertel 6920: #&Apache::lonnet::logthis("start_page ".join(':',caller(0)));
1.313 albertel 6921: my %head_args;
1.352 albertel 6922: foreach my $arg ('redirect','force_register','domain','function',
1.460 albertel 6923: 'bgcolor','frameset','no_nav_bar','only_body',
6924: 'no_auto_mt_title') {
1.319 albertel 6925: if (defined($args->{$arg})) {
1.324 raeburn 6926: $head_args{$arg} = $args->{$arg};
1.319 albertel 6927: }
1.313 albertel 6928: }
1.319 albertel 6929:
1.315 albertel 6930: $env{'internal.start_page'}++;
1.338 albertel 6931: my $result;
6932: if (! exists($args->{'skip_phases'}{'head'}) ) {
6933: $result.=
1.341 albertel 6934: &xml_begin().
1.338 albertel 6935: &headtag($title,$head_extra,\%head_args).&endheadtag();
6936: }
6937:
6938: if (! exists($args->{'skip_phases'}{'body'}) ) {
6939: if ($args->{'frameset'}) {
6940: my $attr_string = &make_attr_string($args->{'force_register'},
6941: $args->{'add_entries'});
6942: $result .= "\n<frameset $attr_string>\n";
1.831 bisitz 6943: } else {
6944: $result .=
6945: &bodytag($title,
6946: $args->{'function'}, $args->{'add_entries'},
6947: $args->{'only_body'}, $args->{'domain'},
6948: $args->{'force_register'}, $args->{'no_nav_bar'},
6949: $args->{'bgcolor'}, $args->{'no_inline_link'},
6950: $args);
6951: }
1.330 albertel 6952: }
1.338 albertel 6953:
1.315 albertel 6954: if ($args->{'js_ready'}) {
1.713 kaisler 6955: $result = &js_ready($result);
1.315 albertel 6956: }
1.320 albertel 6957: if ($args->{'html_encode'}) {
1.713 kaisler 6958: $result = &html_encode($result);
6959: }
6960:
1.813 bisitz 6961: # Preparation for new and consistent functionlist at top of screen
6962: # if ($args->{'functionlist'}) {
6963: # $result .= &build_functionlist();
6964: #}
6965:
6966: # Don't add anything more if only_body wanted
6967: return $result if $args->{'only_body'};
6968:
1.920 raeburn 6969: #Breadcrumbs for Construction Space provided by &bodytag.
6970: if (($env{'environment.remote'} eq 'off') && ($env{'request.state'} eq 'construct')) {
6971: return $result;
6972: }
6973:
1.813 bisitz 6974: #Breadcrumbs
1.758 kaisler 6975: if (exists($args->{'bread_crumbs'}) or exists($args->{'bread_crumbs_component'})) {
6976: &Apache::lonhtmlcommon::clear_breadcrumbs();
6977: #if any br links exists, add them to the breadcrumbs
6978: if (exists($args->{'bread_crumbs'}) and ref($args->{'bread_crumbs'}) eq 'ARRAY') {
6979: foreach my $crumb (@{$args->{'bread_crumbs'}}){
6980: &Apache::lonhtmlcommon::add_breadcrumb($crumb);
6981: }
6982: }
6983:
6984: #if bread_crumbs_component exists show it as headline else show only the breadcrumbs
6985: if(exists($args->{'bread_crumbs_component'})){
6986: $result .= &Apache::lonhtmlcommon::breadcrumbs($args->{'bread_crumbs_component'});
6987: }else{
6988: $result .= &Apache::lonhtmlcommon::breadcrumbs();
6989: }
1.320 albertel 6990: }
1.315 albertel 6991: return $result;
1.306 albertel 6992: }
6993:
1.330 albertel 6994:
1.306 albertel 6995: =pod
6996:
6997: =item * &head()
6998:
6999: Returns a complete </body></html> section for LON-CAPA web pages.
7000:
1.315 albertel 7001: Inputs: $args - additional optional args supported are:
7002: js_ready -> return a string ready for being used in
7003: a javascript writeln
1.320 albertel 7004: html_encode -> return a string ready for being used in
7005: a html attribute
1.330 albertel 7006: frameset -> if true will start with a <frameset>
7007: rather than <body>
1.493 albertel 7008: dicsussion -> if true will get discussion from
7009: lonxml::xmlend
7010: (you can pass the target and parser arguments
7011: through optional 'target' and 'parser' args
7012: to this routine)
1.306 albertel 7013:
7014: =cut
7015:
7016: sub end_page {
1.315 albertel 7017: my ($args) = @_;
7018: $env{'internal.end_page'}++;
1.330 albertel 7019: my $result;
1.335 albertel 7020: if ($args->{'discussion'}) {
7021: my ($target,$parser);
7022: if (ref($args->{'discussion'})) {
7023: ($target,$parser) =($args->{'discussion'}{'target'},
7024: $args->{'discussion'}{'parser'});
7025: }
7026: $result .= &Apache::lonxml::xmlend($target,$parser);
7027: }
7028:
1.330 albertel 7029: if ($args->{'frameset'}) {
7030: $result .= '</frameset>';
7031: } else {
1.635 raeburn 7032: $result .= &endbodytag($args);
1.330 albertel 7033: }
7034: $result .= "\n</html>";
7035:
1.315 albertel 7036: if ($args->{'js_ready'}) {
1.317 albertel 7037: $result = &js_ready($result);
1.315 albertel 7038: }
1.335 albertel 7039:
1.320 albertel 7040: if ($args->{'html_encode'}) {
7041: $result = &html_encode($result);
7042: }
1.335 albertel 7043:
1.315 albertel 7044: return $result;
7045: }
7046:
1.320 albertel 7047: sub html_encode {
7048: my ($result) = @_;
7049:
1.322 albertel 7050: $result = &HTML::Entities::encode($result,'<>&"');
1.320 albertel 7051:
7052: return $result;
7053: }
1.317 albertel 7054: sub js_ready {
7055: my ($result) = @_;
7056:
1.323 albertel 7057: $result =~ s/[\n\r]/ /xmsg;
7058: $result =~ s/\\/\\\\/xmsg;
7059: $result =~ s/'/\\'/xmsg;
1.372 albertel 7060: $result =~ s{</}{<\\/}xmsg;
1.317 albertel 7061:
7062: return $result;
7063: }
7064:
1.315 albertel 7065: sub validate_page {
7066: if ( exists($env{'internal.start_page'})
1.316 albertel 7067: && $env{'internal.start_page'} > 1) {
7068: &Apache::lonnet::logthis('start_page called multiple times '.
1.318 albertel 7069: $env{'internal.start_page'}.' '.
1.316 albertel 7070: $ENV{'request.filename'});
1.315 albertel 7071: }
7072: if ( exists($env{'internal.end_page'})
1.316 albertel 7073: && $env{'internal.end_page'} > 1) {
7074: &Apache::lonnet::logthis('end_page called multiple times '.
1.318 albertel 7075: $env{'internal.end_page'}.' '.
1.316 albertel 7076: $env{'request.filename'});
1.315 albertel 7077: }
7078: if ( exists($env{'internal.start_page'})
7079: && ! exists($env{'internal.end_page'})) {
1.316 albertel 7080: &Apache::lonnet::logthis('start_page called without end_page '.
7081: $env{'request.filename'});
1.315 albertel 7082: }
7083: if ( ! exists($env{'internal.start_page'})
7084: && exists($env{'internal.end_page'})) {
1.316 albertel 7085: &Apache::lonnet::logthis('end_page called without start_page'.
7086: $env{'request.filename'});
1.315 albertel 7087: }
1.306 albertel 7088: }
1.315 albertel 7089:
1.318 albertel 7090: sub simple_error_page {
7091: my ($r,$title,$msg) = @_;
7092: my $page =
7093: &Apache::loncommon::start_page($title).
7094: &mt($msg).
7095: &Apache::loncommon::end_page();
7096: if (ref($r)) {
7097: $r->print($page);
1.327 albertel 7098: return;
1.318 albertel 7099: }
7100: return $page;
7101: }
1.347 albertel 7102:
7103: {
1.610 albertel 7104: my @row_count;
1.948.2.5 raeburn 7105:
7106: sub start_data_table_count {
7107: unshift(@row_count, 0);
7108: return;
7109: }
7110:
7111: sub end_data_table_count {
7112: shift(@row_count);
7113: return;
7114: }
7115:
1.347 albertel 7116: sub start_data_table {
1.422 albertel 7117: my ($add_class) = @_;
7118: my $css_class = (join(' ','LC_data_table',$add_class));
1.948.2.5 raeburn 7119: &start_data_table_count();
1.422 albertel 7120: return '<table class="'.$css_class.'">'."\n";
1.347 albertel 7121: }
7122:
7123: sub end_data_table {
1.948.2.5 raeburn 7124: &end_data_table_count();
1.389 albertel 7125: return '</table>'."\n";;
1.347 albertel 7126: }
7127:
7128: sub start_data_table_row {
1.422 albertel 7129: my ($add_class) = @_;
1.610 albertel 7130: $row_count[0]++;
7131: my $css_class = ($row_count[0] % 2)?'LC_odd_row':'LC_even_row';
1.900 bisitz 7132: $css_class = (join(' ',$css_class,$add_class)) unless ($add_class eq '');
1.422 albertel 7133: return '<tr class="'.$css_class.'">'."\n";;
1.347 albertel 7134: }
1.471 banghart 7135:
7136: sub continue_data_table_row {
7137: my ($add_class) = @_;
1.610 albertel 7138: my $css_class = ($row_count[0] % 2)?'LC_odd_row':'LC_even_row';
1.948.2.32! raeburn 7139: $css_class = (join(' ',$css_class,$add_class)) unless ($add_class eq '');
1.471 banghart 7140: return '<tr class="'.$css_class.'">'."\n";;
7141: }
1.347 albertel 7142:
7143: sub end_data_table_row {
1.389 albertel 7144: return '</tr>'."\n";;
1.347 albertel 7145: }
1.367 www 7146:
1.421 albertel 7147: sub start_data_table_empty_row {
1.707 bisitz 7148: # $row_count[0]++;
1.421 albertel 7149: return '<tr class="LC_empty_row" >'."\n";;
7150: }
7151:
7152: sub end_data_table_empty_row {
7153: return '</tr>'."\n";;
7154: }
7155:
1.367 www 7156: sub start_data_table_header_row {
1.389 albertel 7157: return '<tr class="LC_header_row">'."\n";;
1.367 www 7158: }
7159:
7160: sub end_data_table_header_row {
1.389 albertel 7161: return '</tr>'."\n";;
1.367 www 7162: }
1.890 droeschl 7163:
7164: sub data_table_caption {
7165: my $caption = shift;
7166: return "<caption class=\"LC_caption\">$caption</caption>";
7167: }
1.347 albertel 7168: }
7169:
1.548 albertel 7170: =pod
7171:
7172: =item * &inhibit_menu_check($arg)
7173:
7174: Checks for a inhibitmenu state and generates output to preserve it
7175:
7176: Inputs: $arg - can be any of
7177: - undef - in which case the return value is a string
7178: to add into arguments list of a uri
7179: - 'input' - in which case the return value is a HTML
7180: <form> <input> field of type hidden to
7181: preserve the value
7182: - a url - in which case the return value is the url with
7183: the neccesary cgi args added to preserve the
7184: inhibitmenu state
7185: - a ref to a url - no return value, but the string is
7186: updated to include the neccessary cgi
7187: args to preserve the inhibitmenu state
7188:
7189: =cut
7190:
7191: sub inhibit_menu_check {
7192: my ($arg) = @_;
7193: &get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['inhibitmenu']);
7194: if ($arg eq 'input') {
7195: if ($env{'form.inhibitmenu'}) {
7196: return '<input type="hidden" name="inhibitmenu" value="'.$env{'form.inhibitmenu'}.'" />';
7197: } else {
7198: return
7199: }
7200: }
7201: if ($env{'form.inhibitmenu'}) {
7202: if (ref($arg)) {
7203: $$arg .= '?inhibitmenu='.$env{'form.inhibitmenu'};
7204: } elsif ($arg eq '') {
7205: $arg .= 'inhibitmenu='.$env{'form.inhibitmenu'};
7206: } else {
7207: $arg .= '?inhibitmenu='.$env{'form.inhibitmenu'};
7208: }
7209: }
7210: if (!ref($arg)) {
7211: return $arg;
7212: }
7213: }
7214:
1.251 albertel 7215: ###############################################
1.182 matthew 7216:
7217: =pod
7218:
1.549 albertel 7219: =back
7220:
7221: =head1 User Information Routines
7222:
7223: =over 4
7224:
1.405 albertel 7225: =item * &get_users_function()
1.182 matthew 7226:
7227: Used by &bodytag to determine the current users primary role.
7228: Returns either 'student','coordinator','admin', or 'author'.
7229:
7230: =cut
7231:
7232: ###############################################
7233: sub get_users_function {
1.815 tempelho 7234: my $function = 'norole';
1.818 tempelho 7235: if ($env{'request.role'}=~/^(st)/) {
7236: $function='student';
7237: }
1.907 raeburn 7238: if ($env{'request.role'}=~/^(cc|co|in|ta|ep)/) {
1.182 matthew 7239: $function='coordinator';
7240: }
1.258 albertel 7241: if ($env{'request.role'}=~/^(su|dc|ad|li)/) {
1.182 matthew 7242: $function='admin';
7243: }
1.826 bisitz 7244: if (($env{'request.role'}=~/^(au|ca|aa)/) ||
1.182 matthew 7245: ($ENV{'REQUEST_URI'}=~/^(\/priv|\~)/)) {
7246: $function='author';
7247: }
7248: return $function;
1.54 www 7249: }
1.99 www 7250:
7251: ###############################################
7252:
1.233 raeburn 7253: =pod
7254:
1.821 raeburn 7255: =item * &show_course()
7256:
7257: Used by lonmenu.pm and lonroles.pm to determine whether to use the word
7258: 'Courses' or 'Roles' in inline navigation and on screen displaying user's roles.
7259:
7260: Inputs:
7261: None
7262:
7263: Outputs:
7264: Scalar: 1 if 'Course' to be used, 0 otherwise.
7265:
7266: =cut
7267:
7268: ###############################################
7269: sub show_course {
7270: my $course = !$env{'user.adv'};
7271: if (!$env{'user.adv'}) {
7272: foreach my $env (keys(%env)) {
7273: next if ($env !~ m/^user\.priv\./);
7274: if ($env !~ m/^user\.priv\.(?:st|cm)/) {
7275: $course = 0;
7276: last;
7277: }
7278: }
7279: }
7280: return $course;
7281: }
7282:
7283: ###############################################
7284:
7285: =pod
7286:
1.542 raeburn 7287: =item * &check_user_status()
1.274 raeburn 7288:
7289: Determines current status of supplied role for a
7290: specific user. Roles can be active, previous or future.
7291:
7292: Inputs:
7293: user's domain, user's username, course's domain,
1.375 raeburn 7294: course's number, optional section ID.
1.274 raeburn 7295:
7296: Outputs:
7297: role status: active, previous or future.
7298:
7299: =cut
7300:
7301: sub check_user_status {
1.412 raeburn 7302: my ($udom,$uname,$cdom,$crs,$role,$sec) = @_;
1.948.2.11 raeburn 7303: my $extra = &Apache::lonnet::freeze_escape({'skipcheck' => 1});
7304: my %userinfo = &Apache::lonnet::dump('roles',$udom,$uname,'.',undef,$extra);
1.274 raeburn 7305: my @uroles = keys %userinfo;
7306: my $srchstr;
7307: my $active_chk = 'none';
1.412 raeburn 7308: my $now = time;
1.274 raeburn 7309: if (@uroles > 0) {
1.908 raeburn 7310: if (($role eq 'cc') || ($role eq 'co') || ($sec eq '') || (!defined($sec))) {
1.274 raeburn 7311: $srchstr = '/'.$cdom.'/'.$crs.'_'.$role;
7312: } else {
1.412 raeburn 7313: $srchstr = '/'.$cdom.'/'.$crs.'/'.$sec.'_'.$role;
7314: }
7315: if (grep/^\Q$srchstr\E$/,@uroles) {
1.274 raeburn 7316: my $role_end = 0;
7317: my $role_start = 0;
7318: $active_chk = 'active';
1.412 raeburn 7319: if ($userinfo{$srchstr} =~ m/^\Q$role\E_(\d+)/) {
7320: $role_end = $1;
7321: if ($userinfo{$srchstr} =~ m/^\Q$role\E_\Q$role_end\E_(\d+)$/) {
7322: $role_start = $1;
1.274 raeburn 7323: }
7324: }
7325: if ($role_start > 0) {
1.412 raeburn 7326: if ($now < $role_start) {
1.274 raeburn 7327: $active_chk = 'future';
7328: }
7329: }
7330: if ($role_end > 0) {
1.412 raeburn 7331: if ($now > $role_end) {
1.274 raeburn 7332: $active_chk = 'previous';
7333: }
7334: }
7335: }
7336: }
7337: return $active_chk;
7338: }
7339:
7340: ###############################################
7341:
7342: =pod
7343:
1.405 albertel 7344: =item * &get_sections()
1.233 raeburn 7345:
7346: Determines all the sections for a course including
7347: sections with students and sections containing other roles.
1.419 raeburn 7348: Incoming parameters:
7349:
7350: 1. domain
7351: 2. course number
7352: 3. reference to array containing roles for which sections should
7353: be gathered (optional).
7354: 4. reference to array containing status types for which sections
7355: should be gathered (optional).
7356:
7357: If the third argument is undefined, sections are gathered for any role.
7358: If the fourth argument is undefined, sections are gathered for any status.
7359: Permissible values are 'active' or 'future' or 'previous'.
1.233 raeburn 7360:
1.374 raeburn 7361: Returns section hash (keys are section IDs, values are
7362: number of users in each section), subject to the
1.419 raeburn 7363: optional roles filter, optional status filter
1.233 raeburn 7364:
7365: =cut
7366:
7367: ###############################################
7368: sub get_sections {
1.419 raeburn 7369: my ($cdom,$cnum,$possible_roles,$possible_status) = @_;
1.366 albertel 7370: if (!defined($cdom) || !defined($cnum)) {
7371: my $cid = $env{'request.course.id'};
7372:
7373: return if (!defined($cid));
7374:
7375: $cdom = $env{'course.'.$cid.'.domain'};
7376: $cnum = $env{'course.'.$cid.'.num'};
7377: }
7378:
7379: my %sectioncount;
1.419 raeburn 7380: my $now = time;
1.240 albertel 7381:
1.366 albertel 7382: if (!defined($possible_roles) || (grep(/^st$/,@$possible_roles))) {
1.276 albertel 7383: my ($classlist) = &Apache::loncoursedata::get_classlist($cdom,$cnum);
1.240 albertel 7384: my $sec_index = &Apache::loncoursedata::CL_SECTION();
7385: my $status_index = &Apache::loncoursedata::CL_STATUS();
1.419 raeburn 7386: my $start_index = &Apache::loncoursedata::CL_START();
7387: my $end_index = &Apache::loncoursedata::CL_END();
7388: my $status;
1.366 albertel 7389: while (my ($student,$data) = each(%$classlist)) {
1.419 raeburn 7390: my ($section,$stu_status,$start,$end) = ($data->[$sec_index],
7391: $data->[$status_index],
7392: $data->[$start_index],
7393: $data->[$end_index]);
7394: if ($stu_status eq 'Active') {
7395: $status = 'active';
7396: } elsif ($end < $now) {
7397: $status = 'previous';
7398: } elsif ($start > $now) {
7399: $status = 'future';
7400: }
7401: if ($section ne '-1' && $section !~ /^\s*$/) {
7402: if ((!defined($possible_status)) || (($status ne '') &&
7403: (grep/^\Q$status\E$/,@{$possible_status}))) {
7404: $sectioncount{$section}++;
7405: }
1.240 albertel 7406: }
7407: }
7408: }
7409: my %courseroles = &Apache::lonnet::dump('nohist_userroles',$cdom,$cnum);
7410: foreach my $user (sort(keys(%courseroles))) {
7411: if ($user !~ /^(\w{2})/) { next; }
7412: my ($role) = ($user =~ /^(\w{2})/);
7413: if ($possible_roles && !(grep(/^$role$/,@$possible_roles))) { next; }
1.419 raeburn 7414: my ($section,$status);
1.240 albertel 7415: if ($role eq 'cr' &&
7416: $user =~ m-^$role/[^/]*/[^/]*/[^/]*:[^:]*:[^:]*:(\w+)-) {
7417: $section=$1;
7418: }
7419: if ($user =~ /^$role:[^:]*:[^:]*:(\w+)/) { $section=$1; }
7420: if (!defined($section) || $section eq '-1') { next; }
1.419 raeburn 7421: my ($end,$start) = ($courseroles{$user} =~ /^([^:]*):([^:]*)$/);
7422: if ($end == -1 && $start == -1) {
7423: next; #deleted role
7424: }
7425: if (!defined($possible_status)) {
7426: $sectioncount{$section}++;
7427: } else {
7428: if ((!$end || $end >= $now) && (!$start || $start <= $now)) {
7429: $status = 'active';
7430: } elsif ($end < $now) {
7431: $status = 'future';
7432: } elsif ($start > $now) {
7433: $status = 'previous';
7434: }
7435: if (($status ne '') && (grep/^\Q$status\E$/,@{$possible_status})) {
7436: $sectioncount{$section}++;
7437: }
7438: }
1.233 raeburn 7439: }
1.366 albertel 7440: return %sectioncount;
1.233 raeburn 7441: }
7442:
1.274 raeburn 7443: ###############################################
1.294 raeburn 7444:
7445: =pod
1.405 albertel 7446:
7447: =item * &get_course_users()
7448:
1.275 raeburn 7449: Retrieves usernames:domains for users in the specified course
7450: with specific role(s), and access status.
7451:
7452: Incoming parameters:
1.277 albertel 7453: 1. course domain
7454: 2. course number
7455: 3. access status: users must have - either active,
1.275 raeburn 7456: previous, future, or all.
1.277 albertel 7457: 4. reference to array of permissible roles
1.288 raeburn 7458: 5. reference to array of section restrictions (optional)
7459: 6. reference to results object (hash of hashes).
7460: 7. reference to optional userdata hash
1.609 raeburn 7461: 8. reference to optional statushash
1.630 raeburn 7462: 9. flag if privileged users (except those set to unhide in
7463: course settings) should be excluded
1.609 raeburn 7464: Keys of top level results hash are roles.
1.275 raeburn 7465: Keys of inner hashes are username:domain, with
7466: values set to access type.
1.288 raeburn 7467: Optional userdata hash returns an array with arguments in the
7468: same order as loncoursedata::get_classlist() for student data.
7469:
1.609 raeburn 7470: Optional statushash returns
7471:
1.288 raeburn 7472: Entries for end, start, section and status are blank because
7473: of the possibility of multiple values for non-student roles.
7474:
1.275 raeburn 7475: =cut
1.405 albertel 7476:
1.275 raeburn 7477: ###############################################
1.405 albertel 7478:
1.275 raeburn 7479: sub get_course_users {
1.630 raeburn 7480: my ($cdom,$cnum,$types,$roles,$sections,$users,$userdata,$statushash,$hidepriv) = @_;
1.288 raeburn 7481: my %idx = ();
1.419 raeburn 7482: my %seclists;
1.288 raeburn 7483:
7484: $idx{udom} = &Apache::loncoursedata::CL_SDOM();
7485: $idx{uname} = &Apache::loncoursedata::CL_SNAME();
7486: $idx{end} = &Apache::loncoursedata::CL_END();
7487: $idx{start} = &Apache::loncoursedata::CL_START();
7488: $idx{id} = &Apache::loncoursedata::CL_ID();
7489: $idx{section} = &Apache::loncoursedata::CL_SECTION();
7490: $idx{fullname} = &Apache::loncoursedata::CL_FULLNAME();
7491: $idx{status} = &Apache::loncoursedata::CL_STATUS();
7492:
1.290 albertel 7493: if (grep(/^st$/,@{$roles})) {
1.276 albertel 7494: my ($classlist,$keylist)=&Apache::loncoursedata::get_classlist($cdom,$cnum);
1.278 raeburn 7495: my $now = time;
1.277 albertel 7496: foreach my $student (keys(%{$classlist})) {
1.288 raeburn 7497: my $match = 0;
1.412 raeburn 7498: my $secmatch = 0;
1.419 raeburn 7499: my $section = $$classlist{$student}[$idx{section}];
1.609 raeburn 7500: my $status = $$classlist{$student}[$idx{status}];
1.419 raeburn 7501: if ($section eq '') {
7502: $section = 'none';
7503: }
1.291 albertel 7504: if ((ref($sections) eq 'ARRAY') && (@{$sections} > 0)) {
1.420 albertel 7505: if (grep(/^all$/,@{$sections})) {
1.412 raeburn 7506: $secmatch = 1;
7507: } elsif ($$classlist{$student}[$idx{section}] eq '') {
1.420 albertel 7508: if (grep(/^none$/,@{$sections})) {
1.412 raeburn 7509: $secmatch = 1;
7510: }
7511: } else {
1.419 raeburn 7512: if (grep(/^\Q$section\E$/,@{$sections})) {
1.412 raeburn 7513: $secmatch = 1;
7514: }
1.290 albertel 7515: }
1.412 raeburn 7516: if (!$secmatch) {
7517: next;
7518: }
1.419 raeburn 7519: }
1.275 raeburn 7520: if (defined($$types{'active'})) {
1.288 raeburn 7521: if ($$classlist{$student}[$idx{status}] eq 'Active') {
1.275 raeburn 7522: push(@{$$users{st}{$student}},'active');
1.288 raeburn 7523: $match = 1;
1.275 raeburn 7524: }
7525: }
7526: if (defined($$types{'previous'})) {
1.609 raeburn 7527: if ($$classlist{$student}[$idx{status}] eq 'Expired') {
1.275 raeburn 7528: push(@{$$users{st}{$student}},'previous');
1.288 raeburn 7529: $match = 1;
1.275 raeburn 7530: }
7531: }
7532: if (defined($$types{'future'})) {
1.609 raeburn 7533: if ($$classlist{$student}[$idx{status}] eq 'Future') {
1.275 raeburn 7534: push(@{$$users{st}{$student}},'future');
1.288 raeburn 7535: $match = 1;
1.275 raeburn 7536: }
7537: }
1.609 raeburn 7538: if ($match) {
7539: push(@{$seclists{$student}},$section);
7540: if (ref($userdata) eq 'HASH') {
7541: $$userdata{$student} = $$classlist{$student};
7542: }
7543: if (ref($statushash) eq 'HASH') {
7544: $statushash->{$student}{'st'}{$section} = $status;
7545: }
1.288 raeburn 7546: }
1.275 raeburn 7547: }
7548: }
1.412 raeburn 7549: if ((@{$roles} > 1) || ((@{$roles} == 1) && ($$roles[0] ne "st"))) {
1.439 raeburn 7550: my %coursepersonnel = &Apache::lonnet::dump('nohist_userroles',$cdom,$cnum);
7551: my $now = time;
1.609 raeburn 7552: my %displaystatus = ( previous => 'Expired',
7553: active => 'Active',
7554: future => 'Future',
7555: );
1.630 raeburn 7556: my %nothide;
7557: if ($hidepriv) {
7558: my %coursehash=&Apache::lonnet::coursedescription($cdom.'_'.$cnum);
7559: foreach my $user (split(/\s*\,\s*/,$coursehash{'nothideprivileged'})) {
7560: if ($user !~ /:/) {
7561: $nothide{join(':',split(/[\@]/,$user))}=1;
7562: } else {
7563: $nothide{$user} = 1;
7564: }
7565: }
7566: }
1.439 raeburn 7567: foreach my $person (sort(keys(%coursepersonnel))) {
1.288 raeburn 7568: my $match = 0;
1.412 raeburn 7569: my $secmatch = 0;
1.439 raeburn 7570: my $status;
1.412 raeburn 7571: my ($role,$user,$usec) = ($person =~ /^([^:]*):([^:]+:[^:]+):([^:]*)/);
1.275 raeburn 7572: $user =~ s/:$//;
1.439 raeburn 7573: my ($end,$start) = split(/:/,$coursepersonnel{$person});
7574: if ($end == -1 || $start == -1) {
7575: next;
7576: }
7577: if (($role) && ((grep(/^\Q$role\E$/,@{$roles})) ||
7578: (grep(/^cr$/,@{$roles}) && $role =~ /^cr\//))) {
1.412 raeburn 7579: my ($uname,$udom) = split(/:/,$user);
7580: if ((ref($sections) eq 'ARRAY') && (@{$sections} > 0)) {
1.420 albertel 7581: if (grep(/^all$/,@{$sections})) {
1.412 raeburn 7582: $secmatch = 1;
7583: } elsif ($usec eq '') {
1.420 albertel 7584: if (grep(/^none$/,@{$sections})) {
1.412 raeburn 7585: $secmatch = 1;
7586: }
7587: } else {
7588: if (grep(/^\Q$usec\E$/,@{$sections})) {
7589: $secmatch = 1;
7590: }
7591: }
7592: if (!$secmatch) {
7593: next;
7594: }
1.288 raeburn 7595: }
1.419 raeburn 7596: if ($usec eq '') {
7597: $usec = 'none';
7598: }
1.275 raeburn 7599: if ($uname ne '' && $udom ne '') {
1.630 raeburn 7600: if ($hidepriv) {
7601: if ((&Apache::lonnet::privileged($uname,$udom)) &&
7602: (!$nothide{$uname.':'.$udom})) {
7603: next;
7604: }
7605: }
1.503 raeburn 7606: if ($end > 0 && $end < $now) {
1.439 raeburn 7607: $status = 'previous';
7608: } elsif ($start > $now) {
7609: $status = 'future';
7610: } else {
7611: $status = 'active';
7612: }
1.277 albertel 7613: foreach my $type (keys(%{$types})) {
1.275 raeburn 7614: if ($status eq $type) {
1.420 albertel 7615: if (!grep(/^\Q$type\E$/,@{$$users{$role}{$user}})) {
1.419 raeburn 7616: push(@{$$users{$role}{$user}},$type);
7617: }
1.288 raeburn 7618: $match = 1;
7619: }
7620: }
1.419 raeburn 7621: if (($match) && (ref($userdata) eq 'HASH')) {
7622: if (!exists($$userdata{$uname.':'.$udom})) {
7623: &get_user_info($udom,$uname,\%idx,$userdata);
7624: }
1.420 albertel 7625: if (!grep(/^\Q$usec\E$/,@{$seclists{$uname.':'.$udom}})) {
1.419 raeburn 7626: push(@{$seclists{$uname.':'.$udom}},$usec);
7627: }
1.609 raeburn 7628: if (ref($statushash) eq 'HASH') {
7629: $statushash->{$uname.':'.$udom}{$role}{$usec} = $displaystatus{$status};
7630: }
1.275 raeburn 7631: }
7632: }
7633: }
7634: }
1.290 albertel 7635: if (grep(/^ow$/,@{$roles})) {
1.279 raeburn 7636: if ((defined($cdom)) && (defined($cnum))) {
7637: my %csettings = &Apache::lonnet::get('environment',['internal.courseowner'],$cdom,$cnum);
7638: if ( defined($csettings{'internal.courseowner'}) ) {
7639: my $owner = $csettings{'internal.courseowner'};
1.609 raeburn 7640: next if ($owner eq '');
7641: my ($ownername,$ownerdom);
7642: if ($owner =~ /^([^:]+):([^:]+)$/) {
7643: $ownername = $1;
7644: $ownerdom = $2;
7645: } else {
7646: $ownername = $owner;
7647: $ownerdom = $cdom;
7648: $owner = $ownername.':'.$ownerdom;
1.439 raeburn 7649: }
7650: @{$$users{'ow'}{$owner}} = 'any';
1.290 albertel 7651: if (defined($userdata) &&
1.609 raeburn 7652: !exists($$userdata{$owner})) {
7653: &get_user_info($ownerdom,$ownername,\%idx,$userdata);
7654: if (!grep(/^none$/,@{$seclists{$owner}})) {
7655: push(@{$seclists{$owner}},'none');
7656: }
7657: if (ref($statushash) eq 'HASH') {
7658: $statushash->{$owner}{'ow'}{'none'} = 'Any';
1.419 raeburn 7659: }
1.290 albertel 7660: }
1.279 raeburn 7661: }
7662: }
7663: }
1.419 raeburn 7664: foreach my $user (keys(%seclists)) {
7665: @{$seclists{$user}} = (sort {$a <=> $b} @{$seclists{$user}});
7666: $$userdata{$user}[$idx{section}] = join(',',@{$seclists{$user}});
7667: }
1.275 raeburn 7668: }
7669: return;
7670: }
7671:
1.288 raeburn 7672: sub get_user_info {
7673: my ($udom,$uname,$idx,$userdata) = @_;
1.289 albertel 7674: $$userdata{$uname.':'.$udom}[$$idx{fullname}] =
7675: &plainname($uname,$udom,'lastname');
1.291 albertel 7676: $$userdata{$uname.':'.$udom}[$$idx{uname}] = $uname;
1.297 raeburn 7677: $$userdata{$uname.':'.$udom}[$$idx{udom}] = $udom;
1.609 raeburn 7678: my %idhash = &Apache::lonnet::idrget($udom,($uname));
7679: $$userdata{$uname.':'.$udom}[$$idx{id}] = $idhash{$uname};
1.288 raeburn 7680: return;
7681: }
1.275 raeburn 7682:
1.472 raeburn 7683: ###############################################
7684:
7685: =pod
7686:
7687: =item * &get_user_quota()
7688:
7689: Retrieves quota assigned for storage of portfolio files for a user
7690:
7691: Incoming parameters:
7692: 1. user's username
7693: 2. user's domain
7694:
7695: Returns:
1.536 raeburn 7696: 1. Disk quota (in Mb) assigned to student.
7697: 2. (Optional) Type of setting: custom or default
7698: (individually assigned or default for user's
7699: institutional status).
7700: 3. (Optional) - User's institutional status (e.g., faculty, staff
7701: or student - types as defined in localenroll::inst_usertypes
7702: for user's domain, which determines default quota for user.
7703: 4. (Optional) - Default quota which would apply to the user.
1.472 raeburn 7704:
7705: If a value has been stored in the user's environment,
1.536 raeburn 7706: it will return that, otherwise it returns the maximal default
7707: defined for the user's instituional status(es) in the domain.
1.472 raeburn 7708:
7709: =cut
7710:
7711: ###############################################
7712:
7713:
7714: sub get_user_quota {
7715: my ($uname,$udom) = @_;
1.536 raeburn 7716: my ($quota,$quotatype,$settingstatus,$defquota);
1.472 raeburn 7717: if (!defined($udom)) {
7718: $udom = $env{'user.domain'};
7719: }
7720: if (!defined($uname)) {
7721: $uname = $env{'user.name'};
7722: }
7723: if (($udom eq '' || $uname eq '') ||
7724: ($udom eq 'public') && ($uname eq 'public')) {
7725: $quota = 0;
1.536 raeburn 7726: $quotatype = 'default';
7727: $defquota = 0;
1.472 raeburn 7728: } else {
1.536 raeburn 7729: my $inststatus;
1.472 raeburn 7730: if ($udom eq $env{'user.domain'} && $uname eq $env{'user.name'}) {
7731: $quota = $env{'environment.portfolioquota'};
1.536 raeburn 7732: $inststatus = $env{'environment.inststatus'};
1.472 raeburn 7733: } else {
1.536 raeburn 7734: my %userenv =
7735: &Apache::lonnet::get('environment',['portfolioquota',
7736: 'inststatus'],$udom,$uname);
1.472 raeburn 7737: my ($tmp) = keys(%userenv);
7738: if ($tmp !~ /^(con_lost|error|no_such_host)/i) {
7739: $quota = $userenv{'portfolioquota'};
1.536 raeburn 7740: $inststatus = $userenv{'inststatus'};
1.472 raeburn 7741: } else {
7742: undef(%userenv);
7743: }
7744: }
1.536 raeburn 7745: ($defquota,$settingstatus) = &default_quota($udom,$inststatus);
1.472 raeburn 7746: if ($quota eq '') {
1.536 raeburn 7747: $quota = $defquota;
7748: $quotatype = 'default';
7749: } else {
7750: $quotatype = 'custom';
1.472 raeburn 7751: }
7752: }
1.536 raeburn 7753: if (wantarray) {
7754: return ($quota,$quotatype,$settingstatus,$defquota);
7755: } else {
7756: return $quota;
7757: }
1.472 raeburn 7758: }
7759:
7760: ###############################################
7761:
7762: =pod
7763:
7764: =item * &default_quota()
7765:
1.536 raeburn 7766: Retrieves default quota assigned for storage of user portfolio files,
7767: given an (optional) user's institutional status.
1.472 raeburn 7768:
7769: Incoming parameters:
7770: 1. domain
1.536 raeburn 7771: 2. (Optional) institutional status(es). This is a : separated list of
7772: status types (e.g., faculty, staff, student etc.)
7773: which apply to the user for whom the default is being retrieved.
7774: If the institutional status string in undefined, the domain
7775: default quota will be returned.
1.472 raeburn 7776:
7777: Returns:
7778: 1. Default disk quota (in Mb) for user portfolios in the domain.
1.536 raeburn 7779: 2. (Optional) institutional type which determined the value of the
7780: default quota.
1.472 raeburn 7781:
7782: If a value has been stored in the domain's configuration db,
7783: it will return that, otherwise it returns 20 (for backwards
7784: compatibility with domains which have not set up a configuration
7785: db file; the original statically defined portfolio quota was 20 Mb).
7786:
1.536 raeburn 7787: If the user's status includes multiple types (e.g., staff and student),
7788: the largest default quota which applies to the user determines the
7789: default quota returned.
7790:
1.780 raeburn 7791: =back
7792:
1.472 raeburn 7793: =cut
7794:
7795: ###############################################
7796:
7797:
7798: sub default_quota {
1.536 raeburn 7799: my ($udom,$inststatus) = @_;
7800: my ($defquota,$settingstatus);
7801: my %quotahash = &Apache::lonnet::get_dom('configuration',
1.622 raeburn 7802: ['quotas'],$udom);
7803: if (ref($quotahash{'quotas'}) eq 'HASH') {
1.536 raeburn 7804: if ($inststatus ne '') {
1.765 raeburn 7805: my @statuses = map { &unescape($_); } split(/:/,$inststatus);
1.536 raeburn 7806: foreach my $item (@statuses) {
1.711 raeburn 7807: if (ref($quotahash{'quotas'}{'defaultquota'}) eq 'HASH') {
7808: if ($quotahash{'quotas'}{'defaultquota'}{$item} ne '') {
7809: if ($defquota eq '') {
7810: $defquota = $quotahash{'quotas'}{'defaultquota'}{$item};
7811: $settingstatus = $item;
7812: } elsif ($quotahash{'quotas'}{'defaultquota'}{$item} > $defquota) {
7813: $defquota = $quotahash{'quotas'}{'defaultquota'}{$item};
7814: $settingstatus = $item;
7815: }
7816: }
7817: } else {
7818: if ($quotahash{'quotas'}{$item} ne '') {
7819: if ($defquota eq '') {
7820: $defquota = $quotahash{'quotas'}{$item};
7821: $settingstatus = $item;
7822: } elsif ($quotahash{'quotas'}{$item} > $defquota) {
7823: $defquota = $quotahash{'quotas'}{$item};
7824: $settingstatus = $item;
7825: }
1.536 raeburn 7826: }
7827: }
7828: }
7829: }
7830: if ($defquota eq '') {
1.711 raeburn 7831: if (ref($quotahash{'quotas'}{'defaultquota'}) eq 'HASH') {
7832: $defquota = $quotahash{'quotas'}{'defaultquota'}{'default'};
7833: } else {
7834: $defquota = $quotahash{'quotas'}{'default'};
7835: }
1.536 raeburn 7836: $settingstatus = 'default';
7837: }
7838: } else {
7839: $settingstatus = 'default';
7840: $defquota = 20;
7841: }
7842: if (wantarray) {
7843: return ($defquota,$settingstatus);
1.472 raeburn 7844: } else {
1.536 raeburn 7845: return $defquota;
1.472 raeburn 7846: }
7847: }
7848:
1.384 raeburn 7849: sub get_secgrprole_info {
7850: my ($cdom,$cnum,$needroles,$type) = @_;
7851: my %sections_count = &get_sections($cdom,$cnum);
7852: my @sections = (sort {$a <=> $b} keys(%sections_count));
7853: my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum);
7854: my @groups = sort(keys(%curr_groups));
7855: my $allroles = [];
7856: my $rolehash;
7857: my $accesshash = {
7858: active => 'Currently has access',
7859: future => 'Will have future access',
7860: previous => 'Previously had access',
7861: };
7862: if ($needroles) {
7863: $rolehash = {'all' => 'all'};
1.385 albertel 7864: my %user_roles = &Apache::lonnet::dump('nohist_userroles',$cdom,$cnum);
7865: if (&Apache::lonnet::error(%user_roles)) {
7866: undef(%user_roles);
7867: }
7868: foreach my $item (keys(%user_roles)) {
1.384 raeburn 7869: my ($role)=split(/\:/,$item,2);
7870: if ($role eq 'cr') { next; }
7871: if ($role =~ /^cr/) {
7872: $$rolehash{$role} = (split('/',$role))[3];
7873: } else {
7874: $$rolehash{$role} = &Apache::lonnet::plaintext($role,$type);
7875: }
7876: }
7877: foreach my $key (sort(keys(%{$rolehash}))) {
7878: push(@{$allroles},$key);
7879: }
7880: push (@{$allroles},'st');
7881: $$rolehash{'st'} = &Apache::lonnet::plaintext('st',$type);
7882: }
7883: return (\@sections,\@groups,$allroles,$rolehash,$accesshash);
7884: }
7885:
1.555 raeburn 7886: sub user_picker {
1.948.2.23 raeburn 7887: my ($dom,$srch,$forcenewuser,$caller,$cancreate,$usertype,$context) = @_;
1.555 raeburn 7888: my $currdom = $dom;
7889: my %curr_selected = (
7890: srchin => 'dom',
1.580 raeburn 7891: srchby => 'lastname',
1.555 raeburn 7892: );
7893: my $srchterm;
1.625 raeburn 7894: if ((ref($srch) eq 'HASH') && ($env{'form.origform'} ne 'crtusername')) {
1.555 raeburn 7895: if ($srch->{'srchby'} ne '') {
7896: $curr_selected{'srchby'} = $srch->{'srchby'};
7897: }
7898: if ($srch->{'srchin'} ne '') {
7899: $curr_selected{'srchin'} = $srch->{'srchin'};
7900: }
7901: if ($srch->{'srchtype'} ne '') {
7902: $curr_selected{'srchtype'} = $srch->{'srchtype'};
7903: }
7904: if ($srch->{'srchdomain'} ne '') {
7905: $currdom = $srch->{'srchdomain'};
7906: }
7907: $srchterm = $srch->{'srchterm'};
7908: }
7909: my %lt=&Apache::lonlocal::texthash(
1.573 raeburn 7910: 'usr' => 'Search criteria',
1.563 raeburn 7911: 'doma' => 'Domain/institution to search',
1.558 albertel 7912: 'uname' => 'username',
7913: 'lastname' => 'last name',
1.555 raeburn 7914: 'lastfirst' => 'last name, first name',
1.558 albertel 7915: 'crs' => 'in this course',
1.576 raeburn 7916: 'dom' => 'in selected LON-CAPA domain',
1.558 albertel 7917: 'alc' => 'all LON-CAPA',
1.573 raeburn 7918: 'instd' => 'in institutional directory for selected domain',
1.558 albertel 7919: 'exact' => 'is',
7920: 'contains' => 'contains',
1.569 raeburn 7921: 'begins' => 'begins with',
1.571 raeburn 7922: 'youm' => "You must include some text to search for.",
7923: 'thte' => "The text you are searching for must contain at least two characters when using a 'begins' type search.",
7924: 'thet' => "The text you are searching for must contain at least three characters when using a 'contains' type search.",
7925: 'yomc' => "You must choose a domain when using an institutional directory search.",
7926: 'ymcd' => "You must choose a domain when using a domain search.",
7927: 'whus' => "When using searching by last,first you must include a comma as separator between last name and first name.",
7928: 'whse' => "When searching by last,first you must include at least one character in the first name.",
7929: 'thfo' => "The following need to be corrected before the search can be run:",
1.555 raeburn 7930: );
1.563 raeburn 7931: my $domform = &select_dom_form($currdom,'srchdomain',1,1);
7932: my $srchinsel = ' <select name="srchin">';
1.555 raeburn 7933:
7934: my @srchins = ('crs','dom','alc','instd');
7935:
7936: foreach my $option (@srchins) {
7937: # FIXME 'alc' option unavailable until
7938: # loncreateuser::print_user_query_page()
7939: # has been completed.
7940: next if ($option eq 'alc');
1.880 raeburn 7941: next if (($option eq 'crs') && ($env{'form.form'} eq 'requestcrs'));
1.555 raeburn 7942: next if ($option eq 'crs' && !$env{'request.course.id'});
1.563 raeburn 7943: if ($curr_selected{'srchin'} eq $option) {
7944: $srchinsel .= '
7945: <option value="'.$option.'" selected="selected">'.$lt{$option}.'</option>';
7946: } else {
7947: $srchinsel .= '
7948: <option value="'.$option.'">'.$lt{$option}.'</option>';
7949: }
1.555 raeburn 7950: }
1.563 raeburn 7951: $srchinsel .= "\n </select>\n";
1.555 raeburn 7952:
7953: my $srchbysel = ' <select name="srchby">';
1.580 raeburn 7954: foreach my $option ('lastname','lastfirst','uname') {
1.555 raeburn 7955: if ($curr_selected{'srchby'} eq $option) {
7956: $srchbysel .= '
7957: <option value="'.$option.'" selected="selected">'.$lt{$option}.'</option>';
7958: } else {
7959: $srchbysel .= '
7960: <option value="'.$option.'">'.$lt{$option}.'</option>';
7961: }
7962: }
7963: $srchbysel .= "\n </select>\n";
7964:
7965: my $srchtypesel = ' <select name="srchtype">';
1.580 raeburn 7966: foreach my $option ('begins','contains','exact') {
1.555 raeburn 7967: if ($curr_selected{'srchtype'} eq $option) {
7968: $srchtypesel .= '
7969: <option value="'.$option.'" selected="selected">'.$lt{$option}.'</option>';
7970: } else {
7971: $srchtypesel .= '
7972: <option value="'.$option.'">'.$lt{$option}.'</option>';
7973: }
7974: }
7975: $srchtypesel .= "\n </select>\n";
7976:
1.558 albertel 7977: my ($newuserscript,$new_user_create);
1.948.2.23 raeburn 7978: my $context_dom = $env{'request.role.domain'};
7979: if ($context eq 'requestcrs') {
7980: if ($env{'form.coursedom'} ne '') {
7981: $context_dom = $env{'form.coursedom'};
7982: }
7983: }
1.556 raeburn 7984: if ($forcenewuser) {
1.576 raeburn 7985: if (ref($srch) eq 'HASH') {
1.948.2.23 raeburn 7986: if ($srch->{'srchby'} eq 'uname' && $srch->{'srchtype'} eq 'exact' && $srch->{'srchin'} eq 'dom' && $srch->{'srchdomain'} eq $context_dom) {
1.627 raeburn 7987: if ($cancreate) {
7988: $new_user_create = '<p> <input type="submit" name="forcenew" value="'.&HTML::Entities::encode(&mt('Make new user "[_1]"',$srchterm),'<>&"').'" onclick="javascript:setSearch(\'1\','.$caller.');" /> </p>';
7989: } else {
1.799 bisitz 7990: my $helplink = 'javascript:helpMenu('."'display'".')';
1.627 raeburn 7991: my %usertypetext = (
7992: official => 'institutional',
7993: unofficial => 'non-institutional',
7994: );
1.799 bisitz 7995: $new_user_create = '<p class="LC_warning">'
7996: .&mt("You are not authorized to create new $usertypetext{$usertype} users in this domain.")
7997: .' '
7998: .&mt('Please contact the [_1]helpdesk[_2] for assistance.'
7999: ,'<a href="'.$helplink.'">','</a>')
8000: .'</p><br />';
1.627 raeburn 8001: }
1.576 raeburn 8002: }
8003: }
8004:
1.556 raeburn 8005: $newuserscript = <<"ENDSCRIPT";
8006:
1.570 raeburn 8007: function setSearch(createnew,callingForm) {
1.556 raeburn 8008: if (createnew == 1) {
1.570 raeburn 8009: for (var i=0; i<callingForm.srchby.length; i++) {
8010: if (callingForm.srchby.options[i].value == 'uname') {
8011: callingForm.srchby.selectedIndex = i;
1.556 raeburn 8012: }
8013: }
1.570 raeburn 8014: for (var i=0; i<callingForm.srchin.length; i++) {
8015: if ( callingForm.srchin.options[i].value == 'dom') {
8016: callingForm.srchin.selectedIndex = i;
1.556 raeburn 8017: }
8018: }
1.570 raeburn 8019: for (var i=0; i<callingForm.srchtype.length; i++) {
8020: if (callingForm.srchtype.options[i].value == 'exact') {
8021: callingForm.srchtype.selectedIndex = i;
1.556 raeburn 8022: }
8023: }
1.570 raeburn 8024: for (var i=0; i<callingForm.srchdomain.length; i++) {
1.948.2.23 raeburn 8025: if (callingForm.srchdomain.options[i].value == '$context_dom') {
1.570 raeburn 8026: callingForm.srchdomain.selectedIndex = i;
1.556 raeburn 8027: }
8028: }
8029: }
8030: }
8031: ENDSCRIPT
1.558 albertel 8032:
1.556 raeburn 8033: }
8034:
1.555 raeburn 8035: my $output = <<"END_BLOCK";
1.556 raeburn 8036: <script type="text/javascript">
1.824 bisitz 8037: // <![CDATA[
1.570 raeburn 8038: function validateEntry(callingForm) {
1.558 albertel 8039:
1.556 raeburn 8040: var checkok = 1;
1.558 albertel 8041: var srchin;
1.570 raeburn 8042: for (var i=0; i<callingForm.srchin.length; i++) {
8043: if ( callingForm.srchin[i].checked ) {
8044: srchin = callingForm.srchin[i].value;
1.558 albertel 8045: }
8046: }
8047:
1.570 raeburn 8048: var srchtype = callingForm.srchtype.options[callingForm.srchtype.selectedIndex].value;
8049: var srchby = callingForm.srchby.options[callingForm.srchby.selectedIndex].value;
8050: var srchdomain = callingForm.srchdomain.options[callingForm.srchdomain.selectedIndex].value;
8051: var srchterm = callingForm.srchterm.value;
8052: var srchin = callingForm.srchin.options[callingForm.srchin.selectedIndex].value;
1.556 raeburn 8053: var msg = "";
8054:
8055: if (srchterm == "") {
8056: checkok = 0;
1.571 raeburn 8057: msg += "$lt{'youm'}\\n";
1.556 raeburn 8058: }
8059:
1.569 raeburn 8060: if (srchtype== 'begins') {
8061: if (srchterm.length < 2) {
8062: checkok = 0;
1.571 raeburn 8063: msg += "$lt{'thte'}\\n";
1.569 raeburn 8064: }
8065: }
8066:
1.556 raeburn 8067: if (srchtype== 'contains') {
8068: if (srchterm.length < 3) {
8069: checkok = 0;
1.571 raeburn 8070: msg += "$lt{'thet'}\\n";
1.556 raeburn 8071: }
8072: }
8073: if (srchin == 'instd') {
8074: if (srchdomain == '') {
8075: checkok = 0;
1.571 raeburn 8076: msg += "$lt{'yomc'}\\n";
1.556 raeburn 8077: }
8078: }
8079: if (srchin == 'dom') {
8080: if (srchdomain == '') {
8081: checkok = 0;
1.571 raeburn 8082: msg += "$lt{'ymcd'}\\n";
1.556 raeburn 8083: }
8084: }
8085: if (srchby == 'lastfirst') {
8086: if (srchterm.indexOf(",") == -1) {
8087: checkok = 0;
1.571 raeburn 8088: msg += "$lt{'whus'}\\n";
1.556 raeburn 8089: }
8090: if (srchterm.indexOf(",") == srchterm.length -1) {
8091: checkok = 0;
1.571 raeburn 8092: msg += "$lt{'whse'}\\n";
1.556 raeburn 8093: }
8094: }
8095: if (checkok == 0) {
1.571 raeburn 8096: alert("$lt{'thfo'}\\n"+msg);
1.556 raeburn 8097: return;
8098: }
8099: if (checkok == 1) {
1.570 raeburn 8100: callingForm.submit();
1.556 raeburn 8101: }
8102: }
8103:
8104: $newuserscript
8105:
1.824 bisitz 8106: // ]]>
1.556 raeburn 8107: </script>
1.558 albertel 8108:
8109: $new_user_create
8110:
1.555 raeburn 8111: END_BLOCK
1.558 albertel 8112:
1.876 raeburn 8113: $output .= &Apache::lonhtmlcommon::start_pick_box().
8114: &Apache::lonhtmlcommon::row_title($lt{'doma'}).
8115: $domform.
8116: &Apache::lonhtmlcommon::row_closure().
8117: &Apache::lonhtmlcommon::row_title($lt{'usr'}).
8118: $srchbysel.
8119: $srchtypesel.
8120: '<input type="text" size="15" name="srchterm" value="'.$srchterm.'" />'.
8121: $srchinsel.
8122: &Apache::lonhtmlcommon::row_closure(1).
8123: &Apache::lonhtmlcommon::end_pick_box().
8124: '<br />';
1.555 raeburn 8125: return $output;
8126: }
8127:
1.612 raeburn 8128: sub user_rule_check {
1.615 raeburn 8129: my ($usershash,$checks,$alerts,$rulematch,$inst_results,$curr_rules,$got_rules) = @_;
1.612 raeburn 8130: my $response;
8131: if (ref($usershash) eq 'HASH') {
8132: foreach my $user (keys(%{$usershash})) {
8133: my ($uname,$udom) = split(/:/,$user);
8134: next if ($udom eq '' || $uname eq '');
1.615 raeburn 8135: my ($id,$newuser);
1.612 raeburn 8136: if (ref($usershash->{$user}) eq 'HASH') {
1.615 raeburn 8137: $newuser = $usershash->{$user}->{'newuser'};
1.612 raeburn 8138: $id = $usershash->{$user}->{'id'};
8139: }
8140: my $inst_response;
8141: if (ref($checks) eq 'HASH') {
8142: if (defined($checks->{'username'})) {
1.615 raeburn 8143: ($inst_response,%{$inst_results->{$user}}) =
1.612 raeburn 8144: &Apache::lonnet::get_instuser($udom,$uname);
8145: } elsif (defined($checks->{'id'})) {
1.615 raeburn 8146: ($inst_response,%{$inst_results->{$user}}) =
1.612 raeburn 8147: &Apache::lonnet::get_instuser($udom,undef,$id);
8148: }
1.615 raeburn 8149: } else {
8150: ($inst_response,%{$inst_results->{$user}}) =
8151: &Apache::lonnet::get_instuser($udom,$uname);
8152: return;
1.612 raeburn 8153: }
1.615 raeburn 8154: if (!$got_rules->{$udom}) {
1.612 raeburn 8155: my %domconfig = &Apache::lonnet::get_dom('configuration',
8156: ['usercreation'],$udom);
8157: if (ref($domconfig{'usercreation'}) eq 'HASH') {
1.615 raeburn 8158: foreach my $item ('username','id') {
1.612 raeburn 8159: if (ref($domconfig{'usercreation'}{$item.'_rule'}) eq 'ARRAY') {
8160: $$curr_rules{$udom}{$item} =
8161: $domconfig{'usercreation'}{$item.'_rule'};
1.585 raeburn 8162: }
8163: }
8164: }
1.615 raeburn 8165: $got_rules->{$udom} = 1;
1.585 raeburn 8166: }
1.612 raeburn 8167: foreach my $item (keys(%{$checks})) {
8168: if (ref($$curr_rules{$udom}) eq 'HASH') {
8169: if (ref($$curr_rules{$udom}{$item}) eq 'ARRAY') {
8170: if (@{$$curr_rules{$udom}{$item}} > 0) {
8171: my %rule_check = &Apache::lonnet::inst_rulecheck($udom,$uname,$id,$item,$$curr_rules{$udom}{$item});
8172: foreach my $rule (@{$$curr_rules{$udom}{$item}}) {
8173: if ($rule_check{$rule}) {
8174: $$rulematch{$user}{$item} = $rule;
8175: if ($inst_response eq 'ok') {
1.615 raeburn 8176: if (ref($inst_results) eq 'HASH') {
8177: if (ref($inst_results->{$user}) eq 'HASH') {
8178: if (keys(%{$inst_results->{$user}}) == 0) {
8179: $$alerts{$item}{$udom}{$uname} = 1;
8180: }
1.612 raeburn 8181: }
8182: }
1.615 raeburn 8183: }
8184: last;
1.585 raeburn 8185: }
8186: }
8187: }
8188: }
8189: }
8190: }
8191: }
8192: }
1.612 raeburn 8193: return;
8194: }
8195:
8196: sub user_rule_formats {
8197: my ($domain,$domdesc,$curr_rules,$check) = @_;
8198: my %text = (
8199: 'username' => 'Usernames',
8200: 'id' => 'IDs',
8201: );
8202: my $output;
8203: my ($rules,$ruleorder) = &Apache::lonnet::inst_userrules($domain,$check);
8204: if ((ref($rules) eq 'HASH') && (ref($ruleorder) eq 'ARRAY')) {
8205: if (@{$ruleorder} > 0) {
8206: $output = '<br />'.&mt("$text{$check} with the following format(s) may <span class=\"LC_cusr_emph\">only</span> be used for verified users at [_1]:",$domdesc).' <ul>';
8207: foreach my $rule (@{$ruleorder}) {
8208: if (ref($curr_rules) eq 'ARRAY') {
8209: if (grep(/^\Q$rule\E$/,@{$curr_rules})) {
8210: if (ref($rules->{$rule}) eq 'HASH') {
8211: $output .= '<li>'.$rules->{$rule}{'name'}.': '.
8212: $rules->{$rule}{'desc'}.'</li>';
8213: }
8214: }
8215: }
8216: }
8217: $output .= '</ul>';
8218: }
8219: }
8220: return $output;
8221: }
8222:
8223: sub instrule_disallow_msg {
1.615 raeburn 8224: my ($checkitem,$domdesc,$count,$mode) = @_;
1.612 raeburn 8225: my $response;
8226: my %text = (
8227: item => 'username',
8228: items => 'usernames',
8229: match => 'matches',
8230: do => 'does',
8231: action => 'a username',
8232: one => 'one',
8233: );
8234: if ($count > 1) {
8235: $text{'item'} = 'usernames';
8236: $text{'match'} ='match';
8237: $text{'do'} = 'do';
8238: $text{'action'} = 'usernames',
8239: $text{'one'} = 'ones';
8240: }
8241: if ($checkitem eq 'id') {
8242: $text{'items'} = 'IDs';
8243: $text{'item'} = 'ID';
8244: $text{'action'} = 'an ID';
1.615 raeburn 8245: if ($count > 1) {
8246: $text{'item'} = 'IDs';
8247: $text{'action'} = 'IDs';
8248: }
1.612 raeburn 8249: }
1.674 bisitz 8250: $response = &mt("The $text{'item'} you chose $text{'match'} the format of $text{'items'} defined for [_1], but the $text{'item'} $text{'do'} not exist in the institutional directory.",'<span class="LC_cusr_emph">'.$domdesc.'</span>').'<br />';
1.615 raeburn 8251: if ($mode eq 'upload') {
8252: if ($checkitem eq 'username') {
8253: $response .= &mt("You will need to modify your upload file so it will include $text{'action'} with a different format -- $text{'one'} that will not conflict with 'official' institutional $text{'items'}.");
8254: } elsif ($checkitem eq 'id') {
1.674 bisitz 8255: $response .= &mt("Either upload a file which includes $text{'action'} with a different format -- $text{'one'} that will not conflict with 'official' institutional $text{'items'}, or when associating fields with data columns, omit an association for the Student/Employee ID field.");
1.615 raeburn 8256: }
1.669 raeburn 8257: } elsif ($mode eq 'selfcreate') {
8258: if ($checkitem eq 'id') {
8259: $response .= &mt("You must either choose $text{'action'} with a different format -- $text{'one'} that will not conflict with 'official' institutional $text{'items'}, or leave the ID field blank.");
8260: }
1.615 raeburn 8261: } else {
8262: if ($checkitem eq 'username') {
8263: $response .= &mt("You must choose $text{'action'} with a different format -- $text{'one'} that will not conflict with 'official' institutional $text{'items'}.");
8264: } elsif ($checkitem eq 'id') {
8265: $response .= &mt("You must either choose $text{'action'} with a different format -- $text{'one'} that will not conflict with 'official' institutional $text{'items'}, or leave the ID field blank.");
8266: }
1.612 raeburn 8267: }
8268: return $response;
1.585 raeburn 8269: }
8270:
1.624 raeburn 8271: sub personal_data_fieldtitles {
8272: my %fieldtitles = &Apache::lonlocal::texthash (
8273: id => 'Student/Employee ID',
8274: permanentemail => 'E-mail address',
8275: lastname => 'Last Name',
8276: firstname => 'First Name',
8277: middlename => 'Middle Name',
8278: generation => 'Generation',
8279: gen => 'Generation',
1.765 raeburn 8280: inststatus => 'Affiliation',
1.624 raeburn 8281: );
8282: return %fieldtitles;
8283: }
8284:
1.642 raeburn 8285: sub sorted_inst_types {
8286: my ($dom) = @_;
8287: my ($usertypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($dom);
8288: my $othertitle = &mt('All users');
8289: if ($env{'request.course.id'}) {
1.668 raeburn 8290: $othertitle = &mt('Any users');
1.642 raeburn 8291: }
8292: my @types;
8293: if (ref($order) eq 'ARRAY') {
8294: @types = @{$order};
8295: }
8296: if (@types == 0) {
8297: if (ref($usertypes) eq 'HASH') {
8298: @types = sort(keys(%{$usertypes}));
8299: }
8300: }
8301: if (keys(%{$usertypes}) > 0) {
8302: $othertitle = &mt('Other users');
8303: }
8304: return ($othertitle,$usertypes,\@types);
8305: }
8306:
1.645 raeburn 8307: sub get_institutional_codes {
8308: my ($settings,$allcourses,$LC_code) = @_;
8309: # Get complete list of course sections to update
8310: my @currsections = ();
8311: my @currxlists = ();
8312: my $coursecode = $$settings{'internal.coursecode'};
8313:
8314: if ($$settings{'internal.sectionnums'} ne '') {
8315: @currsections = split(/,/,$$settings{'internal.sectionnums'});
8316: }
8317:
8318: if ($$settings{'internal.crosslistings'} ne '') {
8319: @currxlists = split(/,/,$$settings{'internal.crosslistings'});
8320: }
8321:
8322: if (@currxlists > 0) {
8323: foreach (@currxlists) {
8324: if (m/^([^:]+):(\w*)$/) {
8325: unless (grep/^$1$/,@{$allcourses}) {
8326: push @{$allcourses},$1;
8327: $$LC_code{$1} = $2;
8328: }
8329: }
8330: }
8331: }
8332:
8333: if (@currsections > 0) {
8334: foreach (@currsections) {
8335: if (m/^(\w+):(\w*)$/) {
8336: my $sec = $coursecode.$1;
8337: my $lc_sec = $2;
8338: unless (grep/^$sec$/,@{$allcourses}) {
8339: push @{$allcourses},$sec;
8340: $$LC_code{$sec} = $lc_sec;
8341: }
8342: }
8343: }
8344: }
8345: return;
8346: }
8347:
1.948.2.7 raeburn 8348: sub get_standard_codeitems {
8349: return ('Year','Semester','Department','Number','Section');
8350: }
8351:
1.112 bowersj2 8352: =pod
8353:
1.780 raeburn 8354: =head1 Slot Helpers
8355:
8356: =over 4
8357:
8358: =item * sorted_slots()
8359:
8360: Sorts an array of slot names in order of slot start time (earliest first).
8361:
8362: Inputs:
8363:
8364: =over 4
8365:
8366: slotsarr - Reference to array of unsorted slot names.
8367:
8368: slots - Reference to hash of hash, where outer hash keys are slot names.
8369:
1.549 albertel 8370: =back
8371:
1.780 raeburn 8372: Returns:
8373:
8374: =over 4
8375:
8376: sorted - An array of slot names sorted by the start time of the slot.
8377:
8378: =back
8379:
8380: =back
8381:
8382: =cut
8383:
8384:
8385: sub sorted_slots {
8386: my ($slotsarr,$slots) = @_;
8387: my @sorted;
8388: if ((ref($slotsarr) eq 'ARRAY') && (ref($slots) eq 'HASH')) {
8389: @sorted =
8390: sort {
8391: if (ref($slots->{$a}) && ref($slots->{$b})) {
8392: return $slots->{$a}{'starttime'} <=> $slots->{$b}{'starttime'}
8393: }
8394: if (ref($slots->{$a})) { return -1;}
8395: if (ref($slots->{$b})) { return 1;}
8396: return 0;
8397: } @{$slotsarr};
8398: }
8399: return @sorted;
8400: }
8401:
8402:
8403: =pod
8404:
1.549 albertel 8405: =head1 HTTP Helpers
8406:
8407: =over 4
8408:
1.648 raeburn 8409: =item * &get_unprocessed_cgi($query,$possible_names)
1.112 bowersj2 8410:
1.258 albertel 8411: Modify the %env hash to contain unprocessed CGI form parameters held in
1.112 bowersj2 8412: $query. The parameters listed in $possible_names (an array reference),
1.258 albertel 8413: will be set in $env{'form.name'} if they do not already exist.
1.112 bowersj2 8414:
8415: Typically called with $ENV{'QUERY_STRING'} as the first parameter.
8416: $possible_names is an ref to an array of form element names. As an example:
8417: get_unprocessed_cgi($ENV{'QUERY_STRING'},['uname','udom']);
1.258 albertel 8418: will result in $env{'form.uname'} and $env{'form.udom'} being set.
1.112 bowersj2 8419:
8420: =cut
1.1 albertel 8421:
1.6 albertel 8422: sub get_unprocessed_cgi {
1.25 albertel 8423: my ($query,$possible_names)= @_;
1.26 matthew 8424: # $Apache::lonxml::debug=1;
1.356 albertel 8425: foreach my $pair (split(/&/,$query)) {
8426: my ($name, $value) = split(/=/,$pair);
1.369 www 8427: $name = &unescape($name);
1.25 albertel 8428: if (!defined($possible_names) || (grep {$_ eq $name} @$possible_names)) {
8429: $value =~ tr/+/ /;
8430: $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
1.258 albertel 8431: unless (defined($env{'form.'.$name})) { &add_to_env('form.'.$name,$value) };
1.25 albertel 8432: }
1.16 harris41 8433: }
1.6 albertel 8434: }
8435:
1.112 bowersj2 8436: =pod
8437:
1.648 raeburn 8438: =item * &cacheheader()
1.112 bowersj2 8439:
8440: returns cache-controlling header code
8441:
8442: =cut
8443:
1.7 albertel 8444: sub cacheheader {
1.258 albertel 8445: unless ($env{'request.method'} eq 'GET') { return ''; }
1.216 albertel 8446: my $date=strftime("%a, %d %b %Y %H:%M:%S GMT",gmtime);
8447: my $output .='<meta HTTP-EQUIV="Expires" CONTENT="'.$date.'" />
1.7 albertel 8448: <meta HTTP-EQUIV="Cache-control" CONTENT="no-cache" />
8449: <meta HTTP-EQUIV="Pragma" CONTENT="no-cache" />';
1.216 albertel 8450: return $output;
1.7 albertel 8451: }
8452:
1.112 bowersj2 8453: =pod
8454:
1.648 raeburn 8455: =item * &no_cache($r)
1.112 bowersj2 8456:
8457: specifies header code to not have cache
8458:
8459: =cut
8460:
1.9 albertel 8461: sub no_cache {
1.216 albertel 8462: my ($r) = @_;
8463: if ($ENV{'REQUEST_METHOD'} ne 'GET' &&
1.258 albertel 8464: $env{'request.method'} ne 'GET') { return ''; }
1.216 albertel 8465: my $date=strftime("%a, %d %b %Y %H:%M:%S GMT",gmtime(time));
8466: $r->no_cache(1);
8467: $r->header_out("Expires" => $date);
8468: $r->header_out("Pragma" => "no-cache");
1.123 www 8469: }
8470:
8471: sub content_type {
1.181 albertel 8472: my ($r,$type,$charset) = @_;
1.299 foxr 8473: if ($r) {
8474: # Note that printout.pl calls this with undef for $r.
8475: &no_cache($r);
8476: }
1.258 albertel 8477: if ($env{'browser.mathml'} && $type eq 'text/html') { $type='text/xml'; }
1.181 albertel 8478: unless ($charset) {
8479: $charset=&Apache::lonlocal::current_encoding;
8480: }
8481: if ($charset) { $type.='; charset='.$charset; }
8482: if ($r) {
8483: $r->content_type($type);
8484: } else {
8485: print("Content-type: $type\n\n");
8486: }
1.9 albertel 8487: }
1.25 albertel 8488:
1.112 bowersj2 8489: =pod
8490:
1.648 raeburn 8491: =item * &add_to_env($name,$value)
1.112 bowersj2 8492:
1.258 albertel 8493: adds $name to the %env hash with value
1.112 bowersj2 8494: $value, if $name already exists, the entry is converted to an array
8495: reference and $value is added to the array.
8496:
8497: =cut
8498:
1.25 albertel 8499: sub add_to_env {
8500: my ($name,$value)=@_;
1.258 albertel 8501: if (defined($env{$name})) {
8502: if (ref($env{$name})) {
1.25 albertel 8503: #already have multiple values
1.258 albertel 8504: push(@{ $env{$name} },$value);
1.25 albertel 8505: } else {
8506: #first time seeing multiple values, convert hash entry to an arrayref
1.258 albertel 8507: my $first=$env{$name};
8508: undef($env{$name});
8509: push(@{ $env{$name} },$first,$value);
1.25 albertel 8510: }
8511: } else {
1.258 albertel 8512: $env{$name}=$value;
1.25 albertel 8513: }
1.31 albertel 8514: }
1.149 albertel 8515:
8516: =pod
8517:
1.648 raeburn 8518: =item * &get_env_multiple($name)
1.149 albertel 8519:
1.258 albertel 8520: gets $name from the %env hash, it seemlessly handles the cases where multiple
1.149 albertel 8521: values may be defined and end up as an array ref.
8522:
8523: returns an array of values
8524:
8525: =cut
8526:
8527: sub get_env_multiple {
8528: my ($name) = @_;
8529: my @values;
1.258 albertel 8530: if (defined($env{$name})) {
1.149 albertel 8531: # exists is it an array
1.258 albertel 8532: if (ref($env{$name})) {
8533: @values=@{ $env{$name} };
1.149 albertel 8534: } else {
1.258 albertel 8535: $values[0]=$env{$name};
1.149 albertel 8536: }
8537: }
8538: return(@values);
8539: }
8540:
1.660 raeburn 8541: sub ask_for_embedded_content {
8542: my ($actionurl,$state,$allfiles,$codebase,$args)=@_;
1.948.2.17 raeburn 8543: my (%subdependencies,%dependencies,%mapping,%existing,%newfiles,%pathchanges);
1.660 raeburn 8544: my $num = 0;
1.948.2.17 raeburn 8545: my $numremref = 0;
8546: my $numinvalid = 0;
8547: my $numpathchg = 0;
8548: my $numexisting = 0;
8549: my ($output,$upload_output,$toplevel,$url,$udom,$uname,$getpropath);
1.948.2.12 raeburn 8550: if (($actionurl eq '/adm/portfolio') || ($actionurl eq '/adm/coursegrp_portfolio')) {
8551: my $current_path='/';
8552: if ($env{'form.currentpath'}) {
8553: $current_path = $env{'form.currentpath'};
8554: }
8555: if ($actionurl eq '/adm/coursegrp_portfolio') {
8556: $udom = $env{'course.'.$env{'request.course.id'}.'.domain'};
8557: $uname = $env{'course.'.$env{'request.course.id'}.'.num'};
8558: $url = '/userfiles/groups/'.$env{'form.group'}.'/portfolio';
8559: } else {
8560: $udom = $env{'user.domain'};
8561: $uname = $env{'user.name'};
8562: $url = '/userfiles/portfolio';
8563: }
1.948.2.17 raeburn 8564: $toplevel = $url.'/';
1.948.2.12 raeburn 8565: $url .= $current_path;
8566: $getpropath = 1;
1.948.2.17 raeburn 8567: } elsif (($actionurl eq '/adm/upload') || ($actionurl eq '/adm/testbank') ||
8568: ($actionurl eq '/adm/imsimport')) {
1.948.2.12 raeburn 8569: ($uname,my $rest) = ($args->{'current_path'} =~ m{/priv/($match_username)/?(.*)$});
1.948.2.17 raeburn 8570: $url = '/home/'.$uname.'/public_html/';
8571: $toplevel = $url;
1.948.2.12 raeburn 8572: if ($rest ne '') {
1.948.2.17 raeburn 8573: $url .= $rest;
8574: }
8575: } elsif ($actionurl eq '/adm/coursedocs') {
8576: if (ref($args) eq 'HASH') {
8577: $url = $args->{'docs_url'};
8578: $toplevel = $url;
8579: }
8580: }
8581: my $now = time();
8582: foreach my $embed_file (keys(%{$allfiles})) {
8583: my $absolutepath;
8584: if ($embed_file =~ m{^\w+://}) {
8585: $newfiles{$embed_file} = 1;
8586: $mapping{$embed_file} = $embed_file;
8587: } else {
8588: if ($embed_file =~ m{^/}) {
8589: $absolutepath = $embed_file;
8590: $embed_file =~ s{^(/+)}{};
8591: }
8592: if ($embed_file =~ m{/}) {
8593: my ($path,$fname) = ($embed_file =~ m{^(.+)/([^/]*)$});
8594: $path = &check_for_traversal($path,$url,$toplevel);
8595: my $item = $fname;
8596: if ($path ne '') {
8597: $item = $path.'/'.$fname;
8598: $subdependencies{$path}{$fname} = 1;
8599: } else {
8600: $dependencies{$item} = 1;
8601: }
8602: if ($absolutepath) {
8603: $mapping{$item} = $absolutepath;
8604: } else {
8605: $mapping{$item} = $embed_file;
8606: }
8607: } else {
8608: $dependencies{$embed_file} = 1;
8609: if ($absolutepath) {
8610: $mapping{$embed_file} = $absolutepath;
8611: } else {
8612: $mapping{$embed_file} = $embed_file;
8613: }
8614: }
1.948.2.12 raeburn 8615: }
8616: }
8617: foreach my $path (keys(%subdependencies)) {
8618: my %currsubfile;
8619: if (($actionurl eq '/adm/portfolio') || ($actionurl eq '/adm/coursegrp_portfolio')) {
8620: my @subdir_list = &Apache::lonnet::dirlist($url.$path,$udom,$uname,$getpropath);
8621: foreach my $line (@subdir_list) {
8622: my ($file_name,$rest) = split(/\&/,$line,2);
8623: $currsubfile{$file_name} = 1;
8624: }
1.948.2.17 raeburn 8625: } elsif (($actionurl eq '/adm/upload') || ($actionurl eq '/adm/testbank')) {
1.948.2.12 raeburn 8626: if (opendir(my $dir,$url.'/'.$path)) {
8627: my @subdir_list = grep(!/^\./,readdir($dir));
8628: map {$currsubfile{$_} = 1;} @subdir_list;
8629: }
8630: }
8631: foreach my $file (keys(%{$subdependencies{$path}})) {
1.948.2.17 raeburn 8632: if ($currsubfile{$file}) {
8633: my $item = $path.'/'.$file;
8634: unless ($mapping{$item} eq $item) {
8635: $pathchanges{$item} = 1;
8636: }
8637: $existing{$item} = 1;
8638: $numexisting ++;
8639: } else {
8640: $newfiles{$path.'/'.$file} = 1;
1.948.2.12 raeburn 8641: }
8642: }
8643: }
1.948.2.17 raeburn 8644: my %currfile;
1.948.2.12 raeburn 8645: if (($actionurl eq '/adm/portfolio') || ($actionurl eq '/adm/coursegrp_portfolio')) {
8646: my @dir_list = &Apache::lonnet::dirlist($url,$udom,$uname,$getpropath);
8647: foreach my $line (@dir_list) {
8648: my ($file_name,$rest) = split(/\&/,$line,2);
8649: $currfile{$file_name} = 1;
8650: }
1.948.2.17 raeburn 8651: } elsif (($actionurl eq '/adm/upload') || ($actionurl eq '/adm/testbank')) {
1.948.2.12 raeburn 8652: if (opendir(my $dir,$url)) {
1.948.2.17 raeburn 8653: my @dir_list = grep(!/^\./,readdir($dir));
1.948.2.12 raeburn 8654: map {$currfile{$_} = 1;} @dir_list;
8655: }
8656: }
8657: foreach my $file (keys(%dependencies)) {
1.948.2.17 raeburn 8658: if ($currfile{$file}) {
8659: unless ($mapping{$file} eq $file) {
8660: $pathchanges{$file} = 1;
8661: }
8662: $existing{$file} = 1;
8663: $numexisting ++;
8664: } else {
1.948.2.12 raeburn 8665: $newfiles{$file} = 1;
8666: }
8667: }
8668: foreach my $embed_file (sort {lc($a) cmp lc($b)} keys(%newfiles)) {
1.660 raeburn 8669: $upload_output .= &start_data_table_row().
1.948.2.17 raeburn 8670: '<td><span class="LC_filename">'.$embed_file.'</span>';
8671: unless ($mapping{$embed_file} eq $embed_file) {
8672: $upload_output .= '<br /><span class="LC_info" style="font-size:smaller;">'.&mt('changed from: [_1]',$mapping{$embed_file}).'</span>';
8673: }
8674: $upload_output .= '</td><td>';
1.660 raeburn 8675: if ($args->{'ignore_remote_references'}
8676: && $embed_file =~ m{^\w+://}) {
8677: $upload_output.='<span class="LC_warning">'.&mt("URL points to other server.").'</span>';
1.948.2.17 raeburn 8678: $numremref++;
1.660 raeburn 8679: } elsif ($args->{'error_on_invalid_names'}
8680: && $embed_file ne &Apache::lonnet::clean_filename($embed_file,{'keep_path' => 1,})) {
8681:
1.948.2.17 raeburn 8682: $upload_output.='<span class="LC_warning">'.&mt('Invalid characters').'</span>';
8683: $numinvalid++;
1.660 raeburn 8684: } else {
1.948.2.17 raeburn 8685: $upload_output .= &embedded_file_element('upload_embedded',$num,
8686: $embed_file,\%mapping,
8687: $allfiles,$codebase);
8688: $num++;
1.660 raeburn 8689: }
1.948.2.12 raeburn 8690: $upload_output .= '</td>'.&Apache::loncommon::end_data_table_row()."\n";
1.660 raeburn 8691: }
1.948.2.17 raeburn 8692: foreach my $embed_file (sort {lc($a) cmp lc($b)} keys(%existing)) {
8693: $upload_output .= &start_data_table_row().
8694: '<td><span class="LC_filename">'.$embed_file.'</span></td>'.
8695: '<td><span class="LC_warning">'.&mt('Already exists').'</span></td>'.
8696: &Apache::loncommon::end_data_table_row()."\n";
8697: }
8698: if ($upload_output) {
8699: $upload_output = &start_data_table().
1.948.2.12 raeburn 8700: $upload_output.
1.948.2.17 raeburn 8701: &end_data_table()."\n";
8702: }
8703: my $applies = 0;
8704: if ($numremref) {
8705: $applies ++;
8706: }
8707: if ($numinvalid) {
8708: $applies ++;
8709: }
8710: if ($numexisting) {
8711: $applies ++;
8712: }
8713: if ($num) {
8714: $output = '<form name="upload_embedded" action="'.$actionurl.'"'.
8715: ' method="post" enctype="multipart/form-data">'."\n".
8716: $state.
8717: '<h3>'.&mt('Upload embedded files').
8718: ':</h3>'.$upload_output.'<br />'."\n".
8719: '<input type ="hidden" name="number_embedded_items" value="'.
8720: $num.'" />'."\n";
8721: if ($actionurl eq '') {
8722: $output .= '<input type="hidden" name="phase" value="three" />';
8723: }
8724: } elsif ($applies) {
8725: $output = '<b>'.&mt('Referenced files').'</b>:<br />';
8726: if ($applies > 1) {
8727: $output .=
8728: &mt('No files need to be uploaded, as one of the following applies to each reference:').'<ul>';
8729: if ($numremref) {
8730: $output .= '<li>'.&mt('reference is to a URL which points to another server').'</li>'."\n";
8731: }
8732: if ($numinvalid) {
8733: $output .= '<li>'.&mt('reference is to file with a name containing invalid characters').'</li>'."\n";
8734: }
8735: if ($numexisting) {
8736: $output .= '<li>'.&mt('reference is to an existing file at the specified location').'</li>'."\n";
8737: }
8738: $output .= '</ul><br />';
8739: } elsif ($numremref) {
8740: $output .= '<p>'.&mt('None to upload, as all references are to URLs pointing to another server.').'</p>';
8741: } elsif ($numinvalid) {
8742: $output .= '<p>'.&mt('None to upload, as all references are to files with names containing invalid characters.').'</p>';
8743: } elsif ($numexisting) {
8744: $output .= '<p>'.&mt('None to upload, as all references are to existing files.').'</p>';
8745: }
8746: $output .= $upload_output.'<br />';
8747: }
8748: my ($pathchange_output,$chgcount);
8749: $chgcount = $num;
8750: if (keys(%pathchanges) > 0) {
8751: foreach my $embed_file (sort {lc($a) cmp lc($b)} keys(%pathchanges)) {
8752: if ($num) {
8753: $output .= &embedded_file_element('pathchange',$chgcount,
8754: $embed_file,\%mapping,
8755: $allfiles,$codebase);
8756: } else {
8757: $pathchange_output .=
8758: &start_data_table_row().
8759: '<td><input type ="checkbox" name="namechange" value="'.
8760: $chgcount.'" checked="checked" /></td>'.
8761: '<td>'.$mapping{$embed_file}.'</td>'.
8762: '<td>'.$embed_file.
8763: &embedded_file_element('pathchange',$numpathchg,$embed_file,
8764: \%mapping,$allfiles,$codebase).
8765: '</td>'.&end_data_table_row();
8766: }
8767: $numpathchg ++;
8768: $chgcount ++;
8769: }
8770: }
8771: if ($num) {
8772: if ($numpathchg) {
8773: $output .= '<input type ="hidden" name="number_pathchange_items" value="'.
8774: $numpathchg.'" />'."\n";
8775: }
8776: if (($actionurl eq '/adm/upload') || ($actionurl eq '/adm/testbank') ||
8777: ($actionurl eq '/adm/imsimport')) {
8778: $output .= '<input type="hidden" name="phase" value="three" />'."\n";
8779: } elsif ($actionurl eq '/adm/portfolio' || $actionurl eq '/adm/coursegrp_portfolio') {
8780: $output .= '<input type="hidden" name="action" value="upload_embedded" />';
8781: }
8782: $output .= '<input type ="submit" value="'.&mt('Upload Listed Files').'" />'."\n".
8783: &mt('(only files for which a location has been provided will be uploaded)').'</form>'."\n";
8784: } elsif ($numpathchg) {
8785: my %pathchange = ();
8786: $output .= &modify_html_form('pathchange',$actionurl,$state,\%pathchange,$pathchange_output);
8787: if (($actionurl eq '/adm/portfolio') || ($actionurl eq '/adm/coursegrp_portfolio')) {
8788: $output .= '<p>'.&mt('or').'</p>';
8789: }
8790: }
8791: return ($output,$num,$numpathchg);
8792: }
8793:
8794: sub embedded_file_element {
8795: my ($context,$num,$embed_file,$mapping,$allfiles,$codebase) = @_;
8796: return unless ((ref($mapping) eq 'HASH') && (ref($allfiles) eq 'HASH') &&
8797: (ref($codebase) eq 'HASH'));
8798: my $output;
8799: if ($context eq 'upload_embedded') {
8800: $output = '<input name="embedded_item_'.$num.'" type="file" value="" />'."\n";
8801: }
8802: $output .= '<input name="embedded_orig_'.$num.'" type="hidden" value="'.
8803: &escape($embed_file).'" />';
8804: unless (($context eq 'upload_embedded') &&
8805: ($mapping->{$embed_file} eq $embed_file)) {
8806: $output .='
8807: <input name="embedded_ref_'.$num.'" type="hidden" value="'.&escape($mapping->{$embed_file}).'" />';
8808: }
8809: my $attrib;
8810: if (ref($allfiles->{$mapping->{$embed_file}}) eq 'ARRAY') {
8811: $attrib = &escape(join(':',@{$allfiles->{$mapping->{$embed_file}}}));
1.948.2.12 raeburn 8812: }
1.948.2.17 raeburn 8813: $output .=
8814: "\n\t\t".
8815: '<input name="embedded_attrib_'.$num.'" type="hidden" value="'.
8816: $attrib.'" />';
8817: if (exists($codebase->{$mapping->{$embed_file}})) {
8818: $output .=
8819: "\n\t\t".
8820: '<input name="codebase_'.$num.'" type="hidden" value="'.
8821: &escape($codebase->{$mapping->{$embed_file}}).'" />';
8822: }
8823: return $output;
1.660 raeburn 8824: }
8825:
1.661 raeburn 8826: sub upload_embedded {
8827: my ($context,$dirpath,$uname,$udom,$dir_root,$url_root,$group,$disk_quota,
1.948.2.17 raeburn 8828: $current_disk_usage,$hiddenstate,$actionurl) = @_;
8829: my (%pathchange,$output,$modifyform,$footer,$returnflag);
1.661 raeburn 8830: for (my $i=0; $i<$env{'form.number_embedded_items'}; $i++) {
8831: next if (!exists($env{'form.embedded_item_'.$i.'.filename'}));
8832: my $orig_uploaded_filename =
8833: $env{'form.embedded_item_'.$i.'.filename'};
1.948.2.17 raeburn 8834: foreach my $type ('orig','ref','attrib','codebase') {
8835: if ($env{'form.embedded_'.$type.'_'.$i} ne '') {
8836: $env{'form.embedded_'.$type.'_'.$i} =
8837: &unescape($env{'form.embedded_'.$type.'_'.$i});
8838: }
8839: }
1.661 raeburn 8840: my ($path,$fname) =
8841: ($env{'form.embedded_orig_'.$i} =~ m{(.*/)([^/]*)});
8842: # no path, whole string is fname
8843: if (!$fname) { $fname = $env{'form.embedded_orig_'.$i} };
8844: $fname = &Apache::lonnet::clean_filename($fname);
8845: # See if there is anything left
8846: next if ($fname eq '');
8847:
8848: # Check if file already exists as a file or directory.
8849: my ($state,$msg);
8850: if ($context eq 'portfolio') {
8851: my $port_path = $dirpath;
8852: if ($group ne '') {
8853: $port_path = "groups/$group/$port_path";
8854: }
1.948.2.17 raeburn 8855: ($state,$msg) = &check_for_upload($env{'form.currentpath'}.$path,
8856: $fname,$group,'embedded_item_'.$i,
1.661 raeburn 8857: $dir_root,$port_path,$disk_quota,
8858: $current_disk_usage,$uname,$udom);
8859: if ($state eq 'will_exceed_quota'
1.948.2.12 raeburn 8860: || $state eq 'file_locked') {
1.661 raeburn 8861: $output .= $msg;
8862: next;
8863: }
8864: } elsif (($context eq 'author') || ($context eq 'testbank')) {
8865: ($state,$msg) = &check_for_existing($path,$fname,'embedded_item_'.$i);
8866: if ($state eq 'exists') {
8867: $output .= $msg;
8868: next;
8869: }
8870: }
8871: # Check if extension is valid
8872: if (($fname =~ /\.(\w+)$/) &&
8873: (&Apache::loncommon::fileembstyle($1) eq 'hdn')) {
1.948.2.17 raeburn 8874: $output .= &mt('Invalid file extension ([_1]) - reserved for LONCAPA use - rename the file with a different extension and re-upload. ',$1).'<br />';
1.661 raeburn 8875: next;
8876: } elsif (($fname =~ /\.(\w+)$/) &&
8877: (!defined(&Apache::loncommon::fileembstyle($1)))) {
1.948.2.17 raeburn 8878: $output .= &mt('Unrecognized file extension ([_1]) - rename the file with a proper extension and re-upload.',$1).'<br />';
1.661 raeburn 8879: next;
8880: } elsif ($fname=~/\.(\d+)\.(\w+)$/) {
1.948.2.17 raeburn 8881: $output .= &mt('File name not allowed - rename the file to remove the number immediately before the file extension([_1]) and re-upload.',$2).'<br />';
1.661 raeburn 8882: next;
8883: }
8884:
8885: $env{'form.embedded_item_'.$i.'.filename'}=$fname;
8886: if ($context eq 'portfolio') {
1.948.2.12 raeburn 8887: my $result;
8888: if ($state eq 'existingfile') {
8889: $result=
8890: &Apache::lonnet::userfileupload('embedded_item_'.$i,'existingfile',
1.948.2.17 raeburn 8891: $dirpath.$env{'form.currentpath'}.$path);
1.661 raeburn 8892: } else {
1.948.2.12 raeburn 8893: $result=
8894: &Apache::lonnet::userfileupload('embedded_item_'.$i,'',
1.948.2.17 raeburn 8895: $dirpath.
8896: $env{'form.currentpath'}.$path);
1.948.2.12 raeburn 8897: if ($result !~ m|^/uploaded/|) {
8898: $output .= '<span class="LC_error">'
8899: .&mt('An error occurred ([_1]) while trying to upload [_2] for embedded element [_3].'
8900: ,$result,$orig_uploaded_filename,$env{'form.embedded_orig_'.$i})
8901: .'</span><br />';
8902: next;
8903: } else {
1.948.2.17 raeburn 8904: $output .= &mt('Uploaded [_1]','<span class="LC_filename">'.
8905: $path.$fname.'</span>').'<br />';
1.948.2.12 raeburn 8906: }
1.661 raeburn 8907: }
1.948.2.17 raeburn 8908: } elsif ($context eq 'coursedoc') {
8909: my $result =
8910: &Apache::lonnet::userfileupload('embedded_item_'.$i,'coursedoc',
8911: $dirpath.'/'.$path);
8912: if ($result !~ m|^/uploaded/|) {
8913: $output .= '<span class="LC_error">'
8914: .&mt('An error occurred ([_1]) while trying to upload [_2] for embedded element [_3].'
8915: ,$result,$orig_uploaded_filename,$env{'form.embedded_orig_'.$i})
8916: .'</span><br />';
8917: next;
8918: } else {
8919: $output .= &mt('Uploaded [_1]','<span class="LC_filename">'.
8920: $path.$fname.'</span>').'<br />';
8921: }
1.661 raeburn 8922: } else {
8923: # Save the file
8924: my $target = $env{'form.embedded_item_'.$i};
8925: my $fullpath = $dir_root.$dirpath.'/'.$path;
8926: my $dest = $fullpath.$fname;
8927: my $url = $url_root.$dirpath.'/'.$path.$fname;
8928: my @parts=split(/\//,$fullpath);
8929: my $count;
8930: my $filepath = $dir_root;
8931: for ($count=4;$count<=$#parts;$count++) {
8932: $filepath .= "/$parts[$count]";
8933: if ((-e $filepath)!=1) {
8934: mkdir($filepath,0770);
8935: }
8936: }
8937: my $fh;
8938: if (!open($fh,'>'.$dest)) {
8939: &Apache::lonnet::logthis('Failed to create '.$dest);
8940: $output .= '<span class="LC_error">'.
8941: &mt('An error occurred while trying to upload [_1] for embedded element [_2].',$orig_uploaded_filename,$env{'form.embedded_orig_'.$i}).
8942: '</span><br />';
8943: } else {
8944: if (!print $fh $env{'form.embedded_item_'.$i}) {
8945: &Apache::lonnet::logthis('Failed to write to '.$dest);
8946: $output .= '<span class="LC_error">'.
8947: &mt('An error occurred while writing the file [_1] for embedded element [_2].',$orig_uploaded_filename,$env{'form.embedded_orig_'.$i}).
8948: '</span><br />';
8949: } else {
1.948.2.17 raeburn 8950: $output .= &mt('Uploaded [_1]','<span class="LC_filename">'.
8951: $url.'</span>').'<br />';
8952: unless ($context eq 'testbank') {
8953: $footer .= &mt('View embedded file: [_1]',
8954: '<a href="'.$url.'">'.$fname.'</a>').'<br />';
1.661 raeburn 8955: }
8956: }
8957: close($fh);
8958: }
8959: }
1.948.2.17 raeburn 8960: if ($env{'form.embedded_ref_'.$i}) {
8961: $pathchange{$i} = 1;
8962: }
1.948.2.18 raeburn 8963: }
1.948.2.17 raeburn 8964: if ($output) {
8965: $output = '<p>'.$output.'</p>';
8966: }
8967: $output .= &modify_html_form('upload_embedded',$actionurl,$hiddenstate,\%pathchange);
8968: $returnflag = 'ok';
8969: if (keys(%pathchange) > 0) {
8970: if ($context eq 'portfolio') {
8971: $output .= '<p>'.&mt('or').'</p>';
8972: } elsif ($context eq 'testbank') {
8973: $output .= '<p>'.&mt('Or [_1]continue[_2] the testbank import without modifying the reference(s).','<a href="javascript:document.testbankForm.submit();">','</a>').'</p>';
8974: $returnflag = 'modify_orightml';
8975: }
8976: }
8977: return ($output.$footer,$returnflag);
8978: }
8979:
8980: sub modify_html_form {
8981: my ($context,$actionurl,$hiddenstate,$pathchange,$pathchgtable) = @_;
8982: my $end = 0;
8983: my $modifyform;
8984: if ($context eq 'upload_embedded') {
8985: return unless (ref($pathchange) eq 'HASH');
8986: if ($env{'form.number_embedded_items'}) {
8987: $end += $env{'form.number_embedded_items'};
8988: }
8989: if ($env{'form.number_pathchange_items'}) {
8990: $end += $env{'form.number_pathchange_items'};
8991: }
8992: if ($end) {
8993: for (my $i=0; $i<$end; $i++) {
8994: if ($i < $env{'form.number_embedded_items'}) {
8995: next unless($pathchange->{$i});
8996: }
8997: $modifyform .=
8998: &start_data_table_row().
8999: '<td><input type ="checkbox" name="namechange" value="'.$i.'" '.
9000: 'checked="checked" /></td>'.
9001: '<td>'.$env{'form.embedded_ref_'.$i}.
9002: '<input type="hidden" name="embedded_ref_'.$i.'" value="'.
9003: &escape($env{'form.embedded_ref_'.$i}).'" />'.
9004: '<input type="hidden" name="embedded_codebase_'.$i.'" value="'.
9005: &escape($env{'form.embedded_codebase_'.$i}).'" />'.
9006: '<input type="hidden" name="embedded_attrib_'.$i.'" value="'.
9007: &escape($env{'form.embedded_attrib_'.$i}).'" /></td>'.
9008: '<td>'.$env{'form.embedded_orig_'.$i}.
9009: '<input type="hidden" name="embedded_orig_'.$i.'" value="'.
9010: &escape($env{'form.embedded_orig_'.$i}).'" /></td>'.
9011: &end_data_table_row();
9012: }
9013: }
9014: } else {
9015: $modifyform = $pathchgtable;
9016: if (($actionurl eq '/adm/upload') || ($actionurl eq '/adm/testbank')) {
9017: $hiddenstate .= '<input type="hidden" name="phase" value="four" />';
9018: } elsif (($actionurl eq '/adm/portfolio') || ($actionurl eq '/adm/coursegrp_portfolio')) {
9019: $hiddenstate .= '<input type="hidden" name="action" value="modify_orightml" />';
9020: }
9021: }
9022: if ($modifyform) {
9023: return '<h3>'.&mt('Changes in content of HTML file required').'</h3>'."\n".
9024: '<p>'.&mt('Changes need to be made to the reference(s) used for one or more of the dependencies, if your HTML file is to work correctly:').'<ol>'."\n".
9025: '<li>'.&mt('For consistency between the reference(s) and the location of the corresponding stored file within LON-CAPA.').'</li>'."\n".
9026: '<li>'.&mt('To change absolute paths to relative paths, or replace directory traversal via "../" within the original reference.').'</li>'."\n".
9027: '</ol></p>'."\n".'<p>'.
9028: &mt('LON-CAPA can make the required changes to your HTML file.').'</p>'."\n".
9029: '<form method="post" name="refchanger" action="'.$actionurl.'">'.
9030: &start_data_table()."\n".
9031: &start_data_table_header_row().
9032: '<th>'.&mt('Change?').'</th>'.
9033: '<th>'.&mt('Current reference').'</th>'.
9034: '<th>'.&mt('Required reference').'</th>'.
9035: &end_data_table_header_row()."\n".
9036: $modifyform.
9037: &end_data_table().'<br />'."\n".$hiddenstate.
9038: '<input type="submit" name="pathchanges" value="'.&mt('Modify HTML file').'" />'.
9039: '</form>'."\n";
9040: }
9041: return;
9042: }
9043:
9044: sub modify_html_refs {
9045: my ($context,$dirpath,$uname,$udom,$dir_root) = @_;
9046: my $container;
9047: if ($context eq 'portfolio') {
9048: $container = $env{'form.container'};
9049: } elsif ($context eq 'coursedoc') {
9050: $container = $env{'form.primaryurl'};
9051: } else {
9052: $container = $env{'form.filename'};
9053: $container =~ s{^/priv/(\Q$uname\E)/(.*)}{/home/$1/public_html/$2};
9054: }
9055: my (%allfiles,%codebase,$output,$content);
9056: my @changes = &get_env_multiple('form.namechange');
9057: return unless (@changes > 0);
9058: if (($context eq 'portfolio') || ($context eq 'coursedoc')) {
9059: return unless ($container =~ m{^/uploaded/\Q$udom\E/\Q$uname\E/});
9060: $content = &Apache::lonnet::getfile($container);
9061: return if ($content eq '-1');
9062: } else {
9063: return unless ($container =~ /^\Q$dir_root\E/);
9064: if (open(my $fh,"<$container")) {
9065: $content = join('', <$fh>);
9066: close($fh);
9067: } else {
9068: return;
9069: }
9070: }
9071: my ($count,$codebasecount) = (0,0);
9072: my $mm = new File::MMagic;
9073: my $mime_type = $mm->checktype_contents($content);
9074: if ($mime_type eq 'text/html') {
9075: my $parse_result =
9076: &Apache::lonnet::extract_embedded_items($container,\%allfiles,
9077: \%codebase,\$content);
9078: if ($parse_result eq 'ok') {
9079: foreach my $i (@changes) {
9080: my $orig = &unescape($env{'form.embedded_orig_'.$i});
9081: my $ref = &unescape($env{'form.embedded_ref_'.$i});
9082: if ($allfiles{$ref}) {
9083: my $newname = $orig;
9084: my ($attrib_regexp,$codebase);
1.948.2.28 raeburn 9085: $attrib_regexp = &unescape($env{'form.embedded_attrib_'.$i});
1.948.2.17 raeburn 9086: if ($attrib_regexp =~ /:/) {
9087: $attrib_regexp =~ s/\:/|/g;
9088: }
9089: if ($content =~ m{($attrib_regexp\s*=\s*['"]?)\Q$ref\E(['"]?)}) {
9090: my $numchg = ($content =~ s{($attrib_regexp\s*=\s*['"]?)\Q$ref\E(['"]?)}{$1$newname$2}gi);
9091: $count += $numchg;
9092: }
9093: if ($env{'form.embedded_codebase_'.$i} ne '') {
1.948.2.28 raeburn 9094: $codebase = &unescape($env{'form.embedded_codebase_'.$i});
1.948.2.17 raeburn 9095: my $numchg = ($content =~ s/(codebase\s*=\s*["']?)\Q$codebase\E(["']?)/$1.$2/i); #' stupid emacs
9096: $codebasecount ++;
9097: }
9098: }
9099: }
9100: if ($count || $codebasecount) {
9101: my $saveresult;
9102: if ($context eq 'portfolio' || $context eq 'coursedoc') {
9103: my $url = &Apache::lonnet::store_edited_file($container,$content,$udom,$uname,\$saveresult);
9104: if ($url eq $container) {
9105: my ($fname) = ($container =~ m{/([^/]+)$});
9106: $output = '<p>'.&mt('Updated [quant,_1,reference] in [_2].',
9107: $count,'<span class="LC_filename">'.
9108: $fname.'</span>').'</p>';
9109: } else {
9110: $output = '<p class="LC_error">'.
9111: &mt('Error: update failed for: [_1].',
9112: '<span class="LC_filename">'.
9113: $container.'</span>').'</p>';
9114: }
9115: } else {
9116: if (open(my $fh,">$container")) {
9117: print $fh $content;
9118: close($fh);
9119: $output = '<p>'.&mt('Updated [quant,_1,reference] in [_2].',
9120: $count,'<span class="LC_filename">'.
9121: $container.'</span>').'</p>';
9122: } else {
9123: $output = '<p class="LC_error">'.
9124: &mt('Error: could not update [_1].',
9125: '<span class="LC_filename">'.
9126: $container.'</span>').'</p>';
9127: }
9128: }
9129: }
9130: } else {
9131: &logthis('Failed to parse '.$container.
9132: ' to modify references: '.$parse_result);
9133: }
1.661 raeburn 9134: }
9135: return $output;
9136: }
9137:
9138: sub check_for_existing {
9139: my ($path,$fname,$element) = @_;
9140: my ($state,$msg);
9141: if (-d $path.'/'.$fname) {
9142: $state = 'exists';
9143: $msg = &mt('Unable to upload [_1]. A directory by that name was found in [_2].','<span class="LC_filename">'.$fname.'</span>',$path);
9144: } elsif (-e $path.'/'.$fname) {
9145: $state = 'exists';
9146: $msg = &mt('Unable to upload [_1]. A file by that name was found in [_2].','<span class="LC_filename">'.$fname.'</span>',$path);
9147: }
9148: if ($state eq 'exists') {
9149: $msg = '<span class="LC_error">'.$msg.'</span><br />';
9150: }
9151: return ($state,$msg);
9152: }
9153:
9154: sub check_for_upload {
9155: my ($path,$fname,$group,$element,$portfolio_root,$port_path,
9156: $disk_quota,$current_disk_usage,$uname,$udom) = @_;
1.948.2.12 raeburn 9157: my $filesize = length($env{'form.'.$element});
9158: if (!$filesize) {
9159: my $msg = '<span class="LC_error">'.
9160: &mt('Unable to upload [_1]. (size = [_2] bytes)',
9161: '<span class="LC_filename">'.$fname.'</span>',
9162: $filesize).'<br />'.
1.948.2.29 raeburn 9163: &mt('Either the file you attempted to upload was empty, or your web browser was unable to read its contents.').'<br />'.
1.948.2.12 raeburn 9164: '</span>';
9165: return ('zero_bytes',$msg);
9166: }
9167: $filesize = $filesize/1000; #express in k (1024?)
1.661 raeburn 9168: my $getpropath = 1;
9169: my @dir_list = &Apache::lonnet::dirlist($portfolio_root.$path,$udom,$uname,
9170: $getpropath);
9171: my $found_file = 0;
9172: my $locked_file = 0;
1.948.2.20 raeburn 9173: my @lockers;
9174: my $navmap;
9175: if ($env{'request.course.id'}) {
9176: $navmap = Apache::lonnavmaps::navmap->new();
9177: }
1.661 raeburn 9178: foreach my $line (@dir_list) {
1.948.2.12 raeburn 9179: my ($file_name,$rest)=split(/\&/,$line,2);
1.661 raeburn 9180: if ($file_name eq $fname){
9181: $file_name = $path.$file_name;
9182: if ($group ne '') {
9183: $file_name = $group.$file_name;
9184: }
9185: $found_file = 1;
1.948.2.20 raeburn 9186: if (&Apache::lonnet::is_locked($file_name,$udom,$uname,\@lockers) eq 'true') {
9187: foreach my $lock (@lockers) {
9188: if (ref($lock) eq 'ARRAY') {
9189: my ($symb,$crsid) = @{$lock};
9190: if ($crsid eq $env{'request.course.id'}) {
9191: if (ref($navmap)) {
9192: my $res = $navmap->getBySymb($symb);
9193: foreach my $part (@{$res->parts()}) {
9194: my ($slot_status,$slot_time,$slot_name)=$res->check_for_slot($part);
9195: unless (($slot_status == $res->RESERVED) ||
9196: ($slot_status == $res->RESERVED_LOCATION)) {
9197: $locked_file = 1;
9198: }
9199: }
9200: } else {
9201: $locked_file = 1;
9202: }
9203: } else {
9204: $locked_file = 1;
9205: }
9206: }
9207: }
1.948.2.12 raeburn 9208: } else {
9209: my @info = split(/\&/,$rest);
9210: my $currsize = $info[6]/1000;
9211: if ($currsize < $filesize) {
9212: my $extra = $filesize - $currsize;
9213: if (($current_disk_usage + $extra) > $disk_quota) {
9214: my $msg = '<span class="LC_error">'.
9215: &mt('Unable to upload [_1]. (size = [_2] kilobytes). Disk quota will be exceeded if existing (smaller) file with same name (size = [_3] kilobytes) is replaced.',
9216: '<span class="LC_filename">'.$fname.'</span>',$filesize,$currsize).'</span>'.
9217: '<br />'.&mt('Disk quota is [_1] kilobytes. Your current disk usage is [_2] kilobytes.',
9218: $disk_quota,$current_disk_usage);
9219: return ('will_exceed_quota',$msg);
9220: }
9221: }
1.661 raeburn 9222: }
9223: }
9224: }
9225: if (($current_disk_usage + $filesize) > $disk_quota){
9226: my $msg = '<span class="LC_error">'.
9227: &mt('Unable to upload [_1]. (size = [_2] kilobytes). Disk quota will be exceeded.','<span class="LC_filename">'.$fname.'</span>',$filesize).'</span>'.
9228: '<br />'.&mt('Disk quota is [_1] kilobytes. Your current disk usage is [_2] kilobytes.',$disk_quota,$current_disk_usage);
9229: return ('will_exceed_quota',$msg);
9230: } elsif ($found_file) {
9231: if ($locked_file) {
9232: my $msg = '<span class="LC_error">';
9233: $msg .= &mt('Unable to upload [_1]. A locked file by that name was found in [_2].','<span class="LC_filename">'.$fname.'</span>','<span class="LC_filename">'.$port_path.$env{'form.currentpath'}.'</span>');
9234: $msg .= '</span><br />';
9235: $msg .= &mt('You will be able to rename or delete existing [_1] after a grade has been assigned.','<span class="LC_filename">'.$fname.'</span>');
9236: return ('file_locked',$msg);
9237: } else {
9238: my $msg = '<span class="LC_error">';
1.948.2.12 raeburn 9239: $msg .= &mt(' A file by that name: [_1] was found in [_2].','<span class="LC_filename">'.$fname.'</span>',$port_path.$env{'form.currentpath'});
1.661 raeburn 9240: $msg .= '</span>';
1.948.2.12 raeburn 9241: return ('existingfile',$msg);
1.661 raeburn 9242: }
9243: }
9244: }
9245:
1.948.2.17 raeburn 9246: sub check_for_traversal {
9247: my ($path,$url,$toplevel) = @_;
9248: my @parts=split(/\//,$path);
9249: my $cleanpath;
9250: my $fullpath = $url;
9251: for (my $i=0;$i<@parts;$i++) {
9252: next if ($parts[$i] eq '.');
9253: if ($parts[$i] eq '..') {
9254: $fullpath =~ s{([^/]+/)$}{};
9255: } else {
9256: $fullpath .= $parts[$i].'/';
9257: }
9258: }
9259: if ($fullpath =~ /^\Q$url\E(.*)$/) {
9260: $cleanpath = $1;
9261: } elsif ($fullpath =~ /^\Q$toplevel\E(.*)$/) {
9262: my $curr_toprel = $1;
9263: my @parts = split(/\//,$curr_toprel);
9264: my ($url_toprel) = ($url =~ /^\Q$toplevel\E(.*)$/);
9265: my @urlparts = split(/\//,$url_toprel);
9266: my $doubledots;
9267: my $startdiff = -1;
9268: for (my $i=0; $i<@urlparts; $i++) {
9269: if ($startdiff == -1) {
9270: unless ($urlparts[$i] eq $parts[$i]) {
9271: $startdiff = $i;
9272: $doubledots .= '../';
9273: }
9274: } else {
9275: $doubledots .= '../';
9276: }
9277: }
9278: if ($startdiff > -1) {
9279: $cleanpath = $doubledots;
9280: for (my $i=$startdiff; $i<@parts; $i++) {
9281: $cleanpath .= $parts[$i].'/';
9282: }
9283: }
9284: }
9285: $cleanpath =~ s{(/)$}{};
9286: return $cleanpath;
9287: }
1.31 albertel 9288:
1.41 ng 9289: =pod
1.45 matthew 9290:
1.464 albertel 9291: =back
1.41 ng 9292:
1.112 bowersj2 9293: =head1 CSV Upload/Handling functions
1.38 albertel 9294:
1.41 ng 9295: =over 4
9296:
1.648 raeburn 9297: =item * &upfile_store($r)
1.41 ng 9298:
9299: Store uploaded file, $r should be the HTTP Request object,
1.258 albertel 9300: needs $env{'form.upfile'}
1.41 ng 9301: returns $datatoken to be put into hidden field
9302:
9303: =cut
1.31 albertel 9304:
9305: sub upfile_store {
9306: my $r=shift;
1.258 albertel 9307: $env{'form.upfile'}=~s/\r/\n/gs;
9308: $env{'form.upfile'}=~s/\f/\n/gs;
9309: $env{'form.upfile'}=~s/\n+/\n/gs;
9310: $env{'form.upfile'}=~s/\n+$//gs;
1.31 albertel 9311:
1.258 albertel 9312: my $datatoken=$env{'user.name'}.'_'.$env{'user.domain'}.
9313: '_enroll_'.$env{'request.course.id'}.'_'.time.'_'.$$;
1.31 albertel 9314: {
1.158 raeburn 9315: my $datafile = $r->dir_config('lonDaemons').
9316: '/tmp/'.$datatoken.'.tmp';
9317: if ( open(my $fh,">$datafile") ) {
1.258 albertel 9318: print $fh $env{'form.upfile'};
1.158 raeburn 9319: close($fh);
9320: }
1.31 albertel 9321: }
9322: return $datatoken;
9323: }
9324:
1.56 matthew 9325: =pod
9326:
1.648 raeburn 9327: =item * &load_tmp_file($r)
1.41 ng 9328:
9329: Load uploaded file from tmp, $r should be the HTTP Request object,
1.258 albertel 9330: needs $env{'form.datatoken'},
9331: sets $env{'form.upfile'} to the contents of the file
1.41 ng 9332:
9333: =cut
1.31 albertel 9334:
9335: sub load_tmp_file {
9336: my $r=shift;
9337: my @studentdata=();
9338: {
1.158 raeburn 9339: my $studentfile = $r->dir_config('lonDaemons').
1.258 albertel 9340: '/tmp/'.$env{'form.datatoken'}.'.tmp';
1.158 raeburn 9341: if ( open(my $fh,"<$studentfile") ) {
9342: @studentdata=<$fh>;
9343: close($fh);
9344: }
1.31 albertel 9345: }
1.258 albertel 9346: $env{'form.upfile'}=join('',@studentdata);
1.31 albertel 9347: }
9348:
1.56 matthew 9349: =pod
9350:
1.648 raeburn 9351: =item * &upfile_record_sep()
1.41 ng 9352:
9353: Separate uploaded file into records
9354: returns array of records,
1.258 albertel 9355: needs $env{'form.upfile'} and $env{'form.upfiletype'}
1.41 ng 9356:
9357: =cut
1.31 albertel 9358:
9359: sub upfile_record_sep {
1.258 albertel 9360: if ($env{'form.upfiletype'} eq 'xml') {
1.31 albertel 9361: } else {
1.248 albertel 9362: my @records;
1.258 albertel 9363: foreach my $line (split(/\n/,$env{'form.upfile'})) {
1.248 albertel 9364: if ($line=~/^\s*$/) { next; }
9365: push(@records,$line);
9366: }
9367: return @records;
1.31 albertel 9368: }
9369: }
9370:
1.56 matthew 9371: =pod
9372:
1.648 raeburn 9373: =item * &record_sep($record)
1.41 ng 9374:
1.258 albertel 9375: Separate a record into fields $record should be an item from the upfile_record_sep(), needs $env{'form.upfiletype'}
1.41 ng 9376:
9377: =cut
9378:
1.263 www 9379: sub takeleft {
9380: my $index=shift;
9381: return substr('0000'.$index,-4,4);
9382: }
9383:
1.31 albertel 9384: sub record_sep {
9385: my $record=shift;
9386: my %components=();
1.258 albertel 9387: if ($env{'form.upfiletype'} eq 'xml') {
9388: } elsif ($env{'form.upfiletype'} eq 'space') {
1.31 albertel 9389: my $i=0;
1.356 albertel 9390: foreach my $field (split(/\s+/,$record)) {
1.31 albertel 9391: $field=~s/^(\"|\')//;
9392: $field=~s/(\"|\')$//;
1.263 www 9393: $components{&takeleft($i)}=$field;
1.31 albertel 9394: $i++;
9395: }
1.258 albertel 9396: } elsif ($env{'form.upfiletype'} eq 'tab') {
1.31 albertel 9397: my $i=0;
1.356 albertel 9398: foreach my $field (split(/\t/,$record)) {
1.31 albertel 9399: $field=~s/^(\"|\')//;
9400: $field=~s/(\"|\')$//;
1.263 www 9401: $components{&takeleft($i)}=$field;
1.31 albertel 9402: $i++;
9403: }
9404: } else {
1.561 www 9405: my $separator=',';
1.480 banghart 9406: if ($env{'form.upfiletype'} eq 'semisv') {
1.561 www 9407: $separator=';';
1.480 banghart 9408: }
1.31 albertel 9409: my $i=0;
1.561 www 9410: # the character we are looking for to indicate the end of a quote or a record
9411: my $looking_for=$separator;
9412: # do not add the characters to the fields
9413: my $ignore=0;
9414: # we just encountered a separator (or the beginning of the record)
9415: my $just_found_separator=1;
9416: # store the field we are working on here
9417: my $field='';
9418: # work our way through all characters in record
9419: foreach my $character ($record=~/(.)/g) {
9420: if ($character eq $looking_for) {
9421: if ($character ne $separator) {
9422: # Found the end of a quote, again looking for separator
9423: $looking_for=$separator;
9424: $ignore=1;
9425: } else {
9426: # Found a separator, store away what we got
9427: $components{&takeleft($i)}=$field;
9428: $i++;
9429: $just_found_separator=1;
9430: $ignore=0;
9431: $field='';
9432: }
9433: next;
9434: }
9435: # single or double quotation marks after a separator indicate beginning of a quote
9436: # we are now looking for the end of the quote and need to ignore separators
9437: if ((($character eq '"') || ($character eq "'")) && ($just_found_separator)) {
9438: $looking_for=$character;
9439: next;
9440: }
9441: # ignore would be true after we reached the end of a quote
9442: if ($ignore) { next; }
9443: if (($just_found_separator) && ($character=~/\s/)) { next; }
9444: $field.=$character;
9445: $just_found_separator=0;
1.31 albertel 9446: }
1.561 www 9447: # catch the very last entry, since we never encountered the separator
9448: $components{&takeleft($i)}=$field;
1.31 albertel 9449: }
9450: return %components;
9451: }
9452:
1.144 matthew 9453: ######################################################
9454: ######################################################
9455:
1.56 matthew 9456: =pod
9457:
1.648 raeburn 9458: =item * &upfile_select_html()
1.41 ng 9459:
1.144 matthew 9460: Return HTML code to select a file from the users machine and specify
9461: the file type.
1.41 ng 9462:
9463: =cut
9464:
1.144 matthew 9465: ######################################################
9466: ######################################################
1.31 albertel 9467: sub upfile_select_html {
1.144 matthew 9468: my %Types = (
9469: csv => &mt('CSV (comma separated values, spreadsheet)'),
1.480 banghart 9470: semisv => &mt('Semicolon separated values'),
1.144 matthew 9471: space => &mt('Space separated'),
9472: tab => &mt('Tabulator separated'),
9473: # xml => &mt('HTML/XML'),
9474: );
9475: my $Str = '<input type="file" name="upfile" size="50" />'.
1.727 riegler 9476: '<br />'.&mt('Type').': <select name="upfiletype">';
1.144 matthew 9477: foreach my $type (sort(keys(%Types))) {
9478: $Str .= '<option value="'.$type.'" >'.$Types{$type}."</option>\n";
9479: }
9480: $Str .= "</select>\n";
9481: return $Str;
1.31 albertel 9482: }
9483:
1.301 albertel 9484: sub get_samples {
9485: my ($records,$toget) = @_;
9486: my @samples=({});
9487: my $got=0;
9488: foreach my $rec (@$records) {
9489: my %temp = &record_sep($rec);
9490: if (! grep(/\S/, values(%temp))) { next; }
9491: if (%temp) {
9492: $samples[$got]=\%temp;
9493: $got++;
9494: if ($got == $toget) { last; }
9495: }
9496: }
9497: return \@samples;
9498: }
9499:
1.144 matthew 9500: ######################################################
9501: ######################################################
9502:
1.56 matthew 9503: =pod
9504:
1.648 raeburn 9505: =item * &csv_print_samples($r,$records)
1.41 ng 9506:
9507: Prints a table of sample values from each column uploaded $r is an
9508: Apache Request ref, $records is an arrayref from
9509: &Apache::loncommon::upfile_record_sep
9510:
9511: =cut
9512:
1.144 matthew 9513: ######################################################
9514: ######################################################
1.31 albertel 9515: sub csv_print_samples {
9516: my ($r,$records) = @_;
1.662 bisitz 9517: my $samples = &get_samples($records,5);
1.301 albertel 9518:
1.594 raeburn 9519: $r->print(&mt('Samples').'<br />'.&start_data_table().
9520: &start_data_table_header_row());
1.356 albertel 9521: foreach my $sample (sort({$a <=> $b} keys(%{ $samples->[0] }))) {
1.845 bisitz 9522: $r->print('<th>'.&mt('Column [_1]',($sample+1)).'</th>'); }
1.594 raeburn 9523: $r->print(&end_data_table_header_row());
1.301 albertel 9524: foreach my $hash (@$samples) {
1.594 raeburn 9525: $r->print(&start_data_table_row());
1.356 albertel 9526: foreach my $sample (sort({$a <=> $b} keys(%{ $samples->[0] }))) {
1.31 albertel 9527: $r->print('<td>');
1.356 albertel 9528: if (defined($$hash{$sample})) { $r->print($$hash{$sample}); }
1.31 albertel 9529: $r->print('</td>');
9530: }
1.594 raeburn 9531: $r->print(&end_data_table_row());
1.31 albertel 9532: }
1.594 raeburn 9533: $r->print(&end_data_table().'<br />'."\n");
1.31 albertel 9534: }
9535:
1.144 matthew 9536: ######################################################
9537: ######################################################
9538:
1.56 matthew 9539: =pod
9540:
1.648 raeburn 9541: =item * &csv_print_select_table($r,$records,$d)
1.41 ng 9542:
9543: Prints a table to create associations between values and table columns.
1.144 matthew 9544:
1.41 ng 9545: $r is an Apache Request ref,
9546: $records is an arrayref from &Apache::loncommon::upfile_record_sep,
1.174 matthew 9547: $d is an array of 2 element arrays (internal name, displayed name,defaultcol)
1.41 ng 9548:
9549: =cut
9550:
1.144 matthew 9551: ######################################################
9552: ######################################################
1.31 albertel 9553: sub csv_print_select_table {
9554: my ($r,$records,$d) = @_;
1.301 albertel 9555: my $i=0;
9556: my $samples = &get_samples($records,1);
1.144 matthew 9557: $r->print(&mt('Associate columns with student attributes.')."\n".
1.594 raeburn 9558: &start_data_table().&start_data_table_header_row().
1.144 matthew 9559: '<th>'.&mt('Attribute').'</th>'.
1.594 raeburn 9560: '<th>'.&mt('Column').'</th>'.
9561: &end_data_table_header_row()."\n");
1.356 albertel 9562: foreach my $array_ref (@$d) {
9563: my ($value,$display,$defaultcol)=@{ $array_ref };
1.729 raeburn 9564: $r->print(&start_data_table_row().'<td>'.$display.'</td>');
1.31 albertel 9565:
1.875 bisitz 9566: $r->print('<td><select name="f'.$i.'"'.
1.32 matthew 9567: ' onchange="javascript:flip(this.form,'.$i.');">');
1.31 albertel 9568: $r->print('<option value="none"></option>');
1.356 albertel 9569: foreach my $sample (sort({$a <=> $b} keys(%{ $samples->[0] }))) {
9570: $r->print('<option value="'.$sample.'"'.
9571: ($sample eq $defaultcol ? ' selected="selected" ' : '').
1.662 bisitz 9572: '>'.&mt('Column [_1]',($sample+1)).'</option>');
1.31 albertel 9573: }
1.594 raeburn 9574: $r->print('</select></td>'.&end_data_table_row()."\n");
1.31 albertel 9575: $i++;
9576: }
1.594 raeburn 9577: $r->print(&end_data_table());
1.31 albertel 9578: $i--;
9579: return $i;
9580: }
1.56 matthew 9581:
1.144 matthew 9582: ######################################################
9583: ######################################################
9584:
1.56 matthew 9585: =pod
1.31 albertel 9586:
1.648 raeburn 9587: =item * &csv_samples_select_table($r,$records,$d)
1.41 ng 9588:
9589: Prints a table of sample values from the upload and can make associate samples to internal names.
9590:
9591: $r is an Apache Request ref,
9592: $records is an arrayref from &Apache::loncommon::upfile_record_sep,
9593: $d is an array of 2 element arrays (internal name, displayed name)
9594:
9595: =cut
9596:
1.144 matthew 9597: ######################################################
9598: ######################################################
1.31 albertel 9599: sub csv_samples_select_table {
9600: my ($r,$records,$d) = @_;
9601: my $i=0;
1.144 matthew 9602: #
1.662 bisitz 9603: my $max_samples = 5;
9604: my $samples = &get_samples($records,$max_samples);
1.594 raeburn 9605: $r->print(&start_data_table().
9606: &start_data_table_header_row().'<th>'.
9607: &mt('Field').'</th><th>'.&mt('Samples').'</th>'.
9608: &end_data_table_header_row());
1.301 albertel 9609:
9610: foreach my $key (sort(keys(%{ $samples->[0] }))) {
1.594 raeburn 9611: $r->print(&start_data_table_row().'<td><select name="f'.$i.'"'.
1.32 matthew 9612: ' onchange="javascript:flip(this.form,'.$i.');">');
1.301 albertel 9613: foreach my $option (@$d) {
9614: my ($value,$display,$defaultcol)=@{ $option };
1.174 matthew 9615: $r->print('<option value="'.$value.'"'.
1.253 albertel 9616: ($i eq $defaultcol ? ' selected="selected" ':'').'>'.
1.174 matthew 9617: $display.'</option>');
1.31 albertel 9618: }
9619: $r->print('</select></td><td>');
1.662 bisitz 9620: foreach my $line (0..($max_samples-1)) {
1.301 albertel 9621: if (defined($samples->[$line]{$key})) {
9622: $r->print($samples->[$line]{$key}."<br />\n");
9623: }
9624: }
1.594 raeburn 9625: $r->print('</td>'.&end_data_table_row());
1.31 albertel 9626: $i++;
9627: }
1.594 raeburn 9628: $r->print(&end_data_table());
1.31 albertel 9629: $i--;
9630: return($i);
1.115 matthew 9631: }
9632:
1.144 matthew 9633: ######################################################
9634: ######################################################
9635:
1.115 matthew 9636: =pod
9637:
1.648 raeburn 9638: =item * &clean_excel_name($name)
1.115 matthew 9639:
9640: Returns a replacement for $name which does not contain any illegal characters.
9641:
9642: =cut
9643:
1.144 matthew 9644: ######################################################
9645: ######################################################
1.115 matthew 9646: sub clean_excel_name {
9647: my ($name) = @_;
9648: $name =~ s/[:\*\?\/\\]//g;
9649: if (length($name) > 31) {
9650: $name = substr($name,0,31);
9651: }
9652: return $name;
1.25 albertel 9653: }
1.84 albertel 9654:
1.85 albertel 9655: =pod
9656:
1.648 raeburn 9657: =item * &check_if_partid_hidden($id,$symb,$udom,$uname)
1.85 albertel 9658:
9659: Returns either 1 or undef
9660:
9661: 1 if the part is to be hidden, undef if it is to be shown
9662:
9663: Arguments are:
9664:
9665: $id the id of the part to be checked
9666: $symb, optional the symb of the resource to check
9667: $udom, optional the domain of the user to check for
9668: $uname, optional the username of the user to check for
9669:
9670: =cut
1.84 albertel 9671:
9672: sub check_if_partid_hidden {
9673: my ($id,$symb,$udom,$uname) = @_;
1.133 albertel 9674: my $hiddenparts=&Apache::lonnet::EXT('resource.0.hiddenparts',
1.84 albertel 9675: $symb,$udom,$uname);
1.141 albertel 9676: my $truth=1;
9677: #if the string starts with !, then the list is the list to show not hide
9678: if ($hiddenparts=~s/^\s*!//) { $truth=undef; }
1.84 albertel 9679: my @hiddenlist=split(/,/,$hiddenparts);
9680: foreach my $checkid (@hiddenlist) {
1.141 albertel 9681: if ($checkid =~ /^\s*\Q$id\E\s*$/) { return $truth; }
1.84 albertel 9682: }
1.141 albertel 9683: return !$truth;
1.84 albertel 9684: }
1.127 matthew 9685:
1.138 matthew 9686:
9687: ############################################################
9688: ############################################################
9689:
9690: =pod
9691:
1.157 matthew 9692: =back
9693:
1.138 matthew 9694: =head1 cgi-bin script and graphing routines
9695:
1.157 matthew 9696: =over 4
9697:
1.648 raeburn 9698: =item * &get_cgi_id()
1.138 matthew 9699:
9700: Inputs: none
9701:
9702: Returns an id which can be used to pass environment variables
9703: to various cgi-bin scripts. These environment variables will
9704: be removed from the users environment after a given time by
9705: the routine &Apache::lonnet::transfer_profile_to_env.
9706:
9707: =cut
9708:
9709: ############################################################
9710: ############################################################
1.152 albertel 9711: my $uniq=0;
1.136 matthew 9712: sub get_cgi_id {
1.154 albertel 9713: $uniq=($uniq+1)%100000;
1.280 albertel 9714: return (time.'_'.$$.'_'.$uniq);
1.136 matthew 9715: }
9716:
1.127 matthew 9717: ############################################################
9718: ############################################################
9719:
9720: =pod
9721:
1.648 raeburn 9722: =item * &DrawBarGraph()
1.127 matthew 9723:
1.138 matthew 9724: Facilitates the plotting of data in a (stacked) bar graph.
9725: Puts plot definition data into the users environment in order for
9726: graph.png to plot it. Returns an <img> tag for the plot.
9727: The bars on the plot are labeled '1','2',...,'n'.
9728:
9729: Inputs:
9730:
9731: =over 4
9732:
9733: =item $Title: string, the title of the plot
9734:
9735: =item $xlabel: string, text describing the X-axis of the plot
9736:
9737: =item $ylabel: string, text describing the Y-axis of the plot
9738:
9739: =item $Max: scalar, the maximum Y value to use in the plot
9740: If $Max is < any data point, the graph will not be rendered.
9741:
1.140 matthew 9742: =item $colors: array ref holding the colors to be used for the data sets when
1.138 matthew 9743: they are plotted. If undefined, default values will be used.
9744:
1.178 matthew 9745: =item $labels: array ref holding the labels to use on the x-axis for the bars.
9746:
1.138 matthew 9747: =item @Values: An array of array references. Each array reference holds data
9748: to be plotted in a stacked bar chart.
9749:
1.239 matthew 9750: =item If the final element of @Values is a hash reference the key/value
9751: pairs will be added to the graph definition.
9752:
1.138 matthew 9753: =back
9754:
9755: Returns:
9756:
9757: An <img> tag which references graph.png and the appropriate identifying
9758: information for the plot.
9759:
1.127 matthew 9760: =cut
9761:
9762: ############################################################
9763: ############################################################
1.134 matthew 9764: sub DrawBarGraph {
1.178 matthew 9765: my ($Title,$xlabel,$ylabel,$Max,$colors,$labels,@Values)=@_;
1.134 matthew 9766: #
9767: if (! defined($colors)) {
9768: $colors = ['#33ff00',
9769: '#0033cc', '#990000', '#aaaa66', '#663399', '#ff9933',
9770: '#66ccff', '#ff9999', '#cccc33', '#660000', '#33cc66',
9771: ];
9772: }
1.228 matthew 9773: my $extra_settings = {};
9774: if (ref($Values[-1]) eq 'HASH') {
9775: $extra_settings = pop(@Values);
9776: }
1.127 matthew 9777: #
1.136 matthew 9778: my $identifier = &get_cgi_id();
9779: my $id = 'cgi.'.$identifier;
1.129 matthew 9780: if (! @Values || ref($Values[0]) ne 'ARRAY') {
1.127 matthew 9781: return '';
9782: }
1.225 matthew 9783: #
9784: my @Labels;
9785: if (defined($labels)) {
9786: @Labels = @$labels;
9787: } else {
9788: for (my $i=0;$i<@{$Values[0]};$i++) {
9789: push (@Labels,$i+1);
9790: }
9791: }
9792: #
1.129 matthew 9793: my $NumBars = scalar(@{$Values[0]});
1.225 matthew 9794: if ($NumBars < scalar(@Labels)) { $NumBars = scalar(@Labels); }
1.129 matthew 9795: my %ValuesHash;
9796: my $NumSets=1;
9797: foreach my $array (@Values) {
9798: next if (! ref($array));
1.136 matthew 9799: $ValuesHash{$id.'.data.'.$NumSets++} =
1.132 matthew 9800: join(',',@$array);
1.129 matthew 9801: }
1.127 matthew 9802: #
1.136 matthew 9803: my ($height,$width,$xskip,$bar_width) = (200,120,1,15);
1.225 matthew 9804: if ($NumBars < 3) {
9805: $width = 120+$NumBars*32;
1.220 matthew 9806: $xskip = 1;
1.225 matthew 9807: $bar_width = 30;
9808: } elsif ($NumBars < 5) {
9809: $width = 120+$NumBars*20;
9810: $xskip = 1;
9811: $bar_width = 20;
1.220 matthew 9812: } elsif ($NumBars < 10) {
1.136 matthew 9813: $width = 120+$NumBars*15;
9814: $xskip = 1;
9815: $bar_width = 15;
9816: } elsif ($NumBars <= 25) {
9817: $width = 120+$NumBars*11;
9818: $xskip = 5;
9819: $bar_width = 8;
9820: } elsif ($NumBars <= 50) {
9821: $width = 120+$NumBars*8;
9822: $xskip = 5;
9823: $bar_width = 4;
9824: } else {
9825: $width = 120+$NumBars*8;
9826: $xskip = 5;
9827: $bar_width = 4;
9828: }
9829: #
1.137 matthew 9830: $Max = 1 if ($Max < 1);
9831: if ( int($Max) < $Max ) {
9832: $Max++;
9833: $Max = int($Max);
9834: }
1.127 matthew 9835: $Title = '' if (! defined($Title));
9836: $xlabel = '' if (! defined($xlabel));
9837: $ylabel = '' if (! defined($ylabel));
1.369 www 9838: $ValuesHash{$id.'.title'} = &escape($Title);
9839: $ValuesHash{$id.'.xlabel'} = &escape($xlabel);
9840: $ValuesHash{$id.'.ylabel'} = &escape($ylabel);
1.137 matthew 9841: $ValuesHash{$id.'.y_max_value'} = $Max;
1.136 matthew 9842: $ValuesHash{$id.'.NumBars'} = $NumBars;
9843: $ValuesHash{$id.'.NumSets'} = $NumSets;
9844: $ValuesHash{$id.'.PlotType'} = 'bar';
9845: $ValuesHash{$id.'.Colors'} = join(',',@{$colors});
9846: $ValuesHash{$id.'.height'} = $height;
9847: $ValuesHash{$id.'.width'} = $width;
9848: $ValuesHash{$id.'.xskip'} = $xskip;
9849: $ValuesHash{$id.'.bar_width'} = $bar_width;
9850: $ValuesHash{$id.'.labels'} = join(',',@Labels);
1.127 matthew 9851: #
1.228 matthew 9852: # Deal with other parameters
9853: while (my ($key,$value) = each(%$extra_settings)) {
9854: $ValuesHash{$id.'.'.$key} = $value;
9855: }
9856: #
1.646 raeburn 9857: &Apache::lonnet::appenv(\%ValuesHash);
1.137 matthew 9858: return '<img src="/cgi-bin/graph.png?'.$identifier.'" border="1" />';
9859: }
9860:
9861: ############################################################
9862: ############################################################
9863:
9864: =pod
9865:
1.648 raeburn 9866: =item * &DrawXYGraph()
1.137 matthew 9867:
1.138 matthew 9868: Facilitates the plotting of data in an XY graph.
9869: Puts plot definition data into the users environment in order for
9870: graph.png to plot it. Returns an <img> tag for the plot.
9871:
9872: Inputs:
9873:
9874: =over 4
9875:
9876: =item $Title: string, the title of the plot
9877:
9878: =item $xlabel: string, text describing the X-axis of the plot
9879:
9880: =item $ylabel: string, text describing the Y-axis of the plot
9881:
9882: =item $Max: scalar, the maximum Y value to use in the plot
9883: If $Max is < any data point, the graph will not be rendered.
9884:
9885: =item $colors: Array ref containing the hex color codes for the data to be
9886: plotted in. If undefined, default values will be used.
9887:
9888: =item $Xlabels: Array ref containing the labels to be used for the X-axis.
9889:
9890: =item $Ydata: Array ref containing Array refs.
1.185 www 9891: Each of the contained arrays will be plotted as a separate curve.
1.138 matthew 9892:
9893: =item %Values: hash indicating or overriding any default values which are
9894: passed to graph.png.
9895: Possible values are: width, xskip, x_ticks, x_tick_offset, among others.
9896:
9897: =back
9898:
9899: Returns:
9900:
9901: An <img> tag which references graph.png and the appropriate identifying
9902: information for the plot.
9903:
1.137 matthew 9904: =cut
9905:
9906: ############################################################
9907: ############################################################
9908: sub DrawXYGraph {
9909: my ($Title,$xlabel,$ylabel,$Max,$colors,$Xlabels,$Ydata,%Values)=@_;
9910: #
9911: # Create the identifier for the graph
9912: my $identifier = &get_cgi_id();
9913: my $id = 'cgi.'.$identifier;
9914: #
9915: $Title = '' if (! defined($Title));
9916: $xlabel = '' if (! defined($xlabel));
9917: $ylabel = '' if (! defined($ylabel));
9918: my %ValuesHash =
9919: (
1.369 www 9920: $id.'.title' => &escape($Title),
9921: $id.'.xlabel' => &escape($xlabel),
9922: $id.'.ylabel' => &escape($ylabel),
1.137 matthew 9923: $id.'.y_max_value'=> $Max,
9924: $id.'.labels' => join(',',@$Xlabels),
9925: $id.'.PlotType' => 'XY',
9926: );
9927: #
9928: if (defined($colors) && ref($colors) eq 'ARRAY') {
9929: $ValuesHash{$id.'.Colors'} = join(',',@{$colors});
9930: }
9931: #
9932: if (! ref($Ydata) || ref($Ydata) ne 'ARRAY') {
9933: return '';
9934: }
9935: my $NumSets=1;
1.138 matthew 9936: foreach my $array (@{$Ydata}){
1.137 matthew 9937: next if (! ref($array));
9938: $ValuesHash{$id.'.data.'.$NumSets++} = join(',',@$array);
9939: }
1.138 matthew 9940: $ValuesHash{$id.'.NumSets'} = $NumSets-1;
1.137 matthew 9941: #
9942: # Deal with other parameters
9943: while (my ($key,$value) = each(%Values)) {
9944: $ValuesHash{$id.'.'.$key} = $value;
1.127 matthew 9945: }
9946: #
1.646 raeburn 9947: &Apache::lonnet::appenv(\%ValuesHash);
1.136 matthew 9948: return '<img src="/cgi-bin/graph.png?'.$identifier.'" border="1" />';
9949: }
9950:
9951: ############################################################
9952: ############################################################
9953:
9954: =pod
9955:
1.648 raeburn 9956: =item * &DrawXYYGraph()
1.138 matthew 9957:
9958: Facilitates the plotting of data in an XY graph with two Y axes.
9959: Puts plot definition data into the users environment in order for
9960: graph.png to plot it. Returns an <img> tag for the plot.
9961:
9962: Inputs:
9963:
9964: =over 4
9965:
9966: =item $Title: string, the title of the plot
9967:
9968: =item $xlabel: string, text describing the X-axis of the plot
9969:
9970: =item $ylabel: string, text describing the Y-axis of the plot
9971:
9972: =item $colors: Array ref containing the hex color codes for the data to be
9973: plotted in. If undefined, default values will be used.
9974:
9975: =item $Xlabels: Array ref containing the labels to be used for the X-axis.
9976:
9977: =item $Ydata1: The first data set
9978:
9979: =item $Min1: The minimum value of the left Y-axis
9980:
9981: =item $Max1: The maximum value of the left Y-axis
9982:
9983: =item $Ydata2: The second data set
9984:
9985: =item $Min2: The minimum value of the right Y-axis
9986:
9987: =item $Max2: The maximum value of the left Y-axis
9988:
9989: =item %Values: hash indicating or overriding any default values which are
9990: passed to graph.png.
9991: Possible values are: width, xskip, x_ticks, x_tick_offset, among others.
9992:
9993: =back
9994:
9995: Returns:
9996:
9997: An <img> tag which references graph.png and the appropriate identifying
9998: information for the plot.
1.136 matthew 9999:
10000: =cut
10001:
10002: ############################################################
10003: ############################################################
1.137 matthew 10004: sub DrawXYYGraph {
10005: my ($Title,$xlabel,$ylabel,$colors,$Xlabels,$Ydata1,$Min1,$Max1,
10006: $Ydata2,$Min2,$Max2,%Values)=@_;
1.136 matthew 10007: #
10008: # Create the identifier for the graph
10009: my $identifier = &get_cgi_id();
10010: my $id = 'cgi.'.$identifier;
10011: #
10012: $Title = '' if (! defined($Title));
10013: $xlabel = '' if (! defined($xlabel));
10014: $ylabel = '' if (! defined($ylabel));
10015: my %ValuesHash =
10016: (
1.369 www 10017: $id.'.title' => &escape($Title),
10018: $id.'.xlabel' => &escape($xlabel),
10019: $id.'.ylabel' => &escape($ylabel),
1.136 matthew 10020: $id.'.labels' => join(',',@$Xlabels),
10021: $id.'.PlotType' => 'XY',
10022: $id.'.NumSets' => 2,
1.137 matthew 10023: $id.'.two_axes' => 1,
10024: $id.'.y1_max_value' => $Max1,
10025: $id.'.y1_min_value' => $Min1,
10026: $id.'.y2_max_value' => $Max2,
10027: $id.'.y2_min_value' => $Min2,
1.136 matthew 10028: );
10029: #
1.137 matthew 10030: if (defined($colors) && ref($colors) eq 'ARRAY') {
10031: $ValuesHash{$id.'.Colors'} = join(',',@{$colors});
10032: }
10033: #
10034: if (! ref($Ydata1) || ref($Ydata1) ne 'ARRAY' ||
10035: ! ref($Ydata2) || ref($Ydata2) ne 'ARRAY'){
1.136 matthew 10036: return '';
10037: }
10038: my $NumSets=1;
1.137 matthew 10039: foreach my $array ($Ydata1,$Ydata2){
1.136 matthew 10040: next if (! ref($array));
10041: $ValuesHash{$id.'.data.'.$NumSets++} = join(',',@$array);
1.137 matthew 10042: }
10043: #
10044: # Deal with other parameters
10045: while (my ($key,$value) = each(%Values)) {
10046: $ValuesHash{$id.'.'.$key} = $value;
1.136 matthew 10047: }
10048: #
1.646 raeburn 10049: &Apache::lonnet::appenv(\%ValuesHash);
1.130 albertel 10050: return '<img src="/cgi-bin/graph.png?'.$identifier.'" border="1" />';
1.139 matthew 10051: }
10052:
10053: ############################################################
10054: ############################################################
10055:
10056: =pod
10057:
1.157 matthew 10058: =back
10059:
1.139 matthew 10060: =head1 Statistics helper routines?
10061:
10062: Bad place for them but what the hell.
10063:
1.157 matthew 10064: =over 4
10065:
1.648 raeburn 10066: =item * &chartlink()
1.139 matthew 10067:
10068: Returns a link to the chart for a specific student.
10069:
10070: Inputs:
10071:
10072: =over 4
10073:
10074: =item $linktext: The text of the link
10075:
10076: =item $sname: The students username
10077:
10078: =item $sdomain: The students domain
10079:
10080: =back
10081:
1.157 matthew 10082: =back
10083:
1.139 matthew 10084: =cut
10085:
10086: ############################################################
10087: ############################################################
10088: sub chartlink {
10089: my ($linktext, $sname, $sdomain) = @_;
10090: my $link = '<a href="/adm/statistics?reportSelected=student_assessment'.
1.369 www 10091: '&SelectedStudent='.&escape($sname.':'.$sdomain).
1.219 albertel 10092: '&chartoutputmode='.HTML::Entities::encode('html, with all links').
1.139 matthew 10093: '">'.$linktext.'</a>';
1.153 matthew 10094: }
10095:
10096: #######################################################
10097: #######################################################
10098:
10099: =pod
10100:
10101: =head1 Course Environment Routines
1.157 matthew 10102:
10103: =over 4
1.153 matthew 10104:
1.648 raeburn 10105: =item * &restore_course_settings()
1.153 matthew 10106:
1.648 raeburn 10107: =item * &store_course_settings()
1.153 matthew 10108:
10109: Restores/Store indicated form parameters from the course environment.
10110: Will not overwrite existing values of the form parameters.
10111:
10112: Inputs:
10113: a scalar describing the data (e.g. 'chart', 'problem_analysis')
10114:
10115: a hash ref describing the data to be stored. For example:
10116:
10117: %Save_Parameters = ('Status' => 'scalar',
10118: 'chartoutputmode' => 'scalar',
10119: 'chartoutputdata' => 'scalar',
10120: 'Section' => 'array',
1.373 raeburn 10121: 'Group' => 'array',
1.153 matthew 10122: 'StudentData' => 'array',
10123: 'Maps' => 'array');
10124:
10125: Returns: both routines return nothing
10126:
1.631 raeburn 10127: =back
10128:
1.153 matthew 10129: =cut
10130:
10131: #######################################################
10132: #######################################################
10133: sub store_course_settings {
1.496 albertel 10134: return &store_settings($env{'request.course.id'},@_);
10135: }
10136:
10137: sub store_settings {
1.153 matthew 10138: # save to the environment
10139: # appenv the same items, just to be safe
1.300 albertel 10140: my $udom = $env{'user.domain'};
10141: my $uname = $env{'user.name'};
1.496 albertel 10142: my ($context,$prefix,$Settings) = @_;
1.153 matthew 10143: my %SaveHash;
10144: my %AppHash;
10145: while (my ($setting,$type) = each(%$Settings)) {
1.496 albertel 10146: my $basename = join('.','internal',$context,$prefix,$setting);
1.300 albertel 10147: my $envname = 'environment.'.$basename;
1.258 albertel 10148: if (exists($env{'form.'.$setting})) {
1.153 matthew 10149: # Save this value away
10150: if ($type eq 'scalar' &&
1.258 albertel 10151: (! exists($env{$envname}) ||
10152: $env{$envname} ne $env{'form.'.$setting})) {
10153: $SaveHash{$basename} = $env{'form.'.$setting};
10154: $AppHash{$envname} = $env{'form.'.$setting};
1.153 matthew 10155: } elsif ($type eq 'array') {
10156: my $stored_form;
1.258 albertel 10157: if (ref($env{'form.'.$setting})) {
1.153 matthew 10158: $stored_form = join(',',
10159: map {
1.369 www 10160: &escape($_);
1.258 albertel 10161: } sort(@{$env{'form.'.$setting}}));
1.153 matthew 10162: } else {
10163: $stored_form =
1.369 www 10164: &escape($env{'form.'.$setting});
1.153 matthew 10165: }
10166: # Determine if the array contents are the same.
1.258 albertel 10167: if ($stored_form ne $env{$envname}) {
1.153 matthew 10168: $SaveHash{$basename} = $stored_form;
10169: $AppHash{$envname} = $stored_form;
10170: }
10171: }
10172: }
10173: }
10174: my $put_result = &Apache::lonnet::put('environment',\%SaveHash,
1.300 albertel 10175: $udom,$uname);
1.153 matthew 10176: if ($put_result !~ /^(ok|delayed)/) {
10177: &Apache::lonnet::logthis('unable to save form parameters, '.
10178: 'got error:'.$put_result);
10179: }
10180: # Make sure these settings stick around in this session, too
1.646 raeburn 10181: &Apache::lonnet::appenv(\%AppHash);
1.153 matthew 10182: return;
10183: }
10184:
10185: sub restore_course_settings {
1.499 albertel 10186: return &restore_settings($env{'request.course.id'},@_);
1.496 albertel 10187: }
10188:
10189: sub restore_settings {
10190: my ($context,$prefix,$Settings) = @_;
1.153 matthew 10191: while (my ($setting,$type) = each(%$Settings)) {
1.258 albertel 10192: next if (exists($env{'form.'.$setting}));
1.496 albertel 10193: my $envname = 'environment.internal.'.$context.'.'.$prefix.
1.153 matthew 10194: '.'.$setting;
1.258 albertel 10195: if (exists($env{$envname})) {
1.153 matthew 10196: if ($type eq 'scalar') {
1.258 albertel 10197: $env{'form.'.$setting} = $env{$envname};
1.153 matthew 10198: } elsif ($type eq 'array') {
1.258 albertel 10199: $env{'form.'.$setting} = [
1.153 matthew 10200: map {
1.369 www 10201: &unescape($_);
1.258 albertel 10202: } split(',',$env{$envname})
1.153 matthew 10203: ];
10204: }
10205: }
10206: }
1.127 matthew 10207: }
10208:
1.618 raeburn 10209: #######################################################
10210: #######################################################
10211:
10212: =pod
10213:
10214: =head1 Domain E-mail Routines
10215:
10216: =over 4
10217:
1.648 raeburn 10218: =item * &build_recipient_list()
1.618 raeburn 10219:
1.884 raeburn 10220: Build recipient lists for five types of e-mail:
1.766 raeburn 10221: (a) Error Reports, (b) Package Updates, (c) lonstatus warnings/errors
1.884 raeburn 10222: (d) Help requests, (e) Course requests needing approval, generated by
10223: lonerrorhandler.pm, CHECKRPMS, loncron, lonsupportreq.pm and
10224: loncoursequeueadmin.pm respectively.
1.618 raeburn 10225:
10226: Inputs:
1.619 raeburn 10227: defmail (scalar - email address of default recipient),
1.618 raeburn 10228: mailing type (scalar - errormail, packagesmail, or helpdeskmail),
1.619 raeburn 10229: defdom (domain for which to retrieve configuration settings),
10230: origmail (scalar - email address of recipient from loncapa.conf,
10231: i.e., predates configuration by DC via domainprefs.pm
1.618 raeburn 10232:
1.655 raeburn 10233: Returns: comma separated list of addresses to which to send e-mail.
10234:
10235: =back
1.618 raeburn 10236:
10237: =cut
10238:
10239: ############################################################
10240: ############################################################
10241: sub build_recipient_list {
1.619 raeburn 10242: my ($defmail,$mailing,$defdom,$origmail) = @_;
1.618 raeburn 10243: my @recipients;
10244: my $otheremails;
10245: my %domconfig =
10246: &Apache::lonnet::get_dom('configuration',['contacts'],$defdom);
10247: if (ref($domconfig{'contacts'}) eq 'HASH') {
1.766 raeburn 10248: if (exists($domconfig{'contacts'}{$mailing})) {
10249: if (ref($domconfig{'contacts'}{$mailing}) eq 'HASH') {
10250: my @contacts = ('adminemail','supportemail');
10251: foreach my $item (@contacts) {
10252: if ($domconfig{'contacts'}{$mailing}{$item}) {
10253: my $addr = $domconfig{'contacts'}{$item};
10254: if (!grep(/^\Q$addr\E$/,@recipients)) {
10255: push(@recipients,$addr);
10256: }
1.619 raeburn 10257: }
1.766 raeburn 10258: $otheremails = $domconfig{'contacts'}{$mailing}{'others'};
1.618 raeburn 10259: }
10260: }
1.766 raeburn 10261: } elsif ($origmail ne '') {
10262: push(@recipients,$origmail);
1.618 raeburn 10263: }
1.619 raeburn 10264: } elsif ($origmail ne '') {
10265: push(@recipients,$origmail);
1.618 raeburn 10266: }
1.688 raeburn 10267: if (defined($defmail)) {
10268: if ($defmail ne '') {
10269: push(@recipients,$defmail);
10270: }
1.618 raeburn 10271: }
10272: if ($otheremails) {
1.619 raeburn 10273: my @others;
10274: if ($otheremails =~ /,/) {
10275: @others = split(/,/,$otheremails);
1.618 raeburn 10276: } else {
1.619 raeburn 10277: push(@others,$otheremails);
10278: }
10279: foreach my $addr (@others) {
10280: if (!grep(/^\Q$addr\E$/,@recipients)) {
10281: push(@recipients,$addr);
10282: }
1.618 raeburn 10283: }
10284: }
1.619 raeburn 10285: my $recipientlist = join(',',@recipients);
1.618 raeburn 10286: return $recipientlist;
10287: }
10288:
1.127 matthew 10289: ############################################################
10290: ############################################################
1.154 albertel 10291:
1.655 raeburn 10292: =pod
10293:
10294: =head1 Course Catalog Routines
10295:
10296: =over 4
10297:
10298: =item * &gather_categories()
10299:
10300: Converts category definitions - keys of categories hash stored in
10301: coursecategories in configuration.db on the primary library server in a
10302: domain - to an array. Also generates javascript and idx hash used to
10303: generate Domain Coordinator interface for editing Course Categories.
10304:
10305: Inputs:
1.663 raeburn 10306:
1.655 raeburn 10307: categories (reference to hash of category definitions).
1.663 raeburn 10308:
1.655 raeburn 10309: cats (reference to array of arrays/hashes which encapsulates hierarchy of
10310: categories and subcategories).
1.663 raeburn 10311:
1.655 raeburn 10312: idx (reference to hash of counters used in Domain Coordinator interface for
10313: editing Course Categories).
1.663 raeburn 10314:
1.655 raeburn 10315: jsarray (reference to array of categories used to create Javascript arrays for
10316: Domain Coordinator interface for editing Course Categories).
10317:
10318: Returns: nothing
10319:
10320: Side effects: populates cats, idx and jsarray.
10321:
10322: =cut
10323:
10324: sub gather_categories {
10325: my ($categories,$cats,$idx,$jsarray) = @_;
10326: my %counters;
10327: my $num = 0;
10328: foreach my $item (keys(%{$categories})) {
10329: my ($cat,$container,$depth) = map { &unescape($_); } split(/:/,$item);
10330: if ($container eq '' && $depth == 0) {
10331: $cats->[$depth][$categories->{$item}] = $cat;
10332: } else {
10333: $cats->[$depth]{$container}[$categories->{$item}] = $cat;
10334: }
10335: my ($escitem,$tail) = split(/:/,$item,2);
10336: if ($counters{$tail} eq '') {
10337: $counters{$tail} = $num;
10338: $num ++;
10339: }
10340: if (ref($idx) eq 'HASH') {
10341: $idx->{$item} = $counters{$tail};
10342: }
10343: if (ref($jsarray) eq 'ARRAY') {
10344: push(@{$jsarray->[$counters{$tail}]},$item);
10345: }
10346: }
10347: return;
10348: }
10349:
10350: =pod
10351:
10352: =item * &extract_categories()
10353:
10354: Used to generate breadcrumb trails for course categories.
10355:
10356: Inputs:
1.663 raeburn 10357:
1.655 raeburn 10358: categories (reference to hash of category definitions).
1.663 raeburn 10359:
1.655 raeburn 10360: cats (reference to array of arrays/hashes which encapsulates hierarchy of
10361: categories and subcategories).
1.663 raeburn 10362:
1.655 raeburn 10363: trails (reference to array of breacrumb trails for each category).
1.663 raeburn 10364:
1.655 raeburn 10365: allitems (reference to hash - key is category key
10366: (format: escaped(name):escaped(parent category):depth in hierarchy).
1.663 raeburn 10367:
1.655 raeburn 10368: idx (reference to hash of counters used in Domain Coordinator interface for
10369: editing Course Categories).
1.663 raeburn 10370:
1.655 raeburn 10371: jsarray (reference to array of categories used to create Javascript arrays for
10372: Domain Coordinator interface for editing Course Categories).
10373:
1.665 raeburn 10374: subcats (reference to hash of arrays containing all subcategories within each
10375: category, -recursive)
10376:
1.655 raeburn 10377: Returns: nothing
10378:
10379: Side effects: populates trails and allitems hash references.
10380:
10381: =cut
10382:
10383: sub extract_categories {
1.665 raeburn 10384: my ($categories,$cats,$trails,$allitems,$idx,$jsarray,$subcats) = @_;
1.655 raeburn 10385: if (ref($categories) eq 'HASH') {
10386: &gather_categories($categories,$cats,$idx,$jsarray);
10387: if (ref($cats->[0]) eq 'ARRAY') {
10388: for (my $i=0; $i<@{$cats->[0]}; $i++) {
10389: my $name = $cats->[0][$i];
10390: my $item = &escape($name).'::0';
10391: my $trailstr;
10392: if ($name eq 'instcode') {
10393: $trailstr = &mt('Official courses (with institutional codes)');
1.919 raeburn 10394: } elsif ($name eq 'communities') {
10395: $trailstr = &mt('Communities');
1.655 raeburn 10396: } else {
10397: $trailstr = $name;
10398: }
10399: if ($allitems->{$item} eq '') {
10400: push(@{$trails},$trailstr);
10401: $allitems->{$item} = scalar(@{$trails})-1;
10402: }
10403: my @parents = ($name);
10404: if (ref($cats->[1]{$name}) eq 'ARRAY') {
10405: for (my $j=0; $j<@{$cats->[1]{$name}}; $j++) {
10406: my $category = $cats->[1]{$name}[$j];
1.665 raeburn 10407: if (ref($subcats) eq 'HASH') {
10408: push(@{$subcats->{$item}},&escape($category).':'.&escape($name).':1');
10409: }
10410: &recurse_categories($cats,2,$category,$trails,$allitems,\@parents,$subcats);
10411: }
10412: } else {
10413: if (ref($subcats) eq 'HASH') {
10414: $subcats->{$item} = [];
1.655 raeburn 10415: }
10416: }
10417: }
10418: }
10419: }
10420: return;
10421: }
10422:
10423: =pod
10424:
10425: =item *&recurse_categories()
10426:
10427: Recursively used to generate breadcrumb trails for course categories.
10428:
10429: Inputs:
1.663 raeburn 10430:
1.655 raeburn 10431: cats (reference to array of arrays/hashes which encapsulates hierarchy of
10432: categories and subcategories).
1.663 raeburn 10433:
1.655 raeburn 10434: depth (current depth in hierarchy of categories and sub-categories - 0 indexed).
1.663 raeburn 10435:
10436: category (current course category, for which breadcrumb trail is being generated).
10437:
10438: trails (reference to array of breadcrumb trails for each category).
10439:
1.655 raeburn 10440: allitems (reference to hash - key is category key
10441: (format: escaped(name):escaped(parent category):depth in hierarchy).
1.663 raeburn 10442:
1.655 raeburn 10443: parents (array containing containers directories for current category,
10444: back to top level).
10445:
10446: Returns: nothing
10447:
10448: Side effects: populates trails and allitems hash references
10449:
10450: =cut
10451:
10452: sub recurse_categories {
1.665 raeburn 10453: my ($cats,$depth,$category,$trails,$allitems,$parents,$subcats) = @_;
1.655 raeburn 10454: my $shallower = $depth - 1;
10455: if (ref($cats->[$depth]{$category}) eq 'ARRAY') {
10456: for (my $k=0; $k<@{$cats->[$depth]{$category}}; $k++) {
10457: my $name = $cats->[$depth]{$category}[$k];
10458: my $item = &escape($category).':'.&escape($parents->[-1]).':'.$shallower;
10459: my $trailstr = join(' -> ',(@{$parents},$category));
10460: if ($allitems->{$item} eq '') {
10461: push(@{$trails},$trailstr);
10462: $allitems->{$item} = scalar(@{$trails})-1;
10463: }
10464: my $deeper = $depth+1;
10465: push(@{$parents},$category);
1.665 raeburn 10466: if (ref($subcats) eq 'HASH') {
10467: my $subcat = &escape($name).':'.$category.':'.$depth;
10468: for (my $j=@{$parents}; $j>=0; $j--) {
10469: my $higher;
10470: if ($j > 0) {
10471: $higher = &escape($parents->[$j]).':'.
10472: &escape($parents->[$j-1]).':'.$j;
10473: } else {
10474: $higher = &escape($parents->[$j]).'::'.$j;
10475: }
10476: push(@{$subcats->{$higher}},$subcat);
10477: }
10478: }
10479: &recurse_categories($cats,$deeper,$name,$trails,$allitems,$parents,
10480: $subcats);
1.655 raeburn 10481: pop(@{$parents});
10482: }
10483: } else {
10484: my $item = &escape($category).':'.&escape($parents->[-1]).':'.$shallower;
10485: my $trailstr = join(' -> ',(@{$parents},$category));
10486: if ($allitems->{$item} eq '') {
10487: push(@{$trails},$trailstr);
10488: $allitems->{$item} = scalar(@{$trails})-1;
10489: }
10490: }
10491: return;
10492: }
10493:
1.663 raeburn 10494: =pod
10495:
10496: =item *&assign_categories_table()
10497:
10498: Create a datatable for display of hierarchical categories in a domain,
10499: with checkboxes to allow a course to be categorized.
10500:
10501: Inputs:
10502:
10503: cathash - reference to hash of categories defined for the domain (from
10504: configuration.db)
10505:
10506: currcat - scalar with an & separated list of categories assigned to a course.
10507:
1.919 raeburn 10508: type - scalar contains course type (Course or Community).
10509:
1.663 raeburn 10510: Returns: $output (markup to be displayed)
10511:
10512: =cut
10513:
10514: sub assign_categories_table {
1.919 raeburn 10515: my ($cathash,$currcat,$type) = @_;
1.663 raeburn 10516: my $output;
10517: if (ref($cathash) eq 'HASH') {
10518: my (@cats,@trails,%allitems,%idx,@jsarray,@path,$maxdepth);
10519: &extract_categories($cathash,\@cats,\@trails,\%allitems,\%idx,\@jsarray);
10520: $maxdepth = scalar(@cats);
10521: if (@cats > 0) {
10522: my $itemcount = 0;
10523: if (ref($cats[0]) eq 'ARRAY') {
10524: my @currcategories;
10525: if ($currcat ne '') {
10526: @currcategories = split('&',$currcat);
10527: }
1.919 raeburn 10528: my $table;
1.663 raeburn 10529: for (my $i=0; $i<@{$cats[0]}; $i++) {
10530: my $parent = $cats[0][$i];
1.919 raeburn 10531: next if ($parent eq 'instcode');
10532: if ($type eq 'Community') {
10533: next unless ($parent eq 'communities');
10534: } else {
10535: next if ($parent eq 'communities');
10536: }
1.663 raeburn 10537: my $css_class = $itemcount%2?' class="LC_odd_row"':'';
10538: my $item = &escape($parent).'::0';
10539: my $checked = '';
10540: if (@currcategories > 0) {
10541: if (grep(/^\Q$item\E$/,@currcategories)) {
1.772 bisitz 10542: $checked = ' checked="checked"';
1.663 raeburn 10543: }
10544: }
1.919 raeburn 10545: my $parent_title = $parent;
10546: if ($parent eq 'communities') {
10547: $parent_title = &mt('Communities');
10548: }
10549: $table .= '<tr '.$css_class.'><td><span class="LC_nobreak">'.
10550: '<input type="checkbox" name="usecategory" value="'.
10551: $item.'"'.$checked.' />'.$parent_title.'</span>'.
10552: '<input type="hidden" name="catname" value="'.$parent.'" /></td>';
1.663 raeburn 10553: my $depth = 1;
10554: push(@path,$parent);
1.919 raeburn 10555: $table .= &assign_category_rows($itemcount,\@cats,$depth,$parent,\@path,\@currcategories);
1.663 raeburn 10556: pop(@path);
1.919 raeburn 10557: $table .= '</tr><tr><td colspan="'.$maxdepth.'" class="LC_row_separator"></td></tr>';
1.663 raeburn 10558: $itemcount ++;
10559: }
1.919 raeburn 10560: if ($itemcount) {
10561: $output = &Apache::loncommon::start_data_table().
10562: $table.
10563: &Apache::loncommon::end_data_table();
10564: }
1.663 raeburn 10565: }
10566: }
10567: }
10568: return $output;
10569: }
10570:
10571: =pod
10572:
10573: =item *&assign_category_rows()
10574:
10575: Create a datatable row for display of nested categories in a domain,
10576: with checkboxes to allow a course to be categorized,called recursively.
10577:
10578: Inputs:
10579:
10580: itemcount - track row number for alternating colors
10581:
10582: cats - reference to array of arrays/hashes which encapsulates hierarchy of
10583: categories and subcategories.
10584:
10585: depth - current depth in hierarchy of categories and sub-categories - 0 indexed.
10586:
10587: parent - parent of current category item
10588:
10589: path - Array containing all categories back up through the hierarchy from the
10590: current category to the top level.
10591:
10592: currcategories - reference to array of current categories assigned to the course
10593:
10594: Returns: $output (markup to be displayed).
10595:
10596: =cut
10597:
10598: sub assign_category_rows {
10599: my ($itemcount,$cats,$depth,$parent,$path,$currcategories) = @_;
10600: my ($text,$name,$item,$chgstr);
10601: if (ref($cats) eq 'ARRAY') {
10602: my $maxdepth = scalar(@{$cats});
10603: if (ref($cats->[$depth]) eq 'HASH') {
10604: if (ref($cats->[$depth]{$parent}) eq 'ARRAY') {
10605: my $numchildren = @{$cats->[$depth]{$parent}};
10606: my $css_class = $itemcount%2?' class="LC_odd_row"':'';
10607: $text .= '<td><table class="LC_datatable">';
10608: for (my $j=0; $j<$numchildren; $j++) {
10609: $name = $cats->[$depth]{$parent}[$j];
10610: $item = &escape($name).':'.&escape($parent).':'.$depth;
10611: my $deeper = $depth+1;
10612: my $checked = '';
10613: if (ref($currcategories) eq 'ARRAY') {
10614: if (@{$currcategories} > 0) {
10615: if (grep(/^\Q$item\E$/,@{$currcategories})) {
1.772 bisitz 10616: $checked = ' checked="checked"';
1.663 raeburn 10617: }
10618: }
10619: }
1.664 raeburn 10620: $text .= '<tr><td><span class="LC_nobreak"><label>'.
10621: '<input type="checkbox" name="usecategory" value="'.
1.675 raeburn 10622: $item.'"'.$checked.' />'.$name.'</label></span>'.
10623: '<input type="hidden" name="catname" value="'.$name.'" />'.
10624: '</td><td>';
1.663 raeburn 10625: if (ref($path) eq 'ARRAY') {
10626: push(@{$path},$name);
10627: $text .= &assign_category_rows($itemcount,$cats,$deeper,$name,$path,$currcategories);
10628: pop(@{$path});
10629: }
10630: $text .= '</td></tr>';
10631: }
10632: $text .= '</table></td>';
10633: }
10634: }
10635: }
10636: return $text;
10637: }
10638:
1.655 raeburn 10639: ############################################################
10640: ############################################################
10641:
10642:
1.443 albertel 10643: sub commit_customrole {
1.664 raeburn 10644: my ($udom,$uname,$url,$three,$four,$five,$start,$end,$context) = @_;
1.630 raeburn 10645: my $output = &mt('Assigning custom role').' "'.$five.'" by '.$four.':'.$three.' in '.$url.
1.443 albertel 10646: ($start?', '.&mt('starting').' '.localtime($start):'').
10647: ($end?', ending '.localtime($end):'').': <b>'.
10648: &Apache::lonnet::assigncustomrole(
1.664 raeburn 10649: $udom,$uname,$url,$three,$four,$five,$end,$start,undef,undef,$context).
1.443 albertel 10650: '</b><br />';
10651: return $output;
10652: }
10653:
10654: sub commit_standardrole {
1.541 raeburn 10655: my ($udom,$uname,$url,$three,$start,$end,$one,$two,$sec,$context) = @_;
10656: my ($output,$logmsg,$linefeed);
10657: if ($context eq 'auto') {
10658: $linefeed = "\n";
10659: } else {
10660: $linefeed = "<br />\n";
10661: }
1.443 albertel 10662: if ($three eq 'st') {
1.541 raeburn 10663: my $result = &commit_studentrole(\$logmsg,$udom,$uname,$url,$three,$start,$end,
10664: $one,$two,$sec,$context);
10665: if (($result =~ /^error/) || ($result eq 'not_in_class') ||
1.626 raeburn 10666: ($result eq 'unknown_course') || ($result eq 'refused')) {
10667: $output = $logmsg.' '.&mt('Error: ').$result."\n";
1.443 albertel 10668: } else {
1.541 raeburn 10669: $output = $logmsg.$linefeed.&mt('Assigning').' '.$three.' in '.$url.
1.443 albertel 10670: ($start?', '.&mt('starting').' '.localtime($start):'').
1.541 raeburn 10671: ($end?', '.&mt('ending').' '.localtime($end):'').': ';
10672: if ($context eq 'auto') {
10673: $output .= $result.$linefeed.&mt('Add to classlist').': ok';
10674: } else {
10675: $output .= '<b>'.$result.'</b>'.$linefeed.
10676: &mt('Add to classlist').': <b>ok</b>';
10677: }
10678: $output .= $linefeed;
1.443 albertel 10679: }
10680: } else {
10681: $output = &mt('Assigning').' '.$three.' in '.$url.
10682: ($start?', '.&mt('starting').' '.localtime($start):'').
1.541 raeburn 10683: ($end?', '.&mt('ending').' '.localtime($end):'').': ';
1.652 raeburn 10684: my $result = &Apache::lonnet::assignrole($udom,$uname,$url,$three,$end,$start,'','',$context);
1.541 raeburn 10685: if ($context eq 'auto') {
10686: $output .= $result.$linefeed;
10687: } else {
10688: $output .= '<b>'.$result.'</b>'.$linefeed;
10689: }
1.443 albertel 10690: }
10691: return $output;
10692: }
10693:
10694: sub commit_studentrole {
1.541 raeburn 10695: my ($logmsg,$udom,$uname,$url,$three,$start,$end,$one,$two,$sec,$context) = @_;
1.626 raeburn 10696: my ($result,$linefeed,$oldsecurl,$newsecurl);
1.541 raeburn 10697: if ($context eq 'auto') {
10698: $linefeed = "\n";
10699: } else {
10700: $linefeed = '<br />'."\n";
10701: }
1.443 albertel 10702: if (defined($one) && defined($two)) {
10703: my $cid=$one.'_'.$two;
10704: my $oldsec=&Apache::lonnet::getsection($udom,$uname,$cid);
10705: my $secchange = 0;
10706: my $expire_role_result;
10707: my $modify_section_result;
1.628 raeburn 10708: if ($oldsec ne '-1') {
10709: if ($oldsec ne $sec) {
1.443 albertel 10710: $secchange = 1;
1.628 raeburn 10711: my $now = time;
1.443 albertel 10712: my $uurl='/'.$cid;
10713: $uurl=~s/\_/\//g;
10714: if ($oldsec) {
10715: $uurl.='/'.$oldsec;
10716: }
1.626 raeburn 10717: $oldsecurl = $uurl;
1.628 raeburn 10718: $expire_role_result =
1.652 raeburn 10719: &Apache::lonnet::assignrole($udom,$uname,$uurl,'st',$now,'','',$context);
1.628 raeburn 10720: if ($env{'request.course.sec'} ne '') {
10721: if ($expire_role_result eq 'refused') {
10722: my @roles = ('st');
10723: my @statuses = ('previous');
10724: my @roledoms = ($one);
10725: my $withsec = 1;
10726: my %roleshash =
10727: &Apache::lonnet::get_my_roles($uname,$udom,'userroles',
10728: \@statuses,\@roles,\@roledoms,$withsec);
10729: if (defined ($roleshash{$two.':'.$one.':st:'.$oldsec})) {
10730: my ($oldstart,$oldend) =
10731: split(':',$roleshash{$two.':'.$one.':st:'.$oldsec});
10732: if ($oldend > 0 && $oldend <= $now) {
10733: $expire_role_result = 'ok';
10734: }
10735: }
10736: }
10737: }
1.443 albertel 10738: $result = $expire_role_result;
10739: }
10740: }
10741: if (($expire_role_result eq 'ok') || ($secchange == 0)) {
1.652 raeburn 10742: $modify_section_result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,'','',$cid,'',$context);
1.443 albertel 10743: if ($modify_section_result =~ /^ok/) {
10744: if ($secchange == 1) {
1.628 raeburn 10745: if ($sec eq '') {
10746: $$logmsg .= &mt('Section for [_1] switched from (possibly expired) old section: [_2] to student role without a section.',$uname,$oldsec).$linefeed;
10747: } else {
10748: $$logmsg .= &mt('Section for [_1] switched from (possibly expired) old section: [_2] to new section: [_3].',$uname,$oldsec,$sec).$linefeed;
10749: }
1.443 albertel 10750: } elsif ($oldsec eq '-1') {
1.628 raeburn 10751: if ($sec eq '') {
10752: $$logmsg .= &mt('New student role without a section for [_1] in course [_2].',$uname,$cid).$linefeed;
10753: } else {
10754: $$logmsg .= &mt('New student role for [_1] in section [_2] in course [_3].',$uname,$sec,$cid).$linefeed;
10755: }
1.443 albertel 10756: } else {
1.628 raeburn 10757: if ($sec eq '') {
10758: $$logmsg .= &mt('Student [_1] assigned to course [_2] without a section.',$uname,$cid).$linefeed;
10759: } else {
10760: $$logmsg .= &mt('Student [_1] assigned to section [_2] in course [_3].',$uname,$sec,$cid).$linefeed;
10761: }
1.443 albertel 10762: }
10763: } else {
1.628 raeburn 10764: if ($secchange) {
10765: $$logmsg .= &mt('Error when attempting section change for [_1] from old section "[_2]" to new section: "[_3]" in course [_4] -error:',$uname,$oldsec,$sec,$cid).' '.$modify_section_result.$linefeed;
10766: } else {
10767: $$logmsg .= &mt('Error when attempting to modify role for [_1] for section: "[_2]" in course [_3] -error:',$uname,$sec,$cid).' '.$modify_section_result.$linefeed;
10768: }
1.443 albertel 10769: }
10770: $result = $modify_section_result;
10771: } elsif ($secchange == 1) {
1.628 raeburn 10772: if ($oldsec eq '') {
10773: $$logmsg .= &mt('Error when attempting to expire existing role without a section for [_1] in course [_3] -error: ',$uname,$cid).' '.$expire_role_result.$linefeed;
10774: } else {
10775: $$logmsg .= &mt('Error when attempting to expire existing role for [_1] in section [_2] in course [_3] -error: ',$uname,$oldsec,$cid).' '.$expire_role_result.$linefeed;
10776: }
1.626 raeburn 10777: if ($expire_role_result eq 'refused') {
10778: my $newsecurl = '/'.$cid;
10779: $newsecurl =~ s/\_/\//g;
10780: if ($sec ne '') {
10781: $newsecurl.='/'.$sec;
10782: }
10783: if (&Apache::lonnet::allowed('cst',$newsecurl) && !(&Apache::lonnet::allowed('cst',$oldsecurl))) {
10784: if ($sec eq '') {
10785: $$logmsg .= &mt('Although your current role has privileges to add students to section "[_1]", you do not have privileges to modify existing enrollments unaffiliated with any section.',$sec).$linefeed;
10786: } else {
10787: $$logmsg .= &mt('Although your current role has privileges to add students to section "[_1]", you do not have privileges to modify existing enrollments in other sections.',$sec).$linefeed;
10788: }
10789: }
10790: }
1.443 albertel 10791: }
10792: } else {
1.626 raeburn 10793: $$logmsg .= &mt('Incomplete course id defined.').$linefeed.&mt('Addition of user [_1] from domain [_2] to course [_3], section [_4] not completed.',$uname,$udom,$one.'_'.$two,$sec).$linefeed;
1.443 albertel 10794: $result = "error: incomplete course id\n";
10795: }
10796: return $result;
10797: }
10798:
10799: ############################################################
10800: ############################################################
10801:
1.566 albertel 10802: sub check_clone {
1.578 raeburn 10803: my ($args,$linefeed) = @_;
1.566 albertel 10804: my $cloneid='/'.$args->{'clonedomain'}.'/'.$args->{'clonecourse'};
10805: my ($clonecrsudom,$clonecrsunum)= &LONCAPA::split_courseid($cloneid);
10806: my $clonehome=&Apache::lonnet::homeserver($clonecrsunum,$clonecrsudom);
10807: my $clonemsg;
10808: my $can_clone = 0;
1.944 raeburn 10809: my $lctype = lc($args->{'crstype'});
1.908 raeburn 10810: if ($lctype ne 'community') {
10811: $lctype = 'course';
10812: }
1.566 albertel 10813: if ($clonehome eq 'no_host') {
1.944 raeburn 10814: if ($args->{'crstype'} eq 'Community') {
1.908 raeburn 10815: $clonemsg = &mt('No new community created.').$linefeed.&mt('A new community could not be cloned from the specified original - [_1] - because it is a non-existent community.',$args->{'clonecourse'}.':'.$args->{'clonedomain'});
10816: } else {
10817: $clonemsg = &mt('No new course created.').$linefeed.&mt('A new course could not be cloned from the specified original - [_1] - because it is a non-existent course.',$args->{'clonecourse'}.':'.$args->{'clonedomain'});
10818: }
1.566 albertel 10819: } else {
10820: my %clonedesc = &Apache::lonnet::coursedescription($cloneid,{'one_time' => 1});
1.944 raeburn 10821: if ($args->{'crstype'} eq 'Community') {
1.908 raeburn 10822: if ($clonedesc{'type'} ne 'Community') {
10823: $clonemsg = &mt('No new community created.').$linefeed.&mt('A new community could not be cloned from the specified original - [_1] - because it is a course not a community.',$args->{'clonecourse'}.':'.$args->{'clonedomain'});
10824: return ($can_clone, $clonemsg, $cloneid, $clonehome);
10825: }
10826: }
1.882 raeburn 10827: if (($env{'request.role.domain'} eq $args->{'clonedomain'}) &&
10828: (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'}))) {
1.566 albertel 10829: $can_clone = 1;
10830: } else {
10831: my %clonehash = &Apache::lonnet::get('environment',['cloners'],
10832: $args->{'clonedomain'},$args->{'clonecourse'});
10833: my @cloners = split(/,/,$clonehash{'cloners'});
1.578 raeburn 10834: if (grep(/^\*$/,@cloners)) {
10835: $can_clone = 1;
10836: } elsif (grep(/^\*\:\Q$args->{'ccdomain'}\E$/,@cloners)) {
10837: $can_clone = 1;
10838: } else {
1.908 raeburn 10839: my $ccrole = 'cc';
1.944 raeburn 10840: if ($args->{'crstype'} eq 'Community') {
1.908 raeburn 10841: $ccrole = 'co';
10842: }
1.578 raeburn 10843: my %roleshash =
10844: &Apache::lonnet::get_my_roles($args->{'ccuname'},
10845: $args->{'ccdomain'},
1.908 raeburn 10846: 'userroles',['active'],[$ccrole],
1.578 raeburn 10847: [$args->{'clonedomain'}]);
1.908 raeburn 10848: if (($roleshash{$args->{'clonecourse'}.':'.$args->{'clonedomain'}.':'.$ccrole}) || (grep(/^\Q$args->{'ccuname'}\E:\Q$args->{'ccdomain'}\E$/,@cloners))) {
1.942 raeburn 10849: $can_clone = 1;
10850: } elsif (&Apache::lonnet::is_course_owner($args->{'clonedomain'},$args->{'clonecourse'},$args->{'ccuname'},$args->{'ccdomain'})) {
10851: $can_clone = 1;
10852: } else {
1.944 raeburn 10853: if ($args->{'crstype'} eq 'Community') {
1.908 raeburn 10854: $clonemsg = &mt('No new community created.').$linefeed.&mt('The new community could not be cloned from the existing community because the new community owner ([_1]) does not have cloning rights in the existing community ([_2]).',$args->{'ccuname'}.':'.$args->{'ccdomain'},$clonedesc{'description'});
10855: } else {
10856: $clonemsg = &mt('No new course created.').$linefeed.&mt('The new course could not be cloned from the existing course because the new course owner ([_1]) does not have cloning rights in the existing course ([_2]).',$args->{'ccuname'}.':'.$args->{'ccdomain'},$clonedesc{'description'});
10857: }
1.578 raeburn 10858: }
1.566 albertel 10859: }
1.578 raeburn 10860: }
1.566 albertel 10861: }
10862: return ($can_clone, $clonemsg, $cloneid, $clonehome);
10863: }
10864:
1.444 albertel 10865: sub construct_course {
1.885 raeburn 10866: my ($args,$logmsg,$courseid,$crsudom,$crsunum,$udom,$uname,$context,$cnum,$category) = @_;
1.444 albertel 10867: my $outcome;
1.541 raeburn 10868: my $linefeed = '<br />'."\n";
10869: if ($context eq 'auto') {
10870: $linefeed = "\n";
10871: }
1.566 albertel 10872:
10873: #
10874: # Are we cloning?
10875: #
10876: my ($can_clone, $clonemsg, $cloneid, $clonehome);
10877: if (($args->{'clonecourse'}) && ($args->{'clonedomain'})) {
1.578 raeburn 10878: ($can_clone, $clonemsg, $cloneid, $clonehome) = &check_clone($args,$linefeed);
1.566 albertel 10879: if ($context ne 'auto') {
1.578 raeburn 10880: if ($clonemsg ne '') {
10881: $clonemsg = '<span class="LC_error">'.$clonemsg.'</span>';
10882: }
1.566 albertel 10883: }
10884: $outcome .= $clonemsg.$linefeed;
10885:
10886: if (!$can_clone) {
10887: return (0,$outcome);
10888: }
10889: }
10890:
1.444 albertel 10891: #
10892: # Open course
10893: #
10894: my $crstype = lc($args->{'crstype'});
10895: my %cenv=();
10896: $$courseid=&Apache::lonnet::createcourse($args->{'course_domain'},
10897: $args->{'cdescr'},
10898: $args->{'curl'},
10899: $args->{'course_home'},
10900: $args->{'nonstandard'},
10901: $args->{'crscode'},
10902: $args->{'ccuname'}.':'.
10903: $args->{'ccdomain'},
1.882 raeburn 10904: $args->{'crstype'},
1.885 raeburn 10905: $cnum,$context,$category);
1.444 albertel 10906:
10907: # Note: The testing routines depend on this being output; see
10908: # Utils::Course. This needs to at least be output as a comment
10909: # if anyone ever decides to not show this, and Utils::Course::new
10910: # will need to be suitably modified.
1.541 raeburn 10911: $outcome .= &mt('New LON-CAPA [_1] ID: [_2]',$crstype,$$courseid).$linefeed;
1.943 raeburn 10912: if ($$courseid =~ /^error:/) {
10913: return (0,$outcome);
10914: }
10915:
1.444 albertel 10916: #
10917: # Check if created correctly
10918: #
1.479 albertel 10919: ($$crsudom,$$crsunum)= &LONCAPA::split_courseid($$courseid);
1.444 albertel 10920: my $crsuhome=&Apache::lonnet::homeserver($$crsunum,$$crsudom);
1.943 raeburn 10921: if ($crsuhome eq 'no_host') {
10922: $outcome .= &mt('Course creation failed, unrecognized course home server.').$linefeed;
10923: return (0,$outcome);
10924: }
1.541 raeburn 10925: $outcome .= &mt('Created on').': '.$crsuhome.$linefeed;
1.566 albertel 10926:
1.444 albertel 10927: #
1.566 albertel 10928: # Do the cloning
10929: #
10930: if ($can_clone && $cloneid) {
10931: $clonemsg = &mt('Cloning [_1] from [_2]',$crstype,$clonehome);
10932: if ($context ne 'auto') {
10933: $clonemsg = '<span class="LC_success">'.$clonemsg.'</span>';
10934: }
10935: $outcome .= $clonemsg.$linefeed;
10936: my %oldcenv=&Apache::lonnet::dump('environment',$$crsudom,$$crsunum);
1.444 albertel 10937: # Copy all files
1.637 www 10938: &Apache::lonclonecourse::copycoursefiles($cloneid,$$courseid,$args->{'datemode'},$args->{'dateshift'});
1.444 albertel 10939: # Restore URL
1.566 albertel 10940: $cenv{'url'}=$oldcenv{'url'};
1.444 albertel 10941: # Restore title
1.566 albertel 10942: $cenv{'description'}=$oldcenv{'description'};
1.948.2.2 raeburn 10943: # Restore creation date, creator and creation context.
10944: $cenv{'internal.created'}=$oldcenv{'internal.created'};
10945: $cenv{'internal.creator'}=$oldcenv{'internal.creator'};
10946: $cenv{'internal.creationcontext'}=$oldcenv{'internal.creationcontext'};
1.444 albertel 10947: # Mark as cloned
1.566 albertel 10948: $cenv{'clonedfrom'}=$cloneid;
1.638 www 10949: # Need to clone grading mode
10950: my %newenv=&Apache::lonnet::get('environment',['grading'],$$crsudom,$$crsunum);
10951: $cenv{'grading'}=$newenv{'grading'};
10952: # Do not clone these environment entries
10953: &Apache::lonnet::del('environment',
10954: ['default_enrollment_start_date',
10955: 'default_enrollment_end_date',
10956: 'question.email',
10957: 'policy.email',
10958: 'comment.email',
10959: 'pch.users.denied',
1.725 raeburn 10960: 'plc.users.denied',
10961: 'hidefromcat',
10962: 'categories'],
1.638 www 10963: $$crsudom,$$crsunum);
1.444 albertel 10964: }
1.566 albertel 10965:
1.444 albertel 10966: #
10967: # Set environment (will override cloned, if existing)
10968: #
10969: my @sections = ();
10970: my @xlists = ();
10971: if ($args->{'crstype'}) {
10972: $cenv{'type'}=$args->{'crstype'};
10973: }
10974: if ($args->{'crsid'}) {
10975: $cenv{'courseid'}=$args->{'crsid'};
10976: }
10977: if ($args->{'crscode'}) {
10978: $cenv{'internal.coursecode'}=$args->{'crscode'};
10979: }
10980: if ($args->{'crsquota'} ne '') {
10981: $cenv{'internal.coursequota'}=$args->{'crsquota'};
10982: } else {
10983: $cenv{'internal.coursequota'}=$args->{'crsquota'} = 20;
10984: }
10985: if ($args->{'ccuname'}) {
10986: $cenv{'internal.courseowner'} = $args->{'ccuname'}.
10987: ':'.$args->{'ccdomain'};
10988: } else {
10989: $cenv{'internal.courseowner'} = $args->{'curruser'};
10990: }
10991: my @badclasses = (); # Used to accumulate sections/crosslistings that did not pass classlist access check for course owner.
10992: if ($args->{'crssections'}) {
10993: $cenv{'internal.sectionnums'} = '';
10994: if ($args->{'crssections'} =~ m/,/) {
10995: @sections = split/,/,$args->{'crssections'};
10996: } else {
10997: $sections[0] = $args->{'crssections'};
10998: }
10999: if (@sections > 0) {
11000: foreach my $item (@sections) {
11001: my ($sec,$gp) = split/:/,$item;
11002: my $class = $args->{'crscode'}.$sec;
11003: my $addcheck = &Apache::lonnet::auto_new_course($$crsunum,$$crsudom,$class,$cenv{'internal.courseowner'});
11004: $cenv{'internal.sectionnums'} .= $item.',';
11005: unless ($addcheck eq 'ok') {
11006: push @badclasses, $class;
11007: }
11008: }
11009: $cenv{'internal.sectionnums'} =~ s/,$//;
11010: }
11011: }
11012: # do not hide course coordinator from staff listing,
11013: # even if privileged
11014: $cenv{'nothideprivileged'}=$args->{'ccuname'}.':'.$args->{'ccdomain'};
11015: # add crosslistings
11016: if ($args->{'crsxlist'}) {
11017: $cenv{'internal.crosslistings'}='';
11018: if ($args->{'crsxlist'} =~ m/,/) {
11019: @xlists = split/,/,$args->{'crsxlist'};
11020: } else {
11021: $xlists[0] = $args->{'crsxlist'};
11022: }
11023: if (@xlists > 0) {
11024: foreach my $item (@xlists) {
11025: my ($xl,$gp) = split/:/,$item;
11026: my $addcheck = &Apache::lonnet::auto_new_course($$crsunum,$$crsudom,$xl,$cenv{'internal.courseowner'});
11027: $cenv{'internal.crosslistings'} .= $item.',';
11028: unless ($addcheck eq 'ok') {
11029: push @badclasses, $xl;
11030: }
11031: }
11032: $cenv{'internal.crosslistings'} =~ s/,$//;
11033: }
11034: }
11035: if ($args->{'autoadds'}) {
11036: $cenv{'internal.autoadds'}=$args->{'autoadds'};
11037: }
11038: if ($args->{'autodrops'}) {
11039: $cenv{'internal.autodrops'}=$args->{'autodrops'};
11040: }
11041: # check for notification of enrollment changes
11042: my @notified = ();
11043: if ($args->{'notify_owner'}) {
11044: if ($args->{'ccuname'} ne '') {
11045: push(@notified,$args->{'ccuname'}.':'.$args->{'ccdomain'});
11046: }
11047: }
11048: if ($args->{'notify_dc'}) {
11049: if ($uname ne '') {
1.630 raeburn 11050: push(@notified,$uname.':'.$udom);
1.444 albertel 11051: }
11052: }
11053: if (@notified > 0) {
11054: my $notifylist;
11055: if (@notified > 1) {
11056: $notifylist = join(',',@notified);
11057: } else {
11058: $notifylist = $notified[0];
11059: }
11060: $cenv{'internal.notifylist'} = $notifylist;
11061: }
11062: if (@badclasses > 0) {
11063: my %lt=&Apache::lonlocal::texthash(
11064: 'tclb' => 'The courses listed below were included as sections or crosslistings affiliated with your new LON-CAPA course. However, if automated course roster updates are enabled for this class, these particular sections/crosslistings will not contribute towards enrollment, because the user identified as the course owner for this LON-CAPA course',
11065: 'dnhr' => 'does not have rights to access enrollment in these classes',
11066: 'adby' => 'as determined by the policies of your institution on access to official classlists'
11067: );
1.541 raeburn 11068: my $badclass_msg = $cenv{'internal.courseowner'}.') - '.$lt{'dnhr'}.
11069: ' ('.$lt{'adby'}.')';
11070: if ($context eq 'auto') {
11071: $outcome .= $badclass_msg.$linefeed;
1.566 albertel 11072: $outcome .= '<div class="LC_warning">'.$badclass_msg.$linefeed.'<ul>'."\n";
1.541 raeburn 11073: foreach my $item (@badclasses) {
11074: if ($context eq 'auto') {
11075: $outcome .= " - $item\n";
11076: } else {
11077: $outcome .= "<li>$item</li>\n";
11078: }
11079: }
11080: if ($context eq 'auto') {
11081: $outcome .= $linefeed;
11082: } else {
1.566 albertel 11083: $outcome .= "</ul><br /><br /></div>\n";
1.541 raeburn 11084: }
11085: }
1.444 albertel 11086: }
11087: if ($args->{'no_end_date'}) {
11088: $args->{'endaccess'} = 0;
11089: }
11090: $cenv{'internal.autostart'}=$args->{'enrollstart'};
11091: $cenv{'internal.autoend'}=$args->{'enrollend'};
11092: $cenv{'default_enrollment_start_date'}=$args->{'startaccess'};
11093: $cenv{'default_enrollment_end_date'}=$args->{'endaccess'};
11094: if ($args->{'showphotos'}) {
11095: $cenv{'internal.showphotos'}=$args->{'showphotos'};
11096: }
11097: $cenv{'internal.authtype'} = $args->{'authtype'};
11098: $cenv{'internal.autharg'} = $args->{'autharg'};
11099: if ( ($cenv{'internal.authtype'} =~ /^krb/) && ($cenv{'internal.autoadds'} == 1)) {
11100: if (! defined($cenv{'internal.autharg'}) || $cenv{'internal.autharg'} eq '') {
1.541 raeburn 11101: my $krb_msg = &mt('As you did not include the default Kerberos domain to be used for authentication in this class, the institutional data used by the automated enrollment process must include the Kerberos domain for each new student');
11102: if ($context eq 'auto') {
11103: $outcome .= $krb_msg;
11104: } else {
1.566 albertel 11105: $outcome .= '<span class="LC_error">'.$krb_msg.'</span>';
1.541 raeburn 11106: }
11107: $outcome .= $linefeed;
1.444 albertel 11108: }
11109: }
11110: if (($args->{'ccdomain'}) && ($args->{'ccuname'})) {
11111: if ($args->{'setpolicy'}) {
11112: $cenv{'policy.email'}=$args->{'ccuname'}.':'.$args->{'ccdomain'};
11113: }
11114: if ($args->{'setcontent'}) {
11115: $cenv{'question.email'}=$args->{'ccuname'}.':'.$args->{'ccdomain'};
11116: }
11117: }
11118: if ($args->{'reshome'}) {
11119: $cenv{'reshome'}=$args->{'reshome'}.'/';
11120: $cenv{'reshome'}=~s/\/+$/\//;
11121: }
11122: #
11123: # course has keyed access
11124: #
11125: if ($args->{'setkeys'}) {
11126: $cenv{'keyaccess'}='yes';
11127: }
11128: # if specified, key authority is not course, but user
11129: # only active if keyaccess is yes
11130: if ($args->{'keyauth'}) {
1.487 albertel 11131: my ($user,$domain) = split(':',$args->{'keyauth'});
11132: $user = &LONCAPA::clean_username($user);
11133: $domain = &LONCAPA::clean_username($domain);
1.488 foxr 11134: if ($user ne '' && $domain ne '') {
1.487 albertel 11135: $cenv{'keyauth'}=$user.':'.$domain;
1.444 albertel 11136: }
11137: }
11138:
11139: if ($args->{'disresdis'}) {
11140: $cenv{'pch.roles.denied'}='st';
11141: }
11142: if ($args->{'disablechat'}) {
11143: $cenv{'plc.roles.denied'}='st';
11144: }
11145:
11146: # Record we've not yet viewed the Course Initialization Helper for this
11147: # course
11148: $cenv{'course.helper.not.run'} = 1;
11149: #
11150: # Use new Randomseed
11151: #
11152: $cenv{'rndseed'}=&Apache::lonnet::latest_rnd_algorithm_id();;
11153: $cenv{'receiptalg'}=&Apache::lonnet::latest_receipt_algorithm_id();;
11154: #
11155: # The encryption code and receipt prefix for this course
11156: #
11157: $cenv{'internal.encseed'}=$Apache::lonnet::perlvar{'lonReceipt'}.$$.time.int(rand(9999));
11158: $cenv{'internal.encpref'}=100+int(9*rand(99));
11159: #
11160: # By default, use standard grading
11161: if (!defined($cenv{'grading'})) { $cenv{'grading'} = 'standard'; }
11162:
1.541 raeburn 11163: $outcome .= $linefeed.&mt('Setting environment').': '.
11164: &Apache::lonnet::put('environment',\%cenv,$$crsudom,$$crsunum).$linefeed;
1.444 albertel 11165: #
11166: # Open all assignments
11167: #
11168: if ($args->{'openall'}) {
11169: my $storeunder=$$crsudom.'_'.$$crsunum.'.0.opendate';
11170: my %storecontent = ($storeunder => time,
11171: $storeunder.'.type' => 'date_start');
11172:
11173: $outcome .= &mt('Opening all assignments').': '.&Apache::lonnet::cput
1.541 raeburn 11174: ('resourcedata',\%storecontent,$$crsudom,$$crsunum).$linefeed;
1.444 albertel 11175: }
11176: #
11177: # Set first page
11178: #
11179: unless (($args->{'nonstandard'}) || ($args->{'firstres'} eq 'blank')
11180: || ($cloneid)) {
1.445 albertel 11181: use LONCAPA::map;
1.444 albertel 11182: $outcome .= &mt('Setting first resource').': ';
1.445 albertel 11183:
11184: my $map = '/uploaded/'.$$crsudom.'/'.$$crsunum.'/default.sequence';
11185: my ($errtext,$fatal)=&LONCAPA::map::mapread($map);
11186:
1.444 albertel 11187: $outcome .= ($fatal?$errtext:'read ok').' - ';
11188: my $title; my $url;
11189: if ($args->{'firstres'} eq 'syl') {
1.690 bisitz 11190: $title=&mt('Syllabus');
1.444 albertel 11191: $url='/public/'.$$crsudom.'/'.$$crsunum.'/syllabus';
11192: } else {
1.948.2.5 raeburn 11193: $title=&mt('Table of Contents');
1.444 albertel 11194: $url='/adm/navmaps';
11195: }
1.445 albertel 11196:
11197: $LONCAPA::map::resources[1]=$title.':'.$url.':false:start:res';
11198: (my $outtext,$errtext) = &LONCAPA::map::storemap($map,1);
11199:
11200: if ($errtext) { $fatal=2; }
1.541 raeburn 11201: $outcome .= ($fatal?$errtext:'write ok').$linefeed;
1.444 albertel 11202: }
1.566 albertel 11203:
11204: return (1,$outcome);
1.444 albertel 11205: }
11206:
11207: ############################################################
11208: ############################################################
11209:
1.378 raeburn 11210: sub course_type {
11211: my ($cid) = @_;
11212: if (!defined($cid)) {
11213: $cid = $env{'request.course.id'};
11214: }
1.404 albertel 11215: if (defined($env{'course.'.$cid.'.type'})) {
11216: return $env{'course.'.$cid.'.type'};
1.378 raeburn 11217: } else {
11218: return 'Course';
1.377 raeburn 11219: }
11220: }
1.156 albertel 11221:
1.406 raeburn 11222: sub group_term {
11223: my $crstype = &course_type();
11224: my %names = (
11225: 'Course' => 'group',
1.865 raeburn 11226: 'Community' => 'group',
1.406 raeburn 11227: );
11228: return $names{$crstype};
11229: }
11230:
1.902 raeburn 11231: sub course_types {
11232: my @types = ('official','unofficial','community');
11233: my %typename = (
11234: official => 'Official course',
11235: unofficial => 'Unofficial course',
11236: community => 'Community',
11237: );
11238: return (\@types,\%typename);
11239: }
11240:
1.156 albertel 11241: sub icon {
11242: my ($file)=@_;
1.505 albertel 11243: my $curfext = lc((split(/\./,$file))[-1]);
1.168 albertel 11244: my $iconname=$Apache::lonnet::perlvar{'lonIconsURL'}.'/unknown.gif';
1.156 albertel 11245: my $embstyle = &Apache::loncommon::fileembstyle($curfext);
1.168 albertel 11246: if (!(!defined($embstyle) || $embstyle eq 'unk' || $embstyle eq 'hdn')) {
11247: if (-e $Apache::lonnet::perlvar{'lonDocRoot'}.'/'.
11248: $Apache::lonnet::perlvar{'lonIconsURL'}.'/'.
11249: $curfext.".gif") {
11250: $iconname=$Apache::lonnet::perlvar{'lonIconsURL'}.'/'.
11251: $curfext.".gif";
11252: }
11253: }
1.249 albertel 11254: return &lonhttpdurl($iconname);
1.154 albertel 11255: }
1.84 albertel 11256:
1.575 albertel 11257: sub lonhttpdurl {
1.692 www 11258: #
11259: # Had been used for "small fry" static images on separate port 8080.
11260: # Modify here if lightweight http functionality desired again.
11261: # Currently eliminated due to increasing firewall issues.
11262: #
1.575 albertel 11263: my ($url)=@_;
1.692 www 11264: return $url;
1.215 albertel 11265: }
11266:
1.213 albertel 11267: sub connection_aborted {
11268: my ($r)=@_;
11269: $r->print(" ");$r->rflush();
11270: my $c = $r->connection;
11271: return $c->aborted();
11272: }
11273:
1.221 foxr 11274: # Escapes strings that may have embedded 's that will be put into
1.222 foxr 11275: # strings as 'strings'.
11276: sub escape_single {
1.221 foxr 11277: my ($input) = @_;
1.223 albertel 11278: $input =~ s/\\/\\\\/g; # Escape the \'s..(must be first)>
1.221 foxr 11279: $input =~ s/\'/\\\'/g; # Esacpe the 's....
11280: return $input;
11281: }
1.223 albertel 11282:
1.222 foxr 11283: # Same as escape_single, but escape's "'s This
11284: # can be used for "strings"
11285: sub escape_double {
11286: my ($input) = @_;
11287: $input =~ s/\\/\\\\/g; # Escape the /'s..(must be first)>
11288: $input =~ s/\"/\\\"/g; # Esacpe the "s....
11289: return $input;
11290: }
1.223 albertel 11291:
1.222 foxr 11292: # Escapes the last element of a full URL.
11293: sub escape_url {
11294: my ($url) = @_;
1.238 raeburn 11295: my @urlslices = split(/\//, $url,-1);
1.369 www 11296: my $lastitem = &escape(pop(@urlslices));
1.223 albertel 11297: return join('/',@urlslices).'/'.$lastitem;
1.222 foxr 11298: }
1.462 albertel 11299:
1.820 raeburn 11300: sub compare_arrays {
11301: my ($arrayref1,$arrayref2) = @_;
11302: my (@difference,%count);
11303: @difference = ();
11304: %count = ();
11305: if ((ref($arrayref1) eq 'ARRAY') && (ref($arrayref2) eq 'ARRAY')) {
11306: foreach my $element (@{$arrayref1}, @{$arrayref2}) { $count{$element}++; }
11307: foreach my $element (keys(%count)) {
11308: if ($count{$element} == 1) {
11309: push(@difference,$element);
11310: }
11311: }
11312: }
11313: return @difference;
11314: }
11315:
1.817 bisitz 11316: # -------------------------------------------------------- Initialize user login
1.462 albertel 11317: sub init_user_environment {
1.463 albertel 11318: my ($r, $username, $domain, $authhost, $form, $args) = @_;
1.462 albertel 11319: my $lonids=$Apache::lonnet::perlvar{'lonIDsDir'};
11320:
11321: my $public=($username eq 'public' && $domain eq 'public');
11322:
11323: # See if old ID present, if so, remove
11324:
11325: my ($filename,$cookie,$userroles);
11326: my $now=time;
11327:
11328: if ($public) {
11329: my $max_public=100;
11330: my $oldest;
11331: my $oldest_time=0;
11332: for(my $next=1;$next<=$max_public;$next++) {
11333: if (-e $lonids."/publicuser_$next.id") {
11334: my $mtime=(stat($lonids."/publicuser_$next.id"))[9];
11335: if ($mtime<$oldest_time || !$oldest_time) {
11336: $oldest_time=$mtime;
11337: $oldest=$next;
11338: }
11339: } else {
11340: $cookie="publicuser_$next";
11341: last;
11342: }
11343: }
11344: if (!$cookie) { $cookie="publicuser_$oldest"; }
11345: } else {
1.463 albertel 11346: # if this isn't a robot, kill any existing non-robot sessions
11347: if (!$args->{'robot'}) {
11348: opendir(DIR,$lonids);
11349: while ($filename=readdir(DIR)) {
11350: if ($filename=~/^$username\_\d+\_$domain\_$authhost\.id$/) {
11351: unlink($lonids.'/'.$filename);
11352: }
1.462 albertel 11353: }
1.463 albertel 11354: closedir(DIR);
1.462 albertel 11355: }
11356: # Give them a new cookie
1.463 albertel 11357: my $id = ($args->{'robot'} ? 'robot'.$args->{'robot'}
1.684 www 11358: : $now.$$.int(rand(10000)));
1.463 albertel 11359: $cookie="$username\_$id\_$domain\_$authhost";
1.462 albertel 11360:
11361: # Initialize roles
11362:
11363: $userroles=&Apache::lonnet::rolesinit($domain,$username,$authhost);
11364: }
11365: # ------------------------------------ Check browser type and MathML capability
11366:
11367: my ($httpbrowser,$clientbrowser,$clientversion,$clientmathml,
11368: $clientunicode,$clientos) = &decode_user_agent($r);
11369:
11370: # ------------------------------------------------------------- Get environment
11371:
11372: my %userenv = &Apache::lonnet::dump('environment',$domain,$username);
11373: my ($tmp) = keys(%userenv);
11374: if ($tmp !~ /^(con_lost|error|no_such_host)/i) {
11375: # default remote control to off
11376: if ($userenv{'remote'} ne 'on') { $userenv{'remote'} = 'off'; }
11377: } else {
11378: undef(%userenv);
11379: }
11380: if (($userenv{'interface'}) && (!$form->{'interface'})) {
11381: $form->{'interface'}=$userenv{'interface'};
11382: }
11383: $env{'environment.remote'}=$userenv{'remote'};
11384: if ($userenv{'texengine'} eq 'ttm') { $clientmathml=1; }
11385:
11386: # --------------- Do not trust query string to be put directly into environment
1.817 bisitz 11387: foreach my $option ('interface','localpath','localres') {
11388: $form->{$option}=~s/[\n\r\=]//gs;
1.462 albertel 11389: }
11390: # --------------------------------------------------------- Write first profile
11391:
11392: {
11393: my %initial_env =
11394: ("user.name" => $username,
11395: "user.domain" => $domain,
11396: "user.home" => $authhost,
11397: "browser.type" => $clientbrowser,
11398: "browser.version" => $clientversion,
11399: "browser.mathml" => $clientmathml,
11400: "browser.unicode" => $clientunicode,
11401: "browser.os" => $clientos,
11402: "server.domain" => $Apache::lonnet::perlvar{'lonDefDomain'},
11403: "request.course.fn" => '',
11404: "request.course.uri" => '',
11405: "request.course.sec" => '',
11406: "request.role" => 'cm',
11407: "request.role.adv" => $env{'user.adv'},
11408: "request.host" => $ENV{'REMOTE_ADDR'},);
11409:
11410: if ($form->{'localpath'}) {
11411: $initial_env{"browser.localpath"} = $form->{'localpath'};
11412: $initial_env{"browser.localres"} = $form->{'localres'};
11413: }
11414:
11415: if ($public) {
11416: $initial_env{"environment.remote"} = "off";
11417: }
11418: if ($form->{'interface'}) {
11419: $form->{'interface'}=~s/\W//gs;
11420: $initial_env{"browser.interface"} = $form->{'interface'};
11421: $env{'browser.interface'}=$form->{'interface'};
11422: }
1.948.2.11 raeburn 11423: my %is_adv = ( is_adv => $env{'user.adv'} );
1.948.2.31 raeburn 11424: my %domdef;
11425: unless ($domain eq 'public') {
11426: %domdef = &Apache::lonnet::get_domain_defaults($domain);
11427: }
1.462 albertel 11428:
1.724 raeburn 11429: foreach my $tool ('aboutme','blog','portfolio') {
11430: $userenv{'availabletools.'.$tool} =
1.948.2.10 raeburn 11431: &Apache::lonnet::usertools_access($username,$domain,$tool,'reload',
11432: undef,\%userenv,\%domdef,\%is_adv);
1.724 raeburn 11433: }
11434:
1.864 raeburn 11435: foreach my $crstype ('official','unofficial','community') {
1.765 raeburn 11436: $userenv{'canrequest.'.$crstype} =
11437: &Apache::lonnet::usertools_access($username,$domain,$crstype,
1.948.2.10 raeburn 11438: 'reload','requestcourses',
11439: \%userenv,\%domdef,\%is_adv);
1.765 raeburn 11440: }
11441:
1.462 albertel 11442: $env{'user.environment'} = "$lonids/$cookie.id";
11443:
11444: if (tie(my %disk_env,'GDBM_File',"$lonids/$cookie.id",
11445: &GDBM_WRCREAT(),0640)) {
11446: &_add_to_env(\%disk_env,\%initial_env);
11447: &_add_to_env(\%disk_env,\%userenv,'environment.');
11448: &_add_to_env(\%disk_env,$userroles);
1.463 albertel 11449: if (ref($args->{'extra_env'})) {
11450: &_add_to_env(\%disk_env,$args->{'extra_env'});
11451: }
1.462 albertel 11452: untie(%disk_env);
11453: } else {
1.705 tempelho 11454: &Apache::lonnet::logthis("<span style=\"color:blue;\">WARNING: ".
11455: 'Could not create environment storage in lonauth: '.$!.'</span>');
1.462 albertel 11456: return 'error: '.$!;
11457: }
11458: }
11459: $env{'request.role'}='cm';
11460: $env{'request.role.adv'}=$env{'user.adv'};
11461: $env{'browser.type'}=$clientbrowser;
11462:
11463: return $cookie;
11464:
11465: }
11466:
11467: sub _add_to_env {
11468: my ($idf,$env_data,$prefix) = @_;
1.676 raeburn 11469: if (ref($env_data) eq 'HASH') {
11470: while (my ($key,$value) = each(%$env_data)) {
11471: $idf->{$prefix.$key} = $value;
11472: $env{$prefix.$key} = $value;
11473: }
1.462 albertel 11474: }
11475: }
11476:
1.685 tempelho 11477: # --- Get the symbolic name of a problem and the url
11478: sub get_symb {
11479: my ($request,$silent) = @_;
1.726 raeburn 11480: (my $url=$env{'form.url'}) =~ s-^https?\://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
1.685 tempelho 11481: my $symb=($env{'form.symb'} ne '' ? $env{'form.symb'} : (&Apache::lonnet::symbread($url)));
11482: if ($symb eq '') {
11483: if (!$silent) {
11484: $request->print("Unable to handle ambiguous references:$url:.");
11485: return ();
11486: }
11487: }
11488: &Apache::lonenc::check_decrypt(\$symb);
11489: return ($symb);
11490: }
11491:
11492: # --------------------------------------------------------------Get annotation
11493:
11494: sub get_annotation {
11495: my ($symb,$enc) = @_;
11496:
11497: my $key = $symb;
11498: if (!$enc) {
11499: $key =
11500: &Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]);
11501: }
11502: my %annotation=&Apache::lonnet::get('nohist_annotations',[$key]);
11503: return $annotation{$key};
11504: }
11505:
11506: sub clean_symb {
1.731 raeburn 11507: my ($symb,$delete_enc) = @_;
1.685 tempelho 11508:
11509: &Apache::lonenc::check_decrypt(\$symb);
11510: my $enc = $env{'request.enc'};
1.731 raeburn 11511: if ($delete_enc) {
1.730 raeburn 11512: delete($env{'request.enc'});
11513: }
1.685 tempelho 11514:
11515: return ($symb,$enc);
11516: }
1.462 albertel 11517:
1.948.2.16 raeburn 11518: sub build_release_hashes {
11519: my ($checkparms,$checkresponsetypes,$checkcrstypes,$anonsurvey,$randomizetry) = @_;
11520: return unless((ref($checkparms) eq 'HASH') && (ref($checkresponsetypes) eq 'HASH') &&
11521: (ref($checkcrstypes) eq 'HASH') && (ref($anonsurvey) eq 'HASH') &&
11522: (ref($randomizetry) eq 'HASH'));
11523: foreach my $key (keys(%Apache::lonnet::needsrelease)) {
11524: my ($item,$name,$value) = split(/:/,$key);
11525: if ($item eq 'parameter') {
11526: if (ref($checkparms->{$name}) eq 'ARRAY') {
11527: unless(grep(/^\Q$name\E$/,@{$checkparms->{$name}})) {
11528: push(@{$checkparms->{$name}},$value);
11529: }
11530: } else {
11531: push(@{$checkparms->{$name}},$value);
11532: }
11533: } elsif ($item eq 'resourcetag') {
11534: if ($name eq 'responsetype') {
11535: $checkresponsetypes->{$value} = $Apache::lonnet::needsrelease{$key}
11536: }
11537: } elsif ($item eq 'course') {
11538: if ($name eq 'crstype') {
11539: $checkcrstypes->{$value} = $Apache::lonnet::needsrelease{$key};
11540: }
11541: }
11542: }
11543: ($anonsurvey->{major},$anonsurvey->{minor}) = split(/\./,$Apache::lonnet::needsrelease{'parameter:type:anonsurvey'});
11544: ($randomizetry->{major},$randomizetry->{minor}) = split(/\./,$Apache::lonnet::needsrelease{'parameter:type:randomizetry'});
11545: return;
11546: }
11547:
1.41 ng 11548: =pod
11549:
11550: =back
11551:
1.112 bowersj2 11552: =cut
1.41 ng 11553:
1.112 bowersj2 11554: 1;
11555: __END__;
1.41 ng 11556:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>