Annotation of loncom/interface/lonrequestcourse.pm, revision 1.84
1.1 raeburn 1: # The LearningOnline Network
2: # Request a course
3: #
1.84 ! raeburn 4: # $Id: lonrequestcourse.pm,v 1.83 2014/05/14 18:20:09 raeburn Exp $
1.1 raeburn 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: #
28: ###
29:
30: =head1 NAME
31:
32: Apache::lonrequestcourse.pm
33:
34: =head1 SYNOPSIS
35:
36: Allows users to request creation of new courses.
37:
38: This is part of the LearningOnline Network with CAPA project
39: described at http://www.lon-capa.org.
40:
41: =head1 SUBROUTINES
42:
43: =over
44:
45: =item handler()
46:
1.27 raeburn 47: =item get_breadcrumbs()
48:
1.12 raeburn 49: =item header()
50:
51: =item form_elements()
52:
53: =item onload_action()
54:
55: =item print_main_menu()
56:
57: =item request_administration()
58:
1.27 raeburn 59: =item close_popup_form()
60:
61: =item get_instcode()
62:
1.12 raeburn 63: =item print_request_form()
64:
65: =item print_enrollment_menu()
66:
1.27 raeburn 67: =item show_invalid_crosslists()
68:
1.12 raeburn 69: =item inst_section_selector()
70:
71: =item date_setting_table()
72:
73: =item print_personnel_menu()
74:
75: =item print_request_status()
76:
77: =item print_request_logs()
78:
79: =item print_review()
80:
81: =item dates_from_form()
82:
83: =item courseinfo_form()
84:
85: =item clone_form()
86:
87: =item clone_text()
88:
89: =item coursecode_form()
90:
91: =item get_course_dom()
92:
93: =item display_navbuttons()
94:
95: =item print_request_outcome()
96:
97: =item check_autolimit()
98:
99: =item retrieve_settings()
100:
101: =item get_request_settings()
102:
1.27 raeburn 103: =item extract_instcode()
104:
105: =item generate_date_items()
106:
1.1 raeburn 107: =back
108:
109: =cut
110:
111: package Apache::lonrequestcourse;
112:
113: use strict;
114: use Apache::Constants qw(:common :http);
115: use Apache::lonnet;
116: use Apache::loncommon;
117: use Apache::lonlocal;
1.8 raeburn 118: use Apache::loncoursequeueadmin;
1.30 raeburn 119: use Apache::lonuserutils;
1.4 raeburn 120: use LONCAPA qw(:DEFAULT :match);
1.1 raeburn 121:
122: sub handler {
123: my ($r) = @_;
1.20 raeburn 124: &Apache::loncommon::content_type($r,'text/html');
125: $r->send_http_header;
1.1 raeburn 126: if ($r->header_only) {
127: return OK;
128: }
129:
1.27 raeburn 130: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.73 raeburn 131: ['action','showdom','cnum','state','crstype','queue','tabs']);
1.2 raeburn 132: &Apache::lonhtmlcommon::clear_breadcrumbs();
133: my $dom = &get_course_dom();
1.1 raeburn 134: my $action = $env{'form.action'};
135: my $state = $env{'form.state'};
1.27 raeburn 136: my (%states,%stored);
1.72 raeburn 137: my ($jscript,$uname,$udom,$result,$warning,$showcredits,$instcredits,%can_request,
138: %request_domains,@incdoms);
1.66 raeburn 139: my %domdefs = &Apache::lonnet::get_domain_defaults($dom);
1.69 raeburn 140: if ($domdefs{'officialcredits'} || $domdefs{'unofficialcredits'} || $domdefs{'textbookcredits'}) {
1.66 raeburn 141: $showcredits = 1;
142: }
1.27 raeburn 143:
1.72 raeburn 144: my $canreq =
145: &Apache::lonnet::check_can_request($dom,\%can_request,\%request_domains);
146:
147: foreach my $item (keys(%request_domains)) {
148: if (ref($request_domains{$item}) eq 'ARRAY') {
149: foreach my $possdom (@{$request_domains{$item}}) {
150: unless(grep(/^\Q$possdom\E$/,@incdoms)) {
151: push(@incdoms,$possdom);
152: }
153: }
154: }
155: }
156:
157: if ($canreq) {
1.73 raeburn 158: if (($env{'form.crstype'} eq 'textbook') ||
159: (scalar(keys(%can_request)) == 1) && ($can_request{'textbook'})) {
1.72 raeburn 160: my %domconfig = &Apache::lonnet::get_dom('configuration',['requestcourses'],$dom);
161: if ($action eq 'log') {
1.73 raeburn 162: my $usetabs;
163: if ((scalar(keys(%can_request)) == 1) && ($can_request{'textbook'})) {
164: $usetabs = 1;
165: } elsif ($env{'form.tabs'} eq 'on') {
166: $usetabs = 1;
167: }
1.72 raeburn 168: &Apache::lonhtmlcommon::add_breadcrumb({text=>'Course Request'});
169: my $crumb = &Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests');
1.73 raeburn 170: &print_request_logs($r,$dom,undef,undef,$crumb,$usetabs);
1.72 raeburn 171: } elsif ($action eq 'process') {
1.73 raeburn 172: if ($can_request{'textbook'}) {
173: &process_textbook_request($r,$dom,$action,\%domdefs,\%domconfig,\%can_request);
174: } else {
175: &textbook_request_disabled($r,$dom,\%can_request);
176: }
1.83 raeburn 177: } elsif ($action eq 'display') {
178: my ($uname,$udom,$result,$warning) = &domcoord_display($dom);
179: if ($warning ne '') {
180: my $args = { only_body => 1 };
181: $r->print(&header('Course/Community Requests','','' ,'',$args).
182: '<h3>'.&mt('Course/Community Request Details').'</h3>'.
183: '<div class="LC_warning">'.$warning.'</div>'.
184: &close_popup_form());
185: } else {
186: $states{'display'} = ['details'];
187: my $loaditems = &onload_action($action,$state);
188: my $page = 0;
189: &request_administration($r,$action,$state,$page,\%states,$dom,$jscript,
190: $loaditems,'','','','','',$showcredits,'','',
191: $uname,$udom);
192: }
1.72 raeburn 193: } else {
1.73 raeburn 194: if ($can_request{'textbook'}) {
195: &print_textbook_form($r,$dom,\@incdoms,\%domdefs,$domconfig{'requestcourses'},\%can_request);
196: } else {
197: &textbook_request_disabled($r,$dom,\%can_request);
198: }
1.72 raeburn 199: }
200: return OK;
201: }
202: }
203:
1.27 raeburn 204: $states{'display'} = ['details'];
205: $states{'view'} = ['pick_request','details','cancel','removal'];
1.48 raeburn 206: $states{'log'} = ['display'];
1.27 raeburn 207: $states{'new'} = ['courseinfo','enrollment','personnel','review','process'];
208:
209: if (($action eq 'new') && ($env{'form.crstype'} eq 'official')) {
210: unless ($env{'form.state'} eq 'crstype') {
211: unshift(@{$states{'new'}},'codepick');
212: }
213: }
214:
1.65 raeburn 215: if (($action eq 'new') && (&Apache::loncoursequeueadmin::author_prompt())) {
216: if (ref($states{$action}) eq 'ARRAY') {
217: push(@{$states{$action}},'reqauthor');
218: }
219: }
220:
1.27 raeburn 221: foreach my $key (keys(%states)) {
222: if (ref($states{$key}) eq 'ARRAY') {
223: unshift (@{$states{$key}},'crstype');
224: }
225: }
226:
227: my @invalidcrosslist;
228: my %trail = (
1.73 raeburn 229: crstype => 'Pick Action',
1.27 raeburn 230: codepick => 'Category',
231: courseinfo => 'Description',
232: enrollment => 'Access Dates',
233: personnel => 'Personnel',
234: review => 'Review',
235: process => 'Result',
1.65 raeburn 236: reqauthor => 'Authoring Space Result',
1.27 raeburn 237: pick_request => 'Display Summary',
238: details => 'Request Details',
239: cancel => 'Cancel Request',
240: removal => 'Outcome',
1.48 raeburn 241: display => 'Request Logs',
1.27 raeburn 242: );
243:
244: if (($env{'form.crstype'} eq 'official') && (&Apache::lonnet::auto_run('',$dom))) {
245: $trail{'enrollment'} = 'Enrollment';
246: }
247:
1.66 raeburn 248: my ($page,$crumb,$newinstcode,$codechk,$checkedcode,$description) =
1.27 raeburn 249: &get_breadcrumbs($dom,$action,\$state,\%states,\%trail);
1.26 raeburn 250: if ($action eq 'display') {
1.83 raeburn 251: ($uname,$udom,$result,$warning) = &domcoord_display($dom);
1.26 raeburn 252: } elsif ((defined($state)) && (defined($action))) {
1.16 raeburn 253: if (($action eq 'view') && ($state eq 'details')) {
254: if ((defined($env{'form.showdom'})) && (defined($env{'form.cnum'}))) {
255: my $result = &retrieve_settings($env{'form.showdom'},$env{'form.cnum'});
1.2 raeburn 256: }
1.27 raeburn 257: } elsif ($env{'form.crstype'} eq 'official') {
258: if (&Apache::lonnet::auto_run('',$dom)) {
259: if (($action eq 'new') && (($state eq 'enrollment') ||
260: ($state eq 'personnel'))) {
261: my $checkcrosslist = 0;
262: for (my $i=0; $i<$env{'form.crosslisttotal'}; $i++) {
263: if ($env{'form.crosslist_'.$i}) {
264: $checkcrosslist ++;
265: }
266: }
267: if ($checkcrosslist) {
268: my %codechk;
269: my (@codetitles,%cat_titles,%cat_order,@code_order,$lastitem);
270: &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,
271: \%cat_titles,
272: \%cat_order,
273: \@code_order);
274: my $numtitles = scalar(@codetitles);
275: if ($numtitles) {
276: for (my $i=0; $i<$env{'form.crosslisttotal'}; $i++) {
277: if ($env{'form.crosslist_'.$i}) {
278: my $codecheck;
279: my $crosslistcode = '';
280: foreach my $item (@code_order) {
281: $crosslistcode .= $env{'form.crosslist_'.$i.'_'.$item};
282: }
283: if ($crosslistcode ne '') {
1.36 raeburn 284: ($codechk{$i}, my $rest) =
1.27 raeburn 285: &Apache::lonnet::auto_validate_instcode('',$dom,$crosslistcode);
286: }
287: unless ($codechk{$i} eq 'valid') {
288: $env{'form.crosslist_'.$i} = '';
289: push(@invalidcrosslist,$crosslistcode);
290: }
291: }
292: }
293: }
294: }
295: }
296: }
1.2 raeburn 297: }
1.66 raeburn 298: (my $elements,$instcredits) = &form_elements($dom,$showcredits);
1.2 raeburn 299: my $elementsref = {};
1.66 raeburn 300: if ((ref($elements) eq 'HASH') && (ref($elements->{$action}) eq 'HASH')) {
301: if (ref($elements->{$action}{$state}) eq 'HASH') {
302: $elementsref = $elements->{$action}{$state};
1.2 raeburn 303: }
304: }
1.16 raeburn 305: if (($state eq 'courseinfo') && ($env{'form.clonedom'} eq '')) {
306: $env{'form.clonedom'} = $dom;
307: }
1.30 raeburn 308: if ($state eq 'crstype') {
309: $jscript = &mainmenu_javascript();
310: } else {
311: $jscript = &Apache::lonhtmlcommon::set_form_elements($elementsref,\%stored);
1.45 raeburn 312: if ($state eq 'courseinfo') {
313: $jscript .= &cloning_javascript();
1.84 ! raeburn 314: } elsif ($state eq 'process') {
! 315: $jscript .= &processing_javascript();
1.45 raeburn 316: }
1.30 raeburn 317: }
1.2 raeburn 318: }
319:
320: if ($state eq 'personnel') {
321: $jscript .= "\n".&Apache::loncommon::userbrowser_javascript();
322: }
323:
324: my $loaditems = &onload_action($action,$state);
325:
1.1 raeburn 326: if ($action eq 'new') {
327: if ($canreq) {
328: if ($state eq 'crstype') {
1.3 raeburn 329: &print_main_menu($r,\%can_request,\%states,$dom,$jscript,$loaditems,
1.72 raeburn 330: $crumb,\@incdoms);
1.1 raeburn 331: } else {
1.27 raeburn 332: &request_administration($r,$action,$state,$page,\%states,$dom,
333: $jscript,$loaditems,$crumb,$newinstcode,
1.36 raeburn 334: $codechk,$checkedcode,$description,
1.66 raeburn 335: $showcredits,$instcredits,\@invalidcrosslist);
1.1 raeburn 336: }
337: } else {
1.40 raeburn 338: $r->print(&header('Course/Community Requests').$crumb.
1.1 raeburn 339: '<div class="LC_warning">'.
1.40 raeburn 340: &mt('You do not have privileges to request creation of courses or communities.').
1.2 raeburn 341: '</div>'.&Apache::loncommon::end_page());
1.1 raeburn 342: }
343: } elsif ($action eq 'view') {
1.10 raeburn 344: if ($state eq 'crstype') {
1.72 raeburn 345: &print_main_menu($r,\%can_request,\%states,$dom,$jscript,$loaditems,$crumb,\@incdoms);
1.26 raeburn 346: } else {
347: &request_administration($r,$action,$state,$page,\%states,$dom,$jscript,
1.66 raeburn 348: $loaditems,$crumb,'','','','',$showcredits);
1.26 raeburn 349: }
350: } elsif ($action eq 'display') {
351: if ($warning ne '') {
352: my $args = { only_body => 1 };
1.49 raeburn 353: $r->print(&header('Course/Community Requests','','' ,'',$args).$crumb.
1.40 raeburn 354: '<h3>'.&mt('Course/Community Request Details').'</h3>'.
1.26 raeburn 355: '<div class="LC_warning">'.$warning.'</div>'.
356: &close_popup_form());
1.11 raeburn 357: } else {
1.26 raeburn 358: &request_administration($r,$action,$state,$page,\%states,$dom,$jscript,
1.66 raeburn 359: $loaditems,$crumb,'','','','',$showcredits,'','',
360: $uname,$udom);
1.10 raeburn 361: }
1.1 raeburn 362: } elsif ($action eq 'log') {
1.48 raeburn 363: if ($state eq 'crstype') {
1.72 raeburn 364: &print_main_menu($r,\%can_request,\%states,$dom,$jscript,'',$crumb,\@incdoms);
1.48 raeburn 365: } else {
366: $jscript .= <<ENDJS;
367:
368: function backPage(formname,prevstate) {
369: formname.state.value = prevstate;
370: formname.submit();
371: }
372:
373: function setPage(formname) {
374: formname.page.value = '1';
375: return;
376: }
377:
378: ENDJS
1.73 raeburn 379: &print_request_logs($r,$dom,$jscript,$loaditems,$crumb,\%can_request);
1.48 raeburn 380: }
1.1 raeburn 381: } else {
1.72 raeburn 382: &print_main_menu($r,\%can_request,\%states,$dom,$jscript,'',$crumb,\@incdoms);
1.1 raeburn 383: }
384: return OK;
385: }
386:
1.30 raeburn 387: sub mainmenu_javascript {
388: return <<"END";
389: function setType(courseForm) {
390: for (var i=0; i<courseForm.crstype.length; i++) {
391: if (courseForm.crstype.options[i].value == "$env{'form.crstype'}") {
392: courseForm.crstype.options[i].selected = true;
393: } else {
394: courseForm.crstype.options[i].selected = false;
395: }
396: }
397: }
398:
399: function setAction(courseForm) {
400: for (var i=0; i<courseForm.action.length; i++) {
401: if (courseForm.action.options[i].value == "$env{'form.action'}") {
402: courseForm.action.options[i].selected = true;
403: } else {
404: courseForm.action.options[i].selected = false;
405: }
406: }
407: }
408: END
409: }
410:
1.45 raeburn 411: sub cloning_javascript {
412: return <<"END";
413: function setCloneDisplay(courseForm) {
414: if (courseForm.cloning.length > 1) {
415: for (var i=0; i<courseForm.cloning.length; i++) {
416: if (courseForm.cloning[i].checked) {
417: if (courseForm.cloning[i].value == 1) {
1.84 ! raeburn 418: document.getElementById('cloneoptions').style.display="block";
1.45 raeburn 419: }
420: }
421: }
422: }
423: }
424: END
425: }
426:
1.84 ! raeburn 427: sub processing_javascript {
! 428: return <<"END";
! 429: function hideProcessing() {
! 430: if (document.getElementById('processing')) {
! 431: document.getElementById('processing').style.display="none";
! 432: }
! 433: }
! 434:
! 435: END
! 436: }
! 437:
1.27 raeburn 438: sub get_breadcrumbs {
439: my ($dom,$action,$state,$states,$trail) = @_;
1.36 raeburn 440: my ($crumb,$newinstcode,$codechk,$checkedcode,$numtitles,$description);
1.27 raeburn 441: my $page = 0;
442: if ((ref($states) eq 'HASH') && (ref($trail) eq 'HASH') && (ref($state))) {
443: if (defined($action)) {
444: my $done = 0;
445: my $i=0;
446: if (ref($states->{$action}) eq 'ARRAY') {
447: while ($i<@{$states->{$action}} && !$done) {
448: if ($states->{$action}[$i] eq $$state) {
449: $page = $i;
450: $done = 1;
451: }
452: $i++;
453: }
454: }
455: if ($env{'form.crstype'} eq 'official') {
456: if ($page > 1) {
457: if ($states->{$action}[$page-1] eq 'codepick') {
458: if ($env{'form.instcode'} eq '') {
459: ($newinstcode,$numtitles) = &get_instcode($dom);
460: if ($numtitles) {
461: if ($newinstcode eq '') {
462: $$state = 'codepick';
463: $page --;
464: } else {
1.36 raeburn 465: ($codechk,$description) =
1.27 raeburn 466: &Apache::lonnet::auto_validate_instcode('',
467: $dom,$newinstcode);
468: if ($codechk ne 'valid') {
469: $$state = 'codepick';
470: $page --;
471: }
472: $checkedcode = 1;
473: }
474: }
475: }
476: }
477: }
478: }
479: for (my $i=0; $i<@{$states->{$action}}; $i++) {
480: if ($$state eq $states->{$action}[$i]) {
481: &Apache::lonhtmlcommon::add_breadcrumb(
482: {text=>"$trail->{$$state}"});
1.40 raeburn 483: $crumb = &Apache::lonhtmlcommon::breadcrumbs('Course/Community Requests','Course_Requests');
1.27 raeburn 484: last;
485: } else {
1.65 raeburn 486: if (($$state eq 'process') || ($$state eq 'removal') || ($$state eq 'reqauthor')) {
1.27 raeburn 487: &Apache::lonhtmlcommon::add_breadcrumb(
488: { href => '/adm/requestcourse',
489: text => "$trail->{$states->{$action}[$i]}",
490: }
491: );
492: } else {
493: &Apache::lonhtmlcommon::add_breadcrumb(
494: { href => "javascript:backPage(document.requestcrs,'$states->{$action}[$i]')",
495: text => "$trail->{$states->{$action}[$i]}", }
496: );
497: }
498: }
499: }
500: } else {
501: &Apache::lonhtmlcommon::add_breadcrumb(
502: {text=>'Pick Action'});
1.40 raeburn 503: $crumb = &Apache::lonhtmlcommon::breadcrumbs('Course/Community Requests','Course_Requests');
1.27 raeburn 504: }
505: } else {
506: &Apache::lonhtmlcommon::add_breadcrumb(
507: {text=>'Pick Action'});
1.40 raeburn 508: $crumb = &Apache::lonhtmlcommon::breadcrumbs('Course/Community Requests','Course_Requests');
1.27 raeburn 509: }
1.36 raeburn 510: return ($page,$crumb,$newinstcode,$codechk,$checkedcode,$description);
1.27 raeburn 511: }
512:
1.2 raeburn 513: sub header {
1.26 raeburn 514: my ($bodytitle,$jscript,$loaditems,$jsextra,$args) = @_;
1.2 raeburn 515: if ($jscript) {
1.6 raeburn 516: $jscript = '<script type="text/javascript">'."\n".
517: '// <![CDATA['."\n".
518: $jscript."\n".'// ]]>'."\n".'</script>'."\n";
1.2 raeburn 519: }
520: if ($loaditems) {
1.26 raeburn 521: if (ref($args) eq 'HASH') {
522: my %loadhash = (
523: 'add_entries' => $loaditems,
524: );
525: my %arghash = (%loadhash,%{$args});
526: $args = \%arghash;
527: } else {
528: $args = {'add_entries' => $loaditems,};
529: }
1.3 raeburn 530: }
1.26 raeburn 531: return &Apache::loncommon::start_page($bodytitle,$jscript.$jsextra,$args);
1.2 raeburn 532: }
533:
534: sub form_elements {
1.66 raeburn 535: my ($dom,$showcredits) = @_;
536: my $instcredits;
1.2 raeburn 537: my %elements =
538: (
539: new => {
540: crstype => {
541: crstype => 'selectbox',
542: action => 'selectbox',
1.16 raeburn 543: origcnum => 'hidden',
1.2 raeburn 544: },
545: courseinfo => {
546: cdescr => 'text',
1.45 raeburn 547: cloning => 'radio',
1.13 raeburn 548: clonecrs => 'text',
549: clonedom => 'selectbox',
1.2 raeburn 550: datemode => 'radio',
551: dateshift => 'text',
552: },
553: enrollment => {
1.13 raeburn 554: accessstart_month => 'selectbox',
555: accessstart_hour => 'selectbox',
556: accessend_month => 'selectbox',
557: accessend_hour => 'selectbox',
558: accessstart_day => 'text',
559: accessstart_year => 'text',
560: accessstart_minute => 'text',
561: accessstart_second => 'text',
562: accessend_day => 'text',
563: accessend_year => 'text',
564: accessend_minute => 'text',
565: accessend_second => 'text',
1.2 raeburn 566: no_end_date => 'checkbox',
567: },
568: personnel => {
569: addperson => 'checkbox',
570: },
1.13 raeburn 571: review => {
572: cnum => 'hidden',
573: },
1.2 raeburn 574: },
575: view => {
576: crstype => {
577: crstype => 'selectbox',
578: action => 'selectbox',
579: },
580: },
581: );
1.13 raeburn 582: my %servers = &Apache::lonnet::get_servers($dom,'library');
583: my $numlib = keys(%servers);
584: if ($numlib > 1) {
585: $elements{'new'}{'courseinfo'}{'chome'} = 'selectbox';
586: } else {
587: $elements{'new'}{'courseinfo'}{'chome'} = 'hidden';
588: }
1.2 raeburn 589: my (@codetitles,%cat_titles,%cat_order,@code_order,$lastitem);
590: &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
591: \%cat_order,\@code_order);
592: my $numtitles = scalar(@codetitles);
593: if ($numtitles) {
594: my %extras;
595: $lastitem = pop(@codetitles);
596: $extras{'instcode_'.$lastitem} = 'text';
597: foreach my $item (@codetitles) {
598: $extras{'instcode_'.$item} = 'selectbox';
599: }
600: $elements{'new'}{'codepick'} = \%extras;
601: }
602: if (&Apache::lonnet::auto_run('',$dom)) {
603: my %extras = (
1.13 raeburn 604: enrollstart_month => 'selectbox',
605: enrollstart_hour => 'selectbox',
606: enrollend_month => 'selectbox',
607: enrollend_hour => 'selectbox',
608: enrollstart_day => 'text',
609: enrollstart_year => 'text',
610: enrollstart_minute => 'text',
611: enrollstart_second => 'text',
612: enrollend_day => 'text',
613: enrollend_year => 'text',
614: enrollend_minute => 'text',
615: enrollend_second => 'text',
1.2 raeburn 616: addcrosslist => 'checkbox',
617: autoadds => 'radio',
618: autodrops => 'radio',
1.61 raeburn 619: );
620: my ($instcode,$titlescount) = &get_instcode($dom);
621: if ($instcode) {
622: my @sections = &Apache::lonnet::auto_get_sections(undef,$dom,$instcode);
623: if (@sections) {
624: $extras{'sectotal'} = 'hidden';
625: if ($env{'form.sectotal'} > 0) {
626: for (my $i=0; $i<$env{'form.sectotal'}; $i++) {
627: $extras{'sec_'.$i} = 'radio';
628: $extras{'secnum_'.$i} = 'text';
629: $extras{'loncapasec_'.$i} = 'text';
630: }
631: }
632: } else {
633: $extras{'addsection'} = 'checkbox';
634: my $sectotal = $env{'form.sectotal'};
635: if ($env{'form.addsection'}) {
636: $sectotal ++;
637: }
638: for (my $i=0; $i<$sectotal; $i++) {
639: $extras{'sec_'.$i} = 'checkbox';
640: $extras{'secnum_'.$i} = 'text',
641: $extras{'loncapasec_'.$i} = 'text',
642: }
1.2 raeburn 643: }
1.66 raeburn 644: (my $outcome,my $desc,$instcredits) =
645: &Apache::lonnet::auto_validate_instcode(undef,$dom,$instcode);
646: if ($showcredits && $instcredits eq '') {
647: $extras{'coursecredits'} = 'text';
648: }
1.69 raeburn 649: } elsif (($env{'form.crstype'} eq 'unofficial') || ($env{'form.crstype'} eq 'textbook')) {
1.66 raeburn 650: if ($showcredits) {
651: $extras{'coursecredits'} = 'text';
652: }
1.2 raeburn 653: }
654: my $crosslisttotal = $env{'form.crosslisttotal'};
1.16 raeburn 655: if ($env{'form.addcrosslist'}) {
656: $crosslisttotal ++;
657: }
1.24 raeburn 658: if (!$crosslisttotal) {
1.2 raeburn 659: $crosslisttotal = 1;
660: }
1.24 raeburn 661: for (my $i=0; $i<$env{'form.crosslisttotal'}; $i++) {
662: if ($numtitles) {
663: $extras{'crosslist_'.$i.'_'.$lastitem} = 'text';
664: }
665: if (@codetitles > 0) {
666: foreach my $item (@codetitles) {
667: $extras{'crosslist_'.$i.'_'.$item} = 'selectbox';
1.2 raeburn 668: }
669: }
1.24 raeburn 670: $extras{'crosslist_'.$i} = 'checkbox';
671: $extras{'crosslist_'.$i.'_instsec'} = 'text',
672: $extras{'crosslist_'.$i.'_lcsec'} = 'text',
1.2 raeburn 673: }
674: my %mergedhash = (%{$elements{'new'}{'enrollment'}},%extras);
675: %{$elements{'new'}{'enrollment'}} = %mergedhash;
676: }
677: my %people;
678: my $persontotal = $env{'form.persontotal'};
1.16 raeburn 679: if ($env{'form.addperson'}) {
680: $persontotal ++;
681: }
682: if ((!defined($persontotal)) || (!$persontotal)) {
1.2 raeburn 683: $persontotal = 1;
684: }
685: for (my $i=0; $i<$persontotal; $i++) {
1.13 raeburn 686: $people{'person_'.$i.'_uname'} = 'text',
687: $people{'person_'.$i.'_dom'} = 'selectbox',
688: $people{'person_'.$i.'_hidedom'} = 'hidden',
689: $people{'person_'.$i.'_firstname'} = 'text',
690: $people{'person_'.$i.'_lastname'} = 'text',
691: $people{'person_'.$i.'_emailaddr'} = 'text',
692: $people{'person_'.$i.'_role'} = 'selectbox',
693: $people{'person_'.$i.'_sec'} = 'selectbox',
694: $people{'person_'.$i.'_newsec'} = 'text',
1.2 raeburn 695: }
696: my %personnelhash = (%{$elements{'new'}{'personnel'}},%people);
697: %{$elements{'new'}{'personnel'}} = %personnelhash;
1.66 raeburn 698: return (\%elements,$instcredits);;
1.2 raeburn 699: }
700:
701: sub onload_action {
702: my ($action,$state) = @_;
703: my %loaditems;
704: if (($action eq 'new') || ($action eq 'view')) {
1.30 raeburn 705: if ($state eq 'crstype') {
706: $loaditems{'onload'} = 'javascript:setAction(document.mainmenu_action);javascript:setType(document.mainmenu_coursetype)';
707: } else {
1.45 raeburn 708: $loaditems{'onload'} = 'javascript:setFormElements(document.requestcrs);';
709: }
710: if ($state eq 'courseinfo') {
711: $loaditems{'onload'} .= 'javascript:setCloneDisplay(document.requestcrs);';
1.30 raeburn 712: }
1.84 ! raeburn 713: if ($state eq 'process') {
! 714: $loaditems{'onload'} .= 'javascript:hideProcessing();';
! 715: }
1.2 raeburn 716: }
717: return \%loaditems;
718: }
719:
1.1 raeburn 720: sub print_main_menu {
1.72 raeburn 721: my ($r,$can_request,$states,$dom,$jscript,$loaditems,$crumb,$incdoms) = @_;
1.37 raeburn 722: my ($types,$typename) = &Apache::loncommon::course_types();
1.52 bisitz 723: my $onchange = 'this.form.submit()';
1.2 raeburn 724: my $nextstate_setter = "\n";
725: if (ref($states) eq 'HASH') {
726: foreach my $key (keys(%{$states})) {
727: if (ref($states->{$key}) eq 'ARRAY') {
728: $nextstate_setter .=
729: " if (actionchoice == '$key') {
730: nextstate = '".$states->{$key}[1]."';
731: }
732: ";
733: }
734: }
735: }
1.1 raeburn 736:
1.2 raeburn 737: my $js = <<"END";
1.1 raeburn 738:
1.2 raeburn 739: function nextPage(formname) {
1.27 raeburn 740: var crschoice = document.mainmenu_coursetype.crstype.value;
741: var actionchoice = document.mainmenu_action.action.value;
1.2 raeburn 742: if (check_can_request(crschoice,actionchoice) == true) {
743: if ((actionchoice == 'new') && (crschoice == 'official')) {
744: nextstate = 'codepick';
745: } else {
746: $nextstate_setter
1.27 raeburn 747: }
748: formname.crstype.value = crschoice;
749: formname.action.value = actionchoice;
1.1 raeburn 750: formname.state.value= nextstate;
751: formname.submit();
752: }
753: return;
754: }
755:
1.2 raeburn 756: function check_can_request(crschoice,actionchoice) {
1.1 raeburn 757: var official = '';
758: var unofficial = '';
1.69 raeburn 759: var community = '';
760: var textbook = '';
1.1 raeburn 761: END
1.39 raeburn 762: if (ref($can_request) eq 'HASH') {
763: foreach my $item (keys(%{$can_request})) {
764: $js .= "
1.1 raeburn 765: $item = 1;
766: ";
1.39 raeburn 767: }
1.1 raeburn 768: }
769: my %lt = &Apache::lonlocal::texthash(
770: official => 'You are not permitted to request creation of an official course in this domain.',
771: unofficial => 'You are not permitted to request creation of an unofficial course in this domain.',
1.69 raeburn 772: community => 'You are not permitted to request creation of a community in this domain.',
773: textbook => 'You are not permitted to request creation of a textbook course in this domain',
1.67 raeburn 774: all => 'You must choose a specific course type when making a new course request.',
775: allt => '"All types" is not allowed.',
1.1 raeburn 776: );
777: $js .= <<END;
778: if (crschoice == 'official') {
779: if (official != 1) {
780: alert("$lt{'official'}");
781: return false;
782: }
783: } else {
784: if (crschoice == 'unofficial') {
785: if (unofficial != 1) {
786: alert("$lt{'unofficial'}");
787: return false;
788: }
789: } else {
790: if (crschoice == 'community') {
791: if (community != 1) {
792: alert("$lt{'community'}");
793: return false;
794: }
795: } else {
1.69 raeburn 796: if (crschoice == 'textbook') {
797: if (textbook != 1) {
798: alert("$lt{'community'}");
799: return false;
800: }
801: } else {
802: if (actionchoice == 'new') {
803: alert('$lt{'all'}'+'\\n'+'$lt{'allt'}');
804: return false;
805: }
806: }
1.1 raeburn 807: }
808: }
809: }
810: return true;
811: }
812: END
1.75 raeburn 813: my ($pagetitle,$pageinfo,$domaintitle,$earlyout);
1.39 raeburn 814: if (ref($can_request) eq 'HASH') {
1.69 raeburn 815: if (($can_request->{'official'}) || ($can_request->{'unofficial'}) || $can_request->{'textbook'}) {
1.39 raeburn 816: if ($can_request->{'community'}) {
817: $pagetitle = 'Course/Community Requests';
818: $pageinfo = &mt('Request creation of a new course or community, or review your pending requests.');
819: $domaintitle = &mt('Course/Community Domain');
820: } else {
821: $pagetitle = 'Course Requests';
822: $pageinfo = &mt('Request creation of a new course, or review your pending course requests.');
823: $domaintitle = &mt('Course Domain');
824: }
825: } elsif ($can_request->{'community'}) {
1.40 raeburn 826: $pagetitle = 'Community Requests';
827: $pageinfo = &mt('Request creation of a new course, or review your pending requests.');
1.39 raeburn 828: $domaintitle = &mt('Community Domain');
1.75 raeburn 829: } elsif ((ref($incdoms) eq 'ARRAY') && ((@{$incdoms} > 1) ||
830: ((@{$incdoms} == 1) && ($incdoms->[0] ne $dom)))) {
1.39 raeburn 831: $pagetitle = 'Course/Community Requests';
832: $pageinfo = &mt('You do not have rights to request creation of courses in this domain; please choose a different domain.');
833: $domaintitle = &mt('Course/Community Domain');
1.75 raeburn 834: } else {
835: $pagetitle = 'Course/Community Requests';
836: $pageinfo = &mt('You do not have rights to request creation of courses or communities.');
837: $earlyout = 1;
1.39 raeburn 838: }
839: }
840: $r->print(&header($pagetitle,$js.$jscript,$loaditems).$crumb.
1.75 raeburn 841: '<p>'.$pageinfo.'</p>');
842: if ($earlyout) {
843: $r->print(&Apache::loncommon::end_page());
844: return;
845: }
846: $r->print('<div>'.
1.27 raeburn 847: &Apache::lonhtmlcommon::start_pick_box().
1.39 raeburn 848: &Apache::lonhtmlcommon::row_title($domaintitle).
1.1 raeburn 849: '<form name="domforcourse" method="post" action="/adm/requestcourse">'.
1.72 raeburn 850: &Apache::loncommon::select_dom_form($dom,'showdom','',1,$onchange,$incdoms));
1.1 raeburn 851: if (!$onchange) {
852: $r->print(' <input type="submit" name="godom" value="'.
853: &mt('Change').'" />');
854: }
1.39 raeburn 855: unless ((ref($can_request) eq 'HASH') && (keys(%{$can_request}) > 0)) {
1.72 raeburn 856: $r->print('</form>'.&Apache::lonhtmlcommon::row_closure(1)."\n".
1.39 raeburn 857: &Apache::lonhtmlcommon::end_pick_box().'</div>'."\n".
858: &Apache::loncommon::end_page());
859: return;
860: }
1.27 raeburn 861: $r->print('</form>'.&Apache::lonhtmlcommon::row_closure());
1.2 raeburn 862: my $formname = 'requestcrs';
1.1 raeburn 863: my $nexttext = &mt('Next');
1.27 raeburn 864: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Action')).'
865: <form name="mainmenu_action" method="post" action="">
1.1 raeburn 866: <select size="1" name="action" >
1.2 raeburn 867: <option value="new">'.&mt('New request').'</option>
1.1 raeburn 868: <option value="view">'.&mt('View/Modify/Cancel pending requests').'</option>
869: <option value="log">'.&mt('View request history').'</option>
1.27 raeburn 870: </select></form>'.
1.46 wenzelju 871: &Apache::lonhtmlcommon::row_closure().
1.39 raeburn 872: &Apache::lonhtmlcommon::row_title(&mt('Type')).'
1.27 raeburn 873: <form name="mainmenu_coursetype" method="post" action="">
1.39 raeburn 874: <select size="1" name="crstype">');
875: if (ref($can_request) eq 'HASH') {
876: if (keys(%{$can_request}) > 1) {
877: $r->print(' <option value="any">'.&mt('All types').'</option>');
878: }
879: if ((ref($types) eq 'ARRAY') && (ref($typename) eq 'HASH')) {
880: foreach my $type (@{$types}) {
881: next unless($can_request->{$type});
882: my $selected = '';
883: if ($env{'form.crstype'} eq '') {
884: if ($type eq 'official') {
885: $selected = ' selected="selected"';
886: }
887: } else {
888: if ($type eq $env{'form.crstype'}) {
889: $selected = ' selected="selected"';
890: }
891: }
892: $r->print('<option value="'.$type.'"'.$selected.'>'.&mt($typename->{$type}).
893: '</option>'."\n");
1.4 raeburn 894: }
895: }
896: }
1.27 raeburn 897: $r->print('</select></form>'."\n".
898: &Apache::lonhtmlcommon::row_closure(1)."\n".
899: &Apache::lonhtmlcommon::end_pick_box().'</div>'."\n".
1.38 raeburn 900: '<div><form name="'.$formname.'" method="post" action="/adm/requestcourse">'."\n".
1.27 raeburn 901: '<input type="hidden" name="state" value="crstype" />'."\n".
902: '<input type="hidden" name="showdom" value="'.$dom.'" />'."\n".
903: '<input type="hidden" name="crstype" value="" />'."\n".
904: '<input type="hidden" name="action" value="" />'."\n".
905: '<input type="button" name="next" value="'.$nexttext.
906: '" onclick="javascript:nextPage(document.'.$formname.')" />'."\n".
907: '</form></div>');
1.1 raeburn 908: $r->print(&Apache::loncommon::end_page());
909: return;
910: }
911:
912: sub request_administration {
1.27 raeburn 913: my ($r,$action,$state,$page,$states,$dom,$jscript,$loaditems,$crumb,
1.66 raeburn 914: $newinstcode,$codechk,$checkedcode,$description,$showcredits,
915: $instcredits,$invalidcrosslist,$uname,$udom) = @_;
1.2 raeburn 916: my $js;
1.16 raeburn 917: if (($action eq 'new') || (($action eq 'view') && ($state eq 'pick_request'))) {
1.2 raeburn 918: $js = <<END;
1.1 raeburn 919:
920: function nextPage(formname,nextstate) {
921: formname.state.value= nextstate;
922: formname.submit();
923: }
1.16 raeburn 924:
925: END
926: }
927: if (($action eq 'new') || ($action eq 'view')) {
928: $js .= <<END;
929:
1.1 raeburn 930: function backPage(formname,prevstate) {
931: formname.state.value = prevstate;
932: formname.submit();
933: }
934:
935: END
1.2 raeburn 936: }
937: if ($action eq 'new') {
938: my $jsextra;
1.54 raeburn 939: if (($state eq 'courseinfo') || ($state eq 'codepick')) {
1.2 raeburn 940: $jsextra = "\n".&Apache::loncommon::coursebrowser_javascript($dom);
1.31 raeburn 941: } elsif ($state eq 'enrollment') {
942: if (($env{'form.crstype'} eq 'official') &&
943: (&Apache::lonnet::auto_run('',$dom))) {
944: $js .= "\n".§ion_check_javascript()."\n".&enrollment_lcsec_js();
945: }
946: } elsif ($state eq 'personnel') {
947: $js .= "\n".§ion_check_javascript()."\n".&personnel_lcsec_js();
1.1 raeburn 948: }
1.40 raeburn 949: my $title;
950: if ($env{'form.crstype'} eq 'community') {
951: $title = 'Request a community';
952: } else {
953: $title = 'Request a course';
954: }
955: $r->print(&header($title,$js.$jscript,$loaditems,$jsextra).$crumb);
1.27 raeburn 956: &print_request_form($r,$action,$state,$page,$states,$dom,$newinstcode,
1.66 raeburn 957: $codechk,$checkedcode,$description,$showcredits,
958: $instcredits,$invalidcrosslist);
1.2 raeburn 959: } elsif ($action eq 'view') {
1.16 raeburn 960: my $jsextra;
961: my $formname = 'requestcrs';
962: my $prev = $states->{$action}[$page-1];
963: my $next = $states->{$action}[$page+1];
964: if ($state eq 'pick_request') {
965: $next = $states->{$action}[$page+1];
966: $jsextra = &viewrequest_javascript($formname,$next);
967: } elsif ($state eq 'details') {
968: $jsextra = &viewdetails_javascript($formname);
969:
970: } elsif ($state eq 'cancel') {
971: $jsextra = &viewcancel_javascript($formname);
972: }
1.40 raeburn 973: my $title;
974: if ($env{'form.crstype'} eq 'community') {
975: $title = 'Manage community requests';
976: } else {
977: $title = 'Manage course requests';
978: }
979: $r->print(&header($title,$js.$jscript.$jsextra,$loaditems).$crumb);
1.16 raeburn 980: my $form = '<form method="post" name="'.$formname.'" action="/adm/requestcourse" />';
1.11 raeburn 981: if ($state eq 'pick_request') {
1.40 raeburn 982: my $title;
983: if ($env{'form.crstype'} eq 'community') {
984: $title = &mt('Pending community requests');
985: } elsif ($env{'form.crstype'} eq 'official') {
986: $title = &mt('Pending requests for official courses');
987: } elsif ($env{'form.crstype'} eq 'unofficial') {
988: $title = &mt('Pending requests for unofficial courses');
1.69 raeburn 989: } elsif ($env{'form.crstype'} eq 'textbook') {
990: $title = &mt('Pending requests for textbook courses');
1.40 raeburn 991: } else {
992: $title = &mt('Pending course/community requests');
993: }
994: $r->print('<h3>'.$title.'</h3><div>'."\n".$form."\n".
1.48 raeburn 995: &print_request_status($dom,$action).'</form></div>');
1.16 raeburn 996: } elsif ($state eq 'details') {
997: my (@codetitles,%cat_titles,%cat_order,@code_order,$instcode,$code_chk);
998: my $origcnum = $env{'form.cnum'};
999: if ($origcnum eq '') {
1000: $origcnum = $env{'form.origcnum'};
1001: }
1002: if ($env{'form.crstype'} eq 'official') {
1003: &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
1004: \%cat_order,\@code_order);
1005: }
1.40 raeburn 1006: my $title;
1007: if ($env{'form.crstype'} eq 'community') {
1008: $title = &mt('Community Request Details');
1009: } else {
1010: $title = &mt('Course Request Details');
1011: }
1012: $r->print('<h3>'.$title.'</h3><div>'."\n".$form."\n".
1.26 raeburn 1013: &print_review($dom,\@codetitles,\%cat_titles,\%cat_order,
1.66 raeburn 1014: \@code_order,'','','','',$instcredits)."\n".
1.16 raeburn 1015: '<input name="origcnum" value="'.$origcnum.'" type="hidden" />'."\n");
1.66 raeburn 1016: my @excluded = &get_excluded_elements($dom,$states,'new','review',
1017: $showcredits);
1.16 raeburn 1018: push(@excluded,'origcnum');
1019: $r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'</div>');
1020: my $other = 'modify';
1021: my %navtxt = &Apache::lonlocal::texthash (
1022: prev => 'Back',
1023: other => 'Modify Request',
1024: next => 'Cancel Request',
1025: );
1.31 raeburn 1026: &display_navbuttons($r,$dom,$formname,$prev,$navtxt{'prev'},$next,
1027: $navtxt{'next'},$state,$other,$navtxt{'other'});
1.16 raeburn 1028: $r->print('</form>');
1029: } elsif ($state eq 'cancel') {
1.40 raeburn 1030: my $title;
1031: if ($env{'form.crstype'} eq 'community') {
1032: $title = &mt('Cancel community request');
1033: } else {
1034: $title = &mt('Cancel course request');
1035: }
1.16 raeburn 1036: my ($result,$output) = &print_cancel_request($dom,$env{'form.origcnum'});
1.40 raeburn 1037: $r->print('<h3>'.$title.'</h3><div>'."\n".$form."\n".
1.16 raeburn 1038: $output);
1.66 raeburn 1039: my @excluded = &get_excluded_elements($dom,$states,'view','cancel',
1040: $showcredits);
1.16 raeburn 1041: $r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'</div>');
1042: my %navtxt = &Apache::lonlocal::texthash (
1043: prev => 'Back',
1044: next => 'Confirm Cancellation',
1045: );
1046: if ($result eq 'ok') {
1.31 raeburn 1047: &display_navbuttons($r,$dom,$formname,$prev,$navtxt{'prev'},$next,
1.16 raeburn 1048: $navtxt{'next'},$state);
1049: } else {
1.31 raeburn 1050: &display_navbuttons($r,$dom,$formname,$prev,$navtxt{'prev'},undef,
1051: '',$state);
1.16 raeburn 1052: }
1053: $r->print('</form>');
1054: } elsif ($state eq 'removal') {
1055: my $cnum = $env{'form.origcnum'};
1056: my $statuskey = 'status:'.$dom.':'.$cnum;
1057: my %userreqhash = &Apache::lonnet::get('courserequests',[$statuskey],
1058: $env{'user.domain'},$env{'user.name'});
1059: my $currstatus = $userreqhash{$statuskey};
1060: my ($result,$error);
1061: if (($currstatus eq 'approval') || ($currstatus eq 'pending')) {
1062: my %status = (
1063: $statuskey => 'cancelled',
1064: );
1065: my $statusresult = &Apache::lonnet::put('courserequests',\%status);
1066: if ($statusresult eq 'ok') {
1067: my $delresult =
1068: &Apache::lonnet::del_dom('courserequestqueue',
1069: [$cnum.'_'.$currstatus],$dom);
1070: if ($delresult eq 'ok') {
1071: $result = 'ok';
1072: } else {
1073: $error = &mt('An error occurred when updating the pending requests queue: [_1]',$delresult);
1074: }
1075: } else {
1076: $error = &mt("An error occurred when updating the status of this request in the requestor's records: [_1]",$statusresult);
1077: }
1078: } else {
1079: $error = &mt('The current status of this request could not be verified as pending approval/institutional action.');
1080: }
1081: $r->print('<h3>'.&mt('Request Cancellation').'</h3><div>'."\n".$form."\n".
1082: '<input type="hidden" name="state" value="'.$state.'" />'."\n".
1083: '<input type="hidden" name="action" value="'.$action.'" />'."\n".
1084: '<input type="hidden" name="showdom" value="'.$dom.'" />'."\n".
1085: '<input type="hidden" name="orignum" value="'.$cnum.'" />'."\n");
1086: if ($result eq 'ok') {
1.40 raeburn 1087: if ($env{'form.crstype'} eq 'community') {
1088: $r->print(&mt('Your community request has been cancelled.'));
1089: } else {
1090: $r->print(&mt('Your course request has been cancelled.'));
1091: }
1.16 raeburn 1092: } else {
1093: $r->print('<div class="LC_error">'.
1094: &mt('The request cancellation process was not complete.').
1095: '<br />'.$error.'</div>');
1096: }
1097: $r->print('</form>');
1.11 raeburn 1098: }
1.26 raeburn 1099: } elsif ($action eq 'display') {
1100: my $formname = 'requestcrs';
1101: my (@codetitles,%cat_titles,%cat_order,@code_order,$instcode,$code_chk);
1102: if ($env{'form.crstype'} eq 'official') {
1103: &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
1104: \%cat_order,\@code_order);
1105: }
1.40 raeburn 1106: my ($title,$header);
1107: if ($env{'form.crstype'} eq 'community') {
1108: $title = 'Community Request';
1109: $header = &mt('Community Request');
1110: } else {
1111: $title = 'Course Request';
1112: $header = &mt('Course Request');
1113: }
1114: $r->print(&header($title,'','','',{ 'only_body' => 1}).
1115: $crumb."\n".'<h3>'.$header.'</h3>'.
1.26 raeburn 1116: &print_review($dom,\@codetitles,\%cat_titles,\%cat_order,
1.66 raeburn 1117: \@code_order,$uname,$udom,'','',$instcredits)."\n".
1118: '</div>'.
1.26 raeburn 1119: &close_popup_form());
1.1 raeburn 1120: }
1.2 raeburn 1121: $r->print(&Apache::loncommon::end_page());
1.1 raeburn 1122: return;
1123: }
1124:
1.83 raeburn 1125: sub domcoord_display {
1126: my ($dom) = @_;
1127: my ($uname,$udom,$result,$warning);
1128: if (($dom eq $env{'request.role.domain'}) && (&Apache::lonnet::allowed('ccc',$dom))) {
1129: if ($env{'form.cnum'} ne '') {
1130: my $cnum = $env{'form.cnum'};
1131: my $queue = $env{'form.queue'};
1132: my $reqkey = $cnum.'_'.$queue;
1133: my $namespace = 'courserequestqueue';
1134: my $domconfig = &Apache::lonnet::get_domainconfiguser($dom);
1135: my %queued =
1136: &Apache::lonnet::get($namespace,[$reqkey],$dom,$domconfig);
1137: if (ref($queued{$reqkey}) eq 'HASH') {
1138: $uname = $queued{$reqkey}{'ownername'};
1139: $udom = $queued{$reqkey}{'ownerdom'};
1140: if (($udom =~ /^$match_domain$/) && ($uname =~ /^$match_username$/)) {
1141: $result = &retrieve_settings($dom,$cnum,$udom,$uname);
1142: } else {
1143: if ($env{'form.crstype'} eq 'community') {
1144: $warning = &mt('Invalid username or domain for community requestor');
1145: } else {
1146: $warning = &mt('Invalid username or domain for course requestor');
1147: }
1148: }
1149: } else {
1150: if ($env{'form.crstype'} eq 'community') {
1151: $warning = &mt('No information was found for this community request.');
1152: } else {
1153: $warning = &mt('No information was found for this course request.');
1154: }
1155: }
1156: } else {
1157: $warning = &mt('No course request ID provided.');
1158: }
1159: } else {
1160: if ($env{'form.crstype'} eq 'any') {
1161: $warning = &mt('You do not have rights to view course or community request information.');
1162: } elsif ($env{'form.crstype'} eq 'community') {
1163: $warning = &mt('You do not have rights to view community request information.');
1164: } else {
1165: $warning = &mt('You do not have rights to view course request information.');
1166: }
1167: }
1168: return ($uname,$udom,$result,$warning);
1169: }
1170:
1.31 raeburn 1171: sub enrollment_lcsec_js {
1172: my %alerts = §ion_check_alerts();
1173: my $secname = $alerts{'badsec'};
1174: my $secnone = $alerts{'reserved'};
1175: my $output = '
1176: function validateEnrollSections(formname,nextstate) {
1177: var badsectotal = 0;
1178: var reservedtotal = 0;
1179: var secTest = "";
1180: ';
1181: for (my $i=0; $i<$env{'form.sectotal'}; $i++) {
1182: $output .= "
1183: var selSec = 0;
1184: for (var j=0; j<document.requestcrs.sec_".$i.".length; j++) {
1185: if (document.requestcrs.sec_".$i."[j].checked) {
1186: selSec = document.requestcrs.sec_".$i."[j].value;
1187: }
1188: if (selSec == 1) {
1189: secTest = validsection(document.requestcrs.loncapasec_".$i.");
1190: if (secTest == 'badsec') {
1191: badsectotal++;
1192: }
1193: if (secTest == 'reserved') {
1194: reservedtotal++;
1195: }
1196: }
1197: }
1198: ";
1199: }
1200: for (my $i=0; $i<$env{'form.crosslisttotal'}; $i++) {
1201: $output .= "
1202: if (document.requestcrs.crosslist_".$i.".checked) {
1203: secTest = validsection(document.requestcrs.crosslist_".$i."_lcsec);
1204: if (secTest == 'badsec') {
1205: badsectotal++;
1206: }
1207: if (secTest == 'reserved') {
1208: reservedtotal++;
1209: }
1210: }
1211: ";
1212: }
1213: $output .= "
1214: if (badsectotal>0) {
1215: alert('$secname');
1216: return false;
1217: }
1218: if (reservedtotal>0) {
1219: alert('$secnone');
1220: return false;
1221: }
1222: formname.state.value= nextstate;
1223: formname.submit();
1224: return;
1225: }
1226: ";
1227: return $output;
1228: }
1229:
1230: sub personnel_lcsec_js {
1231: my %alerts = §ion_check_alerts();
1232: my $secname = $alerts{'badsec'}.'\\n'.$alerts{'separate'};
1233: my $secnone = $alerts{'reserved'};
1234: my $output = '
1235: function validatePersonnelSections(formname,nextstate) {
1236: var badsectotal = 0;
1237: var reservedtotal = 0;
1238: var secTest = "";
1239: ';
1240: for (my $i=0; $i<$env{'form.persontotal'}; $i++) {
1241: $output .= "
1242: if (document.requestcrs.person_".$i."_uname.value != '') {
1243: secTest = validsection(document.requestcrs.person_".$i."_newsec,'1');
1244: if (secTest == 'badsec') {
1245: badsectotal++;
1246: }
1247: if (secTest == 'reserved') {
1248: reservedtotal++;
1249: }
1250: }
1251: ";
1252: }
1253: $output .= "
1254: if (badsectotal > 0) {
1255: alert('$secname');
1256: return false;
1257: } else {
1258: if (reservedtotal > 0) {
1259: alert('$secnone');
1260: return false;
1261: }
1262: }
1263: formname.state.value = nextstate;
1264: formname.submit();
1265: return;
1266: }
1267: ";
1268: return $output;
1269: }
1270:
1271: sub section_check_alerts {
1272: my %lt =
1273: &Apache::lonlocal::texthash(
1274: reserved => "You need to change one or more LON-CAPA section names - none is a reserved word in the system, and may not be used.",
1275: badsec => 'You need to change one or more LON-CAPA section names - names may only contain letters or numbers.',
1276: separate => 'Separate multiple sections with a comma.'
1277: );
1278: return %lt;
1279: }
1280:
1281: sub section_check_javascript {
1282: return <<"END";
1283: function validsection(field,mult) {
1284: var str = field.value;
1285: var badsec=0;
1286: var reserved=0;
1287: if (window.RegExp) {
1288: var badsecnum=0;
1289: var reservednum=0;
1290: var pattern=/[^a-zA-Z0-9]/;
1291: str = str.replace(/(^\\s*)|(\\s*\$)/gi,"");
1292: str = str.replace(/[ ]{2,}/gi," ");
1293: if (mult == '1') {
1294: var sections = new Array();
1295: sections = str.split(/\\s*[\\s,;:]\\s*/);
1296: var i;
1297: for (i=0; i<sections.length; i++) {
1298: if ((sections[i] != '') && (sections[i] != undefined) && (sections[i] != null)) {
1299: if (pattern.test(sections[i])) {
1300: badsecnum++;
1301: } else {
1302: if (sections[i] == 'none') {
1303: reservednum++;
1304: }
1305: }
1306: }
1307: }
1308: } else {
1309: if ((str != '') && (str != undefined) && (str != null)) {
1310: if (pattern.test(str)) {
1311: badsecnum++;
1312: } else {
1313: if (str == 'none') {
1314: reservednum++;
1315: }
1316: }
1317: }
1318: }
1319: if (badsecnum > 0) {
1320: return 'badsec';
1321: }
1322: if (reservednum > 0) {
1323: return 'reserved';
1324: }
1325: }
1326: return;
1327: }
1328: END
1329: }
1330:
1.26 raeburn 1331: sub close_popup_form {
1332: my $close= &mt('Close Window');
1333: return << "END";
1334: <p><form name="displayreq" action="" method="post">
1335: <input type="button" name="closeme" value="$close" onclick="javascript:self.close();" />
1336: </form></p>
1337: END
1338: }
1339:
1.27 raeburn 1340: sub get_instcode {
1341: my ($dom) = @_;
1342: my ($instcode,$numtitles);
1343: my (@codetitles,%cat_titles,%cat_order,@code_order,$instcode,$code_chk);
1344: &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
1345: \%cat_order,\@code_order);
1346: $numtitles = scalar(@codetitles);
1347: if (@code_order > 0) {
1348: my $message;
1349: foreach my $item (@code_order) {
1350: $instcode .= $env{'form.instcode_'.$item};
1351: }
1352: }
1353: return ($instcode,$numtitles);
1354: }
1355:
1.1 raeburn 1356: sub print_request_form {
1.27 raeburn 1357: my ($r,$action,$state,$page,$states,$dom,$newinstcode,$codechk,$checkedcode,
1.66 raeburn 1358: $description,$showcredits,$instcredits,$invalidcrosslist) = @_;
1.1 raeburn 1359: my $formname = 'requestcrs';
1.2 raeburn 1360: my ($next,$prev,$message,$output,$codepicker,$crstype);
1361: $prev = $states->{$action}[$page-1];
1362: $next = $states->{$action}[$page+1];
1.4 raeburn 1363: my %navtxt = &Apache::lonlocal::texthash (
1.10 raeburn 1364: prev => 'Back',
1.4 raeburn 1365: next => 'Next',
1366: );
1.2 raeburn 1367: $crstype = $env{'form.crstype'};
1.34 raeburn 1368: $r->print('<br /><form name="'.$formname.'" method="post" action="/adm/requestcourse">');
1.30 raeburn 1369: my (@codetitles,%cat_titles,%cat_order,@code_order,$instcode,$code_chk,
1370: @disallowed);
1.1 raeburn 1371: if ($crstype eq 'official') {
1.2 raeburn 1372: if ($env{'form.instcode'} ne '') {
1373: $instcode = $env{'form.instcode'};
1.27 raeburn 1374: } elsif ($newinstcode ne '') {
1375: $instcode = $newinstcode;
1.2 raeburn 1376: }
1.27 raeburn 1377: if ($checkedcode) {
1378: if ($codechk eq 'valid') {
1379: $message = '<div class="LC_info">'.
1380: &mt('The chosen course category [_1] is valid.','<b>'.
1381: $instcode.'</b>').
1382: '<input type="hidden" name="instcode" value="'.
1383: $instcode.'" /></div>';
1.2 raeburn 1384: } else {
1385: $message = '<div class="LC_warning">'.
1.27 raeburn 1386: &mt('No course was found matching your choice of institutional course category.');
1387: if ($codechk ne '') {
1388: $message .= '<br />'.$codechk;
1389: }
1390: $message .= '</div>';
1.2 raeburn 1391: $prev = 'crstype';
1392: }
1393: $r->print($message);
1.1 raeburn 1394: }
1.2 raeburn 1395: }
1396: if ($prev eq 'crstype') {
1.4 raeburn 1397: if ($crstype eq 'official') {
1398: &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
1399: \%cat_order,\@code_order);
1400: }
1.2 raeburn 1401: if (@code_order > 0) {
1.1 raeburn 1402: $codepicker = &coursecode_form($dom,'instcode',\@codetitles,
1403: \%cat_titles,\%cat_order);
1.2 raeburn 1404: if ($codepicker) {
1.34 raeburn 1405: $r->print(&mt('Specify the course to be created.').
1406: '<div>'.&Apache::lonhtmlcommon::start_pick_box().
1407: $codepicker.
1.2 raeburn 1408: &Apache::lonhtmlcommon::end_pick_box().'</div>');
1409: } else {
1.20 raeburn 1410: $next = $states->{$action}[$page+2];
1.15 raeburn 1411: $r->print(&courseinfo_form($dom,$formname,$crstype,$next));
1.2 raeburn 1412: }
1413: } else {
1.20 raeburn 1414: if ($crstype eq 'official') {
1415: $next = $states->{$action}[$page+2];
1416: }
1.15 raeburn 1417: $r->print(&courseinfo_form($dom,$formname,$crstype,$next));
1.1 raeburn 1418: }
1.2 raeburn 1419: } elsif ($prev eq 'codepick') {
1.27 raeburn 1420: if ($instcode eq '') {
1.20 raeburn 1421: $prev = $states->{$action}[$page-2];
1422: }
1.36 raeburn 1423: $r->print(&courseinfo_form($dom,$formname,$crstype,$next,$description));
1.2 raeburn 1424: } elsif ($state eq 'enrollment') {
1.4 raeburn 1425: if ($crstype eq 'official') {
1426: &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
1427: \%cat_order,\@code_order);
1428: }
1.2 raeburn 1429: $r->print(&print_enrollment_menu($formname,$instcode,$dom,\@codetitles,
1.27 raeburn 1430: \%cat_titles,\%cat_order,\@code_order,
1.66 raeburn 1431: $showcredits,$instcredits,$invalidcrosslist));
1.2 raeburn 1432: } elsif ($state eq 'personnel') {
1.27 raeburn 1433: $r->print(&print_personnel_menu($dom,$formname,$crstype,$invalidcrosslist));
1.4 raeburn 1434: } elsif ($state eq 'review') {
1.30 raeburn 1435: my (%alerts,%rulematch,%inst_results,%curr_rules,%got_rules,%disallowmsg);
1436: my $now = time;
1437: for (my $i=0; $i<$env{'form.persontotal'}; $i++) {
1438: my $personname = $env{'form.person_'.$i.'_uname'};
1439: my $persondom = $env{'form.person_'.$i.'_dom'};
1440: if (($personname =~ /^$match_username$/) &&
1441: ($persondom =~ /^$match_domain$/)) {
1442: if (&Apache::lonnet::domain($persondom)) {
1443: my $personhome =
1444: &Apache::lonnet::homeserver($personname,$persondom);
1445: if ($personhome eq 'no_host') {
1446: if ($persondom ne $dom) {
1447: my $skipuser = 1;
1448: if ($env{'user.role.dc./'.$persondom.'/'}) {
1449: my ($start,$end) = split('.',$env{'user.role.dc./'.$persondom.'/'});
1450: if (((!$start) || ($start < $now)) &&
1451: ((!$end) || ($end > $now))) {
1452: $skipuser = 0;
1453: }
1454: }
1455: if ($skipuser) {
1456: push(@disallowed,$i);
1.60 raeburn 1457: $disallowmsg{$i} = &mt('[_1] was excluded because new users need to be from the course domain','<tt>'.$personname.':'.$persondom.'</tt>');
1.30 raeburn 1458: next;
1459: }
1460: }
1.60 raeburn 1461: my $usertype = &get_usertype($persondom,$personname,\%curr_rules,\%got_rules);
1462: if (&Apache::lonuserutils::can_create_user($dom,'requestcrs',$usertype)) {
1463: my ($allowed,$msg,$authtype,$authparam) =
1.30 raeburn 1464: &check_newuser_rules($persondom,$personname,
1465: \%alerts,\%rulematch,\%inst_results,
1466: \%curr_rules,\%got_rules);
1467: if ($allowed) {
1.60 raeburn 1468: my %domdefaults = &Apache::lonnet::get_domain_defaults($persondom);
1469: if ($usertype eq 'official') {
1470: if ($authtype eq '') {
1471: $authtype = $domdefaults{'auth_def'};
1472: $authparam = $domdefaults{'auth_arg_def'};
1473: }
1474: } elsif ($usertype eq 'unofficial') {
1475: if ($authtype eq '') {
1476: $authtype = 'internal';
1477: $authparam = '';
1478: }
1479: } else {
1480: $authtype = $domdefaults{'auth_def'};
1481: $authparam = $domdefaults{'auth_arg_def'};
1482: }
1483: if (($authtype eq '') ||
1484: (($authtype =~/^krb/) && ($authparam eq ''))) {
1485: push(@disallowed,$i);
1486: $disallowmsg{$i} = &mt('[_1] was excluded because institutional information is incomplete for this new user.','<tt>'.$personname.':'.$persondom.'</tt>');
1487: next;
1488: }
1.30 raeburn 1489: if (ref($inst_results{$personname.':'.$persondom}) eq 'HASH') {
1490: if ($inst_results{$personname.':'.$persondom}{'lastname'} ne '') {
1491: $env{'form.person_'.$i.'_lastname'} = $inst_results{$personname.':'.$persondom}{'lastname'};
1492: }
1493: if ($inst_results{$personname.':'.$persondom}{'firstname'} ne '') {
1494: $env{'form.person_'.$i.'_firstname'} = $inst_results{$personname.':'.$persondom}{'firstname'};
1495: }
1496: if ($inst_results{$personname.':'.$persondom}{'permanentemail'} ne '') {
1497: $env{'form.person_'.$i.'_emailaddr'} = $inst_results{$personname.':'.$persondom}{'permanentemail'};
1498: }
1499: }
1500: } else {
1501: push(@disallowed,$i);
1502: $disallowmsg{$i} = &mt('[_1] was excluded because the username violated format rules for the domain','<tt>'.$personname.':'.$persondom.'</tt>');
1503: }
1504: } else {
1505: push(@disallowed,$i);
1506: $disallowmsg{$i} = &mt('[_1] was excluded because you may not request new users in the domain','<tt>'.$personname.':'.$persondom.'</tt>');
1507: }
1508: } else {
1509: my %userenv =
1510: &Apache::lonnet::userenvironment($persondom,$personname,'lastname','firstname','permanentemail');
1511: if ($env{'form.person_'.$i.'_lastname'} eq '') {
1512: $env{'form.person_'.$i.'_lastname'} = $userenv{'lastname'};
1513: }
1514: if ($env{'form.person_'.$i.'_firstname'} eq '') {
1515: $env{'form.person_'.$i.'_firstname'} = $userenv{'firstname'};
1516: }
1517: if ($env{'form.person_'.$i.'_emailaddr'} eq '') {
1518: $env{'form.person_'.$i.'_emailaddr'} = $userenv{'permanentemail'};
1519: }
1520: }
1521: } elsif ($personname ne '') {
1522: push(@disallowed,$i);
1523: $disallowmsg{$i} = &mt('[_1] was excluded because the domain is invalid','<tt>'.$personname.':'.$persondom.'</tt>');
1524: }
1525: } elsif ($personname ne '') {
1526: push(@disallowed,$i);
1527: $disallowmsg{$i} = &mt('[_1] was excluded because the username or domain is invalid.','<tt>'.$personname.':'.$persondom.'</tt>');
1528: }
1529: }
1.16 raeburn 1530: my $cnum;
1531: if ($env{'form.origcnum'} =~ /^($match_courseid)$/) {
1532: $cnum = $env{'form.origcnum'};
1533: } else {
1.47 raeburn 1534: my $gentype = 'Course';
1535: if ($crstype eq 'community') {
1536: $gentype = 'Community';
1537: }
1538: $cnum = &Apache::lonnet::generate_coursenum($dom,$gentype);
1.16 raeburn 1539: }
1.4 raeburn 1540: &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
1541: \%cat_order,\@code_order);
1.40 raeburn 1542: if ($crstype eq 'community') {
1543: $r->print('<h3>'.&mt('Review community request details before submission').'</h3>');
1544: } else {
1545: $r->print('<h3>'.&mt('Review course request details before submission').'</h3>');
1546: }
1.66 raeburn 1547: $r->print(&print_review($dom,\@codetitles,\%cat_titles,\%cat_order,\@code_order,'','',\@disallowed,\%disallowmsg,$instcredits).
1.16 raeburn 1548: '<input type="hidden" name="cnum" value="'.$cnum.'" />');
1.73 raeburn 1549: my $fullname = &Apache::loncommon::plainname($env{'user.name'},
1550: $env{'user.domain'});
1551: my $postprocess = &Apache::lonnet::auto_crsreq_update($dom,$cnum,$crstype,'review',$env{'user.name'},
1552: $env{'user.domain'},$fullname,$env{'form.cdescr'});
1553: if (ref($postprocess) eq 'HASH') {
1554: if ($postprocess->{'reviewweb'}) {
1555: $r->print($postprocess->{'reviewweb'});
1556: }
1557: }
1.40 raeburn 1558: if ($crstype eq 'community') {
1559: $navtxt{'next'} = &mt('Submit community request');
1560: } else {
1561: $navtxt{'next'} = &mt('Submit course request');
1562: }
1.10 raeburn 1563: } elsif ($state eq 'process') {
1564: if ($crstype eq 'official') {
1565: &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
1566: \%cat_order,\@code_order);
1567: }
1.78 raeburn 1568: my $lonhost = $r->dir_config('lonHostID');
1.84 ! raeburn 1569: my ($storeresult,$result) = &print_request_outcome($r,$lonhost,$dom,\@codetitles,
1.66 raeburn 1570: \@code_order,$instcredits);
1.13 raeburn 1571: $r->print($result);
1.27 raeburn 1572: if (($storeresult eq 'ok') || ($storeresult eq 'created')) {
1573: if ($storeresult eq 'ok') {
1.65 raeburn 1574: $r->print('<p><a href="/adm/requestcourse?action=view&state=details&showdom='.$dom.'&cnum='. $env{'form.cnum'}.'">'.
1575: &mt('Modify this request').'</a>'.(' 'x4).
1576: '<a href="/adm/requestcourse">'.&mt('Make another request').'</a></p>');
1577: }
1578: if (&Apache::loncoursequeueadmin::author_prompt()) {
1.72 raeburn 1579: &print_author_prompt($r,$env{'form.action'},$env{'form.cnum'},$env{'form.showdom'},
1580: $env{'form.crstype'},$storeresult);
1.65 raeburn 1581: } elsif ($storeresult eq 'created') {
1582: $r->print('<p><a href="/adm/requestcourse">'.&mt('Make another request').'</a></p>');
1583: }
1584: }
1585: } elsif ($state eq 'reqauthor') {
1586: my ($result,@links);
1587: if ($env{'form.requestauthor'}) {
1588: $r->print(&Apache::loncoursequeueadmin::process_reqauthor(\$result));
1589: if ($result eq 'created') {
1590: my $role = 'au';
1591: my $spec = "$role./$env{'form.showdom'}/";
1.76 bisitz 1592: push(@links,&mt('Enter your Authoring Space with role: [_1]',
1.65 raeburn 1593: '<a href="/adm/roles?selectrole=1&'.$spec.'=1">'.
1594: &Apache::lonnet::plaintext($role).'</a>'));
1.27 raeburn 1595: }
1.65 raeburn 1596: }
1597: if (($env{'form.disposition'} eq 'created') &&
1598: ($env{'form.cnum'} =~ /^$match_courseid$/) &&
1599: ($env{'form.showdom'} =~ /^$match_domain$/)) {
1600: my ($spec,$area,$role,$type);
1601: my $role = 'cc';
1602: my $spec = "$role./$env{'form.showdom'}/$env{'form.cnum'}";
1603: my $type = 'Course';
1604: if ($env{'form.crstype'} eq 'community') {
1605: $type = 'Community';
1606: }
1607: my $showrole = &Apache::lonnet::plaintext($role,$type);
1608: unshift(@links,&mt('Enter new course with role: [_1]',
1609: '<a href="/adm/roles?selectrole=1&'.$spec.'=1">'.$showrole.'</a>'));
1610: }
1611: if (@links > 1) {
1612: $r->print(&mt('New roles will be listed on your [_1]Roles[_2] page.',
1613: '<a href="/adm/roles">','</a>').' '.&mt('Choose a role:').
1614: '<ul>');
1615: foreach my $link (@links) {
1616: $r->print('<li>'.$link.'</li>');
1617: }
1618: $r->print('</ul>');
1619: } elsif (@links == 1) {
1620: $r->print('<p>'.$links[0].'</p>');
1.27 raeburn 1621: }
1.1 raeburn 1622: }
1.66 raeburn 1623: my @excluded = &get_excluded_elements($dom,$states,$action,$state,$showcredits);
1.24 raeburn 1624: if ($state eq 'personnel') {
1625: push(@excluded,'persontotal');
1626: }
1.30 raeburn 1627: if ($state eq 'review') {
1628: if (@disallowed > 0) {
1629: my @items = qw(uname dom lastname firstname emailaddr hidedom role newsec);
1630: my @currsecs = ¤t_lc_sections();
1631: if (@currsecs) {
1632: push(@items,'sec');
1633: }
1634: my $count = 0;
1635: for (my $i=0; $i<$env{'form.persontotal'}; $i++) {
1636: unless ($env{'form.person_'.$i.'_uname'} eq '') {
1637: if (grep(/^$i$/,@disallowed)) {
1638: foreach my $item (@items) {
1639: $env{'form.person_'.$i.'_'.$item} = '';
1640: }
1641: } else {
1642: foreach my $item (@items) {
1643: $env{'form.person_'.$count.'_'.$item} = $env{'form.person_'.$i.'_'.$item};
1644: }
1645: }
1646: }
1647: $count ++;
1648: }
1649: $env{'form.persontotal'} = $count;
1650: }
1651: }
1.27 raeburn 1652: if ($state eq 'enrollment') {
1.61 raeburn 1653: push(@excluded,('sectotal','crosslisttotal'));
1.27 raeburn 1654: }
1.65 raeburn 1655: if (($state eq 'process') || ($state eq 'reqauthor')) {
1656: $r->print('</form>');
1657: } else {
1658: $r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'</form>');
1659: &display_navbuttons($r,$dom,$formname,$prev,$navtxt{'prev'},$next,
1660: $navtxt{'next'},$state);
1661: }
1.16 raeburn 1662: return;
1663: }
1664:
1.72 raeburn 1665: sub print_author_prompt {
1666: my ($r,$action,$cnum,$showdom,$crstype,$storeresult) = @_;
1.76 bisitz 1667: $r->print('<h3>'.&mt('Access to Authoring Space').'</h3>'.
1.72 raeburn 1668: '<p>'.
1669: &mt('Although assessment items can be created directly inside a course, such items only use part of the assessment capabilities of LON-CAPA.').
1670: '<br />'.
1.76 bisitz 1671: &mt('By contrast, items created in Authoring Space, then imported into a course, can use all of the features of the assessment engine.').'</p>'.
1672: '<p>'.&mt('Request Authoring Space access now?').
1.72 raeburn 1673: '<span class="LC_nobreak"> '.
1674: '<label><input type="radio" name="requestauthor" value="1" />'.&mt('Yes').'</label>'.
1675: (' 'x2).
1676: '<label><input type="radio" name="requestauthor" value="0" checked="checked"/>'.&mt('No').'</label>'.
1677: '</span></p>'.
1678: '<input type="submit" name="newauthor" value="'.&mt('Submit authoring request').'" />'.
1679: '<input type="hidden" name="state" value="reqauthor" />'.
1680: '<input type="hidden" name="action" value="'.$action.'" />'.
1681: '<input type="hidden" name="cnum" value="'.$cnum.'" />'.
1682: '<input type="hidden" name="showdom" value="'.$showdom.'" />'.
1683: '<input type="hidden" name="crstype" value="'.$crstype.'" />'.
1684: '<input type="hidden" name="disposition" value="'.$storeresult.'" />'.
1685: '<br />');
1686: }
1687:
1.60 raeburn 1688: sub get_usertype {
1689: my ($persondom,$personname,$curr_rules,$got_rules) = @_;
1.30 raeburn 1690: my ($rules,$ruleorder) =
1691: &Apache::lonnet::inst_userrules($persondom,'username');
1692: my $usertype = &Apache::lonuserutils::check_usertype($persondom,$personname,
1.60 raeburn 1693: $rules,$curr_rules,$got_rules);
1694: return $usertype;
1.30 raeburn 1695: }
1696:
1697: sub check_newuser_rules {
1698: my ($persondom,$personname,$alerts,$rulematch,$inst_results,$curr_rules,
1699: $got_rules) = @_;
1700: my $allowed = 1;
1701: my $newuser = 1;
1.60 raeburn 1702: my ($checkhash,$userchkmsg,$authtype,$authparam);
1.30 raeburn 1703: my $checks = { 'username' => 1 };
1704: $checkhash->{$personname.':'.$persondom} = { 'newuser' => $newuser };
1705: &Apache::loncommon::user_rule_check($checkhash,$checks,$alerts,$rulematch,
1706: $inst_results,$curr_rules,$got_rules);
1707: if (ref($alerts->{'username'}) eq 'HASH') {
1708: if (ref($alerts->{'username'}{$persondom}) eq 'HASH') {
1709: my $domdesc =
1710: &Apache::lonnet::domain($persondom,'description');
1711: if ($alerts->{'username'}{$persondom}{$personname}) {
1712: if (ref($curr_rules->{$persondom}) eq 'HASH') {
1713: $userchkmsg =
1714: &Apache::loncommon::instrule_disallow_msg('username',
1715: $domdesc,1).
1716: &Apache::loncommon::user_rule_formats($persondom,
1717: $domdesc,$curr_rules->{$persondom}{'username'},
1718: 'username');
1719: }
1720: $allowed = 0;
1721: }
1722: }
1723: }
1.60 raeburn 1724: if ($allowed) {
1725: if (ref($rulematch) eq 'HASH') {
1726: if (ref($rulematch->{$personname.':'.$persondom}) eq 'HASH') {
1727: my $matchedrule = $rulematch->{$personname.':'.$persondom}{'username'};
1728: my ($rules,$ruleorder) =
1729: &Apache::lonnet::inst_userrules($persondom,'username');
1730: if (ref($rules) eq 'HASH') {
1731: if (ref($rules->{$matchedrule}) eq 'HASH') {
1732: $authtype = $rules->{$matchedrule}{'authtype'};
1733: $authparam = $rules->{$matchedrule}{'authparm'};
1734: }
1735: }
1736: }
1737: }
1738: }
1739: return ($allowed,$userchkmsg,$authtype,$authparam);
1.30 raeburn 1740: }
1741:
1.16 raeburn 1742: sub get_excluded_elements {
1.66 raeburn 1743: my ($dom,$states,$action,$state,$showcredits) = @_;
1.2 raeburn 1744: my @excluded = ('counter');
1.66 raeburn 1745: my ($elements,$instcredits) = &form_elements($dom,$showcredits);
1.2 raeburn 1746: if (ref($states) eq 'HASH') {
1747: if (ref($states->{$action}) eq 'ARRAY') {
1748: my @items = @{$states->{$action}};
1749: my $numitems = scalar(@items);
1750: if ($numitems) {
1751: for (my $i=$numitems-1; $i>=0; $i--) {
1.66 raeburn 1752: if ((ref($elements) eq 'HASH') &&
1753: (ref($elements->{$action}) eq 'HASH')) {
1754: if (ref($elements->{$action}{$items[$i]}) eq 'HASH') {
1755: foreach my $key (keys(%{$elements->{$action}{$items[$i]}})) {
1.2 raeburn 1756: push(@excluded,$key);
1757: }
1758: }
1759: }
1760: last if ($items[$i] eq $state);
1761: }
1762: }
1763: }
1764: }
1765: if (grep(/^instcode_/,@excluded)) {
1766: push(@excluded,'instcode');
1.1 raeburn 1767: }
1.16 raeburn 1768: return @excluded;
1.1 raeburn 1769: }
1770:
1.2 raeburn 1771: sub print_enrollment_menu {
1.27 raeburn 1772: my ($formname,$instcode,$dom,$codetitles,$cat_titles,$cat_order,$code_order,
1.66 raeburn 1773: $showcredits,$instcredits,$invalidcrosslist) =@_;
1774: my ($sections,$autoenroll,$access_dates,$output,$hasauto,$hascredits,
1775: $creditsrow,$domdefcredits);
1.2 raeburn 1776: my $starttime = time;
1777: my $endtime = time+(6*30*24*60*60); # 6 months from now, approx
1778:
1779: my %accesstitles = (
1780: 'start' => 'Default start access',
1.16 raeburn 1781: 'end' => 'Default end access',
1.2 raeburn 1782: );
1783: my %enrolltitles = (
1784: 'start' => 'Start auto-enrollment',
1785: 'end' => 'End auto-enrollment',
1786: );
1.66 raeburn 1787: if ($showcredits) {
1788: unless ($env{'form.crstype'} eq 'community') {
1789: my %domdefs = &Apache::lonnet::get_domain_defaults($dom);
1790: $domdefcredits = $domdefs{$env{'form.crstype'}.'credits'};
1791: }
1792: }
1.2 raeburn 1793: if ($env{'form.crstype'} eq 'official') {
1794: if (&Apache::lonnet::auto_run('',$dom)) {
1.27 raeburn 1795: $output = &show_invalid_crosslists($invalidcrosslist);
1796: my ($section_form,$crosslist_form);
1.61 raeburn 1797: if ($instcode ne '') {
1798: $section_form = &inst_section_selector($dom,$instcode);
1799: if ($section_form eq '') {
1800: my $sectotal = $env{'form.sectotal'};
1801: if (!$sectotal) {
1802: $sectotal = 1;
1803: }
1804: if ($env{'form.addsection'}) {
1805: $sectotal ++;
1806: }
1807: for (my $i=0; $i<$sectotal; $i++) {
1808: $section_form .= §ions_form($dom,$instcode,$i);
1809: }
1810: if ($section_form) {
1811: $section_form .=
1812: &Apache::lonhtmlcommon::row_title(&mt('Add another')).
1813: '<input name="sectotal" type="hidden" value="'.$sectotal.'" />'.
1814: '<input name="addsection" type="checkbox" value="'.$sectotal.'"'.
1815: ' onclick="javascript:nextPage(document.'.$formname.",'".$env{'form.state'}.
1816: "'".');" />'.&mt('Add?').&Apache::lonhtmlcommon::row_closure();
1817: }
1818: }
1819: }
1.27 raeburn 1820: if ($section_form) {
1821: $sections = &Apache::lonhtmlcommon::row_headline().
1.34 raeburn 1822: '<h3>'.&Apache::loncommon::help_open_topic('Course_Request_Sections').
1823: ' '.&mt('Sections for auto-enrollment').'</h3>'.
1.27 raeburn 1824: &Apache::lonhtmlcommon::row_closure(1).
1825: $section_form;
1826: }
1.2 raeburn 1827: my $crosslisttotal = $env{'form.crosslisttotal'};
1.24 raeburn 1828: if (!$crosslisttotal) {
1.2 raeburn 1829: $crosslisttotal = 1;
1830: }
1831: if ($env{'form.addcrosslist'}) {
1832: $crosslisttotal ++;
1833: }
1834: for (my $i=0; $i<$crosslisttotal; $i++) {
1835: $crosslist_form .= &coursecode_form($dom,'crosslist',$codetitles,
1836: $cat_titles,$cat_order,$i);
1837: }
1838: if ($crosslist_form) {
1839: $crosslist_form .=
1.40 raeburn 1840: &Apache::lonhtmlcommon::row_title(&mt('Add another')).
1.2 raeburn 1841: '<input name="crosslisttotal" type="hidden" value="'.$crosslisttotal.'" />'.
1842: '<input name="addcrosslist" type="checkbox" value="'.$crosslisttotal.'"'.
1843: ' onclick="javascript:nextPage(document.'.$formname.",'".$env{'form.state'}.
1.27 raeburn 1844: "'".');" />'.&mt('Add?').&Apache::lonhtmlcommon::row_closure();
1845: $sections .= &Apache::lonhtmlcommon::row_headline.
1.61 raeburn 1846: '<h3>'.&Apache::loncommon::help_open_topic('Course_Request_Crosslist').' '.&mt('Crosslisted courses for auto-enrollment').'</h3>'.
1.27 raeburn 1847: &Apache::lonhtmlcommon::row_closure(1).
1848: $crosslist_form;
1.2 raeburn 1849: }
1.34 raeburn 1850: $hasauto = 1;
1.27 raeburn 1851: $autoenroll =
1.34 raeburn 1852: &Apache::lonhtmlcommon::row_title(&Apache::loncommon::help_open_topic('Course_Request_Autoadd').' '.&mt('Add registered students automatically')).
1.2 raeburn 1853: '<span class="LC_nobreak"><label>'.
1854: '<input type="radio" name="autoadds" value="1">'.
1855: &mt('Yes').'</label>'.(' 'x3).'<label>'.
1856: '<input type="radio" name="autoadds" value="0" checked="checked">'.
1857: &mt('No').'</label></span>'.
1.27 raeburn 1858: &Apache::lonhtmlcommon::row_closure(1).
1.34 raeburn 1859: &Apache::lonhtmlcommon::row_title(&Apache::loncommon::help_open_topic('Course_Request_Autodrop').' '.&mt('Drop unregistered students automatically')).
1.2 raeburn 1860: '<span class="LC_nobreak"><label>'.
1861: '<input type="radio" name="autodrops" value="1">'.
1862: &mt('Yes').'</label>'.(' 'x3).'<label>'.
1863: '<input type="radio" name="autodrops" value="0" checked="checked">'.
1864: &mt('No').'</label></span>'.
1.27 raeburn 1865: &Apache::lonhtmlcommon::row_closure(1).
1.34 raeburn 1866: &date_setting_table($starttime,$endtime,$formname,'enroll',
1.66 raeburn 1867: $hasauto,undef,%enrolltitles);
1868: if ($showcredits) {
1869: if ($instcredits) {
1870: $creditsrow = &mt('[quant,_1,credit]',$instcredits);
1871: } else {
1872: $creditsrow = '<span class="LC_nobreak">'.
1873: '<input type="text" size="3" name="coursecredits"'.
1874: ' value="'.$domdefcredits.'" />';
1875: }
1876: $hascredits = 1;
1877: }
1878: }
1.69 raeburn 1879: } elsif (($env{'form.crstype'} eq 'unofficial') || ($env{'form.crstype'} eq 'textbook')) {
1.66 raeburn 1880: if ($showcredits) {
1881: $creditsrow = '<span class="LC_nobreak">'.
1882: '<input type="text" size="3" name="coursecredits"'.
1883: ' value="'.$domdefcredits.'"/>';
1884: $hascredits = 1;
1.2 raeburn 1885: }
1886: }
1.27 raeburn 1887: my $access_dates =
1.34 raeburn 1888: &date_setting_table($starttime,$endtime,$formname,'access',$hasauto,
1.66 raeburn 1889: $hascredits,%accesstitles);
1.27 raeburn 1890: $output .= &Apache::lonhtmlcommon::start_pick_box();
1891: if ($sections) {
1892: $output .= $sections;
1893: }
1894: if ($autoenroll) {
1895: $output .= &Apache::lonhtmlcommon::row_headline('Auto-enroll').
1896: '<h3>'.&mt('Auto-enrollment settings').'</h3>'.
1897: &Apache::lonhtmlcommon::row_closure(1).
1898: $autoenroll;
1899: }
1900: if ($access_dates) {
1901: my $header = &mt('Access dates for students');
1902: if ($env{'form.crstype'} eq 'community') {
1903: $header = &mt('Access dates for community members');
1904: }
1905: $output .= &Apache::lonhtmlcommon::row_headline('Access').
1906: '<h3>'.$header.'</h3>'.
1907: &Apache::lonhtmlcommon::row_closure(1).
1.66 raeburn 1908: $access_dates;
1909: }
1910: if ($creditsrow) {
1911: $output .= &Apache::lonhtmlcommon::row_headline('Credits').
1912: '<h3>'.&mt('Credits earned by students').'</h3>'.
1913: &Apache::lonhtmlcommon::row_closure(1).
1914: &Apache::lonhtmlcommon::row_title(&mt('Default credits')).
1915: $creditsrow.
1916: &Apache::lonhtmlcommon::row_closure(1);
1.2 raeburn 1917: }
1.27 raeburn 1918: return '<div>'.&Apache::lonhtmlcommon::start_pick_box().$output.
1919: &Apache::lonhtmlcommon::end_pick_box().'</div>';
1.2 raeburn 1920: }
1921:
1.27 raeburn 1922: sub show_invalid_crosslists {
1923: my ($invalidcrosslist) = @_;
1924: my $output;
1925: if (ref($invalidcrosslist) eq 'ARRAY') {
1926: if (@{$invalidcrosslist} > 0) {
1927: $output = '<div class="LC_warning">'.
1928: &mt('The following crosslisted courses were invalid:').'<ul>';
1929: foreach my $item (@{$invalidcrosslist}) {
1930: $output .= '<li>'.$item.'</li>';
1931: }
1932: $output .= '</ul></div><br />';
1933: }
1934: }
1935: return $output;
1936: }
1937:
1938:
1.1 raeburn 1939: sub inst_section_selector {
1.2 raeburn 1940: my ($dom,$instcode) = @_;
1941: my @sections = &Apache::lonnet::auto_get_sections(undef,$dom,$instcode);
1942: my $sectotal = scalar(@sections);
1.1 raeburn 1943: my $output;
1.2 raeburn 1944: if ($sectotal) {
1.27 raeburn 1945: $output .= &Apache::lonhtmlcommon::row_title(&mt('Sections of [_1]',$instcode)).
1.2 raeburn 1946: &Apache::loncommon::start_data_table().
1947: &Apache::loncommon::start_data_table_row().
1948: '<th>'.&mt('Include?').'<input type="hidden" name="sectotal" '.
1.24 raeburn 1949: 'value="'.$sectotal.'" /></th>'.
1.2 raeburn 1950: '<th>'.&mt('Institutional Section').'</th>'.
1.34 raeburn 1951: '<th>'.&Apache::loncommon::help_open_topic('Course_Request_LCSection').
1952: ' '.&mt('LON-CAPA section').'</th>'.
1.2 raeburn 1953: &Apache::loncommon::end_data_table_row();
1954: for (my $i=0; $i<@sections; $i++) {
1.1 raeburn 1955: my $colflag = $i%2;
1.31 raeburn 1956: my $secon = ' checked="checked"';
1957: my $secoff = '';
1.24 raeburn 1958: if ($env{'form.origcnum'}) {
1.31 raeburn 1959: $secoff = $secon;
1960: $secon='';
1.24 raeburn 1961: }
1.1 raeburn 1962: $output .= &Apache::loncommon::start_data_table_row().
1.31 raeburn 1963: '<td><label><input type="radio" name="sec_'.$i.
1964: '"'.$secon.' value="1" />'.&mt('Yes').'</label>'.
1965: (' 'x2).'<label><input type="radio" name="sec_'.$i.
1966: '"'.$secoff.' value="0" />'.&mt('No').'</label></td>'.
1967: '<td align="center">'.$sections[$i].
1.1 raeburn 1968: '<input type="hidden" name="secnum_'.$i.'" value="'.
1.2 raeburn 1969: $sections[$i].'" /></td>'.
1.1 raeburn 1970: '<td><input type="text" size="10" name="loncapasec_'.$i.
1.2 raeburn 1971: '" value="'.$sections[$i].'" /></td>'.
1.1 raeburn 1972: &Apache::loncommon::end_data_table_row();
1973: }
1.2 raeburn 1974: $output .= &Apache::loncommon::end_data_table().
1975: &Apache::lonhtmlcommon::row_closure();
1.1 raeburn 1976: }
1977: return $output;
1978: }
1979:
1.2 raeburn 1980: sub date_setting_table {
1.66 raeburn 1981: my ($starttime,$endtime,$formname,$prefix,$hasauto,$hascredits,%datetitles)=@_;
1.2 raeburn 1982: my ($perpetual,$table);
1.14 raeburn 1983: my $startform = &Apache::lonhtmlcommon::date_setter($formname,$prefix.'start',
1.2 raeburn 1984: $starttime,'','','',1,'','','',1);
1.14 raeburn 1985: my $endform = &Apache::lonhtmlcommon::date_setter($formname,$prefix.'end',
1.2 raeburn 1986: $endtime,'','','',1,'','','',1);
1.27 raeburn 1987: my $closure = '';
1.14 raeburn 1988: if ($prefix eq 'access') {
1.2 raeburn 1989: $perpetual = ' <span class="LC_nobreak"><label>'.
1990: '<input type="checkbox" name="no_end_date" />'.
1991: &mt('No end date').'</label></span>';
1.66 raeburn 1992: unless ($hascredits) {
1993: $closure = '1';
1994: }
1.2 raeburn 1995: }
1.34 raeburn 1996:
1997: my %help_item = (
1998: access => {
1999: start => 'Course_Request_Access_Start',
2000: end => 'Course_Request_Access_End',
2001: },
2002: enroll => {
2003: start => 'Course_Request_Enroll_Start',
2004: end => 'Course_Request_Enroll_End',
2005: },
2006: );
2007: if ($hasauto) {
2008: $help_item{'access'}{'start'} = 'Course_Request_RegAccess_Start';
2009: $help_item{'access'}{'end'} = 'Course_Request_RegAccess_End';
2010: }
2011:
2012: $table = &Apache::lonhtmlcommon::row_title(&Apache::loncommon::help_open_topic($help_item{$prefix}{'start'}).
1.46 wenzelju 2013: ' '.&mt($datetitles{'start'})).$startform.
1.27 raeburn 2014: &Apache::lonhtmlcommon::row_closure(1).
1.34 raeburn 2015: &Apache::lonhtmlcommon::row_title(&Apache::loncommon::help_open_topic($help_item{$prefix}{'end'}).
1.46 wenzelju 2016: ' '.&mt($datetitles{'end'})).$endform.$perpetual.
1.27 raeburn 2017: &Apache::lonhtmlcommon::row_closure($closure);
1.2 raeburn 2018: return $table;
2019: }
2020:
2021: sub print_personnel_menu {
1.27 raeburn 2022: my ($dom,$formname,$crstype,$invalidcrosslist) = @_;
2023: my $output;
2024: if ($crstype eq 'official') {
2025: if (&Apache::lonnet::auto_run('',$dom)) {
2026: $output .= &show_invalid_crosslists($invalidcrosslist);
2027: }
2028: }
2029: $output .= '<div>'.&Apache::lonhtmlcommon::start_pick_box();
1.2 raeburn 2030: my $persontotal = $env{'form.persontotal'};
1.16 raeburn 2031: if ((!defined($persontotal)) || (!$persontotal)) {
1.2 raeburn 2032: $persontotal = 1;
2033: }
2034: if ($env{'form.addperson'}) {
2035: $persontotal ++;
2036: }
1.13 raeburn 2037: my @items = ('uname','dom','lastname','firstname','emailaddr','hidedom');
1.2 raeburn 2038:
1.8 raeburn 2039: my $type = 'Course';
2040: if ($crstype eq 'community') {
2041: $type = 'Community';
2042: }
1.41 raeburn 2043: my $roleoptions;
2044: my @roles = &Apache::lonuserutils::roles_by_context('course','',$type);
1.2 raeburn 2045: foreach my $role (@roles) {
1.28 raeburn 2046: my $plrole = &Apache::lonnet::plaintext($role,$type);
1.2 raeburn 2047: $roleoptions .= ' <option value="'.$role.'">'.$plrole.'</option>'."\n";
2048: }
2049: my %customroles=&Apache::lonuserutils::my_custom_roles();
2050: if (keys(%customroles) > 0) {
2051: foreach my $cust (sort(keys(%customroles))) {
1.28 raeburn 2052: my $custrole="cr/$env{'user.domain'}/$env{'user.name'}/$cust";
1.2 raeburn 2053: $roleoptions .= ' <option value="'.$custrole.'">'.$cust.'</option>'."\n";
2054: }
2055: }
2056:
1.30 raeburn 2057: my @currsecs = ¤t_lc_sections();
1.2 raeburn 2058:
2059: my ($existtitle,$existops,$existmult,$newtitle,$seccolspan);
2060: if (@currsecs) {
2061: my $existsize = scalar(@currsecs);
2062: if ($existsize > 3) {
2063: $existsize = 3;
2064: }
2065: if ($existsize > 1) {
2066: $existmult = ' multiple="multiple" size="'.$existsize.'" ';
2067: }
2068: @currsecs = sort { $a <=> $b } (@currsecs);
2069: $existtitle = &mt('Official').': ';
2070: $existops = '<option value="">'.&mt('None').'</option>';
2071: foreach my $sec (@currsecs) {
2072: $existops .= '<option value="'.$sec.'">'.$sec.'</option>'."\n";
2073: }
2074: $seccolspan = ' colspan="2"';
2075: $newtitle = &mt('Other').': ';
2076: }
2077:
1.27 raeburn 2078: if ($persontotal) {
1.32 raeburn 2079: my %lt = &Apache::lonlocal::texthash(
2080: community => 'Requestor is automatically assigned Coordinator role.',
2081: official => 'Requestor is automatically assigned Course Coordinator role.',
2082: );
2083: $lt{'unofficial'} = $lt{'official'};
1.69 raeburn 2084: $lt{'textbook'} = $lt{'textbook'};
1.27 raeburn 2085: $output .= &Apache::lonhtmlcommon::row_headline().
1.34 raeburn 2086: '<h3>'.&Apache::loncommon::help_open_topic('Course_Request_Personnel').' '.$lt{$crstype}.' '.&mt('Include other personnel?').'</h3>';
1.27 raeburn 2087: }
1.2 raeburn 2088: for (my $i=0; $i<$persontotal; $i++) {
2089: my @linkargs = map { 'person_'.$i.'_'.$_ } (@items);
2090: my $linkargstr = join("','",@linkargs);
1.29 raeburn 2091: my $uname_form = '<input type="text" name="person_'.$i.'_uname" value="" size="20" />';
1.2 raeburn 2092: my $onchange = 'javascript:fix_domain('."'$formname','person_".$i."_dom',".
1.29 raeburn 2093: "'person_".$i."_hidedom','person_".$i."_uname'".');';
1.2 raeburn 2094: my $udom_form = &Apache::loncommon::select_dom_form($dom,'person_'.$i.'_dom','',
2095: 1,$onchange).
1.29 raeburn 2096: '<input type="hidden" name="person_'.$i.'_hidedom" value="" />';
1.2 raeburn 2097: my %form_elems;
2098: foreach my $item (@items) {
2099: next if (($item eq 'dom') || ($item eq 'uname') || ($item eq 'hidedom'));
2100: $form_elems{$item} = '<input type="text" name="person_'.$i.'_'.$item.'" '.
2101: 'value="" readonly="readonly" />';
2102: }
2103: my $roleselector = '<select name="person_'.$i.'_role">'."\n".
2104: $roleoptions.'</select>';
2105: my $sectionselector;
2106: if (@currsecs) {
2107: $sectionselector = $existtitle.'<select name="person_'.$i.'_sec"'.
2108: $existmult.'>'."\n".$existops.'</select>'.(' ' x3);
2109: }
2110: $sectionselector .= $newtitle.
1.14 raeburn 2111: '<input type="text" name="person_'.$i.'_newsec" size="15" value="" />'."\n";
1.29 raeburn 2112: my $usersrchlinktxt = &mt('Search for user');
2113: my $usersrchlink = &Apache::loncommon::selectuser_link($formname,@linkargs,$dom,
2114: $usersrchlinktxt);
2115: my $userchklinktxt = &mt('Check username');
2116: my $userchklink = &Apache::loncommon::selectuser_link($formname,@linkargs,$dom,
2117: $userchklinktxt,'checkusername');
1.2 raeburn 2118: $output .=
1.29 raeburn 2119: &Apache::lonhtmlcommon::row_title(&mt('Additional Personnel')).
2120: '<table><tr><td align="center" valign="middle"><b>'.$usersrchlink.'</b></td>'."\n".
2121: '<td align="left" valign="top" colspan="2"><span class="LC_nobreak">'.
2122: &mt('Username').': '.$uname_form.' '.$userchklink.'</span><br />'."\n".
2123: '<span class="LC_nobreak">'.&mt('Domain').': '.$udom_form.'</span></td>'.
2124: '</tr>'."\n".'<tr>'.
1.13 raeburn 2125: '<td align="center" valign="top">'.&mt('First Name').'<br />'.$form_elems{'firstname'}.'</td>'."\n".
2126: '<td align="center" valign="top">'.&mt('Last Name').'<br />'.$form_elems{'lastname'}.'</td>'."\n".
2127: '<td align="center" valign="top">'.&mt('E-mail').'<br />'.$form_elems{'emailaddr'}.'</td></tr>'."\n".
1.34 raeburn 2128: '<tr><td align="center" valign="top">'.&Apache::loncommon::help_open_topic('Course_Roles').' '.&mt('Role').'<br />'.$roleselector.'</td>'."\n".
2129: '<td'.$seccolspan.' align="center" valign="top">'.
2130: &Apache::loncommon::help_open_topic('Course_Request_Rolesection').' '.&mt('LON-CAPA Section(s)').'<br />'.$sectionselector.'</td>'."\n".
1.2 raeburn 2131: '</tr></table>'.&Apache::lonhtmlcommon::row_closure();
2132: }
1.40 raeburn 2133: $output .= &Apache::lonhtmlcommon::row_title(&mt('Add another')).
1.2 raeburn 2134: '<input name="persontotal" type="hidden" value="'.$persontotal.'" />'.
2135: '<input name="addperson" type="checkbox" value="'.$persontotal.'"'.
2136: ' onclick="javascript:nextPage(document.'.$formname.",'".$env{'form.state'}.
2137: "'".');" />'.&mt('Add?').&Apache::lonhtmlcommon::row_closure(1).
1.40 raeburn 2138: &Apache::lonhtmlcommon::end_pick_box().'</div>';
2139: if ($crstype eq 'community') {
2140: $output .= '<p>'.&mt('You may also add users later, once the community has been created, by using the "Manage community users" link, accessible from the "Main Menu".').'</p>';
2141: } else {
2142: $output .= '<p>'.&mt('You may also add users later, once the course has been created, by using the "Manage course users" link, accessible from the "Main Menu".').'</p>';
2143: }
1.2 raeburn 2144: return $output;
2145: }
2146:
1.30 raeburn 2147: sub current_lc_sections {
2148: my @currsecs;
2149: if ($env{'form.sectotal'}) {
2150: for (my $i=0; $i<$env{'form.sectotal'}; $i++) {
1.31 raeburn 2151: if ($env{'form.sec_'.$i}) {
2152: if (defined($env{'form.loncapasec_'.$i})) {
2153: my $lcsec = $env{'form.loncapasec_'.$i};
2154: unless (grep(/^\Q$lcsec\E$/,@currsecs)) {
2155: push(@currsecs,$lcsec);
2156: }
1.30 raeburn 2157: }
2158: }
2159: }
2160: }
2161: return @currsecs;
2162: }
2163:
1.48 raeburn 2164: sub sorted_request_history {
1.49 raeburn 2165: my ($dom,$action,$curr_req) = @_;
2166: my ($after,$before,$statusfilter,$crstypefilter);
2167: if ($env{'form.status'} ne '') {
2168: $statusfilter = $env{'form.status'};
2169: }
2170: if ($env{'form.crstype'} ne '') {
2171: $crstypefilter = $env{'form.crstype'};
2172: }
2173: if (ref($curr_req) eq 'HASH') {
2174: $after = $curr_req->{'requested_after_date'},
2175: $before = $curr_req->{'requested_before_date'};
2176: $statusfilter = $curr_req->{'status'};
2177: $crstypefilter = $curr_req->{'crstype'};
2178: }
1.14 raeburn 2179: my %statusinfo = &Apache::lonnet::dump('courserequests',$env{'user.domain'},
2180: $env{'user.name'},'^status:'.$dom);
1.48 raeburn 2181: my %queue_by_date;
1.37 raeburn 2182: my ($types,$typenames) = &Apache::loncommon::course_types();
1.14 raeburn 2183: foreach my $key (keys(%statusinfo)) {
1.48 raeburn 2184: if ($action eq 'view') {
2185: next unless (($statusinfo{$key} eq 'approval') || ($statusinfo{$key} eq 'pending'));
2186: } else {
1.49 raeburn 2187: next unless (($statusfilter eq 'any') ||
2188: ($statusfilter eq $statusinfo{$key}));
1.48 raeburn 2189: }
2190: (undef,my($cdom,$cnum)) = split(':',$key);
2191: next if ($cdom ne $dom);
2192: my $requestkey = $cdom.'_'.$cnum;
2193: if ($requestkey =~ /^($match_domain)_($match_courseid)$/) {
2194: my %history = &Apache::lonnet::restore($requestkey,'courserequests',
2195: $env{'user.domain'},$env{'user.name'});
2196: my $entry;
2197: my $reqtime = $history{'reqtime'};
2198: my $lastupdate = $history{'timestamp'};
2199: my $crstype = $history{'crstype'};
2200: my $disposition = $history{'disposition'};
2201: my $status = $history{'status'};
1.73 raeburn 2202: my $uniquecode = $history{'code'};
1.48 raeburn 2203: if ($action eq 'view') {
1.14 raeburn 2204: next if ((exists($history{'status'})) && ($history{'status'} eq 'created'));
1.48 raeburn 2205: } else {
2206: next if (($reqtime < $after) || ($reqtime > $before));
2207: }
1.49 raeburn 2208: next unless (($crstypefilter eq 'any') ||
2209: ($crstypefilter eq $crstype));
1.48 raeburn 2210: if ($action eq 'view') {
1.14 raeburn 2211: next unless (($disposition eq 'approval') ||
2212: ($disposition eq 'pending'));
1.48 raeburn 2213: }
2214: if (ref($history{'details'}) eq 'HASH') {
2215: $entry = $requestkey.':'.$crstype.':'.
2216: &escape($history{'details'}{'cdescr'});
2217: if ($action eq 'log') {
1.73 raeburn 2218: $entry .= ':'.$uniquecode.':'.$lastupdate.':';
1.48 raeburn 2219: if ($statusinfo{$key} ne '') {
2220: $entry .= $statusinfo{$key};
2221: } elsif ($status ne '') {
2222: $entry .= $status;
2223: } else {
2224: $entry .= $disposition;
1.14 raeburn 2225: }
2226: }
1.48 raeburn 2227: if ($crstype eq 'official') {
2228: $entry .= ':'.&escape($history{'details'}{'instcode'});
2229: }
2230: }
2231: if ($entry ne '') {
2232: if (exists($queue_by_date{$reqtime})) {
2233: if (ref($queue_by_date{$reqtime}) eq 'ARRAY') {
2234: push(@{$queue_by_date{$reqtime}},$entry);
1.10 raeburn 2235: }
1.48 raeburn 2236: } else {
2237: @{$queue_by_date{$reqtime}} = ($entry);
1.10 raeburn 2238: }
2239: }
2240: }
2241: }
1.48 raeburn 2242: return %queue_by_date;
2243: }
2244:
2245: sub print_request_status {
2246: my ($dom,$action) = @_;
2247: my %queue_by_date = &sorted_request_history($dom,$action);
1.10 raeburn 2248: my @sortedtimes = sort {$a <=> $b} (keys(%queue_by_date));
1.48 raeburn 2249: my $formname = 'requestcrs';
2250: my ($types,$typenames) = &Apache::loncommon::course_types();
2251: my $output = '<input type="hidden" name="action" value="'.$env{'form.action'}.'" />'."\n".
1.16 raeburn 2252:
1.10 raeburn 2253: '<input type="hidden" name="state" value="'.$env{'form.state'}.'" />'."\n".
1.16 raeburn 2254: '<input type="hidden" name="crstype" value="'.$env{'form.crstype'}.'" />'."\n".
2255: '<input type="hidden" name="showdom" value="" />'."\n".
2256: '<input type="hidden" name="cnum" value="" />'."\n";
1.10 raeburn 2257: if (@sortedtimes > 0) {
1.40 raeburn 2258: my $desctitle;
2259: if ($env{'form.crstype'} eq 'any') {
2260: $desctitle = &mt('Course/Community Description')
2261: } elsif ($env{'form.crstype'} eq 'community') {
2262: $desctitle = &mt('Community Description')
2263: } else {
2264: $desctitle = &mt('Course Description');
2265: }
1.10 raeburn 2266: $output .= &Apache::loncommon::start_data_table().
2267: &Apache::loncommon::start_data_table_header_row().
2268: '<th>'.&mt('Action').'</th>'.
1.40 raeburn 2269: '<th>'.$desctitle.'</th>'.
1.14 raeburn 2270: '<th>'.&mt('Domain').'</th>';
2271: if ($env{'form.crstype'} eq 'any') {
1.10 raeburn 2272: $output .= '<th>'.&mt('Type').'</th>';
2273: }
1.14 raeburn 2274: if (($env{'form.crstype'} eq 'any') || ($env{'form.crstype'} eq 'official')) {
1.10 raeburn 2275: $output .= '<th>'.&mt('Institutional Code').'</th>';
2276: }
2277: $output .= '<th>'.&mt('Date requested').'</th>'.
2278: &Apache::loncommon::end_data_table_header_row();
2279: my $count = 0;
2280: foreach my $item (@sortedtimes) {
2281: my $showtime = &Apache::lonlocal::locallocaltime($item);
2282: if (ref($queue_by_date{$item}) eq 'ARRAY') {
2283: foreach my $request (sort(@{$queue_by_date{$item}})) {
2284: my ($key,$type,$desc,$instcode) = split(':',$request);
2285: my ($cdom,$cnum) = split('_',$key);
2286: $output .= &Apache::loncommon::start_data_table_row().
1.16 raeburn 2287: '<td><input type="button" value="'.&mt('Select').'" onclick="javascript:chooseRequest('."'$cdom','$cnum'".')" /></td>'.
1.14 raeburn 2288: '<td>'.&unescape($desc).'</td>'.
2289: '<td>'.$cdom.'</td>';
2290: if ($env{'form.crstype'} eq 'any') {
1.35 raeburn 2291: my $typename;
2292: if (ref($typenames) eq 'HASH') {
2293: $typename = &mt($typenames->{$type});
2294: }
1.14 raeburn 2295: if ($typename eq '') {
2296: $typename = &mt('Unknown type');
2297: }
2298: $output .= '<td>'.$typename.'</td>';
1.10 raeburn 2299: }
1.14 raeburn 2300: if (($env{'form.crstype'} eq 'any') ||
1.10 raeburn 2301: ($env{'form.crstype'} eq 'official')) {
1.14 raeburn 2302: my $showinstcode;
2303: if ($type eq 'official') {
2304: $showinstcode = &unescape($instcode);
2305: } else {
2306: $showinstcode = &mt('Not applicable');
2307: }
2308: $output .= '<td>'.$showinstcode.'</td>';
1.10 raeburn 2309: }
2310: $output .= '<td>'.$showtime.'</td>'.
2311: &Apache::loncommon::end_data_table_row();
2312: }
2313: }
2314: }
2315: $output .= &Apache::loncommon::end_data_table();
2316: } else {
1.40 raeburn 2317: if ($env{'form.crstype'} eq 'any') {
2318: $output .= '<div>'.&mt('You have no matching course or community requests awaiting approval by a Domain Coordinator or held in a queue pending administrative action at your institution.').'</div>';
2319: } elsif ($env{'form.crstype'} eq 'community') {
2320: $output .= '<div>'.&mt('You have no matching community requests awaiting approval by a Domain Coordinator or held in a queue pending administrative action at your institution.').'</div>';
2321: } else {
2322: $output .= '<div>'.&mt('You have no matching course requests awaiting approval by a Domain Coordinator or held in a queue pending administrative action at your institution.').'</div>';
2323: }
1.10 raeburn 2324: }
2325: $output .= '
1.30 raeburn 2326: <br /><input type="button" name="prev" value="'.&mt('Back').'" onclick="javascript:backPage(document.'.$formname.",'crstype'".')" />';
1.10 raeburn 2327: return $output;
1.1 raeburn 2328: }
2329:
1.16 raeburn 2330: sub print_cancel_request {
2331: my ($dom,$cnum) = @_;
2332: my $requestkey = $dom.'_'.$cnum;
2333: my ($result,$output);
2334: if ($requestkey =~ /^($match_domain)_($match_courseid)$/) {
2335: my %history = &Apache::lonnet::restore($requestkey,'courserequests',
2336: $env{'user.domain'},$env{'user.name'});
2337: my $timestamp = $history{'reqtime'};
2338: my $crstype = $history{'crstype'};
2339: my $status = $history{'status'};
2340: if (($status eq 'cancelled') || ($status eq 'created')) {
2341: if ($status eq 'cancelled') {
2342: $output = &mt('This request has already been cancelled.');
2343: } elsif ($status eq 'created') {
2344: $output = &mt('This request has already been processed, and a course created.');
2345: }
2346: $output = &mt('No further action will be taken');
2347: } elsif (ref($history{'details'}) eq 'HASH') {
1.37 raeburn 2348: my ($types,$typename) = &Apache::loncommon::course_types();
1.16 raeburn 2349: my $showtype = $crstype;
2350: if (defined($typename->{$crstype})) {
2351: $showtype = $typename->{$crstype};
2352: }
2353: $output = '<p>'.&Apache::loncommon::start_data_table().
2354: &Apache::loncommon::start_data_table_header_row().
2355: '<th>'.&mt('Description').'</th><th>'.&mt('Requested').'</th>'.
2356: '<th>'.&mt('Type').'</th>'.
2357: &Apache::loncommon::end_data_table_header_row().
2358: &Apache::loncommon::start_data_table_row().
2359: '<td>'.$history{details}{'cdescr'}.'</td><td>'.
2360: &Apache::lonlocal::locallocaltime($timestamp).'</td>'.
2361: '<td>'.$showtype.'</td>'.
2362: &Apache::loncommon::end_data_table_row().
2363: &Apache::loncommon::end_data_table().
1.40 raeburn 2364: '<br /><div class="LC_warning">';
2365: if ($crstype eq 'community') {
2366: $output .= &mt('Cancelling the request will remove it from the queue of pending community requests').'</div>';
2367: } else {
2368: $output .= &mt('Cancelling the request will remove it from the queue of pending course requests').'</div>';
2369: }
1.16 raeburn 2370: $result = 'ok';
2371: } else {
2372: $output = '<div class="LC_error">'.&mt('No record exists for the course ID').'</div>';
2373: }
2374: } else {
2375: $output = '<div class="LC_error">'.&mt('Invalid course ID').'</div>';
2376: }
2377: return ($result,$output);
2378: }
2379:
2380: sub viewrequest_javascript {
2381: my ($formname,$next) = @_;
2382: return <<"ENDJS";
2383:
2384: function chooseRequest(cdom,cnum) {
2385: document.$formname.showdom.value = cdom;
2386: document.$formname.cnum.value = cnum;
2387: nextPage(document.$formname,'$next');
2388: }
2389:
2390: ENDJS
2391: }
2392:
2393: sub viewdetails_javascript {
2394: my ($formname) = @_;
2395: return << "ENDJS";
2396:
2397: function nextPage(formname,nextstate) {
2398: if (nextstate == "modify") {
2399: formname.state.value = "personnel";
2400: formname.action.value = "new";
2401: } else {
2402: formname.state.value = nextstate;
2403: }
2404: formname.submit();
2405: }
2406:
2407: function backPage(formname,prevstate) {
2408: formname.state.value = prevstate;
2409: formname.submit();
2410: }
2411:
2412: ENDJS
2413: }
2414:
2415: sub viewcancel_javascript {
1.68 bisitz 2416: my $alert = &mt('Are you sure you want to cancel this request?').'\\n'.
2417: &mt('Your request will be removed.');
1.16 raeburn 2418: return << "ENDJS";
2419: function nextPage(formname,nextstate) {
2420: if (confirm('$alert')) {
2421: formname.state.value = nextstate;
2422: formname.submit();
2423: }
2424: return;
2425: }
2426:
2427: ENDJS
2428: }
2429:
1.1 raeburn 2430: sub print_request_logs {
1.73 raeburn 2431: my ($r,$dom,$jscript,$loaditems,$crumb,$usetabs) = @_;
1.48 raeburn 2432: my $title;
2433: if ($env{'form.crstype'} eq 'community') {
2434: $title = 'Community Request Logs';
2435: } elsif ($env{'form.crstype'} eq 'any') {
2436: $title = 'Course/Community Request Logs';
2437: } else {
2438: $title = 'Course Request Logs';
2439: }
2440: $r->print(&header($title,$jscript,$loaditems).$crumb);
1.73 raeburn 2441: if ($usetabs) {
2442: &startContentScreen($r,'textbooklogs');
2443: }
1.48 raeburn 2444: my $formname = 'requestcrs';
2445: $r->print('<form action="/adm/requestcourse" method="post" name="'.$formname.'" onsubmit="javascript:setPage(this);">'."\n".
2446: '<input type="hidden" name="action" value="log" />'."\n".
2447: '<input type="hidden" name="state" value="display" />'."\n");
2448: # set defaults
2449: my $now = time();
2450: my $defstart = $now - (7*24*3600); #7 days ago
2451: my %defaults = (
2452: page => '1',
2453: show => '10',
2454: crstype => 'any',
2455: status => 'any',
2456: requested_before_date => $now,
2457: requested_after_date => $defstart,
2458: );
2459: my ($types,$typenames) = &Apache::loncommon::course_types();
2460: my $more_records = 0;
2461: my %curr;
2462: foreach my $item ('show','page','crstype','status') {
2463: $curr{$item} = $env{'form.'.$item};
2464: }
2465: $curr{'requested_after_date'} = &Apache::lonhtmlcommon::get_date_from_form('requested_after_date');
2466: $curr{'requested_before_date'} = &Apache::lonhtmlcommon::get_date_from_form('requested_before_date');
2467: foreach my $key (keys(%defaults)) {
2468: if ($curr{$key} eq '') {
2469: $curr{$key} = $defaults{$key};
2470: }
2471: }
2472: my ($statuses,$statusnames) = &reqstatus_names($curr{'crstype'});
2473: $r->print('<input type="hidden" name="page" value="'.$curr{'page'}.'" />'.
2474: &requestlog_display_filter($formname,\%curr));
1.49 raeburn 2475: my %queue_by_date = &sorted_request_history($dom,$env{'form.action'},\%curr);
1.48 raeburn 2476: my @sortedtimes = sort {$a <=> $b} (keys(%queue_by_date));
2477: my $showntablehdr = 0;
2478: my $tablehdr = &Apache::loncommon::start_data_table().
2479: &Apache::loncommon::start_data_table_header_row().
2480: '<th> </th><th>'.&mt('Request Date').'</th>'.
2481: '<th>'.&mt('Description').'</th>';
2482: if ($curr{'crstype'} eq 'any') {
2483: $tablehdr .= '<th>'.&mt('Course Type').'</th>';
2484: }
2485: if (($curr{'crstype'} eq 'official') || ($curr{'crstype'} eq 'any')) {
2486: $tablehdr .= '<th>'.&mt('Institutional Code').'</th>';
2487: }
1.73 raeburn 2488: my $showuniquecode;
2489: my %domconfig = &Apache::lonnet::get_dom('configuration',['requestcourses'],$dom);
2490: if (($curr{'status'} eq 'any') || ($curr{'status'} eq 'created')) {
2491: if (ref($domconfig{'requestcourses'}) eq 'HASH') {
2492: if (ref($domconfig{'requestcourses'}{'uniquecode'}) eq 'HASH') {
2493: if ($curr{'crstype'} eq 'any') {
2494: my @types = qw(official unofficial community textbook);
2495: foreach my $type (@types) {
2496: if ($domconfig{'requestcourses'}{'uniquecode'}{$type}) {
2497: $showuniquecode = 1;
2498: last;
2499: }
2500: }
2501: } elsif ($domconfig{'requestcourses'}{'uniquecode'}{$curr{'crstype'}}) {
2502: $showuniquecode = 1;
2503: }
2504: }
2505: }
2506: }
2507: if ($showuniquecode) {
2508: $tablehdr .= '<th>'.&mt('Unique Code').'</th>';
2509: }
1.48 raeburn 2510: if ($curr{'status'} eq 'any') {
2511: $tablehdr .= '<th>'.&mt('Status').'</th>';
2512: } elsif ($curr{'status'} eq 'created') {
2513: $tablehdr .= '<th>'.&mt('Creation Date').'</th>';
2514: } elsif ($curr{'status'} eq 'cancelled') {
2515: $tablehdr .= '<th>'.&mt('Cancellation Date').'</th>';
2516: } elsif ($curr{'status'} eq 'rejected') {
2517: $tablehdr .= '<th>'.&mt('Rejection Date').'</th>';
2518: }
2519: $tablehdr .= &Apache::loncommon::end_data_table_header_row();
2520: my ($minshown,$maxshown);
2521: $minshown = 1;
2522: my $count = 0;
2523: if ($curr{'show'} ne &mt('all')) {
2524: $maxshown = $curr{'page'} * $curr{'show'};
2525: if ($curr{'page'} > 1) {
2526: $minshown = 1 + ($curr{'page'} - 1) * $curr{'show'};
2527: }
2528: }
2529: my $norecords;
2530: if (@sortedtimes > 0) {
2531: foreach my $item (@sortedtimes) {
2532: if ($curr{'show'} ne &mt('all')) {
2533: if ($count >= $curr{'page'} * $curr{'show'}) {
2534: $more_records = 1;
2535: last;
2536: }
2537: }
2538: $count ++;
2539: next if ($count < $minshown);
2540: if (!$showntablehdr) {
2541: $r->print($tablehdr);
2542: $showntablehdr = 1;
2543: }
2544: my $showtime = &Apache::lonlocal::locallocaltime($item);
2545: if (ref($queue_by_date{$item}) eq 'ARRAY') {
2546: foreach my $request (sort(@{$queue_by_date{$item}})) {
1.73 raeburn 2547: my ($key,$crstype,$desc,$uniquecode,$timestamp,$status,$instcode) = split(':',$request);
1.48 raeburn 2548: my ($cdom,$cnum) = split('_',$key);
2549: my $output = &Apache::loncommon::start_data_table_row().
2550: '<td>'.$count.'</td>'.
2551: '<td>'.$showtime.'</td>'.
2552: '<td>'.&unescape($desc).'</td>';
2553: if ($curr{'crstype'} eq 'any') {
2554: my $typename;
2555: if (ref($typenames) eq 'HASH') {
2556: $typename = &mt($typenames->{$crstype});
2557: }
2558: if ($typename eq '') {
2559: $typename = &mt('Unknown type');
2560: }
2561: $output .= '<td>'.$typename.'</td>';
2562: }
2563: if (($curr{'crstype'} eq 'any') ||
2564: ($curr{'crstype'} eq 'official')) {
2565: my $showinstcode;
2566: if ($crstype eq 'official') {
2567: $showinstcode = &unescape($instcode);
2568: } else {
2569: $showinstcode = &mt('Not applicable');
2570: }
2571: $output .= '<td>'.$showinstcode.'</td>';
2572: }
1.73 raeburn 2573: if ($showuniquecode) {
2574: if ($status eq 'created') {
2575: $output .= '<td>'.$uniquecode.'</td>';
2576: } else {
2577: $output .= '<td>'.&mt('Not applicable').'</td>';
2578: }
2579: }
1.48 raeburn 2580: if ($curr{'status'} eq 'any') {
2581: my $statusname = &mt('Unknown status');
2582: if (ref($statusnames) eq 'HASH') {
2583: if ($statusnames->{$status} ne '') {
2584: $statusname = $statusnames->{$status};
2585: }
2586: }
2587: if (($status eq 'created') || ($status eq 'cancelled') ||
2588: ($status eq 'rejected')) {
2589: $statusname .= ' '.&Apache::lonlocal::locallocaltime($timestamp);
2590: }
2591: $output .= '<td>'.$statusname.'</td>';
2592: } elsif (($status eq 'created') || ($status eq 'cancelled') ||
2593: ($status eq 'rejected')) {
2594: $output .= '<td>'.&Apache::lonlocal::locallocaltime($timestamp).'</td>';
2595: }
2596: $output .= &Apache::loncommon::end_data_table_row();
2597: $r->print($output);
2598: }
2599: }
2600: }
2601: if ($showntablehdr) {
2602: $r->print(&Apache::loncommon::end_data_table());
2603: if (($curr{'page'} > 1) || ($more_records)) {
2604: $r->print('<table><tr>');
2605: if ($curr{'page'} > 1) {
2606: $r->print('<td><a href="javascript:chgPage('."'previous'".');">'.&mt('Previous [_1] changes',$curr{'show'}).'</a></td>');
2607: }
2608: if ($more_records) {
2609: $r->print('<td><a href="javascript:chgPage('."'next'".');">'.&mt('Next [_1] changes',$curr{'show'}).'</a></td>');
2610: }
2611: $r->print('</tr></table>');
2612: $r->print(<<"ENDSCRIPT");
2613: <script type="text/javascript">
2614: // <![CDATA[
2615: function chgPage(caller) {
2616: if (caller == 'previous') {
2617: document.$formname.page.value --;
2618: }
2619: if (caller == 'next') {
2620: document.$formname.page.value ++;
2621: }
2622: document.$formname.submit();
1.1 raeburn 2623: return;
2624: }
1.48 raeburn 2625: // ]]>
2626: </script>
2627: ENDSCRIPT
2628: }
2629: } else {
2630: $norecords = 1;
2631: }
2632: } else {
2633: $norecords = 1;
2634: }
2635: if ($norecords) {
2636: $r->print('<p class="LC_info">'.
2637: &mt('There are no records to display').
2638: '</p>');
2639: }
1.73 raeburn 2640: if ($usetabs) {
2641: $r->print('<input type="hidden" name="tabs" value="on" />');
2642: }
2643: $r->print('</form>');
2644: if ($usetabs) {
2645: &endContentScreen($r);
2646: }
2647: $r->print(&Apache::loncommon::end_page());
1.48 raeburn 2648: return;
2649: }
2650:
2651: sub reqstatus_names {
2652: my ($crstype) = @_;
2653: my @statuses = qw(created approval pending rejected cancelled);
2654: my %statusnames =
2655: &Apache::lonlocal::texthash (
1.50 raeburn 2656: created => 'Created',
1.48 raeburn 2657: approval => 'Queued pending approval',
2658: pending => 'Queued pending validation',
2659: rejected => 'Request rejected',
2660: cancelled => 'Request cancelled',
2661: );
1.69 raeburn 2662: if (($crstype eq 'official') || ($crstype eq 'unofficial') || ($crstype eq 'textbook')) {
1.48 raeburn 2663: $statusnames{'created'} = &mt('Course created');
2664: } elsif ($crstype eq 'community') {
2665: $statusnames{'created'} = &mt('Community created');
2666: }
2667: return (\@statuses,\%statusnames);
2668: }
2669:
2670: sub requestlog_display_filter {
2671: my ($formname,$curr) = @_;
2672: my $nolink = 1;
2673: my $output = '<table><tr><td valign="top">'.
2674: '<span class="LC_nobreak"><b>'.&mt('Records/page:').'</b></span><br />'.
2675: &Apache::lonmeta::selectbox('show',$curr->{'show'},undef,
2676: (&mt('all'),5,10,20,50,100,1000,10000)).
2677: '</td><td> </td>';
2678: my $startform =
2679: &Apache::lonhtmlcommon::date_setter($formname,'requested_after_date',
2680: $curr->{'requested_after_date'},undef,
2681: undef,undef,undef,undef,undef,undef,$nolink);
2682: my $endform =
2683: &Apache::lonhtmlcommon::date_setter($formname,'requested_before_date',
2684: $curr->{'requested_before_date'},undef,
2685: undef,undef,undef,undef,undef,undef,$nolink);
2686: $output .= '<td valign="top"><b>'.&mt('Window during which course/community was requested:').'</b><br />'.
2687: '<table><tr><td>'.&mt('After:').
2688: '</td><td>'.$startform.'</td></tr>'.
2689: '<tr><td>'.&mt('Before:').'</td>'.
2690: '<td>'.$endform.'</td></tr></table>'.
2691: '</td>'.
2692: '<td> </td>';
2693: my ($types,$typenames) = &Apache::loncommon::course_types();
2694: if (ref($types) eq 'ARRAY') {
2695: if (@{$types} > 1) {
2696: $output .= '<td valign="top"><b>'.
2697: &mt('Course Type:').'</b><br /><select name="crstype">';
2698: my $selstr = '';
2699: if ($curr->{'crstype'} eq 'any') {
2700: $selstr = ' selected="selected"';
2701: }
2702: $output .= '<option value="any"'.$selstr.'>'.&mt('All types').'</option>'."\n";
2703: foreach my $crstype (@{$types}) {
2704: my $selstr = '';
2705: if ($curr->{'crstype'} eq $crstype) {
2706: $selstr = ' selected="selected"';
2707: }
2708: my $typename = $crstype;
2709: if (ref($typenames) eq 'HASH') {
2710: if ($typenames->{$crstype} ne '') {
2711: $typename = $typenames->{$crstype};
2712: }
2713: }
2714: $output .= '<option value="'.$crstype.'"'.$selstr.'>'.$typename.'</option>'."\n";
2715: }
2716: $output .= '</select></td>';
2717: }
2718: }
2719: my ($statuses,$statusnames) = &reqstatus_names($curr->{'crstype'});
2720: if (ref($statuses) eq 'ARRAY') {
2721: if (@{$statuses} > 1) {
2722: $output .= '<td valign="top"><b>'.
2723: &mt('Request Status:').'</b><br /><select name="status">';
2724: my $selstr = '';
2725: if ($curr->{'status'} eq 'any') {
2726: $selstr = ' selected="selected"';
2727: }
2728: $output .= '<option value="any"'.$selstr.'>'.&mt('Any status').'</option>'."\n";
2729: foreach my $status (@{$statuses}) {
2730: my $selstr = '';
2731: if ($curr->{'status'} eq $status) {
2732: $selstr = ' selected="selected"';
2733: }
2734: my $statusname = $status;
2735: if (ref($statusnames) eq 'HASH') {
2736: if ($statusnames->{$status} ne '') {
2737: $statusname = $statusnames->{$status};
2738: }
2739: }
2740: $output .= '<option value="'.$status.'"'.$selstr.'>'.$statusname.'</option>'."\n";
2741: }
2742: $output .= '</select></td>';
2743: }
2744: }
2745: $output .= '</tr></table>';
2746:
2747: # Update Display button
2748: $output .= '<p>'.
2749: '<input type="submit" value="'.&mt('Update Display').'" />'.
2750: '</p><hr />';
2751: return $output;
2752: }
1.1 raeburn 2753:
2754: sub print_review {
1.30 raeburn 2755: my ($dom,$codetitles,$cat_titles,$cat_order,$code_order,$uname,$udom,
1.66 raeburn 2756: $disallowed,$disallowmsg,$instcredits) = @_;
1.37 raeburn 2757: my ($types,$typename) = &Apache::loncommon::course_types();
1.4 raeburn 2758: my ($owner,$ownername,$owneremail);
1.26 raeburn 2759: if ($uname eq '' || $udom eq '') {
2760: $uname = $env{'user.name'};
2761: $udom = $env{'user.domain'};
2762: }
2763: $owner = $uname.':'.$udom;
2764: $ownername = &Apache::loncommon::plainname($uname,$udom,'first');
2765: my %emails = &Apache::loncommon::getemails($uname,$udom);
1.4 raeburn 2766: foreach my $email ('permanentemail','critnotification','notification') {
2767: $owneremail = $emails{$email};
2768: last if ($owneremail ne '');
2769: }
2770: my ($inst_headers,$inst_values,$crstypename,$enroll_headers,$enroll_values,
2771: $section_headers,$section_values,$personnel_headers,$personnel_values);
2772:
2773: $crstypename = $env{'form.crstype'};
2774: if (ref($typename) eq 'HASH') {
2775: unless ($typename->{$env{'form.crstype'}} eq '') {
1.35 raeburn 2776: $crstypename = &mt($typename->{$env{'form.crstype'}});
1.4 raeburn 2777: }
2778: }
1.16 raeburn 2779: my $category = 'Course';
2780: if ($env{'form.crstype'} eq 'community') {
2781: $category = 'Community';
2782: }
1.4 raeburn 2783:
2784: $inst_headers = '<th>'.&mt('Description').'</th><th>'.&mt('Type').'</th>';
2785: $inst_values = '<td>'.$env{'form.cdescr'}.'</td><td>'.$crstypename.'</td>';
2786:
1.16 raeburn 2787: my $enrollrow_title = &mt('Default Access Dates').'<br />'.
2788: '('.&Apache::lonnet::plaintext('st',$category).')';
1.4 raeburn 2789: if ($env{'form.crstype'} eq 'official') {
2790: if ((ref($codetitles) eq 'ARRAY') && (ref($cat_titles) eq 'HASH')) {
2791: foreach my $title (@{$codetitles}) {
2792: if ($env{'form.instcode_'.$title} ne '') {
2793: $inst_headers .= '<th>'.$title.'</th>';
2794: my $longitem = $env{'form.instcode_'.$title};
2795: if (ref($cat_titles->{$title}) eq 'HASH') {
2796: if ($cat_titles->{$title}{$env{'form.instcode_'.$title}} ne '') {
2797: $longitem = $cat_titles->{$title}{$env{'form.instcode_'.$title}};
2798: }
2799: }
2800: $inst_values .= '<td>'.$longitem.'</td>';
2801: }
2802: }
2803: }
1.66 raeburn 2804: $inst_headers .= '<th>'.&mt('Credits').'</th>';
2805: if ($instcredits) {
2806: $inst_values .= '<td>'.$instcredits.'</td>';
2807: } else {
2808: $inst_values .= '<td>'.$env{'form.coursecredits'}.'</td>';
2809: }
1.4 raeburn 2810: if (&Apache::lonnet::auto_run('',$dom)) {
1.16 raeburn 2811: $enrollrow_title = &mt('Enrollment');
1.4 raeburn 2812: $enroll_headers = '<th>'.&mt('Automatic Adds').'</th>'.
2813: '<th>'.&mt('Automatic Drops').'</th>'.
2814: '<th>'.&mt('Enrollment Starts').'</th>'.
2815: '<th>'.&mt('Enrollment Ends').'</th>';
2816: $section_headers = '<th>'.&mt('Sections').'</th>'.
2817: '<th>'.&mt('Crosslistings').'</th>';
2818:
1.13 raeburn 2819: my ($enrollstart,$enrollend) = &dates_from_form('enrollstart','enrollend');
1.4 raeburn 2820: my @autoroster = (&mt('No'),&mt('Yes'));
2821: $enroll_values = '<td>'.$autoroster[$env{'form.autoadds'}].'</td>'.
2822: '<td>'.$autoroster[$env{'form.autodrops'}].'</td>'.
1.13 raeburn 2823: '<td>'.&Apache::lonlocal::locallocaltime($enrollstart).'</td>'.
2824: '<td>'.&Apache::lonlocal::locallocaltime($enrollend).'</td>';
1.6 raeburn 2825: $section_values = '<td><table class="LC_innerpickbox"><tr><th>'.
2826: &mt('Institutional section').'</th>'.
2827: '<th>'.&mt('LON-CAPA section').'</th></tr>';
1.5 raeburn 2828: my $secinfo;
1.4 raeburn 2829: if ($env{'form.sectotal'} > 0) {
2830: for (my $i=0; $i<$env{'form.sectotal'}; $i++) {
2831: if ($env{'form.sec_'.$i}) {
1.5 raeburn 2832: $secinfo .= '<tr><td>'.$env{'form.secnum_'.$i}.'</td><td>';
1.4 raeburn 2833: if ($env{'form.loncapasec_'.$i} ne '') {
1.5 raeburn 2834: $secinfo .= $env{'form.loncapasec_'.$i};
2835: } else {
2836: $secinfo .= &mt('None');
1.4 raeburn 2837: }
1.5 raeburn 2838: $secinfo .= '</td></tr>';
1.4 raeburn 2839: }
2840: }
2841: }
1.6 raeburn 2842: if ($secinfo eq '') {
2843: $secinfo = '<tr><td colspan="2">'.&mt('None').'</td></tr>';
1.5 raeburn 2844: }
1.6 raeburn 2845: $section_values .= $secinfo.'</table></td><td>'.
2846: '<table class="LC_innerpickbox"><tr><th>'.
2847: &mt('Institutional course/section').'</th>'.
2848: '<th>'.&mt('LON-CAPA section').'</th></tr>';
1.5 raeburn 2849: my $xlistinfo;
1.24 raeburn 2850: my $crosslisttotal = $env{'form.crosslisttotal'};
2851: if (!$crosslisttotal) {
2852: $crosslisttotal = 1;
2853: }
2854: for (my $i=0; $i<$crosslisttotal; $i++) {
2855: if ($env{'form.crosslist_'.$i}) {
2856: $xlistinfo .= '<tr><td>';
2857: if (ref($code_order) eq 'ARRAY') {
2858: if (@{$code_order} > 0) {
2859: foreach my $item (@{$code_order}) {
2860: $xlistinfo .= $env{'form.crosslist_'.$i.'_'.$item};
1.4 raeburn 2861: }
2862: }
2863: }
1.24 raeburn 2864: $xlistinfo .= $env{'form.crosslist_'.$i.'_instsec'}.'</td><td>';
2865: if ($env{'form.crosslist_'.$i.'_lcsec'}) {
2866: $xlistinfo .= $env{'form.crosslist_'.$i.'_lcsec'};
2867: } else {
2868: $xlistinfo .= &mt('None');
2869: }
2870: $xlistinfo .= '</td></tr>';
1.4 raeburn 2871: }
2872: }
1.6 raeburn 2873: if ($xlistinfo eq '') {
2874: $xlistinfo = '<tr><td colspan="2">'.&mt('None').'</td></tr>';
1.5 raeburn 2875: }
1.24 raeburn 2876: $section_values .= $xlistinfo;
1.4 raeburn 2877: }
1.24 raeburn 2878: $section_values .= '</table></td>';
1.69 raeburn 2879: } elsif (($env{'form.crstype'} eq 'unofficial') || ($env{'form.crstype'} eq 'textbook')) {
1.66 raeburn 2880: $inst_headers .= '<th>'.&mt('Credits').'</th>';
2881: $inst_values .= '<td>'.$env{'form.coursecredits'}.'</td>';
1.4 raeburn 2882: }
2883:
2884: my %ctxt = &clone_text();
2885: $inst_headers .= '<th>'.&mt('Clone From').'</th>';
1.45 raeburn 2886: if (($env{'form.cloning'}) &&
2887: ($env{'form.clonecrs'} =~ /^$match_name$/) &&
1.13 raeburn 2888: ($env{'form.clonedom'} =~ /^$match_domain$/)) {
1.56 raeburn 2889: my $canclone = &Apache::loncoursequeueadmin::can_clone_course($uname,
2890: $udom,$env{'form.clonecrs'},$env{'form.clonedom'},
1.39 raeburn 2891: $env{'form.crstype'});
1.15 raeburn 2892: if ($canclone) {
2893: my %courseenv = &Apache::lonnet::userenvironment($env{'form.clonedom'},
2894: $env{'form.clonecrs'},('description','internal.coursecode'));
2895: if (keys(%courseenv) > 0) {
2896: $inst_headers .= '<th>'.$ctxt{'dsh'}.'</th>';
2897: $inst_values .= '<td>'.$courseenv{'description'}.' ';
2898: my $cloneinst = $courseenv{'internal.coursecode'};
2899: if ($cloneinst ne '') {
1.18 raeburn 2900: $inst_values .= $cloneinst.' '.&mt('in').' '.$env{'form.clonedom'};
1.15 raeburn 2901: } else {
1.18 raeburn 2902: $inst_values .= &mt('from').' '.$env{'form.clonedom'};
1.15 raeburn 2903: }
2904: $inst_values .= '</td><td>';
2905: if ($env{'form.datemode'} eq 'preserve') {
1.16 raeburn 2906: $inst_values .= $ctxt{'prd'};
1.15 raeburn 2907: } elsif ($env{'form.datemode'} eq 'shift') {
2908: $inst_values .= &mt('Shift dates by [_1] days',$env{'form.dateshift'});
2909: } else {
2910: $inst_values .= $ctxt{'ncd'};
2911: }
2912: $inst_values .= '</td>';
2913: } else {
2914: $inst_values .= '<td>'.&mt('Unknown').'</td>';
2915: }
2916: } else {
2917: $inst_values .= '<td>'.&mt('Not permitted'),'</td>';
2918: }
1.4 raeburn 2919: } else {
2920: $inst_values .= '<td>'.&mt('None').'</td>';
2921: }
2922: $enroll_headers .= '<th>'.&mt('Access Starts').'</th>'.
2923: '<th>'.&mt('Access Ends').'</th>';
1.13 raeburn 2924: my ($accessstart,$accessend) = &dates_from_form('accessstart','accessend');
2925: $enroll_values .= '<td>'.&Apache::lonlocal::locallocaltime($accessstart).'</td>';
2926: if ($accessend == 0) {
1.4 raeburn 2927: $enroll_values .= '<td>'.&mt('No end date').'</td>';
2928: } else {
1.13 raeburn 2929: $enroll_values .= '<td>'.&Apache::lonlocal::locallocaltime($accessend).'</td>';
1.4 raeburn 2930: }
2931:
2932: my $container = 'Course';
1.41 raeburn 2933: my $ccrole = 'cc';
1.4 raeburn 2934: if ($env{'form.crstype'} eq 'community') {
2935: $container = 'Community';
1.41 raeburn 2936: $ccrole = 'co';
1.4 raeburn 2937: }
2938:
2939: $personnel_headers = '<th>'.&mt('Name').'</th><th>'.&mt('Username:Domain').
2940: '</th><th>'.&mt('Role').'</th><th>'.&mt('LON-CAPA Sections').
2941: '</th>';
1.41 raeburn 2942:
1.4 raeburn 2943: $personnel_values .= '<tr><td>'.$ownername.'</td><td>'.$owner.'</td>'.
1.41 raeburn 2944: '<td>'.&Apache::lonnet::plaintext($ccrole,$container).'</td>'.
1.4 raeburn 2945: '<td>'.&mt('None').'</td></tr>';
2946: for (my $i=0; $i<$env{'form.persontotal'}; $i++) {
2947: if ($env{'form.person_'.$i.'_uname'} ne '') {
1.30 raeburn 2948: if (ref($disallowed) eq 'ARRAY') {
2949: next if (grep(/^$i$/,@{$disallowed}));
2950: }
1.31 raeburn 2951: my @officialsecs = &Apache::loncommon::get_env_multiple('form.person_'.$i.'_sec');
2952: my @allsecs;
2953: foreach my $sec (@officialsecs) {
2954: next unless ($sec =~ /\w/);
2955: next if ($sec =~ /\W/);
2956: next if ($sec eq 'none');
2957: push(@allsecs,$sec);
2958: }
1.14 raeburn 2959: my $newsec = $env{'form.person_'.$i.'_newsec'};
2960: $newsec =~ s/^\s+//;
2961: $newsec =~s/\s+$//;
1.31 raeburn 2962: my @newsecs = split(/\s*[\s,;:]\s*/,$newsec);
1.14 raeburn 2963: foreach my $sec (@newsecs) {
1.31 raeburn 2964: next unless ($sec =~ /\w/);
1.14 raeburn 2965: next if ($sec =~ /\W/);
1.31 raeburn 2966: next if ($sec eq 'none');
1.14 raeburn 2967: if ($sec ne '') {
2968: unless (grep(/^\Q$sec\E$/,@allsecs)) {
2969: push(@allsecs,$sec);
2970: }
2971: }
2972: }
1.24 raeburn 2973: my $showsec;
1.14 raeburn 2974: if (@allsecs) {
2975: $showsec = join(', ',@allsecs);
2976: }
1.24 raeburn 2977: if ($showsec eq '') {
2978: $showsec = &mt('None');
2979: }
1.41 raeburn 2980: if ($env{'form.person_'.$i.'_role'} eq $ccrole) {
1.24 raeburn 2981: $showsec = &mt('None');
2982: }
1.28 raeburn 2983: my $role = $env{'form.person_'.$i.'_role'};
1.4 raeburn 2984: $personnel_values .=
1.13 raeburn 2985: '<tr><td>'.$env{'form.person_'.$i.'_firstname'}.' '.
2986: $env{'form.person_'.$i.'_lastname'}.'</td>'.
1.4 raeburn 2987: '<td>'.$env{'form.person_'.$i.'_uname'}.':'.
2988: $env{'form.person_'.$i.'_dom'}.'</td>'.
1.28 raeburn 2989: '<td>'.&Apache::lonnet::plaintext($role,$container).'</td>'.
1.14 raeburn 2990: '<td>'.$showsec.'</td></tr>';
1.4 raeburn 2991: }
2992: }
1.30 raeburn 2993: my $output;
2994: if (ref($disallowed) eq 'ARRAY') {
2995: if (@{$disallowed} > 0) {
2996: if (ref($disallowmsg) eq 'HASH') {
2997: $output = '<p class="LC_warning">'.
2998: &mt('Not all requested personnel could be included.').'<ul>';
2999: foreach my $item (@{$disallowed}) {
3000: $output .= '<li>'.$disallowmsg->{$item}.'</li>';
3001: }
3002: $output .= '</ul></p>';
3003: }
3004: }
3005: }
3006: $output .= '<div>'.&Apache::lonhtmlcommon::start_pick_box().
1.4 raeburn 3007: &Apache::lonhtmlcommon::row_title(&mt('Owner')).
1.6 raeburn 3008: '<table class="LC_innerpickbox"><tr>'.
1.4 raeburn 3009: '<th>'.&mt('Name').'</th>'.
3010: '<th>'.&mt('Username:Domain').'</th>'.
3011: '<th>'.&mt('E-mail address').'</th>'.
3012: '</tr><tr>'."\n".
3013: '<td>'.$ownername.'</td><td>'.$owner.'</td>'.
3014: '<td>'.$owneremail.'</td>'.
3015: '</tr></table>'."\n".
3016: &Apache::lonhtmlcommon::row_closure().
1.5 raeburn 3017: &Apache::lonhtmlcommon::row_title(&mt('Description')).
1.4 raeburn 3018: '<table class="LC_innerpickbox"><tr>'.$inst_headers.'</tr>'."\n".
3019: '<tr>'.$inst_values.'</tr></table>'."\n".
3020: &Apache::lonhtmlcommon::row_closure().
1.16 raeburn 3021: &Apache::lonhtmlcommon::row_title($enrollrow_title).
1.4 raeburn 3022: '<table class="LC_innerpickbox"><tr>'.$enroll_headers.'</tr>'."\n".
3023: '<tr>'.$enroll_values.'</tr></table>'."\n".
3024: &Apache::lonhtmlcommon::row_closure();
3025: if ($section_headers ne '') {
3026: $output .= &Apache::lonhtmlcommon::row_title(&mt('Sections')).
3027: '<table class="LC_innerpickbox"><tr>'.$section_headers.'</tr>'."\n".
3028: '<tr>'.$section_values.'</tr></table>'."\n".
3029: &Apache::lonhtmlcommon::row_closure();
3030: }
3031: $output .= &Apache::lonhtmlcommon::row_title(&mt('Personnel')).
3032: '<table class="LC_innerpickbox"><tr>'.$personnel_headers.'</tr>'."\n".
3033: $personnel_values.'</table>'."\n".
3034: &Apache::lonhtmlcommon::row_closure(1).
1.26 raeburn 3035: &Apache::lonhtmlcommon::end_pick_box().'</div>';
1.4 raeburn 3036: return $output;
3037: }
3038:
3039: sub dates_from_form {
3040: my ($startname,$endname) = @_;
3041: my $startdate = &Apache::lonhtmlcommon::get_date_from_form($startname);
3042: my $enddate = &Apache::lonhtmlcommon::get_date_from_form($endname);
1.13 raeburn 3043: if ($endname eq 'accessend') {
1.4 raeburn 3044: if (exists($env{'form.no_end_date'}) ) {
3045: $enddate = 0;
3046: }
3047: }
3048: return ($startdate,$enddate);
1.1 raeburn 3049: }
3050:
3051: sub courseinfo_form {
1.36 raeburn 3052: my ($dom,$formname,$crstype,$next,$description) = @_;
1.32 raeburn 3053: my %lt = &Apache::lonlocal::texthash(
3054: official => 'You must provide a (brief) course description.',
3055: community => 'You must provide a (brief) community description.'
3056: );
3057: $lt{'unofficial'} = $lt{'official'};
1.69 raeburn 3058: $lt{'textbook'} = $lt{'official'};
1.15 raeburn 3059: my $js_validate = <<"ENDJS";
3060: <script type="text/javascript">
3061: // <![CDATA['
3062:
3063: function validateForm() {
3064: if ((document.$formname.cdescr.value == "") || (document.$formname.cdescr.value == "undefined")) {
1.32 raeburn 3065: alert('$lt{$crstype}');
1.15 raeburn 3066: return;
3067: }
3068: nextPage(document.$formname,'$next');
3069: }
1.45 raeburn 3070:
3071: function toggleCloning() {
3072: var willclone;
3073: if (document.$formname.cloning.length > 1) {
3074: for (var i=0; i<document.$formname.cloning.length; i++) {
3075: if (document.$formname.cloning[i].checked) {
3076: willclone = document.$formname.cloning[i].value;
3077: }
3078: }
3079: }
3080: if (willclone == 1) {
3081: document.getElementById('cloneoptions').style.display="block";
3082: } else {
3083: document.getElementById('cloneoptions').style.display="none";
3084: document.$formname.clonecrs.value = '';
3085: }
3086: }
3087:
1.15 raeburn 3088: // ]]
3089: </script>
3090:
3091: ENDJS
1.27 raeburn 3092: my $title = &mt('Brief Course Description');
1.40 raeburn 3093: my $clonetitle = &mt('Clone content and settings from an existing course?');
1.27 raeburn 3094: if ($crstype eq 'community') {
3095: $title = &mt('Brief Community Description');
1.40 raeburn 3096: $clonetitle = &mt('Clone content and settings from an existing community?');
1.27 raeburn 3097: }
1.45 raeburn 3098: my $output .= $js_validate."\n".&Apache::lonhtmlcommon::start_pick_box().
1.27 raeburn 3099: &Apache::lonhtmlcommon::row_headline().
1.34 raeburn 3100: '<h3>'.&Apache::loncommon::help_open_topic('Course_Request_Description').' '.$title.'</h3>'.
1.27 raeburn 3101: &Apache::lonhtmlcommon::row_closure(1).
3102: &Apache::lonhtmlcommon::row_title(&mt('Description')).
1.36 raeburn 3103: '<input type="text" size="60" name="cdescr" value="'.$description.'" />';
1.13 raeburn 3104: my ($home_server_pick,$numlib) =
3105: &Apache::loncommon::home_server_form_item($dom,'chome',
3106: 'default','hide');
3107: if ($numlib > 1) {
3108: $output .= &Apache::lonhtmlcommon::row_closure().
1.16 raeburn 3109: &Apache::lonhtmlcommon::row_title(&mt('Home Server for Course'));
1.13 raeburn 3110: }
3111: $output .= $home_server_pick.
1.27 raeburn 3112: &Apache::lonhtmlcommon::row_closure().
3113: &Apache::lonhtmlcommon::row_headline().
1.45 raeburn 3114: '<h3>'.&Apache::loncommon::help_open_topic('Course_Request_Clone').' '.$clonetitle.
1.46 wenzelju 3115: &Apache::lonhtmlcommon::row_closure(1).
3116: &Apache::lonhtmlcommon::row_title(&mt('Clone?')).
1.45 raeburn 3117: '<label><input type="radio" name="cloning" value="1" '.
3118: 'onclick="javascript:toggleCloning()" />'.
3119: &mt('Yes').(' 'x2).'</label><label>'.
1.49 raeburn 3120: '<input type="radio" name="cloning" value="0" checked="checked" '.
1.45 raeburn 3121: 'onclick="javascript:toggleCloning()" />'.&mt('No').'</label>'.
3122: '</h3>'.
1.13 raeburn 3123: &Apache::lonhtmlcommon::row_closure(1).
1.45 raeburn 3124: &Apache::lonhtmlcommon::row_headline().
3125: '<div id="cloneoptions" style="display: none" >'.
3126: &Apache::lonhtmlcommon::start_pick_box().
1.27 raeburn 3127: &clone_form($dom,$formname,$crstype).
1.45 raeburn 3128: &Apache::lonhtmlcommon::end_pick_box().'</div>'.
3129: &Apache::lonhtmlcommon::end_pick_box()."\n";
1.1 raeburn 3130: return $output;
3131: }
3132:
3133: sub clone_form {
3134: my ($dom,$formname,$crstype) = @_;
3135: my $type = 'Course';
3136: if ($crstype eq 'community') {
3137: $type = 'Community';
3138: }
1.4 raeburn 3139: my %lt = &clone_text();
1.2 raeburn 3140: my $output .=
1.53 raeburn 3141: &Apache::lonhtmlcommon::row_title($lt{'dmn'}).'<label>'.
3142: &Apache::loncommon::select_dom_form($dom,'clonedom').'</label>'.
3143: &Apache::lonhtmlcommon::row_closure(1).
1.2 raeburn 3144: &Apache::lonhtmlcommon::row_title($lt{'cid'}).'<label>'.
1.53 raeburn 3145: '<input type="text" size="25" name="clonecrs" value="" onfocus="this.blur();opencrsbrowser('."'$formname','clonecrs','clonedom','','','','','$type'".')" />'.
3146: '</label> '.
3147: &Apache::loncommon::selectcourse_link($formname,'clonecrs','clonedom','','','',$type).
3148: &Apache::lonhtmlcommon::row_closure(1).
1.2 raeburn 3149: &Apache::lonhtmlcommon::row_title($lt{'dsh'}).'<label>'.
3150: '<input type="radio" name="datemode" value="delete" /> '.$lt{'ncd'}.
3151: '</label><br /><label>'.
3152: '<input type="radio" name="datemode" value="preserve" /> '.$lt{'prd'}.
3153: '</label><br /><label>'.
3154: '<input type="radio" name="datemode" value="shift" checked="checked" /> '.
3155: $lt{'shd'}.'</label>'.
3156: '<input type="text" size="5" name="dateshift" value="365" />'.
1.27 raeburn 3157: &Apache::lonhtmlcommon::row_closure(1);
1.1 raeburn 3158: return $output;
3159: }
3160:
1.16 raeburn 3161: sub clone_text {
1.4 raeburn 3162: return &Apache::lonlocal::texthash(
3163: 'cid' => 'Course ID',
3164: 'dmn' => 'Domain',
3165: 'dsh' => 'Date Shift',
3166: 'ncd' => 'Do not clone date parameters',
3167: 'prd' => 'Clone date parameters as-is',
3168: 'shd' => 'Shift date parameters by number of days',
3169: );
3170: }
3171:
1.1 raeburn 3172: sub coursecode_form {
1.2 raeburn 3173: my ($dom,$context,$codetitles,$cat_titles,$cat_order,$num) = @_;
1.1 raeburn 3174: my $output;
1.46 wenzelju 3175: my %rowtitle = &Apache::lonlocal::texthash (
1.2 raeburn 3176: instcode => 'Course Category',
3177: crosslist => 'Cross Listed Course',
3178: );
1.34 raeburn 3179: my %helpitem = (
3180: instcode => 'Course_Request_Category',
3181: );
1.1 raeburn 3182: if ((ref($codetitles) eq 'ARRAY') && (ref($cat_titles) eq 'HASH') &&
3183: (ref($cat_order))) {
1.2 raeburn 3184: my ($sel,$instsec,$lcsec);
3185: $sel = $context;
3186: if ($context eq 'crosslist') {
3187: $sel .= '_'.$num;
3188: $instsec = &mt('Institutional section').'<br />'.
3189: '<input type="text" size="10" name="'.$sel.'_instsec" />';
3190: $lcsec = &mt('LON-CAPA section').'<br />'.
3191: '<input type="text" size="10" name="'.$sel.'_lcsec" />';
3192: }
1.1 raeburn 3193: if (@{$codetitles} > 0) {
3194: my $lastitem = pop(@{$codetitles});
1.2 raeburn 3195: my $lastinput = '<input type="text" size="5" name="'.$sel.'_'. $lastitem.'" />';
1.1 raeburn 3196: if (@{$codetitles} > 0) {
1.61 raeburn 3197: my $helplink;
3198: if (defined($helpitem{$context})) {
3199: $helplink = &Apache::loncommon::help_open_topic($helpitem{$context}).' ';
3200: }
3201: $output = &Apache::lonhtmlcommon::row_title($helplink.$rowtitle{$context}).
1.2 raeburn 3202: '<table><tr>';
1.1 raeburn 3203: if ($context eq 'crosslist') {
1.2 raeburn 3204: $output .= '<td>'.&mt('Include?').'<br />'.
3205: '<input type="checkbox" name="'.$sel.'" value="1" /></td>';
1.1 raeburn 3206: }
3207: foreach my $title (@{$codetitles}) {
3208: if (ref($cat_order->{$title}) eq 'ARRAY') {
3209: if (@{$cat_order->{$title}} > 0) {
3210: $output .= '<td align="center">'.$title.'<br />'."\n".
3211: '<select name="'.$sel.'_'.$title.'">'."\n".
3212: ' <option value="" selected="selected">'.
3213: &mt('Select').'</option>'."\n";
3214: foreach my $item (@{$cat_order->{$title}}) {
3215: my $longitem = $item;
3216: if (ref($cat_titles->{$title}) eq 'HASH') {
3217: if ($cat_titles->{$title}{$item} ne '') {
3218: $longitem = $cat_titles->{$title}{$item};
3219: }
3220: }
3221: $output .= '<option value="'.$item.'">'.$longitem.
3222: '</option>'."\n";
3223: }
3224: }
3225: $output .= '</select></td>'."\n";
3226: }
3227: }
3228: if ($context eq 'crosslist') {
3229: $output .= '<td align="center">'.$lastitem.'<br />'."\n".
1.2 raeburn 3230: $lastinput.'</td><td align="center">'.$instsec.'</td>'.
3231: '<td align="center">'.$lcsec.'</td></tr></table>';
1.1 raeburn 3232: } else {
3233: $output .= '</tr></table>'.
3234: &Apache::lonhtmlcommon::row_closure().
3235: &Apache::lonhtmlcommon::row_title('Course '.$lastitem).
3236: $lastinput;
3237: }
3238: } else {
3239: if ($context eq 'crosslist') {
3240: $output .= &Apache::lonhtmlcommon::row_title($rowtitle{$context}).
1.2 raeburn 3241: '<table><tr>'.
3242: '<td align="center">'.$lastitem.'<br />'.$lastinput.'</td>'.
3243: '<td align="center">'.$instsec.'</td><td>'.$lcsec.'</td>'.
3244: '</tr></table>';
1.1 raeburn 3245: } else {
3246: $output .= &Apache::lonhtmlcommon::row_title('Course '.$lastitem).
3247: $lastinput;
3248: }
3249: }
1.2 raeburn 3250: $output .= &Apache::lonhtmlcommon::row_closure(1);
3251: push(@$codetitles,$lastitem);
3252: } elsif ($context eq 'crosslist') {
3253: $output .= &Apache::lonhtmlcommon::row_title($rowtitle{$context}).
3254: '<table><tr><td align="center">'.
3255: '<span class="LC_nobreak">'.&mt('Include?').
3256: '<input type="checkbox" name="'.$sel.'" value="1" /></span>'.
3257: '</td><td align="center">'.&mt('Institutional ID').'<br />'.
3258: '<input type="text" size="10" name="'.$sel.'_instsec" />'.
3259: '</td><td align="center">'.$lcsec.'</td></tr></table>'.
3260: &Apache::lonhtmlcommon::row_closure(1);
1.1 raeburn 3261: }
3262: }
3263: return $output;
3264: }
3265:
1.61 raeburn 3266: sub sections_form {
3267: my ($dom,$instcode,$num) = @_;
3268: my $rowtitle;
3269: if ($instcode eq '') {
3270: $rowtitle = &mt('Sections');
3271: } else {
3272: $rowtitle = &mt('Sections of [_1]',$instcode);
3273: }
3274: return &Apache::lonhtmlcommon::row_title($rowtitle).
3275: '<table><tr><td align="center">'.
3276: '<span class="LC_nobreak">'.&mt('Include?').
3277: '<input type="checkbox" name="sec_'.$num.'" value="1" /></span>'.
3278: '</td><td align="center">'.&mt('Institutional section').'<br />'.
3279: '<input type="text" size="10" name="secnum_'.$num.'" />'.
3280: '</td><td align="center">'.&mt('LON-CAPA section').'<br />'.
3281: '<input type="text" size="10" name="loncapasec_'.$num.'" />'.
3282: '</td></tr></table>'.
3283: &Apache::lonhtmlcommon::row_closure(1);
3284: }
3285:
1.1 raeburn 3286: sub get_course_dom {
3287: my $codedom = &Apache::lonnet::default_login_domain();
1.19 raeburn 3288: if ($env{'form.showdom'} ne '') {
3289: if (&Apache::lonnet::domain($env{'form.showdom'}) ne '') {
3290: return $env{'form.showdom'};
3291: }
3292: }
1.1 raeburn 3293: if (($env{'user.domain'} ne '') && ($env{'user.domain'} ne 'public')) {
1.37 raeburn 3294: my ($types,$typename) = &Apache::loncommon::course_types();
1.19 raeburn 3295: if (ref($types) eq 'ARRAY') {
3296: foreach my $type (@{$types}) {
3297: if (&Apache::lonnet::usertools_access($env{'user.name'},
3298: $env{'user.domain'},$type,
3299: undef,'requestcourses')) {
3300: return $env{'user.domain'};
3301: }
3302: }
3303: my @possible_doms;
3304: foreach my $type (@{$types}) {
3305: my $dom_str = $env{'environment.reqcrsotherdom.'.$type};
3306: if ($dom_str ne '') {
3307: my @domains = split(',',$dom_str);
3308: foreach my $entry (@domains) {
3309: my ($extdom,$extopt) = split(':',$entry);
3310: if ($extdom eq $env{'request.role.domain'}) {
3311: return $extdom;
3312: }
3313: unless(grep(/^\Q$extdom\E$/,@possible_doms)) {
3314: push(@possible_doms,$extdom);
3315: }
3316: }
3317: }
3318: }
3319: if (@possible_doms) {
3320: @possible_doms = sort(@possible_doms);
3321: return $possible_doms[0];
3322: }
3323: }
1.1 raeburn 3324: $codedom = $env{'user.domain'};
3325: if ($env{'request.role.domain'} ne '') {
3326: $codedom = $env{'request.role.domain'};
3327: }
3328: }
3329: return $codedom;
3330: }
3331:
3332: sub display_navbuttons {
1.31 raeburn 3333: my ($r,$dom,$formname,$prev,$prevtext,$next,$nexttext,$state,$other,$othertext) = @_;
1.1 raeburn 3334: $r->print('<div class="LC_navbuttons">');
3335: if ($prev) {
1.16 raeburn 3336: $r->print('<input type="button" name="previous" value = "'.$prevtext.'" '.
1.31 raeburn 3337: 'onclick="javascript:backPage('."document.$formname,'$prev'".')"/>'.
1.16 raeburn 3338: (' 'x3));
1.1 raeburn 3339: } elsif ($prevtext) {
1.16 raeburn 3340: $r->print('<input type="button" name="previous" value = "'.$prevtext.'" '.
3341: 'onclick="javascript:history.back()"/>'.(' 'x3));
3342: }
3343: if ($state eq 'details') {
3344: $r->print(' <input type="button" name="other" value="'.$othertext.'" '.
1.31 raeburn 3345: 'onclick="javascript:nextPage('."document.$formname,'$other'".
1.16 raeburn 3346: ')" />');
1.1 raeburn 3347: }
1.31 raeburn 3348: my $gotnext;
1.15 raeburn 3349: if ($state eq 'courseinfo') {
1.16 raeburn 3350: $r->print('<input type="button" name="next" value="'.$nexttext.'" '.
3351: 'onclick="javascript:validateForm();" />');
1.31 raeburn 3352: $gotnext = 1;
3353: } elsif ($state eq 'enrollment') {
3354: if (($env{'form.crstype'} eq 'official') &&
3355: (&Apache::lonnet::auto_run('',$dom))) {
3356: $r->print('<input type="button" name="next" value="'.$nexttext.'" '.
3357: 'onclick="javascript:validateEnrollSections('."document.$formname,'$next'".');" />');
3358: $gotnext = 1;
3359: }
3360: } elsif ($state eq 'personnel') {
3361: if ($env{'form.persontotal'} > 0) {
3362: $r->print('<input type="button" name="next" value="'.$nexttext.'" '.
3363: 'onclick="javascript:validatePersonnelSections('."document.$formname,'$next'".');" />');
3364: $gotnext = 1;
3365: }
3366: }
3367: unless ($gotnext) {
3368: if ($next) {
3369: $r->print('
3370: <input type="button" name="next" value="'.$nexttext.'" '.
3371: 'onclick="javascript:nextPage('."document.$formname,'$next'".')" />');
3372: }
1.1 raeburn 3373: }
3374: $r->print('</div>');
3375: }
3376:
3377: sub print_request_outcome {
1.84 ! raeburn 3378: my ($r,$lonhost,$dom,$codetitles,$code_order,$instcredits) = @_;
1.13 raeburn 3379: my ($output,$cnum,$now,$req_notifylist,$crstype,$enrollstart,$enrollend,
1.70 raeburn 3380: %sections,%crosslistings,%personnel,@baduname,@missingdom,%domconfig,
3381: $uniquecode);
1.24 raeburn 3382: my $sectotal = $env{'form.sectotal'};
3383: my $crosslisttotal = 0;
1.10 raeburn 3384: $cnum = $env{'form.cnum'};
1.8 raeburn 3385: unless ($cnum =~ /^$match_courseid$/) {
3386: $output = &mt('Invalid LON-CAPA course number for the new course')."\n";
3387: return $output;
3388: }
1.73 raeburn 3389: $crstype = $env{'form.crstype'};
3390: my %domconfig = &Apache::lonnet::get_dom('configuration',['requestcourses'],$dom);
1.9 raeburn 3391: if (ref($domconfig{'requestcourses'}) eq 'HASH') {
3392: if (ref($domconfig{'requestcourses'}{'notify'}) eq 'HASH') {
3393: $req_notifylist = $domconfig{'requestcourses'}{'notify'}{'approval'};
3394: }
1.73 raeburn 3395: if (ref($domconfig{'requestcourses'}{'uniquecode'}) eq 'HASH') {
3396: $uniquecode = $domconfig{'requestcourses'}{'uniquecode'}{$crstype};
3397: }
1.9 raeburn 3398: }
1.10 raeburn 3399: $now = time;
1.41 raeburn 3400: my $ccrole = 'cc';
3401: if ($crstype eq 'community') {
3402: $ccrole = 'co';
3403: }
1.17 raeburn 3404: my @instsections;
1.8 raeburn 3405: if ($crstype eq 'official') {
3406: if (&Apache::lonnet::auto_run('',$dom)) {
1.13 raeburn 3407: ($enrollstart,$enrollend)=&dates_from_form('enrollstart','enrollend');
1.8 raeburn 3408: }
1.10 raeburn 3409: for (my $i=0; $i<$env{'form.sectotal'}; $i++) {
3410: if ($env{'form.sec_'.$i}) {
3411: if ($env{'form.secnum_'.$i} ne '') {
1.17 raeburn 3412: my $sec = $env{'form.secnum_'.$i};
3413: $sections{$i}{'inst'} = $sec;
3414: if (($sec ne '') && (!grep(/^\Q$sec\E$/,@instsections))) {
3415: push(@instsections,$sec);
3416: }
1.13 raeburn 3417: $sections{$i}{'loncapa'} = $env{'form.loncapasec_'.$i};
1.58 raeburn 3418: $sections{$i}{'loncapa'} =~ s/\W//g;
3419: if ($sections{$i}{'loncapa'} eq 'none') {
3420: $sections{$i}{'loncapa'} = '';
3421: }
1.10 raeburn 3422: }
3423: }
3424: }
3425: for (my $i=0; $i<$env{'form.crosslisttotal'}; $i++) {
3426: if ($env{'form.crosslist_'.$i}) {
3427: my $xlistinfo = '';
3428: if (ref($code_order) eq 'ARRAY') {
3429: if (@{$code_order} > 0) {
3430: foreach my $item (@{$code_order}) {
3431: $xlistinfo .= $env{'form.crosslist_'.$i.'_'.$item};
3432: }
3433: }
3434: }
1.22 raeburn 3435: $crosslistings{$i}{'instcode'} = $xlistinfo;
1.24 raeburn 3436: if ($xlistinfo ne '') {
3437: $crosslisttotal ++;
3438: }
1.22 raeburn 3439: $crosslistings{$i}{'instsec'} = $env{'form.crosslist_'.$i.'_instsec'};
1.13 raeburn 3440: $crosslistings{$i}{'loncapa'} = $env{'form.crosslist_'.$i.'_lcsec'};
1.10 raeburn 3441: }
3442: }
1.14 raeburn 3443: } else {
3444: $enrollstart = '';
3445: $enrollend = '';
1.10 raeburn 3446: }
1.62 raeburn 3447: my (%alerts,%rulematch,%inst_results,%curr_rules,%got_rules,%disallowmsg,%skipped);
1.10 raeburn 3448: for (my $i=0; $i<$env{'form.persontotal'}; $i++) {
3449: my $uname = $env{'form.person_'.$i.'_uname'};
1.16 raeburn 3450: my $udom = $env{'form.person_'.$i.'_dom'};
1.10 raeburn 3451: if (($uname =~ /^$match_username$/) && ($udom =~ /^$match_domain$/)) {
3452: if (&Apache::lonnet::domain($udom) ne '') {
1.13 raeburn 3453: unless (ref($personnel{$uname.':'.$udom}) eq 'HASH') {
3454: $personnel{$uname.':'.$udom} = {
3455: firstname => $env{'form.person_'.$i.'_firstname'},
3456: lastname => $env{'form.person_'.$i.'_lastname'},
3457: emailaddr => $env{'form.person_'.$i.'_emailaddr'},
3458: };
1.62 raeburn 3459: if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
3460: my $usertype = &get_usertype($udom,$uname,\%curr_rules,\%got_rules);
3461: if (&Apache::lonuserutils::can_create_user($udom,'requestcrs',$usertype)) {
3462: my ($allowed,$msg,$authtype,$authparam) =
3463: &check_newuser_rules($udom,$uname,\%alerts,\%rulematch,
3464: \%inst_results,\%curr_rules,\%got_rules);
3465: if ($allowed) {
3466: my %domdefaults = &Apache::lonnet::get_domain_defaults($udom);
3467: if ($usertype eq 'official') {
3468: if ($authtype eq '') {
1.60 raeburn 3469: $authtype = $domdefaults{'auth_def'};
3470: $authparam = $domdefaults{'auth_arg_def'};
1.62 raeburn 3471: } else {
3472: if ($authtype eq 'loc') {
3473: $authtype = 'localauth';
3474: } elsif ($authtype eq 'int') {
3475: $authtype = 'internal';
3476: }
3477: if ($authtype !~ /^(krb4|krb5|internal|localauth)$/) {
3478: $authtype = $domdefaults{'auth_def'};
3479: $authparam = $domdefaults{'auth_arg_def'};
3480: }
3481: }
3482: } elsif ($usertype eq 'unofficial') {
3483: if ($authtype eq '') {
3484: $authtype = 'internal';
3485: $authparam = '';
1.60 raeburn 3486: }
1.62 raeburn 3487: } else {
3488: $authtype = $domdefaults{'auth_def'};
3489: $authparam = $domdefaults{'auth_arg_def'};
1.60 raeburn 3490: }
1.62 raeburn 3491: if (($authtype eq '') ||
3492: (($authtype =~/^krb(4|5)$/) && ($authparam eq '')) ||
3493: ($authtype !~ /^(krb4|krb5|internal|localauth)$/)) {
3494: $skipped{$uname.':'.$udom} = 1;
3495: next;
3496: } else {
3497: $personnel{$uname.':'.$udom}{'authtype'} = $authtype;
3498: $personnel{$uname.':'.$udom}{'autharg'} = $authparam;
1.60 raeburn 3499: }
3500: } else {
1.62 raeburn 3501: $skipped{$uname.':'.$udom} = 1;
1.60 raeburn 3502: next;
3503: }
3504: } else {
1.62 raeburn 3505: $skipped{$uname.':'.$udom} = 1;
1.60 raeburn 3506: next;
3507: }
3508: }
1.13 raeburn 3509: }
3510: my $role = $env{'form.person_'.$i.'_role'};
3511: unless ($role eq '') {
1.16 raeburn 3512: if (ref($personnel{$uname.':'.$udom}{'roles'}) eq 'ARRAY') {
1.13 raeburn 3513: my @curr_roles = @{$personnel{$uname.':'.$udom}{'roles'}};
3514: unless (grep(/^\Q$role\E$/,@curr_roles)) {
3515: push(@{$personnel{$uname.':'.$udom}{'roles'}},$role);
3516: }
3517: } else {
3518: @{$personnel{$uname.':'.$udom}{'roles'}} = ($role);
3519: }
1.41 raeburn 3520: if ($role eq $ccrole) {
1.13 raeburn 3521: @{$personnel{$uname.':'.$udom}{$role}{'usec'}} = ();
3522: } else {
1.14 raeburn 3523: my @currsec = &Apache::loncommon::get_env_multiple('form.person_'.$i.'_sec');
1.31 raeburn 3524: my @allsecs;
3525: foreach my $sec (@currsec) {
3526: next unless ($sec =~ /\w/);
3527: next if ($sec =~ /\W/);
3528: next if ($sec eq 'none');
3529: push(@allsecs,$sec);
3530: }
1.14 raeburn 3531: my $newsec = $env{'form.person_'.$i.'_newsec'};
3532: $newsec =~ s/^\s+//;
3533: $newsec =~s/\s+$//;
3534: my @newsecs = split(/[\s,;]+/,$newsec);
3535: foreach my $sec (@newsecs) {
3536: next if ($sec =~ /\W/);
1.31 raeburn 3537: next if ($sec eq 'none');
1.14 raeburn 3538: if ($sec ne '') {
1.31 raeburn 3539: unless (grep(/^\Q$sec\E$/,@allsecs)) {
3540: push(@allsecs,$sec);
1.13 raeburn 3541: }
3542: }
3543: }
1.31 raeburn 3544: @{$personnel{$uname.':'.$udom}{$role}{'usec'}} = @allsecs;
1.13 raeburn 3545: }
3546: }
1.10 raeburn 3547: } else {
3548: push(@missingdom,$uname.':'.$udom);
3549: }
3550: } else {
3551: push(@baduname,$uname.':'.$udom);
3552: }
1.8 raeburn 3553: }
1.62 raeburn 3554: if (keys(%skipped)) {
3555: foreach my $key (keys(%skipped)) {
3556: delete($personnel{$key});
3557: }
3558: }
1.13 raeburn 3559: my ($accessstart,$accessend) = &dates_from_form('accessstart','accessend');
1.14 raeburn 3560: my $autodrops = 0;
3561: if ($env{'form.autodrops'}) {
3562: $autodrops = $env{'form.autodrops'};
3563: }
3564: my $autoadds = 0;
3565: if ($env{'form.autoadds'}) {
1.57 raeburn 3566: $autoadds = $env{'form.autoadds'};
1.14 raeburn 3567: }
3568: my $instcode = '';
3569: if (exists($env{'form.instcode'})) {
3570: $instcode = $env{'form.instcode'};
3571: }
1.66 raeburn 3572: my $credits;
3573: if ($instcredits) {
3574: $credits = $instcredits;
3575: } elsif (exists($env{'form.coursecredits'})) {
3576: $credits = $env{'form.coursecredits'};
3577: }
1.15 raeburn 3578: my $clonecrs = '';
3579: my $clonedom = '';
1.45 raeburn 3580: if (($env{'form.cloning'}) &&
3581: ($env{'form.clonecrs'} =~ /^($match_courseid)$/) &&
1.15 raeburn 3582: ($env{'form.clonedom'} =~ /^($match_domain)$/)) {
1.16 raeburn 3583: my $clonehome = &Apache::lonnet::homeserver($env{'form.clonecrs'},
3584: $env{'form.clonedom'});
1.15 raeburn 3585: if ($clonehome ne 'no_host') {
1.16 raeburn 3586: my $canclone =
3587: &Apache::loncoursequeueadmin::can_clone_course($env{'user.name'},
1.39 raeburn 3588: $env{'user.domain'},$env{'form.clonecrs'},$env{'form.clonedom'},
3589: $crstype);
1.15 raeburn 3590: if ($canclone) {
3591: $clonecrs = $env{'form.clonecrs'};
3592: $clonedom = $env{'form.clonedom'};
3593: }
3594: }
3595: }
1.8 raeburn 3596: my $details = {
1.10 raeburn 3597: owner => $env{'user.name'},
3598: domain => $env{'user.domain'},
3599: cdom => $dom,
1.11 raeburn 3600: cnum => $cnum,
1.13 raeburn 3601: coursehome => $env{'form.chome'},
3602: cdescr => $env{'form.cdescr'},
1.10 raeburn 3603: crstype => $env{'form.crstype'},
1.14 raeburn 3604: instcode => $instcode,
1.66 raeburn 3605: defaultcredits => $credits,
1.70 raeburn 3606: uniquecode => $uniquecode,
1.15 raeburn 3607: clonedom => $clonedom,
3608: clonecrs => $clonecrs,
1.10 raeburn 3609: datemode => $env{'form.datemode'},
1.14 raeburn 3610: dateshift => $env{'form.dateshift'},
3611: sectotal => $sectotal,
1.10 raeburn 3612: sections => \%sections,
1.14 raeburn 3613: crosslisttotal => $crosslisttotal,
1.13 raeburn 3614: crosslists => \%crosslistings,
1.14 raeburn 3615: autoadds => $autoadds,
3616: autodrops => $autodrops,
1.13 raeburn 3617: enrollstart => $enrollstart,
3618: enrollend => $enrollend,
3619: accessstart => $accessstart,
3620: accessend => $accessend,
1.10 raeburn 3621: personnel => \%personnel,
1.8 raeburn 3622: };
1.84 ! raeburn 3623: my ($result,$output) = &process_request($r,$lonhost,$dom,$cnum,$crstype,$now,$details,$instcode,
1.72 raeburn 3624: $req_notifylist,\@instsections,\%domconfig);
3625: return ($result,$output);
3626: }
3627:
3628: sub process_request {
1.84 ! raeburn 3629: my ($r,$lonhost,$dom,$cnum,$crstype,$now,$details,$instcode,$req_notifylist,$instsections,
1.78 raeburn 3630: $domconfig) = @_;
1.72 raeburn 3631: my (@inststatuses,$storeresult,$creationresult,$output);
1.43 raeburn 3632: my $val =
1.64 raeburn 3633: &Apache::loncoursequeueadmin::get_processtype('course',$env{'user.name'},
3634: $env{'user.domain'},$env{'user.adv'},
1.72 raeburn 3635: $dom,$crstype,\@inststatuses,$domconfig);
1.8 raeburn 3636: if ($val eq '') {
3637: if ($crstype eq 'official') {
1.19 raeburn 3638: $output = &mt('You are not permitted to request creation of official courses.');
1.8 raeburn 3639: } elsif ($crstype eq 'unofficial') {
1.19 raeburn 3640: $output = &mt('You are not permitted to request creation of unofficial courses.');
1.8 raeburn 3641: } elsif ($crstype eq 'community') {
3642: $output = &mt('You are not permitted to request creation of communities');
1.69 raeburn 3643: } elsif ($crstype eq 'textbook') {
3644: $output = &mt('You are not permitted to request creation of textbook courses');
1.8 raeburn 3645: } else {
3646: $output = &mt('Unrecognized course type: [_1]',$crstype);
3647: }
1.27 raeburn 3648: $storeresult = 'notpermitted';
1.8 raeburn 3649: } else {
1.78 raeburn 3650: my ($disposition,$message,$reqstatus,$coursedesc);
1.8 raeburn 3651: my %reqhash = (
1.14 raeburn 3652: reqtime => $now,
1.10 raeburn 3653: crstype => $crstype,
3654: details => $details,
1.8 raeburn 3655: );
3656: my $requestkey = $dom.'_'.$cnum;
1.17 raeburn 3657: my $validationerror;
1.78 raeburn 3658: my $fullname = &Apache::loncommon::plainname($env{'user.name'},
3659: $env{'user.domain'});
3660: if (ref($details) eq 'HASH') {
3661: $coursedesc = $details->{'cdescr'};
3662: }
1.10 raeburn 3663: if ($val eq 'autolimit=') {
3664: $disposition = 'process';
3665: } elsif ($val =~ /^autolimit=(\d+)$/) {
3666: my $limit = $1;
1.8 raeburn 3667: $disposition = &check_autolimit($env{'user.name'},$env{'user.domain'},
1.10 raeburn 3668: $dom,$crstype,$limit,\$message);
1.8 raeburn 3669: } elsif ($val eq 'validate') {
1.78 raeburn 3670: my ($inststatuslist,$validationchk,$validation,%custominfo);
1.17 raeburn 3671: if (@inststatuses > 0) {
3672: $inststatuslist = join(',',@inststatuses);
3673: }
3674: my $instseclist;
1.72 raeburn 3675: if (ref($instsections) eq 'ARRAY') {
3676: if (@{$instsections} > 0) {
3677: $instseclist = join(',',@{$instsections});
3678: }
1.17 raeburn 3679: }
1.78 raeburn 3680: my $preprocess = &Apache::lonnet::auto_crsreq_update($dom,$cnum,$crstype,'prevalidate',$env{'user.name'},
3681: $env{'user.domain'},$fullname,$coursedesc);
3682: if (ref($preprocess) eq 'HASH') {
3683: if (ref($preprocess->{'formitems'}) eq 'HASH') {
3684: foreach my $key (keys(%{$preprocess->{'formitems'}})) {
3685: if ($preprocess->{'formitems'}->{$key} eq 'multiple') {
3686: if (exists($env{'form.'.$key})) {
3687: @{$custominfo{$key}} = &Apache::loncommon::get_env_multiple($env{'form.'.$key});
3688: }
3689: } else {
3690: if (exists($env{'form.'.$key})) {
3691: $custominfo{$key} = $env{'form.'.$key};
3692: }
3693: }
3694: }
3695: }
3696: }
1.21 raeburn 3697: $validationchk =
3698: &Apache::lonnet::auto_courserequest_validation($dom,
3699: $env{'user.name'}.':'.$env{'user.domain'},$crstype,
1.78 raeburn 3700: $inststatuslist,$instcode,$instseclist,\%custominfo);
1.21 raeburn 3701: if ($validationchk =~ /:/) {
3702: ($validation,$message) = split(':',$validationchk);
3703: } else {
3704: $validation = $validationchk;
3705: }
3706: if ($validation =~ /^error(.*)$/) {
1.17 raeburn 3707: $disposition = 'approval';
3708: $validationerror = $1;
1.23 raeburn 3709: } else {
3710: $disposition = $validation;
1.17 raeburn 3711: }
1.8 raeburn 3712: } else {
3713: $disposition = 'approval';
3714: }
1.14 raeburn 3715: $reqhash{'disposition'} = $disposition;
3716: $reqstatus = $disposition;
1.78 raeburn 3717: my ($modified,$queued,$coursedesc,$token,%customitems);
1.73 raeburn 3718: unless ($disposition eq 'rejected') {
3719: my $inprocess = &Apache::lonnet::auto_crsreq_update($dom,$cnum,$crstype,'process',$env{'user.name'},
3720: $env{'user.domain'},$fullname,$coursedesc);
3721: if (ref($inprocess) eq 'HASH') {
3722: if (ref($inprocess->{'formitems'}) eq 'HASH') {
3723: foreach my $key (keys(%{$inprocess->{'formitems'}})) {
3724: if ($inprocess->{'formitems'}->{$key} eq 'multiple') {
3725: if (exists($env{'form.'.$key})) {
3726: @{$customitems{$key}} = &Apache::loncommon::get_env_multiple($env{'form.'.$key});
3727: }
3728: } else {
3729: if (exists($env{'form.'.$key})) {
3730: $customitems{$key} = $env{'form.'.$key};
3731: $reqhash{'custom'}{$key} = $customitems{$key};
3732: }
3733: }
3734: }
3735: }
3736: }
3737: }
1.8 raeburn 3738: if ($disposition eq 'rejected') {
1.40 raeburn 3739: if ($crstype eq 'community') {
3740: $output = &mt('Your community request was rejected.');
3741: } else {
3742: $output = &mt('Your course request was rejected.');
3743: }
1.8 raeburn 3744: if ($message) {
3745: $output .= '<div class="LC_warning">'.$message.'</div>';
3746: }
1.27 raeburn 3747: $storeresult = 'rejected';
1.8 raeburn 3748: } elsif ($disposition eq 'process') {
1.14 raeburn 3749: my %domdefs = &Apache::lonnet::get_domain_defaults($dom);
1.70 raeburn 3750: my ($logmsg,$newusermsg,$addresult,$enrollcount,$response,$keysmsg,%longroles,$code);
1.8 raeburn 3751: my $type = 'Course';
3752: if ($crstype eq 'community') {
3753: $type = 'Community';
3754: }
1.41 raeburn 3755: my @roles = &Apache::lonuserutils::roles_by_context('course','',$type);
1.8 raeburn 3756: foreach my $role (@roles) {
3757: $longroles{$role}=&Apache::lonnet::plaintext($role,$type);
3758: }
1.84 ! raeburn 3759: $r->print('<div id="processing" style="display:block;">'."\n".
! 3760: &mt('Your request is being processed; this page will update when processing is complete.').
! 3761: '</div>');
! 3762: $r->rflush();
1.73 raeburn 3763: my ($result,$postprocess) = &Apache::loncoursequeueadmin::course_creation($dom,$cnum,
3764: 'autocreate',$details,\$logmsg,\$newusermsg,\$addresult,
3765: \$enrollcount,\$response,\$keysmsg,\%domdefs,\%longroles,
3766: \$code,\%customitems);
1.14 raeburn 3767: if ($result eq 'created') {
1.8 raeburn 3768: $disposition = 'created';
1.14 raeburn 3769: $reqstatus = 'created';
1.28 raeburn 3770: my $role_result = &update_requestors_roles($dom,$cnum,$crstype,$details,
3771: \%longroles);
1.40 raeburn 3772: if ($crstype eq 'community') {
3773: $output = '<p>'.&mt('Your community request has been processed and the community has been created.');
3774: } else {
3775: $output = '<p>'.&mt('Your course request has been processed and the course has been created.');
3776: }
1.73 raeburn 3777: if (($code) || ((ref($postprocess) eq 'HASH') &&
3778: (($postprocess->{'createdweb'}) || ($postprocess->{'createdmsg'})))) {
3779: $output .= ¬ification_information($disposition,$env{'user.name'}.':'.$env{'user.domain'},
1.74 raeburn 3780: $dom,$cnum,$now,$code,$postprocess);
1.73 raeburn 3781: }
1.70 raeburn 3782: if ($code) {
1.73 raeburn 3783: $reqhash{'code'} = $code;
1.70 raeburn 3784: }
1.79 raeburn 3785: if (ref($postprocess) eq 'HASH') {
3786: if (ref($postprocess->{'createdactions'}) eq 'HASH') {
1.80 raeburn 3787: if (ref($postprocess->{'createdactions'}{'environment'}) eq 'HASH') {
3788: &Apache::loncoursequeueadmin::postprocess_crsenv($dom,$cnum,
3789: $postprocess->{'createdactions'}{'environment'});
1.79 raeburn 3790: }
3791: }
3792: }
1.40 raeburn 3793: $output .= '<br />'.$role_result.'</p>';
1.27 raeburn 3794: $creationresult = 'created';
1.8 raeburn 3795: } else {
1.40 raeburn 3796: $output = '<span class="LC_error">';
3797: if ($crstype eq 'community') {
3798: $output .= &mt('An error occurred when processing your community request.');
3799: } else {
3800: $output .= &mt('An error occurred when processing your course request.');
3801: }
3802: $output .= '<br />'.
3803: &mt('You may want to review the request details and submit the request again.').
1.14 raeburn 3804: '</span>';
1.27 raeburn 3805: $creationresult = 'error';
1.8 raeburn 3806: }
3807: } else {
3808: my $requestid = $cnum.'_'.$disposition;
1.73 raeburn 3809: my $request = {
1.8 raeburn 3810: $requestid => {
3811: timestamp => $now,
3812: crstype => $crstype,
3813: ownername => $env{'user.name'},
3814: ownerdom => $env{'user.domain'},
1.78 raeburn 3815: description => $env{'form.cdescr'},
3816: lonhost => $lonhost,
1.8 raeburn 3817: },
3818: };
1.49 raeburn 3819: if ($crstype eq 'official') {
3820: $request->{$requestid}->{'instcode'} = $instcode;
3821: }
1.16 raeburn 3822: my $statuskey = 'status:'.$dom.':'.$cnum;
3823: my %userreqhash = &Apache::lonnet::get('courserequests',[$statuskey],
3824: $env{'user.domain'},$env{'user.name'});
1.17 raeburn 3825: if ($userreqhash{$statuskey} ne '') {
1.16 raeburn 3826: $modified = 1;
1.25 raeburn 3827: my $uname = &Apache::lonnet::get_domainconfiguser($dom);
3828: my %queuehash = &Apache::lonnet::get('courserequestqueue',
3829: [$cnum.'_approval',
3830: $cnum.'_pending'],$dom,$uname);
1.17 raeburn 3831: if (($queuehash{$cnum.'_approval'} ne '') ||
3832: ($queuehash{$cnum.'_pending'} ne '')) {
1.16 raeburn 3833: $queued = 1;
1.78 raeburn 3834: if (ref($queuehash{$cnum.'_pending'}) eq 'HASH') {
3835: $token = $queuehash{$cnum.'_pending'}{'token'};
3836: }
1.16 raeburn 3837: }
3838: }
3839: unless ($queued) {
1.78 raeburn 3840: if (($disposition eq 'pending') && ($crstype ne 'official')) {
3841: my %reqinfo = (
3842: $cnum.':'.$dom => $now.':'.$env{'user.name'}.':'.$env{'user.domain'},
3843: );
3844: $token = &Apache::lonnet::tmpput(\%reqinfo,$lonhost);
3845: $request->{$requestid}->{'token'} = $token;
3846: }
1.16 raeburn 3847: my $putresult = &Apache::lonnet::newput_dom('courserequestqueue',$request,
3848: $dom);
3849: if ($putresult eq 'ok') {
1.40 raeburn 3850: if ($crstype eq 'community') {
3851: $output .= &mt('Your community request has been recorded.');
3852: } else {
3853: $output .= &mt('Your course request has been recorded.')
3854: }
1.78 raeburn 3855: unless ($disposition eq 'pending') {
3856: $output .= '<br />'.
3857: ¬ification_information($disposition,$req_notifylist,
3858: $dom,$cnum,$now);
3859: }
1.8 raeburn 3860: } else {
1.16 raeburn 3861: $reqstatus = 'domainerror';
3862: $reqhash{'disposition'} = $disposition;
3863: my $warning = &mt('An error occurred saving your request in the pending requests queue.');
3864: $output = '<span class"LC_warning">'.$warning.'</span><br />';
1.8 raeburn 3865: }
3866: }
3867: }
1.44 raeburn 3868: ($storeresult,my $updateresult) =
3869: &Apache::loncoursequeueadmin::update_coursereq_status(\%reqhash,$dom,
1.63 raeburn 3870: $cnum,$reqstatus,'request',$env{'user.domain'},$env{'user.name'});
1.78 raeburn 3871: if ($storeresult eq 'ok') {
3872: my $postprocess;
3873: if (($disposition eq 'approval') || ($disposition eq 'pending')) {
3874: my $updateaction = $disposition;
3875: if ($disposition eq 'approval') {
3876: $updateaction = 'queued';
3877: }
1.73 raeburn 3878: my $fullname = &Apache::loncommon::plainname($env{'user.name'},
3879: $env{'user.domain'});
1.78 raeburn 3880: $postprocess =
3881: &Apache::lonnet::auto_crsreq_update($dom,$cnum,$crstype,$updateaction,$env{'user.name'},
1.73 raeburn 3882: $env{'user.domain'},$fullname,$env{'form.cdescr'});
1.78 raeburn 3883: }
3884: if ($modified && $queued) {
3885: if ($crstype eq 'community') {
3886: $output .= '<p>'.&mt('Your community request has been updated').'</p>';
3887: } else {
3888: $output .= '<p>'.&mt('Your course request has been updated').'</p>';
3889: }
3890: if ($disposition eq 'approval') {
3891: $output .= ¬ification_information($disposition,$req_notifylist,$dom,$cnum,$now);
3892: }
3893: }
3894: if ($disposition eq 'approval') {
1.73 raeburn 3895: if ((ref($postprocess) eq 'HASH') &&
3896: ((ref($postprocess->{'queuedmsg'}) eq 'HASH') || ($postprocess->{'queuedweb'}))) {
1.77 raeburn 3897: ¬ification_information($disposition,undef,$dom,$cnum,$now,undef,$postprocess);
1.73 raeburn 3898: }
1.78 raeburn 3899: } elsif ($disposition eq 'pending') {
3900: my $pendingform;
3901: if ($crstype ne 'official') {
3902: $pendingform = &pending_validation_form($dom,$cnum,$crstype,$now,$token,
3903: $lonhost,$env{'form.cdescr'});
3904: }
3905: if ($pendingform) {
3906: $output .= $pendingform;
3907: } else {
3908: $output .= ¬ification_information($disposition,undef,$dom,$cnum,$now,undef,$postprocess);
3909: }
1.73 raeburn 3910: }
1.16 raeburn 3911: }
1.17 raeburn 3912: if ($validationerror ne '') {
1.44 raeburn 3913: $output .= '<p class="LC_warning">'.&mt('An error occurred validating your request with institutional data sources: [_1].',$validationerror).'</p>';
3914: }
3915: if ($updateresult) {
3916: $output .= $updateresult;
1.17 raeburn 3917: }
1.16 raeburn 3918: }
1.27 raeburn 3919: if ($creationresult ne '') {
3920: return ($creationresult,$output);
3921: } else {
3922: return ($storeresult,$output);
3923: }
1.16 raeburn 3924: }
3925:
1.28 raeburn 3926: sub update_requestors_roles {
3927: my ($dom,$cnum,$crstype,$details,$longroles) = @_;
3928: my $now = time;
3929: my ($active,$future,$numactive,$numfuture,$output);
3930: my $owner = $env{'user.name'}.':'.$env{'user.domain'};
3931: if (ref($details) eq 'HASH') {
3932: if (ref($details->{'personnel'}) eq 'HASH') {
1.41 raeburn 3933: my $ccrole = 'cc';
3934: if ($crstype eq 'community') {
3935: $ccrole = 'co';
3936: }
1.35 raeburn 3937: unless (ref($details->{'personnel'}{$owner}) eq 'HASH') {
3938: $details->{'personnel'}{$owner} = {
1.41 raeburn 3939: 'roles' => [$ccrole],
3940: $ccrole => { 'usec' => [] },
1.35 raeburn 3941: };
3942: }
3943: my @roles;
3944: if (ref($details->{'personnel'}{$owner}{'roles'}) eq 'ARRAY') {
3945: @roles = sort(@{$details->{'personnel'}{$owner}{'roles'}});
1.41 raeburn 3946: unless (grep(/^\Q$ccrole\E$/,@roles)) {
3947: push(@roles,$ccrole);
1.35 raeburn 3948: }
3949: } else {
1.41 raeburn 3950: @roles = ($ccrole);
1.35 raeburn 3951: }
3952: foreach my $role (@roles) {
1.42 raeburn 3953: my $refresh=$env{'user.refresh.time'};
3954: if ($refresh eq '') {
3955: $refresh = $env{'user.login.time'};
3956: }
3957: if ($refresh eq '') {
3958: $refresh = $now;
3959: }
3960: my $start = $refresh-1;
1.35 raeburn 3961: my $end = '0';
3962: if ($role eq 'st') {
3963: if ($details->{'accessstart'} ne '') {
3964: $start = $details->{'accessstart'};
3965: }
3966: if ($details->{'accessend'} ne '') {
3967: $end = $details->{'accessend'};
3968: }
3969: }
3970: my @usecs;
1.41 raeburn 3971: if ($role ne $ccrole) {
1.35 raeburn 3972: if (ref($details->{'personnel'}{$owner}{$role}{'usec'}) eq 'ARRAY') {
3973: @usecs = @{$details->{'personnel'}{$owner}{$role}{'usec'}};
3974: }
3975: }
3976: if ($role eq 'st') {
3977: if (@usecs > 1) {
3978: my $firstsec = $usecs[0];
3979: @usecs = ($firstsec);
3980: }
3981: }
3982: if (@usecs == 0) {
3983: push(@usecs,'');
3984: }
3985: foreach my $usec (@usecs) {
3986: my (%userroles,%newrole,%newgroups,$spec,$area);
3987: my $area = '/'.$dom.'/'.$cnum;
3988: my $spec = $role.'.'.$area;
3989: if ($usec ne '') {
3990: $spec .= '/'.$usec;
3991: $area .= '/'.$usec;
3992: }
3993: if ($role =~ /^cr\//) {
3994: &Apache::lonnet::custom_roleprivs(\%newrole,$role,$dom,
3995: $cnum,$spec,$area);
3996: } else {
3997: &Apache::lonnet::standard_roleprivs(\%newrole,$role,$dom,
3998: $spec,$cnum,$area);
1.28 raeburn 3999: }
1.35 raeburn 4000: &Apache::lonnet::set_userprivs(\%userroles,\%newrole,
4001: \%newgroups);
4002: $userroles{'user.role.'.$spec} = $start.'.'.$end;
4003: &Apache::lonnet::appenv(\%userroles,[$role,'cm']);
4004: if (($end == 0) || ($end > $now)) {
4005: my $showrole = $role;
1.28 raeburn 4006: if ($role =~ /^cr\//) {
1.35 raeburn 4007: $showrole = &Apache::lonnet::plaintext($role,$crstype);
4008: } elsif (ref($longroles) eq 'HASH') {
4009: if ($longroles->{$role} ne '') {
4010: $showrole = $longroles->{$role};
4011: }
1.28 raeburn 4012: }
1.35 raeburn 4013: if ($start <= $now) {
4014: $active .= '<li><a href="/adm/roles?selectrole=1&'.
4015: $spec.'=1">'.$showrole;
4016: if ($usec ne '') {
4017: $active .= ' - '.&mt('section:').' '.$usec;
1.28 raeburn 4018: }
1.35 raeburn 4019: $active .= '</a></li>';
4020: $numactive ++;
4021: } else {
4022: $future .= '<li>'.$showrole;
4023: if ($usec ne '') {
4024: $future .= ' - '.&mt('section:').' '.$usec;
1.28 raeburn 4025: }
1.35 raeburn 4026: $future .= '</li>';
4027: $numfuture ++;
1.28 raeburn 4028: }
4029: }
4030: }
4031: }
4032: }
4033: }
4034: if ($active) {
4035: if ($numactive == 1) {
1.41 raeburn 4036: if ($crstype eq 'Community') {
4037: $output = &mt('Use the following link to enter the community:');
4038: } else {
4039: $output = &mt('Use the following link to enter the course:');
4040: }
1.28 raeburn 4041: } else {
1.41 raeburn 4042: if ($crstype eq 'Community') {
4043: $output = &mt('Use the following links to your new roles to enter the community:');
4044: } else {
4045: $output = &mt('Use the following links to your new roles to enter the course:');
4046: }
1.28 raeburn 4047: }
4048: $output .= ' <ul>'.$active.'</ul><br />';
4049: }
4050: if ($future) {
1.41 raeburn 4051: if ($crstype eq 'Community') {
4052: $output .= &mt('The following community [quant,_1,role] will become available for selection from your [_2]roles page[_3], once the default student access start date - [_4] - has been reached:',$numfuture,'<a href="/adm/roles">','</a>',&Apache::lonlocal::locallocaltime($details->{'accessstart'}))
4053: } else {
4054: $output .= &mt('The following course [quant,_1,role] will become available for selection from your [_2]roles page[_3], once the default student access start date - [_4] - has been reached:',$numfuture,'<a href="/adm/roles">','</a>',&Apache::lonlocal::locallocaltime($details->{'accessstart'}));
4055: }
4056: $output .= ' <ul>'.$future.'</ul>';
1.28 raeburn 4057: }
4058: return $output;
4059: }
4060:
1.16 raeburn 4061: sub notification_information {
1.74 raeburn 4062: my ($disposition,$req_notifylist,$dom,$cnum,$now,$code,$postprocess) = @_;
1.16 raeburn 4063: my %emails = &Apache::loncommon::getemails();
4064: my $address;
4065: if (($emails{'permanentemail'} ne '') || ($emails{'notification'} ne '')) {
4066: $address = $emails{'permanentemail'};
4067: if ($address eq '') {
4068: $address = $emails{'notification'};
4069: }
4070: }
4071: my $output;
4072: if ($disposition eq 'approval') {
4073: $output .= &mt('A message will be sent to your LON-CAPA account when a domain coordinator takes action on your request.').'<br />'.
4074: &mt('To access your LON-CAPA message, go to the Main Menu and click on "Send and Receive Messages".').'<br />';
4075: if ($address ne '') {
4076: $output.= &mt('An e-mail will also be sent to: [_1] when this occurs.',$address).'<br />';
4077: }
4078: if ($req_notifylist) {
4079: my $fullname = &Apache::loncommon::plainname($env{'user.name'},
1.73 raeburn 4080: $env{'user.domain'});
1.16 raeburn 4081: my $sender = $env{'user.name'}.':'.$env{'user.domain'};
1.74 raeburn 4082: &Apache::loncoursequeueadmin::send_selfserve_notification($req_notifylist,"$fullname ($env{'user.name'}:$env{'user.domain'})",
4083: 'undef',$env{'form.cdescr'},$now,'coursereq',$sender);
1.16 raeburn 4084: }
1.73 raeburn 4085: if (ref($postprocess) eq 'HASH') {
4086: if (ref($postprocess->{'queuedmsg'}) eq 'ARRAY') {
4087: if (scalar(@{$postprocess->{'queuedmsg'}}) > 0) {
4088: my $recipient = $env{'user.name'}.':'.$env{'user.domain'};
4089: my $sender = $recipient;
4090: my $addmsg = [];
4091: foreach my $item (@{$postprocess->{'queuedmsg'}}) {
4092: if (ref($item) eq 'HASH') {
4093: if ($item->{'mt'} ne '') {
4094: push(@{$addmsg},$item);
4095: }
4096: }
4097: }
4098: if (scalar(@{$addmsg}) > 0) {
1.74 raeburn 4099: &Apache::loncoursequeueadmin::send_selfserve_notification($recipient,$addmsg,undef,
1.73 raeburn 4100: $env{'form.cdescr'},$now,
1.77 raeburn 4101: 'queuedcrsreq',$sender);
1.73 raeburn 4102: }
4103: }
4104: }
4105: if ($postprocess->{'queuedweb'}) {
4106: $output .= $postprocess->{'queuedweb'};
4107: }
4108: }
1.17 raeburn 4109: } elsif ($disposition eq 'pending') {
1.78 raeburn 4110: my $pending_default = '<div class="LC_info">'.
1.16 raeburn 4111: &mt('Your request has been placed in a queue pending administrative action.').'<br />'.
4112: &mt("Usually this means that your institution's information systems do not list you among the instructional personnel for this course.").'<br />'.
4113: &mt('The list of instructional personnel for the course will be automatically checked daily, and once you are listed the request will be processed.').
1.78 raeburn 4114: '</div>';
4115: if (ref($postprocess) eq 'HASH') {
4116: if ($postprocess->{'pendingweb'}) {
4117: $output .= $postprocess->{'pendingweb'};
4118: } else {
4119: $output .= $pending_default;
4120: }
4121: } else {
4122: $output .= $pending_default;
4123: }
1.73 raeburn 4124: } elsif ($disposition eq 'created') {
4125: if (($code) || ((ref($postprocess) eq 'HASH') &&
4126: ((ref($postprocess->{'createdmsg'}) eq 'ARRAY') || ($postprocess->{'createdweb'})))) {
4127: my $addmsg = [];
4128: my $recipient = $env{'user.name'}.':'.$env{'user.domain'};
4129: my $sender = $recipient;
4130: if ($code) {
4131: push(@{$addmsg},{
1.74 raeburn 4132: mt => 'Students can automatically select your course: "[_1]" by entering this code: [_2]',
4133: args => [$env{'form.cdescr'},$code],
1.73 raeburn 4134: });
4135: $output .= '<p>'.
4136: &mt('Students can automatically select your course by entering this code: [_1].','<b>'.$code.'</b>').
4137: '<br />'.
4138: &mt('A message has been sent to your LON-CAPA account with this information.');
4139: if ($address ne '') {
4140: $output.= '<br />'.&mt('An e-mail has also been sent to: [_1] with this code.',$address);
4141: }
4142: $output .= '</p>';
4143: }
4144: if (ref($postprocess) eq 'HASH') {
4145: if (ref($postprocess->{'createdmsg'}) eq 'ARRAY') {
4146: foreach my $item (@{$postprocess->{'createdmsg'}}) {
4147: if (ref($item) eq 'HASH') {
4148: if ($item->{'mt'} ne '') {
4149: push(@{$addmsg},$item);
4150: }
4151: }
4152: }
4153: }
4154: if ($postprocess->{'createdweb'}) {
4155: $output .= $postprocess->{'createdweb'}
4156: }
4157: }
4158: if (scalar(@{$addmsg}) > 0) {
1.77 raeburn 4159: my $type = 'createdcrsreq';
1.73 raeburn 4160: if ($code) {
4161: $type = 'uniquecode';
4162: }
1.74 raeburn 4163: &Apache::loncoursequeueadmin::send_selfserve_notification($recipient,$addmsg,$dom.'_'.$cnum,$env{'form.cdescr'},
1.73 raeburn 4164: $now,$type,$sender);
4165: }
1.70 raeburn 4166: }
1.17 raeburn 4167: } else {
4168: $output .= '<div class="LC_warning">'.
1.44 raeburn 4169: &mt('Your request status is: [_1].',$disposition).
4170: '</div>';
1.8 raeburn 4171: }
4172: return $output;
4173: }
4174:
1.78 raeburn 4175: sub pending_validation_form {
4176: my ($cdom,$cnum,$crstype,$now,$token,$lonhost,$cdesc) = @_;
4177: my $output;
4178: my %postvalues = (
4179: 'owner' => $env{'user.name'}.':'.$env{'user.domain'},
4180: 'course' => $cdom.'_'.$cnum,
4181: 'coursetype' => $crstype,
4182: );
4183: my %domconfig = &Apache::lonnet::get_dom('configuration',['requestcourses'],$cdom);
4184:
4185: if (ref($domconfig{'requestcourses'}) eq 'HASH') {
4186: my ($url,$buttontext,$code,@fields);
4187: if (ref($domconfig{'requestcourses'}{'validation'}) eq 'HASH') {
4188: $postvalues{'description'} = $cdesc;
4189: $url = $domconfig{'requestcourses'}{'validation'}{'url'};
4190: if (ref($domconfig{'requestcourses'}{'validation'}{'fields'}) eq 'ARRAY') {
4191: @fields = @{$domconfig{'requestcourses'}{'validation'}{'fields'}};
4192: }
4193: $buttontext = $domconfig{'requestcourses'}{'validation'}{'button'};
4194: $output .= $domconfig{'requestcourses'}{'validation'}{'markup'};
4195: if (($url =~ m{^(https?\://|/)}) && (@fields > 0)) {
4196: $output .= '<form name="crsreqvalidation" action="'.$url.'" method="post">'."\n";
4197: foreach my $field (@fields) {
4198: if ($postvalues{$field}) {
4199: $output .= '<input type="hidden" name="'.$field.'" value="'.$postvalues{$field}.'" />'."\n";
4200: }
4201: }
4202: if ($buttontext eq '') {
4203: if ($crstype eq 'community') {
4204: $buttontext = &mt('Create community');
4205: } else {
4206: $buttontext = &mt('Create course');
4207: }
4208: }
4209: my $protocol = $Apache::lonnet::protocol{$lonhost};
4210: $protocol = 'http' if ($protocol ne 'https');
4211: my $crscreator = $protocol.'://'.&Apache::lonnet::hostname($lonhost).'/cgi-bin/createpending.pl';
4212: $output .= '<input type="hidden" name="crscreator" value="'.$crscreator.'" />'."\n".
4213: '<input type="hidden" name="token" value="'.$token.'" />'."\n".
4214: '<input type="submit" name="validate" value="'.$buttontext.'" />'."\n".
4215: '</form>'."\n";
4216: }
4217: }
4218: }
4219: return $output;
4220: }
4221:
1.8 raeburn 4222: sub check_autolimit {
1.10 raeburn 4223: my ($uname,$udom,$dom,$crstype,$limit,$message) = @_;
4224: my %crsroles = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},
1.41 raeburn 4225: 'userroles',['active','future'],['cc','co'],[$dom]);
1.37 raeburn 4226: my ($types,$typename) = &Apache::loncommon::course_types();
1.10 raeburn 4227: my %requests = &Apache::lonnet::dumpstore('courserequests',$udom,$uname);
1.41 raeburn 4228: my $count = 0;
1.10 raeburn 4229: foreach my $key (keys(%requests)) {
4230: my ($cdom,$cnum) = split('_',$key);
1.41 raeburn 4231: if (ref($requests{$key}) eq 'HASH') {
4232: next if ($requests{$key}{'crstype'} ne $crstype);
4233: if (($crstype eq 'community') &&
4234: (exists($crsroles{$cnum.':'.$cdom.':co'}))) {
4235: $count ++;
1.69 raeburn 4236: } elsif ((($crstype eq 'official') || ($crstype eq 'unofficial') || ($crstype eq 'textbook')) &&
1.41 raeburn 4237: (exists($crsroles{$cnum.':'.$cdom.':cc'}))) {
4238: $count ++;
1.10 raeburn 4239: }
4240: }
4241: }
1.41 raeburn 4242: if ($count < $limit) {
1.10 raeburn 4243: return 'process';
4244: } else {
4245: if (ref($typename) eq 'HASH') {
1.41 raeburn 4246: if ($crstype eq 'community') {
4247: $$message = &mt('Your request has not been processed because you have reached the limit for the number of communities.').
4248: '<br />'.&mt("Your limit is [_1].",$limit);
4249: } else {
4250: $$message = &mt('Your request has not been processed because you have reached the limit for the number of courses of this type.').
4251: '<br />'.&mt("Your $typename->{$crstype} limit is [_1].",$limit);
4252: }
1.10 raeburn 4253: }
4254: return 'rejected';
4255: }
1.1 raeburn 4256: return;
4257: }
4258:
1.2 raeburn 4259: sub retrieve_settings {
1.26 raeburn 4260: my ($dom,$cnum,$udom,$uname) = @_;
4261: if ($udom eq '' || $uname eq '') {
4262: $udom = $env{'user.domain'};
4263: $uname = $env{'user.name'};
4264: }
4265: my ($result,%reqinfo) = &get_request_settings($dom,$cnum,$udom,$uname);
1.16 raeburn 4266: if ($result eq 'ok') {
1.26 raeburn 4267: if (($udom eq $reqinfo{'domain'}) && ($uname eq $reqinfo{'owner'})) {
1.16 raeburn 4268: $env{'form.chome'} = $reqinfo{'coursehome'};
4269: $env{'form.cdescr'} = $reqinfo{'cdescr'};
4270: $env{'form.crstype'} = $reqinfo{'crstype'};
4271: &generate_date_items($reqinfo{'accessstart'},'accessstart');
4272: &generate_date_items($reqinfo{'accessend'},'accessend');
4273: if ($reqinfo{'accessend'} == 0) {
4274: $env{'form.no_end_date'} = 1;
4275: }
4276: if (($reqinfo{'crstype'} eq 'official') && (&Apache::lonnet::auto_run('',$dom))) {
4277: &generate_date_items($reqinfo{'enrollstart'},'enrollstart');
4278: &generate_date_items($reqinfo{'enrollend'},'enrollend');
4279: }
4280: $env{'form.clonecrs'} = $reqinfo{'clonecrs'};
4281: $env{'form.clonedom'} = $reqinfo{'clonedom'};
1.55 raeburn 4282: if (($reqinfo{'clonecrs'} ne '') && ($reqinfo{'clonedom'} ne '')) {
4283: $env{'form.cloning'} = 1;
4284: }
1.16 raeburn 4285: $env{'form.datemode'} = $reqinfo{'datemode'};
4286: $env{'form.dateshift'} = $reqinfo{'dateshift'};
1.59 raeburn 4287: if ($reqinfo{'crstype'} eq 'official') {
4288: $env{'form.autoadds'} = $reqinfo{'autoadds'};
4289: $env{'form.autodrops'} = $reqinfo{'autodrops'};
4290: if ($reqinfo{'instcode'} ne '') {
4291: $env{'form.sectotal'} = $reqinfo{'sectotal'};
4292: $env{'form.crosslisttotal'} = $reqinfo{'crosslisttotal'};
4293: $env{'form.instcode'} = $reqinfo{'instcode'};
4294: my $crscode = {
4295: $cnum => $reqinfo{'instcode'},
4296: };
4297: &extract_instcode($dom,'instcode',$crscode,$cnum);
1.66 raeburn 4298: (undef,undef,my $instcredits) =
4299: &Apache::lonnet::auto_validate_instcode(undef,$dom,
4300: $reqinfo{'instcode'});
4301: if ($instcredits ne $reqinfo{'defaultcredits'}) {
4302: $env{'form.coursecredits'} = $reqinfo{'defaultcredits'};
4303: }
1.59 raeburn 4304: }
1.69 raeburn 4305: } elsif (($reqinfo{'crstype'} eq 'unofficial') || ($reqinfo{'crstype'} eq 'textbook')) {
1.66 raeburn 4306: $env{'form.coursecredits'} = $reqinfo{'defaultcredits'};
1.16 raeburn 4307: }
4308: my @currsec;
4309: if (ref($reqinfo{'sections'}) eq 'HASH') {
4310: foreach my $i (sort(keys(%{$reqinfo{'sections'}}))) {
4311: if (ref($reqinfo{'sections'}{$i}) eq 'HASH') {
1.24 raeburn 4312: my $sec = $reqinfo{'sections'}{$i}{'inst'};
1.16 raeburn 4313: $env{'form.secnum_'.$i} = $sec;
1.24 raeburn 4314: $env{'form.sec_'.$i} = '1';
1.16 raeburn 4315: if (!grep(/^\Q$sec\E$/,@currsec)) {
4316: push(@currsec,$sec);
4317: }
4318: $env{'form.loncapasec_'.$i} = $reqinfo{'sections'}{$i}{'loncapa'};
4319: }
4320: }
4321: }
1.24 raeburn 4322: if (ref($reqinfo{'crosslists'}) eq 'HASH') {
4323: foreach my $i (sort(keys(%{$reqinfo{'crosslists'}}))) {
4324: if (ref($reqinfo{'crosslists'}{$i}) eq 'HASH') {
4325: $env{'form.crosslist_'.$i} = '1';
4326: $env{'form.crosslist_'.$i.'_instsec'} = $reqinfo{'crosslists'}{$i}{'instsec'};
4327: $env{'form.crosslist_'.$i.'_lcsec'} = $reqinfo{'crosslists'}{$i}{'loncapa'};
4328: if ($reqinfo{'crosslists'}{$i}{'instcode'} ne '') {
4329: my $key = $cnum.$i;
4330: my $crscode = {
4331: $key => $reqinfo{'crosslists'}{$i}{'instcode'},
4332: };
4333: &extract_instcode($dom,'crosslist',$crscode,$key,$i);
4334: }
1.16 raeburn 4335: }
4336: }
4337: }
4338: if (ref($reqinfo{'personnel'}) eq 'HASH') {
4339: my $i = 0;
4340: foreach my $user (sort(keys(%{$reqinfo{'personnel'}}))) {
4341: my ($uname,$udom) = split(':',$user);
4342: if (ref($reqinfo{'personnel'}{$user}) eq 'HASH') {
4343: if (ref($reqinfo{'personnel'}{$user}{'roles'}) eq 'ARRAY') {
4344: foreach my $role (sort(@{$reqinfo{'personnel'}{$user}{'roles'}})) {
4345: $env{'form.person_'.$i.'_role'} = $role;
4346: $env{'form.person_'.$i.'_firstname'} = $reqinfo{'personnel'}{$user}{'firstname'};
4347: $env{'form.person_'.$i.'_lastname'} = $reqinfo{'personnel'}{$user}{'lastname'}; ;
4348: $env{'form.person_'.$i.'_emailaddr'} = $reqinfo{'personnel'}{$user}{'emailaddr'};
4349: $env{'form.person_'.$i.'_uname'} = $uname;
4350: $env{'form.person_'.$i.'_dom'} = $udom;
4351: if (ref($reqinfo{'personnel'}{$user}{$role}) eq 'HASH') {
4352: if (ref($reqinfo{'personnel'}{$user}{$role}{'usec'}) eq 'ARRAY') {
4353: my @usecs = @{$reqinfo{'personnel'}{$user}{$role}{'usec'}};
4354: my @newsecs;
4355: if (@usecs > 0) {
4356: foreach my $sec (@usecs) {
4357: if (grep(/^\Q$sec\E/,@currsec)) {
4358: $env{'form.person_'.$i.'_sec'} = $sec;
4359: } else {
1.20 raeburn 4360: push(@newsecs,$sec);
1.16 raeburn 4361: }
4362: }
4363: }
4364: if (@newsecs > 0) {
4365: $env{'form.person_'.$i.'_newsec'} = join(',',@newsecs);
4366: }
4367: }
4368: }
4369: $i ++;
4370: }
4371: }
4372: }
4373: }
4374: $env{'form.persontotal'} = $i;
4375: }
4376: }
4377: }
4378: return $result;
4379: }
4380:
4381: sub get_request_settings {
1.26 raeburn 4382: my ($dom,$cnum,$udom,$uname) = @_;
1.16 raeburn 4383: my $requestkey = $dom.'_'.$cnum;
4384: my ($result,%reqinfo);
4385: if ($requestkey =~ /^($match_domain)_($match_courseid)$/) {
1.26 raeburn 4386: my %history = &Apache::lonnet::restore($requestkey,'courserequests',$udom,$uname);
1.16 raeburn 4387: my $disposition = $history{'disposition'};
4388: if (($disposition eq 'approval') || ($disposition eq 'pending')) {
4389: if (ref($history{'details'}) eq 'HASH') {
4390: %reqinfo = %{$history{'details'}};
4391: $result = 'ok';
4392: } else {
4393: $result = 'nothash';
4394: }
4395: } else {
4396: $result = 'notqueued';
4397: }
4398: } else {
4399: $result = 'invalid';
4400: }
4401: return ($result,%reqinfo);
4402: }
1.2 raeburn 4403:
1.16 raeburn 4404: sub extract_instcode {
1.24 raeburn 4405: my ($cdom,$element,$crscode,$crskey,$counter) = @_;
1.16 raeburn 4406: my (%codes,@codetitles,%cat_titles,%cat_order);
1.24 raeburn 4407: if (&Apache::lonnet::auto_instcode_format('requests',$cdom,$crscode,\%codes,
4408: \@codetitles,\%cat_titles,
4409: \%cat_order) eq 'ok') {
4410: if (ref($codes{$crskey}) eq 'HASH') {
1.16 raeburn 4411: if (@codetitles > 0) {
4412: my $sel = $element;
4413: if ($element eq 'crosslist') {
4414: $sel .= '_'.$counter;
4415: }
4416: foreach my $title (@codetitles) {
1.24 raeburn 4417: $env{'form.'.$sel.'_'.$title} = $codes{$crskey}{$title};
1.16 raeburn 4418: }
4419: }
4420: }
4421: }
4422: return;
1.2 raeburn 4423: }
4424:
1.16 raeburn 4425: sub generate_date_items {
4426: my ($currentval,$item) = @_;
4427: if ($currentval =~ /\d+/) {
4428: my ($tzname,$sec,$min,$hour,$mday,$month,$year) =
4429: &Apache::lonhtmlcommon::get_timedates($currentval);
4430: $env{'form.'.$item.'_day'} = $mday;
4431: $env{'form.'.$item.'_month'} = $month+1;
4432: $env{'form.'.$item.'_year'} = $year;
4433: }
4434: return;
1.2 raeburn 4435: }
4436:
1.72 raeburn 4437: sub print_textbook_form {
1.73 raeburn 4438: my ($r,$dom,$incdoms,$domdefs,$settings,$can_request) = @_;
1.81 raeburn 4439: my (%prefab,%ordered,%numprefab);
1.72 raeburn 4440: my $crstype = 'textbook';
4441: #
1.81 raeburn 4442: # Retrieve list of prefabricated courses (textbook courses and templates) cloneable by user
1.72 raeburn 4443: #
1.81 raeburn 4444: foreach my $type ('textbooks','templates') {
4445: $numprefab{$type} = 0;
4446: if (ref($settings) eq 'HASH') {
4447: $prefab{$type} = $settings->{$type};
4448: if (ref($prefab{$type}) eq 'HASH') {
4449: foreach my $item (keys(%{$prefab{$type}})) {
1.72 raeburn 4450: my ($clonedom,$clonecrs) = split(/_/,$item);
1.81 raeburn 4451: if (ref($prefab{$type}{$item}) eq 'HASH') {
4452: if (&Apache::loncoursequeueadmin::can_clone_course($env{'user.name'},
4453: $env{'user.domain'},$clonecrs,$clonedom,$crstype)) {
4454:
4455: my $num = $prefab{$type}{$item}{'order'};
4456: $ordered{$type}{$num} = $item;
4457: $numprefab{$type} ++;
4458: }
1.72 raeburn 4459: }
4460: }
4461: }
4462: }
4463: }
4464:
4465: #
4466: # Check if domain has multiple library servers
4467: #
4468: my ($home_server_pick,$numlib) =
4469: &Apache::loncommon::home_server_form_item($dom,'chome',
4470: 'default','hide');
4471: if ($numlib > 1) {
4472: $home_server_pick = &mt('Home Server for Course').': '.$home_server_pick.'<br />';
4473: }
4474:
4475: #
4476: # Retrieve information about courses owned by user, or in which user has an active or future
4477: # Course Coordinator role
4478: #
4479: my $numcurrent;
4480: my %cloneable = &Apache::lonnet::courseiddump($dom,'.',1,'.',$env{'user.name'}.':'.$env{'user.domain'},
4481: undef,undef,undef,'Course');
4482: my %ccroles = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},'userroles',
4483: ['active','future'],['cc']);
4484: foreach my $role (keys(%ccroles)) {
4485: my ($cnum,$cdom,$rest) = split(/:/,$role,3);
4486: unless (exists($cloneable{$cdom.'_'.$cnum})) {
4487: my %courseinfo = &Apache::lonnet::coursedescription($cdom.'_'.$cnum,{'one_time' => 1});
4488: $cloneable{$cdom.'_'.$cnum} = \%courseinfo;
4489: }
4490: }
4491:
4492: my $numcurrent = scalar(keys(%cloneable));
4493:
1.81 raeburn 4494: my $jscript = &textbook_request_javascript(\%numprefab,$numcurrent);
1.72 raeburn 4495: my %loaditems;
4496: $loaditems{'onload'} = 'javascript:uncheckAllRadio();';
4497: $r->print(&header('Course Request',$jscript,\%loaditems));
4498:
1.73 raeburn 4499: if (ref($can_request) eq 'HASH') {
4500: unless ((scalar(keys(%{$can_request})) == 1) && ($can_request->{'textbook'})) {
4501: &Apache::lonhtmlcommon::add_breadcrumb(
4502: { href => '/adm/requestcourse',
4503: text => 'Pick action',
4504: });
4505: }
4506: }
1.72 raeburn 4507: &Apache::lonhtmlcommon::add_breadcrumb({text=>'Course Request'});
4508: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests'));
4509:
1.73 raeburn 4510: &startContentScreen($r,'textbookrequests');
1.72 raeburn 4511: #
4512: # Show domain selector form, if required.
4513: #
4514: if (@{$incdoms} > 1) {
4515: my $onchange = 'this.form.submit()';
4516: $r->print('<form name="domforcourse" method="post" action="/adm/requestcourse">'.
4517: '<div><fieldset><legend>'.&mt('Domain').'</legend>'.
4518: &Apache::loncommon::select_dom_form($dom,'showdom','',1,$onchange,$incdoms).
4519: '</fieldset></form>');
4520: }
4521:
4522: #
4523: # Course request form
4524: #
4525:
4526: #
4527: # Course Title
4528: #
4529: $r->print('<form name="requestcourse" method="post" action="/adm/requestcourse" onsubmit="return validTextbookReq();">'.
4530: '<div>'.
4531: '<fieldset>'.
4532: '<legend>'.&mt('Course Information').'</legend>'.
4533: '<span class="LC_nobreak">'.&mt('Title').': '.
4534: '<input type="text" size="60" name="cdescr" value="" /></span><br />'.
4535: $home_server_pick.'<br /></fieldset>'.
4536: '</div>');
4537:
4538: #
4539: # Content source selection, if more than one available
4540: #
4541: if (keys(%cloneable) || keys(%ordered)) {
4542: $r->print('<div>'.
4543: '<fieldset><legend>'.&mt('Course Content').'</legend>');
4544: if (keys(%ordered)) {
1.81 raeburn 4545: if (ref($ordered{'textbooks'}) eq 'HASH') {
4546: $r->print('<span class="LC_nobreak"><label>'.
4547: '<input type="radio" name="cloning" value="textbook" onclick="javascript:cloneChoice();" />'.
4548: &mt('Load textbook content').'</span>'.(' 'x2).' ');
4549: }
4550: if (ref($ordered{'templates'}) eq 'HASH') {
4551: $r->print('<span class="LC_nobreak"><label>'.
4552: '<input type="radio" name="cloning" value="template" onclick="javascript:cloneChoice();" />'.
1.83 raeburn 4553: &mt('Load pre-existing template').'</span>'.(' 'x2).' ');
1.81 raeburn 4554: }
1.72 raeburn 4555: }
4556: if (keys(%cloneable)) {
4557: $r->print('<span class="LC_nobreak"><label>'.
4558: '<input type="radio" name="cloning" value="existing" onclick="javascript:cloneChoice();" />'.
4559: &mt('Copy one of your courses').'</label></span>'.(' 'x2).' ');
4560: }
4561: $r->print('<span class="LC_nobreak"><label>'.
4562: '<input type="radio" name="cloning" value="none" checked="checked" onclick="javascript:cloneChoice();" />'.
4563: &mt('Empty course shell').'</label></span>');
4564: } else {
4565: $r->print('<input type="hidden" name="cloning" value="none" />');
4566: }
4567:
4568: #
4569: # Table of cloneable textbook courses
4570: #
4571: if (keys(%ordered)) {
1.81 raeburn 4572: foreach my $type ('textbooks','templates') {
4573: my $divid = 'showtextbook';
4574: my $radioid = 'book';
4575: if ($type eq 'templates') {
4576: $divid = 'showtemplate';
4577: $radioid = 'template';
4578: }
4579: if (ref($ordered{$type}) eq 'HASH') {
4580: $r->print('<div id="'.$divid.'" style="display:none">'.
4581: &Apache::loncommon::start_data_table().
4582: &Apache::loncommon::start_data_table_header_row().
4583: '<th>'.&mt('Title').'</th>');
4584: if ($type eq 'textbooks') {
4585: $r->print('<th>'.&mt('Author(s)').'</th>');
4586: }
4587: $r->print('<th>'.&mt('Subject').'</th>');
4588: if ($type eq 'textbooks') {
1.82 raeburn 4589: $r->print('<th>'.&mt('Publisher').'</th>'.
4590: '<th>'.&mt('Book').'</th>');
1.81 raeburn 4591: }
4592: $r->print(&Apache::loncommon::end_data_table_header_row());
4593: my @items = sort { $a <=> $b } keys(%{$ordered{$type}});
4594: foreach my $num (@items) {
4595: my $item = $ordered{$type}{$num};
4596: my $cleantitle=&HTML::Entities::encode($prefab{$type}{$item}{'title'},'<>&"');
4597: $cleantitle=~s/'/\\'/g;
4598: $cleantitle =~ s/^\s+//;
4599: $r->print(&Apache::loncommon::start_data_table_row().
4600: '<td><label><input type="radio" name="'.$radioid.'" value="'.$item.'" />'.
4601: $cleantitle.'</label></td>');
4602: if ($type eq 'textbooks') {
4603: $r->print('<td>'.$prefab{$type}{$item}{'author'}.'</td>');
4604: }
4605: $r->print('<td>'.$prefab{$type}{$item}{'subject'}.'</td>');
4606: if ($type eq 'textbooks') {
1.82 raeburn 4607: $r->print('<td>'.$prefab{$type}{$item}{'publisher'}.'</td>'.
4608: '<td><img border="0" src="'.$prefab{$type}{$item}{'image'}.
1.81 raeburn 4609: '" alt="'.$cleantitle.'" /></td>');
4610: }
4611: $r->print(&Apache::loncommon::end_data_table_row());
4612: }
4613: $r->print(&Apache::loncommon::end_data_table().
4614: '</div>');
4615: }
1.72 raeburn 4616: }
4617: }
4618:
4619: #
4620: # Table of user's current courses (owner and/or course coordinator)
4621: #
4622: if (keys(%cloneable)) {
4623: my %lt = &clone_text();
4624: $r->print('<div id="showexisting" style="display:none">'.
4625: &Apache::loncommon::start_data_table().
4626: &Apache::loncommon::start_data_table_header_row().
4627: '<th>'.&mt('Title').'</th>'.
4628: '<th>'.&mt('Owner/co-owner(s)').'</th>'.
4629: &Apache::loncommon::end_data_table_header_row());
4630: my %allownernames;
4631: my %sortbytitle;
4632: foreach my $cid (sort(keys(%cloneable))) {
4633: if (ref($cloneable{$cid}) eq 'HASH') {
4634: my $cdesc = $cloneable{$cid}{'description'};
4635: $cdesc =~ s/`/'/g;
4636: if ($cdesc ne '') {
4637: push(@{$sortbytitle{$cdesc}},$cid);
4638: }
4639: }
4640: }
4641: foreach my $title (sort(keys(%sortbytitle))) {
4642: if (ref($sortbytitle{$title}) eq 'ARRAY') {
4643: foreach my $cid (sort(@{$sortbytitle{$title}})) {
4644: my $cleantitle=&HTML::Entities::encode($title,'<>&"');
4645: $cleantitle=~s/'/\\'/g;
4646: $cleantitle =~ s/^\s+//;
4647: my ($namestr,@owners,%ownernames);
4648: my $singleowner = $cloneable{$cid}{'internal.courseowner'};
4649: push(@owners,$singleowner);
4650: if ($cloneable{$cid}{'co-owners'} ne '') {
4651: foreach my $item (split(/,/,$cloneable{$cid}{'internal.co-owners'})) {
4652: push(@owners,$item);
4653: }
4654: }
4655: foreach my $owner (@owners) {
4656: my ($ownername,$ownerdom);
4657: if ($owner =~ /:/) {
4658: ($ownername,$ownerdom) = split(/:/,$owner);
4659: } else {
4660: $ownername = $owner;
4661: if ($owner ne '') {
4662: $ownerdom = $dom;
4663: }
4664: }
4665: if ($ownername ne '' && $ownerdom ne '') {
4666: if (exists($allownernames{$ownername.':'.$ownerdom})) {
4667: $ownernames{$ownername.':'.$ownerdom} = $allownernames{$ownername.':'.$ownerdom};
4668: } else {
4669: my %namehash=&Apache::loncommon::getnames($ownername,$ownerdom);
4670: $ownernames{$ownername.':'.$ownerdom} = \%namehash;
4671: $allownernames{$ownername.':'.$ownerdom} = $ownernames{$ownername.':'.$ownerdom};
4672: }
4673: }
4674: }
4675: my @lastnames;
4676: foreach my $owner (keys(%ownernames)) {
4677: if (ref($ownernames{$owner}) eq 'HASH') {
4678: push(@lastnames,$ownernames{$owner}{'lastname'});
4679: }
4680: }
4681: if (@lastnames) {
4682: $namestr = join(', ',sort(@lastnames));
4683: }
4684: $r->print(&Apache::loncommon::start_data_table_row().
4685: '<td><label><input type="radio" name="owned" value="'.$cid.'" />'.
4686: ' '.$cleantitle.'</label></td>'.
4687: '<td>'.$namestr.'</td>'.
4688: &Apache::loncommon::end_data_table_row());
4689: }
4690: }
4691: }
4692: $r->print(&Apache::loncommon::end_data_table().
4693: '<p><input type="radio" name="datemode" value="delete" /> '.$lt{'ncd'}.
4694: '</label><br /><label>'.
4695: '<input type="radio" name="datemode" value="preserve" /> '.$lt{'prd'}.
4696: '</label><br /><label>'.
4697: '<input type="radio" name="datemode" value="shift" checked="checked" /> '.
4698: $lt{'shd'}.'</label>'.
4699: '<input type="text" size="5" name="dateshift" value="365" />'.
4700: '</div>');
4701: }
4702: #
4703: # End of content selector
4704: #
4705: if (keys(%cloneable) || keys(%ordered)) {
4706: $r->print('</fieldset></div>');
4707: }
4708:
4709: my %accesstitles = (
4710: 'start' => 'Default start access',
4711: 'end' => 'Default end access',
4712: );
4713: my %help_item = (
4714: start => 'Course_Request_Access_Start',
4715: end => 'Course_Request_Access_End',
4716: );
4717: my $starttime = time;
4718: my $endtime = time+(6*30*24*60*60); # 6 months from now, approx
4719: my $startform = &Apache::lonhtmlcommon::date_setter('requestcourse','accessstart',
4720: $starttime,'','','',1,'','','',1);
4721: my $endform = &Apache::lonhtmlcommon::date_setter('requestcourse','accessend',
4722: $endtime,'','','',1,'','','',1);
4723: #
4724: # Set default start and end dates for student access
4725: #
4726: $r->print('<div>'.
4727: '<fieldset><legend>'.&mt('Student Access Dates').'</legend>'.
4728: &Apache::loncommon::help_open_topic($help_item{'start'}).
4729: ' '.&mt($accesstitles{'start'}).$startform.'<br />'.
4730: &Apache::loncommon::help_open_topic($help_item{'end'}).
4731: ' '.&mt($accesstitles{'end'}).$endform.'<br /></div>');
4732:
4733: #
1.73 raeburn 4734: # Display any custom fields for this course type
4735: #
4736: my $fullname = &Apache::loncommon::plainname($env{'user.name'},
4737: $env{'user.domain'});
4738: my $postprocess = &Apache::lonnet::auto_crsreq_update($dom,undef,$crstype,'review',
4739: $env{'user.name'},
4740: $env{'user.domain'},$fullname);
4741: if (ref($postprocess) eq 'HASH') {
4742: if ($postprocess->{'reviewweb'}) {
4743: $r->print($postprocess->{'reviewweb'});
4744: }
4745: }
4746:
4747: #
1.72 raeburn 4748: # Submit button
4749: #
1.73 raeburn 4750: $r->print('<input type="hidden" name="crstype" value="textbook" />'.
4751: '<input type="hidden" name="action" value="process" />'.
1.72 raeburn 4752: '<input type="submit" value="'.&mt('Create course').'" />');
4753:
4754: #
4755: # End request form
4756: #
1.73 raeburn 4757: $r->print('</form>');
4758: &endContentScreen($r).
4759: $r->print(&Apache::loncommon::end_page());
1.72 raeburn 4760: return;
4761: }
4762:
4763: sub process_textbook_request {
1.73 raeburn 4764: my ($r,$dom,$action,$domdefs,$domconfig,$can_request) = @_;
1.72 raeburn 4765: my ($uniquecode,$req_notifylist);
4766: my $crstype = 'textbook';
4767: if (ref($domconfig) eq 'HASH') {
4768: if (ref($domconfig->{'requestcourses'}) eq 'HASH') {
4769: if (ref($domconfig->{'requestcourses'}{'notify'}) eq 'HASH') {
4770: $req_notifylist = $domconfig->{'requestcourses'}{'notify'}{'approval'};
4771: }
4772: if (ref($domconfig->{'requestcourses'}{'uniquecode'}) eq 'HASH') {
4773: $uniquecode = $domconfig->{'requestcourses'}{'uniquecode'}{$crstype};
4774: }
4775: }
4776: }
4777: my $now = time;
4778: my $reqtype = $env{'form.cloning'};
4779: my (@inststatuses,$storeresult,$creationresult);
4780: my $cnum = &Apache::lonnet::generate_coursenum($dom,'Course');
4781: my ($clonefrom,$clonedom,$clonecrs);
4782: if ($reqtype eq 'textbook') {
4783: $clonefrom = $env{'form.book'};
1.81 raeburn 4784: } elsif ($reqtype eq 'template') {
4785: $clonefrom = $env{'form.template'};
1.72 raeburn 4786: } elsif ($reqtype eq 'existing') {
4787: $clonefrom = $env{'form.owned'};
4788: }
4789: my ($accessstart,$accessend) = &dates_from_form('accessstart','accessend');
4790: if ($clonefrom) {
4791: ($clonedom,$clonecrs) = split(/_/,$clonefrom);
4792: if (&Apache::lonnet::homeserver($clonecrs,$clonedom) ne 'no_host') {
4793: my $canclone =
4794: &Apache::loncoursequeueadmin::can_clone_course($env{'user.name'},
4795: $env{'user.domain'},$clonecrs,$clonedom,$crstype);
4796: unless ($canclone) {
4797: undef($clonecrs);
4798: undef($clonedom);
4799: }
4800: } else {
4801: undef($clonecrs);
4802: undef($clonedom);
4803: }
4804: }
1.84 ! raeburn 4805: my $js = &processing_javascript();
! 4806: my $loaditems = {
! 4807: onload => 'javascript:hideProcessing();',
! 4808: };
! 4809: $r->print(&header('Course Creation',$js,$loaditems));
1.72 raeburn 4810:
1.73 raeburn 4811: if (ref($can_request) eq 'HASH') {
4812: unless ((scalar(keys(%{$can_request})) == 1) && ($can_request->{'textbook'})) {
4813: &Apache::lonhtmlcommon::add_breadcrumb(
4814: { href => '/adm/requestcourse',
4815: text => 'Pick action',
4816: });
4817: }
4818: }
1.72 raeburn 4819: &Apache::lonhtmlcommon::add_breadcrumb(
4820: { href => '/adm/requestcourse',
4821: text => "Create Course",
4822: }
4823: );
4824: &Apache::lonhtmlcommon::add_breadcrumb({text=>'Request Processed'});
4825: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests'));
1.73 raeburn 4826: &startContentScreen($r,'textbookrequests');
1.72 raeburn 4827:
4828: my $details = {
4829: owner => $env{'user.name'},
4830: domain => $env{'user.domain'},
4831: cdom => $dom,
4832: cnum => $cnum,
4833: coursehome => $env{'form.chome'},
4834: cdescr => $env{'form.cdescr'},
4835: crstype => $crstype,
4836: uniquecode => $uniquecode,
4837: clonedom => $clonedom,
4838: clonecrs => $clonecrs,
4839: accessstart => $accessstart,
4840: accessend => $accessend,
4841: personnel => {},
4842: };
4843: if ($reqtype eq 'existing') {
4844: $details->{datemode} = $env{'form.datemode'};
4845: $details->{dateshift} = $env{'form.dateshift'};
4846: }
1.78 raeburn 4847: my $lonhost = $r->dir_config('lonHostID');
1.84 ! raeburn 4848: $r->rflush();
! 4849: my ($result,$output) = &process_request($r,$lonhost,$dom,$cnum,$crstype,$now,$details,'',
1.78 raeburn 4850: $req_notifylist,[],$domconfig);
1.72 raeburn 4851: $r->print($output);
4852: if (&Apache::loncoursequeueadmin::author_prompt()) {
4853: &print_author_prompt($r,$action,$cnum,$dom,$crstype,$result);
4854: } elsif ($result eq 'created') {
4855: $r->print('<p><a href="/adm/requestcourse">'.&mt('Create another course').'</a></p>');
4856: }
1.73 raeburn 4857: &endContentScreen($r);
1.72 raeburn 4858: $r->print(&Apache::loncommon::end_page());
4859: }
4860:
4861: sub textbook_request_javascript {
1.81 raeburn 4862: my ($numprefab,$numcurrent) = @_;
4863: return unless (ref($numprefab) eq 'HASH');
4864: return if (!$numprefab->{'textbooks'} && !$numprefab->{'templates'} && !$numcurrent);
1.72 raeburn 4865: my %lt = &Apache::lonlocal::texthash(
4866: choose => 'Please select a content option.',
4867: textbook => 'Please select a textbook, or choose a different option.',
1.81 raeburn 4868: template => 'Please select a template, or choose a different option.',
1.72 raeburn 4869: existing => 'Please select one of your existing courses to copy, or choose a different option.',
4870: title => 'Please enter a course title.',
4871: );
4872: return <<"ENDSCRIPT";
4873: function cloneChoice() {
4874: if (document.requestcourse.cloning) {
4875: var radioLength = document.requestcourse.cloning.length;
4876: if (radioLength == undefined) {
4877: var val = document.requestcourse.cloning.value;
1.81 raeburn 4878: if ((val == 'textbook') || (val == 'template') || (val == 'existing')) {
1.72 raeburn 4879: var elem = document.getElementById('show'+val);
4880: if (document.requestcourse.cloning.checked) {
4881: elem.style.display = 'block';
4882: } else {
4883: uncheckRadio(val);
4884: elem.style.display = 'none';
4885: }
4886: }
4887: } else {
4888: for (var i=0; i<radioLength; i++) {
4889: var val = document.requestcourse.cloning[i].value;
1.81 raeburn 4890: if ((val == 'textbook') || (val == 'template') || (val == 'existing')) {
1.72 raeburn 4891: var elem = document.getElementById('show'+val);
4892: if (document.requestcourse.cloning[i].checked) {
4893: elem.style.display = 'block';
4894: } else {
4895: if (val == 'textbook') {
4896: uncheckRadio('book');
4897: }
1.81 raeburn 4898: if (val == 'template') {
4899: uncheckRadio('template');
4900: }
1.72 raeburn 4901: if (val == 'existing') {
4902: uncheckRadio('owned');
4903: }
4904: elem.style.display = 'none';
4905: }
4906: }
4907: }
4908: }
4909: }
4910: return;
4911: }
4912:
4913: function uncheckRadio(radioGroupName) {
4914: var group = document.getElementsByName(radioGroupName);
4915: var radioLength = group.length;
4916: if (radioLength == undefined) {
4917: group.checked = false;
4918: } else {
4919: for (var i=0; i<radioLength; i++) {
4920: group[i].checked = false;
4921: }
4922: }
4923: return;
4924: }
4925:
4926: function uncheckAllRadio() {
4927: uncheckRadio('cloning');
1.81 raeburn 4928: var numbook = $numprefab->{'textbooks'};
4929: var numtemplate = $numprefab->{'templates'};
1.72 raeburn 4930: var numcurrent = $numcurrent;
4931: if (numbook > 0) {
4932: uncheckRadio('textbook');
4933: }
1.81 raeburn 4934: if (nutemplate > 0) {
4935: uncheckRadio('template');
4936: }m
1.72 raeburn 4937: if (numcurrent > 0) {
4938: uncheckRadio('existing');
4939: }
4940: return;
4941: }
4942:
4943: function validTextbookReq() {
4944: if (document.requestcourse.cloning) {
4945: var cloneChoice = 0;
4946: var radioLength = document.requestcourse.cloning.length;
4947: if (radioLength == undefined) {
4948: if (document.requestcourse.cloning.checked == false) {
4949: alert("$lt{'choose'}");
4950: return false;
4951: } else {
4952: cloneChoice = document.requestcourse.cloning.value;
4953: }
4954: } else {
4955: for (var i=0; i<radioLength; i++) {
4956: if (document.requestcourse.cloning[i].checked) {
4957: cloneChoice = document.requestcourse.cloning[i].value;
4958: break;
4959: }
4960: }
4961: if (cloneChoice == 0) {
4962: alert("$lt{'choose'}");
4963: return false;
4964: }
4965: }
4966: var group;
1.81 raeburn 4967: if ((cloneChoice == 'textbook') || (cloneChoice == 'template') || (cloneChoice == 'existing')) {
1.72 raeburn 4968: var group;
4969: if (cloneChoice == 'textbook') {
4970: group = document.getElementsByName('book');
4971: } else {
1.81 raeburn 4972: if (cloneChoice == 'template') {
4973: group = document.getElementsByName('template');
4974: } else {
4975: group = document.getElementsByName('owned');
4976: }
1.72 raeburn 4977: }
4978: var groupLength = group.length;
4979: var chosen = 0;
4980: if (groupLength == undefined) {
4981: if (group.checked) {
4982: chosen = 1;
4983: }
4984: } else {
4985: for (var j=0; j<groupLength; j++) {
4986: if (group[j].checked) {
4987: chosen = 1;
4988: break;
4989: }
4990: }
4991: }
4992: if (chosen == 0) {
4993: if (cloneChoice == 'textbook') {
4994: alert("$lt{'textbook'}");
4995: } else {
1.81 raeburn 4996: if (cloneChoice == 'template') {
4997: alert("$lt{'template'}");
4998: } else {
4999: alert("$lt{'existing'}");
5000: }
1.72 raeburn 5001: }
5002: return false;
5003: }
5004: }
5005: }
5006: if (document.requestcourse.cdescr.value == '') {
5007: alert("$lt{'title'}");
5008: return false;
5009: }
5010: return true;
5011: }
5012:
5013: ENDSCRIPT
5014:
5015: }
1.73 raeburn 5016:
5017: sub startContentScreen {
5018: my ($r,$mode)=@_;
5019: $r->print("\n".'<ul class="LC_TabContentBigger" id="textbookreq">'."\n");
5020: $r->print('<li'.(($mode eq 'textbookrequests')?' class="active"':'').'><a href="/adm/requestcourse"><b> '.&mt('Request a Course').' </b></a></li>'."\n");
5021: $r->print('<li'.(($mode eq 'textbooklogs')?' class="active"':'').'><a href="/adm/requestcourse?action=log&crstype=textbook&tabs=on"><b> '.&mt('Course Request History').' </b></a></li>'."\n");
5022: $r->print("\n".'</ul>'."\n");
5023: $r->print('<div class="LC_Box" style="clear:both;margin:0;"><div id="mainbox" style="margin:0 0;padding:0 0;"><div class="LC_ContentBox" id="maincontentbox" style="display: block;">');
5024: }
5025:
5026: sub endContentScreen {
5027: my ($r)=@_;
5028: $r->print('</div></div></div>');
5029: }
1.72 raeburn 5030:
1.1 raeburn 5031: 1;
5032:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>