Annotation of loncom/interface/lonrequestcourse.pm, revision 1.7
1.1 raeburn 1: # The LearningOnline Network
2: # Request a course
3: #
1.7 ! raeburn 4: # $Id: lonrequestcourse.pm,v 1.6 2009/08/06 04:01:36 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:
47: =back
48:
49: =cut
50:
51: package Apache::lonrequestcourse;
52:
53: use strict;
54: use Apache::Constants qw(:common :http);
55: use Apache::lonnet;
56: use Apache::loncommon;
57: use Apache::lonlocal;
1.4 raeburn 58: use LONCAPA qw(:DEFAULT :match);
1.1 raeburn 59:
60: sub handler {
61: my ($r) = @_;
62: if ($r->header_only) {
63: &Apache::loncommon::content_type($r,'text/html');
64: $r->send_http_header;
65: return OK;
66: }
67: &Apache::loncommon::content_type($r,'text/html');
68: $r->send_http_header;
69:
1.2 raeburn 70: &Apache::lonhtmlcommon::clear_breadcrumbs();
71: my $dom = &get_course_dom();
1.1 raeburn 72: my $action = $env{'form.action'};
73: my $state = $env{'form.state'};
1.2 raeburn 74:
75: my %stored;
76: my $jscript;
77: if ((defined($state)) && (defined($action))) {
78: my %elements = &form_elements($dom);
79: if (($action eq 'view') && ($state ne 'crstype')) {
80: if (defined($env{'form.request_id'})) {
81: %stored = &retrieve_settings($dom,$env{'form.request_id'});
82: }
83: }
84: my $elementsref = {};
85: if (ref($elements{$action}) eq 'HASH') {
86: if (ref($elements{$action}{$state}) eq 'HASH') {
87: $elementsref = $elements{$action}{$state};
88: }
89: }
90: $jscript = &Apache::lonhtmlcommon::set_form_elements($elementsref,\%stored);
91: }
92:
93: if ($state eq 'personnel') {
94: $jscript .= "\n".&Apache::loncommon::userbrowser_javascript();
95: }
96:
97: my $loaditems = &onload_action($action,$state);
98:
99: my %states;
100: $states{'view'} = ['pick_request','details','review','process'];
101: $states{'log'} = ['filter','display'];
102: $states{'new'} = ['courseinfo','enrollment','personnel','review','process'];
103: if (($action eq 'new') && ($env{'form.crstype'} eq 'official')) {
104: unless ($env{'form.state'} eq 'crstype') {
105: unshift (@{$states{'new'}},'codepick');
106: }
107: }
108:
109: foreach my $key (keys(%states)) {
110: if (ref($states{$key}) eq 'ARRAY') {
111: unshift (@{$states{$key}},'crstype');
112: }
113: }
114:
1.3 raeburn 115: my %trail = (
1.4 raeburn 116: crstype => 'Course Request Action',
117: codepick => 'Category',
1.5 raeburn 118: courseinfo => 'Description',
1.3 raeburn 119: enrollment => 'Enrollment',
120: personnel => 'Personnel',
121: review => 'Review',
122: process => 'Result',
123: );
124:
1.2 raeburn 125: my $page = 0;
1.3 raeburn 126: my $crumb;
1.2 raeburn 127: if (defined($action)) {
128: my $done = 0;
129: my $i=0;
130: if (ref($states{$action}) eq 'ARRAY') {
131: while ($i<@{$states{$action}} && !$done) {
132: if ($states{$action}[$i] eq $state) {
133: $page = $i;
134: $done = 1;
135: }
136: $i++;
137: }
138: }
1.3 raeburn 139: for (my $i=0; $i<@{$states{$action}}; $i++) {
140: if ($state eq $states{$action}[$i]) {
141: &Apache::lonhtmlcommon::add_breadcrumb(
142: {text=>"$trail{$state}"});
143: $crumb = &Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests');
144: last;
145: } else {
146: if (($state eq 'process') && ($i > 0)) {
147: &Apache::lonhtmlcommon::add_breadcrumb(
148: {href=>"javascript:backPage(document.requestcrs,'$states{$action}[0]')",
149: text=>"$trail{$states{$action}[$i]}"});
150: } else {
151: &Apache::lonhtmlcommon::add_breadcrumb(
152: {href=>"javascript:backPage(document.requestcrs,'$states{$action}[$i]')",
153: text=>"$trail{$states{$action}[$i]}"});
154: }
155: }
156: }
157: } else {
158: &Apache::lonhtmlcommon::add_breadcrumb(
159: {text=>'Pick Action'});
160: $crumb = &Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests');
1.2 raeburn 161: }
162:
1.1 raeburn 163: my %can_request;
164: my $canreq = &check_can_request($dom,\%can_request);
165: if ($action eq 'new') {
166: if ($canreq) {
167: if ($state eq 'crstype') {
1.3 raeburn 168: &print_main_menu($r,\%can_request,\%states,$dom,$jscript,$loaditems,
169: $crumb);
1.1 raeburn 170: } else {
1.2 raeburn 171: &request_administration($r,$action,$state,$page,\%states,$dom,$jscript,
1.3 raeburn 172: $loaditems,$crumb);
1.1 raeburn 173: }
174: } else {
1.3 raeburn 175: $r->print(&header('Course Requests').$crumb.
1.1 raeburn 176: '<div class="LC_warning">'.
177: &mt('You do not have privileges to request creation of courses.').
1.2 raeburn 178: '</div>'.&Apache::loncommon::end_page());
1.1 raeburn 179: }
180: } elsif ($action eq 'view') {
1.3 raeburn 181: &print_request_status($jscript,$loaditems,$crumb);
1.1 raeburn 182: } elsif ($action eq 'log') {
1.3 raeburn 183: &print_request_logs($jscript,$loaditems,$crumb);
1.1 raeburn 184: } else {
1.3 raeburn 185: &print_main_menu($r,\%can_request,\%states,$dom,$jscript,'',$crumb);
1.1 raeburn 186: }
187: return OK;
188: }
189:
1.2 raeburn 190: sub header {
191: my ($bodytitle,$jscript,$loaditems,$jsextra) = @_;
192: if ($jscript) {
1.6 raeburn 193: $jscript = '<script type="text/javascript">'."\n".
194: '// <![CDATA['."\n".
195: $jscript."\n".'// ]]>'."\n".'</script>'."\n";
1.2 raeburn 196: }
197: if ($loaditems) {
1.3 raeburn 198: $loaditems = {'add_entries' => $loaditems,};
199: return &Apache::loncommon::start_page($bodytitle,$jscript.$jsextra,$loaditems);
200: } else {
201: return &Apache::loncommon::start_page($bodytitle,$jscript.$jsextra);
202: }
1.2 raeburn 203: }
204:
205: sub form_elements {
206: my ($dom) = @_;
207: my %elements =
208: (
209: new => {
210: crstype => {
211: crstype => 'selectbox',
212: action => 'selectbox',
213: },
214: courseinfo => {
215: cdescr => 'text',
216: clonecourse => 'text',
217: clonedomain => 'selectbox',
218: datemode => 'radio',
219: dateshift => 'text',
220: },
221: enrollment => {
222: startaccess_month => 'selectbox',
223: startaccess_hour => 'selectbox',
224: endaccess_month => 'selectbox',
225: endaccess_hour => 'selectbox',
226: startaccess_day => 'text',
227: startaccess_year => 'text',
228: startaccess_minute => 'text',
229: startaccess_second => 'text',
230: endaccess_day => 'text',
231: endaccess_year => 'text',
232: endaccess_minute => 'text',
233: endaccess_second => 'text',
234: no_end_date => 'checkbox',
235: },
236: personnel => {
237: persontotal => 'hidden',
238: addperson => 'checkbox',
239: },
240: },
241: view => {
242: crstype => {
243: crstype => 'selectbox',
244: action => 'selectbox',
245: },
246: },
247: );
248: my (@codetitles,%cat_titles,%cat_order,@code_order,$lastitem);
249: &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
250: \%cat_order,\@code_order);
251: my $numtitles = scalar(@codetitles);
252: if ($numtitles) {
253: my %extras;
254: $lastitem = pop(@codetitles);
255: $extras{'instcode_'.$lastitem} = 'text';
256: foreach my $item (@codetitles) {
257: $extras{'instcode_'.$item} = 'selectbox';
258: }
259: $elements{'new'}{'codepick'} = \%extras;
260: }
261: if (&Apache::lonnet::auto_run('',$dom)) {
262: my %extras = (
263: sectotal => 'hidden',
264: startenroll_month => 'selectbox',
265: startenroll_hour => 'selectbox',
266: endenroll_month => 'selectbox',
267: endenroll_hour => 'selectbox',
268: startenroll_day => 'text',
269: startenroll_year => 'text',
270: startenroll_minute => 'text',
271: startenroll_second => 'text',
272: endenroll_day => 'text',
273: endenroll_year => 'text',
274: endenroll_minute => 'text',
275: endenroll_second => 'text',
276: crosslisttotal => 'hidden',
277: addcrosslist => 'checkbox',
278: autoadds => 'radio',
279: autodrops => 'radio',
280: );
281: if ($env{'form.sectotal'} > 0) {
282: for (my $i=0; $i<$env{'form.sectotal'}; $i++) {
283: $extras{'sec_'.$i} = 'checkbox',
284: $extras{'secnum_'.$i} = 'text',
285: $extras{'loncapasec_'.$i} = 'checkbox',
286: }
287: }
288: my $crosslisttotal = $env{'form.crosslisttotal'};
289: if (!defined($crosslisttotal)) {
290: $crosslisttotal = 1;
291: }
292: if ($crosslisttotal > 0) {
293: for (my $i=0; $i<$env{'form.crosslisttotal'}; $i++) {
294: if ($numtitles) {
295: $extras{'crosslist_'.$i.'_'.$lastitem} = 'text';
296: }
297: if (@codetitles > 0) {
298: foreach my $item (@codetitles) {
299: $extras{'crosslist_'.$i.'_'.$item} = 'selectbox';
300: }
301: }
302: $extras{'crosslist_'.$i} = 'checkbox';
303: $extras{'crosslist_'.$i.'_instsec'} = 'text',
304: $extras{'crosslist_'.$i.'_lcsec'} = 'text',
305: }
306: }
307: my %mergedhash = (%{$elements{'new'}{'enrollment'}},%extras);
308: %{$elements{'new'}{'enrollment'}} = %mergedhash;
309: }
310: my %people;
311: my $persontotal = $env{'form.persontotal'};
312: if (!defined($persontotal)) {
313: $persontotal = 1;
314: }
315: for (my $i=0; $i<$persontotal; $i++) {
316: $people{'person_'.$i.'_uname'} = 'text',
317: $people{'person_'.$i.'_dom'} = 'selectbox',
318: $people{'person_'.$i.'_hidedom'} = 'hidden',
319: $people{'person_'.$i.'_first'} = 'text',
320: $people{'person_'.$i.'_last'} = 'text',
321: $people{'person_'.$i.'_email'} = 'text',
322: $people{'person_'.$i.'_role'} = 'selectbox',
323: $people{'person_'.$i.'_sec'} = 'selectbox',
324: $people{'person_'.$i.'_newsec'} = 'text',
325: $people{'person_'.$i.'_sections'} = 'hidden',
326: }
327: my %personnelhash = (%{$elements{'new'}{'personnel'}},%people);
328: %{$elements{'new'}{'personnel'}} = %personnelhash;
329: return %elements;
330: }
331:
332: sub onload_action {
333: my ($action,$state) = @_;
334: my %loaditems;
335: if (($action eq 'new') || ($action eq 'view')) {
336: $loaditems{'onload'} = 'javascript:setFormElements(document.requestcrs)';
337: }
338: return \%loaditems;
339: }
340:
1.1 raeburn 341: sub check_can_request {
342: my ($dom,$can_request) = @_;
343: my $canreq = 0;
1.4 raeburn 344: my ($types,$typename) = &course_types();
345: if ((ref($can_request) eq 'HASH') && (ref($types) eq 'ARRAY')) {
346: foreach my $type (@{$types}) {
1.1 raeburn 347: if (&Apache::lonnet::usertools_access($env{'user.name'},
348: $env{'user.domain'},
349: $type,undef,'requestcourses')) {
350: $canreq ++;
351: if ($dom eq $env{'user.domain'}) {
352: $can_request->{$type} = 1;
353: }
354: }
355: if ($env{'environment.reqcrsotherdom.'.$type} ne '') {
356: my @curr = split(',',$env{'environment.reqcrsotherdom.'.$type});
357: if (@curr > 0) {
358: $canreq ++;
359: unless ($dom eq $env{'user.domain'}) {
360: if (grep(/^\Q$dom\E$/,@curr)) {
361: $can_request->{$type} = 1;
362: }
363: }
364: }
365: }
366: }
367: }
368: return $canreq;
369: }
370:
1.4 raeburn 371: sub course_types {
372: my @types = ('official','unofficial','community');
373: my %typename = (
374: official => 'Official course',
375: unofficial => 'Unofficial course',
376: community => 'Community',
377: );
378: return (\@types,\%typename);
379: }
380:
381:
1.1 raeburn 382: sub print_main_menu {
1.3 raeburn 383: my ($r,$can_request,$states,$dom,$jscript,$loaditems,$crumb) = @_;
1.4 raeburn 384: my ($types,$typename) = &course_types();
1.1 raeburn 385: my $onchange;
386: unless ($env{'form.interface'} eq 'textual') {
387: $onchange = 1;
388: }
389:
1.2 raeburn 390: my $nextstate_setter = "\n";
391: if (ref($states) eq 'HASH') {
392: foreach my $key (keys(%{$states})) {
393: if (ref($states->{$key}) eq 'ARRAY') {
394: $nextstate_setter .=
395: " if (actionchoice == '$key') {
396: nextstate = '".$states->{$key}[1]."';
397: }
398: ";
399: }
400: }
401: }
1.1 raeburn 402:
1.2 raeburn 403: my $js = <<"END";
1.1 raeburn 404:
1.2 raeburn 405: function nextPage(formname) {
406: var crschoice = document.requestcrs.crstype.value;
407: var actionchoice = document.requestcrs.action.value;
408: if (check_can_request(crschoice,actionchoice) == true) {
409: if ((actionchoice == 'new') && (crschoice == 'official')) {
410: nextstate = 'codepick';
411: } else {
412: $nextstate_setter
413: }
1.1 raeburn 414: formname.state.value= nextstate;
415: formname.submit();
416: }
417: return;
418: }
419:
1.2 raeburn 420: function check_can_request(crschoice,actionchoice) {
1.1 raeburn 421: var official = '';
422: var unofficial = '';
423: var community = '';
424: END
425:
426: foreach my $item (keys(%{$can_request})) {
427: $js .= "
428: $item = 1;
429: ";
430: }
431: my %lt = &Apache::lonlocal::texthash(
432: official => 'You are not permitted to request creation of an official course in this domain.',
433: unofficial => 'You are not permitted to request creation of an unofficial course in this domain.',
434: community => 'You are not permitted to request creation of a community this domain.',
435: all => 'You must choose a specific course type when making a new course request.\\nAll types is not allowed.',
436: );
437: $js .= <<END;
438: if (crschoice == 'official') {
439: if (official != 1) {
440: alert("$lt{'official'}");
441: return false;
442: }
443: } else {
444: if (crschoice == 'unofficial') {
445: if (unofficial != 1) {
446: alert("$lt{'unofficial'}");
447: return false;
448: }
449: } else {
450: if (crschoice == 'community') {
451: if (community != 1) {
452: alert("$lt{'community'}");
453: return false;
454: }
455: } else {
456: if (actionchoice == 'new') {
457: alert("$lt{'all'}");
458: return false;
459: }
460: }
461: }
462: }
463: return true;
464: }
465:
466: END
467:
1.3 raeburn 468: $r->print(&header('Course Requests',$js.$jscript,$loaditems).$crumb.
469: '<div>'.
1.1 raeburn 470: '<form name="domforcourse" method="post" action="/adm/requestcourse">'.
471: &Apache::lonhtmlcommon::start_pick_box().
472: &Apache::lonhtmlcommon::row_title('Domain').
473: &Apache::loncommon::select_dom_form($dom,'showdom','',1,$onchange));
474: if (!$onchange) {
475: $r->print(' <input type="submit" name="godom" value="'.
476: &mt('Change').'" />');
477: }
478: $r->print(&Apache::lonhtmlcommon::row_closure(1).
479: &Apache::lonhtmlcommon::end_pick_box().'</form></div>');
480:
1.2 raeburn 481: my $formname = 'requestcrs';
1.1 raeburn 482: my $nexttext = &mt('Next');
483: $r->print('<div><form name="'.$formname.'" method="post" action="/adm/requestcourse">'.
484: &Apache::lonhtmlcommon::start_pick_box().
485: &Apache::lonhtmlcommon::row_title('Action').'
486: <input type="hidden" name="showdom" value="'.$dom.'" />
487: <select size="1" name="action" >
1.2 raeburn 488: <option value="new">'.&mt('New request').'</option>
1.1 raeburn 489: <option value="view">'.&mt('View/Modify/Cancel pending requests').'</option>
490: <option value="log">'.&mt('View request history').'</option>
491: </select>'.
492: &Apache::lonhtmlcommon::row_closure().
493: &Apache::lonhtmlcommon::row_title('Course Type').'
494: <select size="1" name="crstype">
1.4 raeburn 495: <option value="any">'.&mt('All types').'</option>');
496: if ((ref($types) eq 'ARRAY') && (ref($typename) eq 'HASH')) {
497: foreach my $type (@{$types}) {
498: my $selected = '';
499: if ($type eq 'official') {
500: $selected = ' selected="selected"';
501: }
502: $r->print('<option value="'.$type.'"'.$selected.'>'.$typename->{$type}.
503: '</option>'."\n");
504: }
505: }
506: $r->print('</select>
1.1 raeburn 507: <input type="hidden" name="state" value="crstype" />'.
508: &Apache::lonhtmlcommon::row_closure(1).
509: &Apache::lonhtmlcommon::end_pick_box().'<br />
1.2 raeburn 510: <input type="button" name="next" value="'.$nexttext.'" onclick="javascript:nextPage(document.'.$formname.')" />
1.1 raeburn 511: </form></div>');
512: $r->print(&Apache::loncommon::end_page());
513: return;
514: }
515:
516: sub request_administration {
1.3 raeburn 517: my ($r,$action,$state,$page,$states,$dom,$jscript,$loaditems,$crumb) = @_;
1.2 raeburn 518: my $js;
519: if (($action eq 'new') || ($action eq 'view')) {
520: $js = <<END;
1.1 raeburn 521:
522: function nextPage(formname,nextstate) {
523: formname.state.value= nextstate;
524: formname.submit();
525: }
526: function backPage(formname,prevstate) {
527: formname.state.value = prevstate;
528: formname.submit();
529: }
530:
531: END
1.2 raeburn 532: }
533: if ($action eq 'new') {
534: my $jsextra;
1.1 raeburn 535: unless (($state eq 'review') || ($state eq 'process')) {
1.2 raeburn 536: $jsextra = "\n".&Apache::loncommon::coursebrowser_javascript($dom);
1.1 raeburn 537: }
1.3 raeburn 538: $r->print(&header('Request a course',$js.$jscript,$loaditems,$jsextra).$crumb);
1.4 raeburn 539: if ($state eq 'process') {
1.1 raeburn 540: &print_request_outcome($r,$state,$dom);
541: } else {
1.2 raeburn 542: &print_request_form($r,$action,$state,$page,$states,$dom);
1.1 raeburn 543: }
1.2 raeburn 544: } elsif ($action eq 'view') {
1.3 raeburn 545: $r->print(&header('Manage course requests',$js.$jscript,$loaditems).$crumb);
1.1 raeburn 546: } elsif ($action eq 'log') {
1.3 raeburn 547: $r->print(&coursereq_log('View request log',$jscript,$loaditems).$crumb);
1.1 raeburn 548: }
1.2 raeburn 549: $r->print(&Apache::loncommon::end_page());
1.1 raeburn 550: return;
551: }
552:
553: sub print_request_form {
1.2 raeburn 554: my ($r,$action,$state,$page,$states,$dom) = @_;
1.1 raeburn 555: my $formname = 'requestcrs';
1.2 raeburn 556: my ($next,$prev,$message,$output,$codepicker,$crstype);
557: $prev = $states->{$action}[$page-1];
558: $next = $states->{$action}[$page+1];
1.4 raeburn 559: my %navtxt = &Apache::lonlocal::texthash (
560: prev => 'Previous',
561: next => 'Next',
562: );
1.2 raeburn 563: $crstype = $env{'form.crstype'};
1.1 raeburn 564: $r->print('<form name="'.$formname.'" method="post" action="/adm/requestcourse">');
1.2 raeburn 565: my (@codetitles,%cat_titles,%cat_order,@code_order,$instcode,$code_chk);
1.1 raeburn 566: if ($crstype eq 'official') {
1.2 raeburn 567: if ($env{'form.instcode'} ne '') {
568: $instcode = $env{'form.instcode'};
569: }
570: }
571: if ($prev eq 'codepick') {
1.4 raeburn 572: if ($crstype eq 'official') {
573: &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
574: \%cat_order,\@code_order);
575: }
1.2 raeburn 576: if (@code_order > 0) {
577: my $message;
578: if ($instcode eq '') {
1.1 raeburn 579: foreach my $item (@code_order) {
1.2 raeburn 580: $instcode .= $env{'form.instcode_'.$item};
1.1 raeburn 581: }
1.2 raeburn 582: $r->print('<input type="hidden" name="instcode" value="'.$instcode.'" />'."\n");
1.1 raeburn 583: }
584: if ($instcode ne '') {
1.2 raeburn 585: $code_chk = &Apache::lonnet::auto_validate_instcode('',$dom,$instcode);
1.1 raeburn 586: if ($code_chk eq 'ok') {
587: $message = '<div class="LC_info">'.
588: &mt('The chosen course category [_1] is valid.','<b>'.
1.2 raeburn 589: $instcode.'</b>').'</div>';
1.1 raeburn 590: } else {
591: $message = '<div class="LC_warning">'.
592: &mt('No course was found matching your choice of institutional course category.');
593: if ($code_chk ne '') {
594: $message .= '<br />'.$code_chk;
595: }
596: $message .= '</div>';
597: }
1.2 raeburn 598: } else {
599: $message = '<div class="LC_warning">'.
600: &mt('No course was found matching your choice of institutional course category.');
1.1 raeburn 601: }
1.2 raeburn 602: unless ($code_chk eq 'ok') {
603: $prev = 'crstype';
604: }
605: $r->print($message);
1.1 raeburn 606: }
1.2 raeburn 607: }
608: if ($prev eq 'crstype') {
1.4 raeburn 609: if ($crstype eq 'official') {
610: &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
611: \%cat_order,\@code_order);
612: }
1.2 raeburn 613: if (@code_order > 0) {
1.1 raeburn 614: $codepicker = &coursecode_form($dom,'instcode',\@codetitles,
615: \%cat_titles,\%cat_order);
1.2 raeburn 616: if ($codepicker) {
617: $r->print('<div>'.&Apache::lonhtmlcommon::start_pick_box().$codepicker.
618: &Apache::lonhtmlcommon::end_pick_box().'</div>');
619: } else {
620: $r->print(&courseinfo_form($dom,$formname,$crstype));
621: }
622: } else {
623: $r->print(&courseinfo_form($dom,$formname,$crstype));
1.1 raeburn 624: }
1.2 raeburn 625: } elsif ($prev eq 'codepick') {
626: $r->print(&courseinfo_form($dom,$formname,$crstype));
627: } elsif ($state eq 'enrollment') {
1.4 raeburn 628: if ($crstype eq 'official') {
629: &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
630: \%cat_order,\@code_order);
631: }
1.2 raeburn 632: $r->print(&print_enrollment_menu($formname,$instcode,$dom,\@codetitles,
633: \%cat_titles,\%cat_order,\@code_order));
634: } elsif ($state eq 'personnel') {
635: $r->print(&print_personnel_menu($dom,$formname));
1.4 raeburn 636: } elsif ($state eq 'review') {
637: &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
638: \%cat_order,\@code_order);
639: $r->print(&print_review($formname,$dom,\@codetitles,\%cat_titles,\%cat_order,
640: \@code_order));
641: $navtxt{'next'} = &mt('Submit course request');
1.1 raeburn 642: }
1.2 raeburn 643: my @excluded = ('counter');
644: my %elements = &form_elements($dom);
645: if (ref($states) eq 'HASH') {
646: if (ref($states->{$action}) eq 'ARRAY') {
647: my @items = @{$states->{$action}};
648: my $numitems = scalar(@items);
649: if ($numitems) {
650: for (my $i=$numitems-1; $i>=0; $i--) {
651: if (ref($elements{$action}) eq 'HASH') {
652: if (ref($elements{$action}{$items[$i]}) eq 'HASH') {
653: foreach my $key (keys(%{$elements{$action}{$items[$i]}})) {
654: push(@excluded,$key);
655: }
656: }
657: }
658: last if ($items[$i] eq $state);
659: }
660: }
661: }
662: }
663: if (grep(/^instcode_/,@excluded)) {
664: push(@excluded,'instcode');
1.1 raeburn 665: }
1.2 raeburn 666: $r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'</form>');
1.4 raeburn 667: &display_navbuttons($r,$formname,$prev,$navtxt{'prev'},$next,$navtxt{'next'});
1.1 raeburn 668: return;
669: }
670:
1.2 raeburn 671: sub print_enrollment_menu {
672: my ($formname,$instcode,$dom,$codetitles,$cat_titles,$cat_order,$code_order) =@_;
673: my ($sections,$autoenroll,$access_dates);
674: my $starttime = time;
675: my $endtime = time+(6*30*24*60*60); # 6 months from now, approx
676:
677: my %accesstitles = (
678: 'start' => 'Default start access',
679: 'end' => 'Default end accss',
680: );
681: my %enrolltitles = (
682: 'start' => 'Start auto-enrollment',
683: 'end' => 'End auto-enrollment',
684: );
685: if ($env{'form.crstype'} eq 'official') {
686: if (&Apache::lonnet::auto_run('',$dom)) {
687: my ($section_form,$crosslist_form,$autoenroll_form);
688: $section_form = &inst_section_selector($dom,$instcode);
689: my $crosslisttotal = $env{'form.crosslisttotal'};
690: if (!defined($crosslisttotal)) {
691: $crosslisttotal = 1;
692: }
693: if ($env{'form.addcrosslist'}) {
694: $crosslisttotal ++;
695: }
696: for (my $i=0; $i<$crosslisttotal; $i++) {
697: $crosslist_form .= &coursecode_form($dom,'crosslist',$codetitles,
698: $cat_titles,$cat_order,$i);
699: }
700: if ($crosslist_form) {
701: $crosslist_form .=
702: &Apache::lonhtmlcommon::row_title(&mt('Add another?')).
703: '<input name="crosslisttotal" type="hidden" value="'.$crosslisttotal.'" />'.
704: '<input name="addcrosslist" type="checkbox" value="'.$crosslisttotal.'"'.
705: ' onclick="javascript:nextPage(document.'.$formname.",'".$env{'form.state'}.
706: "'".');" />'.&mt('Add?').&Apache::lonhtmlcommon::row_closure(1);
707: }
708: if ($section_form || $crosslist_form) {
709: $sections = '<div>'.&Apache::lonhtmlcommon::start_pick_box().
710: $section_form.$crosslist_form.
711: &Apache::lonhtmlcommon::end_pick_box().'</div>'."\n";
712: }
713: $autoenroll_form =
714: &Apache::lonhtmlcommon::row_title(&mt('Add registered students automatically')).
715: '<span class="LC_nobreak"><label>'.
716: '<input type="radio" name="autoadds" value="1">'.
717: &mt('Yes').'</label>'.(' 'x3).'<label>'.
718: '<input type="radio" name="autoadds" value="0" checked="checked">'.
719: &mt('No').'</label></span>'.
720: &Apache::lonhtmlcommon::row_closure().
721: &Apache::lonhtmlcommon::row_title(&mt('Drop unregistered students automatically')).
722: '<span class="LC_nobreak"><label>'.
723: '<input type="radio" name="autodrops" value="1">'.
724: &mt('Yes').'</label>'.(' 'x3).'<label>'.
725: '<input type="radio" name="autodrops" value="0" checked="checked">'.
726: &mt('No').'</label></span>'.
727: &Apache::lonhtmlcommon::row_closure().
728: &date_setting_table($starttime,$endtime,$formname,'enroll',%enrolltitles);
729: if ($autoenroll_form) {
730: $autoenroll = '<div>'.&Apache::lonhtmlcommon::start_pick_box().
731: $autoenroll_form.
732: &Apache::lonhtmlcommon::end_pick_box().'</div>'."\n";
733: }
734: }
735: }
736: my $access_dates_form =
737: &date_setting_table($starttime,$endtime,$formname,'access',%accesstitles);
738: if ($access_dates_form) {
739: $access_dates = '<div>'.&Apache::lonhtmlcommon::start_pick_box().
740: $access_dates_form.
741: &Apache::lonhtmlcommon::end_pick_box().'</div>'."\n";
742: }
743: return $sections.$autoenroll.$access_dates;
744: }
745:
1.1 raeburn 746: sub inst_section_selector {
1.2 raeburn 747: my ($dom,$instcode) = @_;
748: my @sections = &Apache::lonnet::auto_get_sections(undef,$dom,$instcode);
749: my $sectotal = scalar(@sections);
1.1 raeburn 750: my $output;
1.2 raeburn 751: if ($sectotal) {
752: $output .= &Apache::lonhtmlcommon::row_title('Sections').
753: &Apache::loncommon::start_data_table().
754: &Apache::loncommon::start_data_table_row().
755: '<th>'.&mt('Include?').'<input type="hidden" name="sectotal" '.
756: 'value="'.$sectotal.'"</th>'.
757: '<th>'.&mt('Institutional Section').'</th>'.
758: '<th>'.&mt('LON-CAPA section').'</th>'.
759: &Apache::loncommon::end_data_table_row();
760: for (my $i=0; $i<@sections; $i++) {
1.1 raeburn 761: my $colflag = $i%2;
762: $output .= &Apache::loncommon::start_data_table_row().
1.2 raeburn 763: '<td><input type="checkbox" name="sec_'.$i.
764: '" checked="checked" /></td>'.
765: '<td>'.$sections[$i].
1.1 raeburn 766: '<input type="hidden" name="secnum_'.$i.'" value="'.
1.2 raeburn 767: $sections[$i].'" /></td>'.
1.1 raeburn 768: '<td><input type="text" size="10" name="loncapasec_'.$i.
1.2 raeburn 769: '" value="'.$sections[$i].'" /></td>'.
1.1 raeburn 770: &Apache::loncommon::end_data_table_row();
771: }
1.2 raeburn 772: $output .= &Apache::loncommon::end_data_table().
773: &Apache::lonhtmlcommon::row_closure();
1.1 raeburn 774: }
775: return $output;
776: }
777:
1.2 raeburn 778: sub date_setting_table {
779: my ($starttime,$endtime,$formname,$suffix,%datetitles) = @_;
780: my ($perpetual,$table);
781: my $startform = &Apache::lonhtmlcommon::date_setter($formname,'start'.$suffix,
782: $starttime,'','','',1,'','','',1);
783: my $endform = &Apache::lonhtmlcommon::date_setter($formname,'end'.$suffix,
784: $endtime,'','','',1,'','','',1);
785: if ($suffix eq 'access') {
786: $perpetual = ' <span class="LC_nobreak"><label>'.
787: '<input type="checkbox" name="no_end_date" />'.
788: &mt('No end date').'</label></span>';
789: }
790: $table = &Apache::lonhtmlcommon::row_title($datetitles{'start'}).
791: $startform.
792: &Apache::lonhtmlcommon::row_closure().
793: &Apache::lonhtmlcommon::row_title($datetitles{'end'}).
794: $endform.$perpetual.
795: &Apache::lonhtmlcommon::row_closure(1);
796: return $table;
797: }
798:
799: sub print_personnel_menu {
800: my ($dom,$formname) = @_;
801: my $output = '<div>'.&Apache::lonhtmlcommon::start_pick_box();
802: my $persontotal = $env{'form.persontotal'};
803: if (!defined($persontotal)) {
804: $persontotal = 1;
805: }
806: if ($env{'form.addperson'}) {
807: $persontotal ++;
808: }
809: my $userlinktxt = &mt('Set User');
810: my @items = ('uname','dom','last','first','email','hidedom');
811:
812: my $roleoptions;
813: my @roles = &Apache::lonuserutils::roles_by_context('course');
814: foreach my $role (@roles) {
815: my $plrole=&Apache::lonnet::plaintext($role);
816: $roleoptions .= ' <option value="'.$role.'">'.$plrole.'</option>'."\n";
817: }
818: my %customroles=&Apache::lonuserutils::my_custom_roles();
819: if (keys(%customroles) > 0) {
820: foreach my $cust (sort(keys(%customroles))) {
821: my $custrole='cr_cr_'.$env{'user.domain'}.
822: '_'.$env{'user.name'}.'_'.$cust;
823: $roleoptions .= ' <option value="'.$custrole.'">'.$cust.'</option>'."\n";
824: }
825: }
826:
827: my @currsecs;
828: if ($env{'form.sectotal'}) {
829: for (my $i=0; $i<$env{'form.sectotal'}; $i++) {
830: if (defined($env{'form.loncapasec_'.$i})) {
831: my $lcsec = $env{'form.loncapasec_'.$i};
832: unless (grep(/^\Q$lcsec\E$/,@currsecs)) {
833: push(@currsecs,$lcsec);
834: }
835: }
836: }
837: }
838:
839: my ($existtitle,$existops,$existmult,$newtitle,$seccolspan);
840: if (@currsecs) {
841: my $existsize = scalar(@currsecs);
842: if ($existsize > 3) {
843: $existsize = 3;
844: }
845: if ($existsize > 1) {
846: $existmult = ' multiple="multiple" size="'.$existsize.'" ';
847: }
848: @currsecs = sort { $a <=> $b } (@currsecs);
849: $existtitle = &mt('Official').': ';
850: $existops = '<option value="">'.&mt('None').'</option>';
851: foreach my $sec (@currsecs) {
852: $existops .= '<option value="'.$sec.'">'.$sec.'</option>'."\n";
853: }
854: $seccolspan = ' colspan="2"';
855: $newtitle = &mt('Other').': ';
856: }
857:
858: for (my $i=0; $i<$persontotal; $i++) {
859: my @linkargs = map { 'person_'.$i.'_'.$_ } (@items);
860: my $linkargstr = join("','",@linkargs);
1.7 ! raeburn 861: my $userlink = &Apache::loncommon::selectuser_link($formname,@linkargs,$dom,$userlinktxt);
1.2 raeburn 862: my $uname_form = '<input type="text" name="person_'.$i.'_uname" value=""'.
863: ' onFocus="this.blur();'.
1.7 ! raeburn 864: 'openuserbrowser('."'$formname','$linkargstr','$dom'".');" />';
1.2 raeburn 865: my $onchange = 'javascript:fix_domain('."'$formname','person_".$i."_dom',".
866: "'person_".$i."_hidedom'".');'.
1.7 ! raeburn 867: 'openuserbrowser('."'$formname','$linkargstr','$dom'".');';
1.2 raeburn 868: my $udom_form = &Apache::loncommon::select_dom_form($dom,'person_'.$i.'_dom','',
869: 1,$onchange).
870: '<input type="hidden" name="person_'.$i.'_hidedom" value="'.$dom.'" />';
871: my %form_elems;
872: foreach my $item (@items) {
873: next if (($item eq 'dom') || ($item eq 'uname') || ($item eq 'hidedom'));
874: $form_elems{$item} = '<input type="text" name="person_'.$i.'_'.$item.'" '.
875: 'value="" readonly="readonly" />';
876: }
877: my $roleselector = '<select name="person_'.$i.'_role">'."\n".
878: $roleoptions.'</select>';
879: my $sectionselector;
880: if (@currsecs) {
881: $sectionselector = $existtitle.'<select name="person_'.$i.'_sec"'.
882: $existmult.'>'."\n".$existops.'</select>'.(' ' x3);
883: }
884: $sectionselector .= $newtitle.
885: '<input type="text" name="person_'.$i.'_newsec" size="15" value="" />'.
886: '<input type="hidden" name="person_'.$i.'_sections" value="" />'."\n";
887:
888: $output .=
889: &Apache::lonhtmlcommon::row_title(&mt('Additional Personnel').'<br />'.
890: '<span class="LC_nobreak">'.$userlink.
891: '</span>').
892: '<table><tr><td align="center" valign="top">'.&mt('Username').'<br />'.$uname_form.'</td>'."\n".
893: '<td align="center" valign="top" colspan="2">'.&mt('Domain').'<br />'.$udom_form.'</td></tr><tr>'."\n".
894: '<td align="center" valign="top">'.&mt('First Name').'<br />'.$form_elems{'first'}.'</td>'."\n".
895: '<td align="center" valign="top">'.&mt('Last Name').'<br />'.$form_elems{'last'}.'</td>'."\n".
896: '<td align="center" valign="top">'.&mt('E-mail').'<br />'.$form_elems{email}.'</td></tr>'."\n".
897: '<tr><td align="center" valign="top">'.&mt('Role').'<br />'.$roleselector.'</td>'."\n".
898: '<td'.$seccolspan.' align="center" valign="top">'.&mt('Section(s)').'<br />'.$sectionselector.'</td>'."\n".
899: '</tr></table>'.&Apache::lonhtmlcommon::row_closure();
900: }
901: $output .= &Apache::lonhtmlcommon::row_title(&mt('Add another?')).
902: '<input name="persontotal" type="hidden" value="'.$persontotal.'" />'.
903: '<input name="addperson" type="checkbox" value="'.$persontotal.'"'.
904: ' onclick="javascript:nextPage(document.'.$formname.",'".$env{'form.state'}.
905: "'".');" />'.&mt('Add?').&Apache::lonhtmlcommon::row_closure(1).
906: &Apache::lonhtmlcommon::end_pick_box().'</div>';
907: return $output;
908: }
909:
1.1 raeburn 910: sub print_request_status {
911: return;
912: }
913:
914: sub print_request_logs {
915: return;
916: }
917:
918: sub print_review {
1.4 raeburn 919: my ($formname,$dom,$codetitles,$cat_titles,$cat_order,$code_order) = @_;
920: my ($types,$typename) = &course_types();
921: my ($owner,$ownername,$owneremail);
922: $owner = $env{'user.name'}.':'.$env{'user.domain'};
923: $ownername = &Apache::loncommon::plainname($env{'user.name'},
924: $env{'user.domain'},'first');
925: my %emails = &Apache::loncommon::getemails();
926: foreach my $email ('permanentemail','critnotification','notification') {
927: $owneremail = $emails{$email};
928: last if ($owneremail ne '');
929: }
930: my ($inst_headers,$inst_values,$crstypename,$enroll_headers,$enroll_values,
931: $section_headers,$section_values,$personnel_headers,$personnel_values);
932:
933: $crstypename = $env{'form.crstype'};
934: if (ref($typename) eq 'HASH') {
935: unless ($typename->{$env{'form.crstype'}} eq '') {
936: $crstypename = $typename->{$env{'form.crstype'}};
937: }
938: }
939:
940: $inst_headers = '<th>'.&mt('Description').'</th><th>'.&mt('Type').'</th>';
941: $inst_values = '<td>'.$env{'form.cdescr'}.'</td><td>'.$crstypename.'</td>';
942:
943: if ($env{'form.crstype'} eq 'official') {
944: if ((ref($codetitles) eq 'ARRAY') && (ref($cat_titles) eq 'HASH')) {
945: foreach my $title (@{$codetitles}) {
946: if ($env{'form.instcode_'.$title} ne '') {
947: $inst_headers .= '<th>'.$title.'</th>';
948: my $longitem = $env{'form.instcode_'.$title};
949: if (ref($cat_titles->{$title}) eq 'HASH') {
950: if ($cat_titles->{$title}{$env{'form.instcode_'.$title}} ne '') {
951: $longitem = $cat_titles->{$title}{$env{'form.instcode_'.$title}};
952: }
953: }
954: $inst_values .= '<td>'.$longitem.'</td>';
955: }
956: }
957: }
958: if (&Apache::lonnet::auto_run('',$dom)) {
959: $enroll_headers = '<th>'.&mt('Automatic Adds').'</th>'.
960: '<th>'.&mt('Automatic Drops').'</th>'.
961: '<th>'.&mt('Enrollment Starts').'</th>'.
962: '<th>'.&mt('Enrollment Ends').'</th>';
963: $section_headers = '<th>'.&mt('Sections').'</th>'.
964: '<th>'.&mt('Crosslistings').'</th>';
965:
966: my ($startenroll,$endenroll) = &dates_from_form('startenroll','endenroll');
967: my @autoroster = (&mt('No'),&mt('Yes'));
968: $enroll_values = '<td>'.$autoroster[$env{'form.autoadds'}].'</td>'.
969: '<td>'.$autoroster[$env{'form.autodrops'}].'</td>'.
970: '<td>'.&Apache::lonlocal::locallocaltime($startenroll).'</td>'.
971: '<td>'.&Apache::lonlocal::locallocaltime($endenroll).'</td>';
1.6 raeburn 972: $section_values = '<td><table class="LC_innerpickbox"><tr><th>'.
973: &mt('Institutional section').'</th>'.
974: '<th>'.&mt('LON-CAPA section').'</th></tr>';
1.5 raeburn 975: my $secinfo;
1.4 raeburn 976: if ($env{'form.sectotal'} > 0) {
977: for (my $i=0; $i<$env{'form.sectotal'}; $i++) {
978: if ($env{'form.sec_'.$i}) {
1.5 raeburn 979: $secinfo .= '<tr><td>'.$env{'form.secnum_'.$i}.'</td><td>';
1.4 raeburn 980: if ($env{'form.loncapasec_'.$i} ne '') {
1.5 raeburn 981: $secinfo .= $env{'form.loncapasec_'.$i};
982: } else {
983: $secinfo .= &mt('None');
1.4 raeburn 984: }
1.5 raeburn 985: $secinfo .= '</td></tr>';
1.4 raeburn 986: }
987: }
988: }
1.6 raeburn 989: if ($secinfo eq '') {
990: $secinfo = '<tr><td colspan="2">'.&mt('None').'</td></tr>';
1.5 raeburn 991: }
1.6 raeburn 992: $section_values .= $secinfo.'</table></td><td>'.
993: '<table class="LC_innerpickbox"><tr><th>'.
994: &mt('Institutional course/section').'</th>'.
995: '<th>'.&mt('LON-CAPA section').'</th></tr>';
1.5 raeburn 996: my $xlistinfo;
1.4 raeburn 997: if ($env{'form.crosslisttotal'}) {
998: for (my $i=0; $i<$env{'form.crosslisttotal'}; $i++) {
999: if ($env{'form.crosslist_'.$i}) {
1.5 raeburn 1000: $xlistinfo .= '<tr><td>';
1001: if (ref($code_order) eq 'ARRAY') {
1002: if (@{$code_order} > 0) {
1003: foreach my $item (@{$code_order}) {
1004: $xlistinfo .= $env{'form.crosslist_'.$i.'_'.$item};
1.4 raeburn 1005: }
1006: }
1007: }
1.5 raeburn 1008: $xlistinfo .= $env{'form.crosslist_'.$i.'_instsec'}.'</td><td>';
1.4 raeburn 1009: if ($env{'form.crosslist_'.$i.'_lcsec'}) {
1.5 raeburn 1010: $xlistinfo .= $env{'form.crosslist_'.$i.'_lcsec'};
1011: } else {
1012: $xlistinfo .= &mt('None');
1.4 raeburn 1013: }
1.5 raeburn 1014: $xlistinfo .= '</td></tr>';
1.4 raeburn 1015: }
1016: }
1017: }
1.6 raeburn 1018: if ($xlistinfo eq '') {
1019: $xlistinfo = '<tr><td colspan="2">'.&mt('None').'</td></tr>';
1.5 raeburn 1020: }
1.6 raeburn 1021: $section_values .= $xlistinfo.'</table></td>';
1.4 raeburn 1022: }
1023: }
1024:
1025: my %ctxt = &clone_text();
1026: $inst_headers .= '<th>'.&mt('Clone From').'</th>';
1027: if (($env{'form.clonecourse'} =~ /^$match_name$/) &&
1028: ($env{'form.clonedomain'} =~ /^$match_domain$/)) {
1029: my %coursehash =
1030: &Apache::lonnet::courseiddump($env{'form.clonedomain'},'.',1,'.','.',
1031: $env{'form.clonecourse'},undef,undef,'.');
1032: my $cloneid = $env{'form.clonedomain'}.'_'.$env{'form.clonecourse'};
1033: if (ref($coursehash{$cloneid}) eq 'HASH') {
1034: $inst_headers .= '<th>'.$ctxt{'dsh'}.'</th>';
1035: my $clonedesc = $coursehash{$cloneid}{'description'};
1036: my $cloneinst = $coursehash{$cloneid}{'inst_code'};
1037:
1038: $inst_values .= '<td>'.$clonedesc.' ';
1039: if ($cloneinst ne '') {
1040: $inst_values .= &mt('([_1] in [_2])',$cloneinst,$env{'form.clonedomain'});
1041: } else {
1042: $inst_values .= &mt('(from [_1])',$env{'form.clonedomain'});
1043: }
1044: $inst_values .= '</td><td>';
1045: if ($env{'form.datemode'} eq 'preserve') {
1046: $inst_values .= $ctxt{'pcd'};
1047: } elsif ($env{'form.datemode'} eq 'shift') {
1048: $inst_values .= &mt('Shift dates by [_1] days',$env{'form.dateshift'});
1049: } else {
1050: $inst_values .= $ctxt{'ncd'};
1051: }
1052: $inst_values .= '</td>';
1053: } else {
1054: $inst_values .= '<td>'.&mt('Unknown').'</td>';
1055: }
1056: } else {
1057: $inst_values .= '<td>'.&mt('None').'</td>';
1058: }
1059: $enroll_headers .= '<th>'.&mt('Access Starts').'</th>'.
1060: '<th>'.&mt('Access Ends').'</th>';
1061: my ($startaccess,$endaccess) = &dates_from_form('startaccess','endaccess');
1062: $enroll_values .= '<td>'.&Apache::lonlocal::locallocaltime($startaccess).'</td>';
1063: if ($endaccess == 0) {
1064: $enroll_values .= '<td>'.&mt('No end date').'</td>';
1065: } else {
1066: $enroll_values .= '<td>'.&Apache::lonlocal::locallocaltime($endaccess).'</td>';
1067: }
1068:
1069: my $container = 'Course';
1070: if ($env{'form.crstype'} eq 'community') {
1071: $container = 'Community';
1072: }
1073:
1074: $personnel_headers = '<th>'.&mt('Name').'</th><th>'.&mt('Username:Domain').
1075: '</th><th>'.&mt('Role').'</th><th>'.&mt('LON-CAPA Sections').
1076: '</th>';
1077: $personnel_values .= '<tr><td>'.$ownername.'</td><td>'.$owner.'</td>'.
1078: '<td>'.&Apache::lonnet::plaintext('cc',$container).'</td>'.
1079: '<td>'.&mt('None').'</td></tr>';
1080: for (my $i=0; $i<$env{'form.persontotal'}; $i++) {
1081: if ($env{'form.person_'.$i.'_uname'} ne '') {
1082: $personnel_values .=
1083: '<tr><td>'.$env{'form.person_'.$i.'_first'}.' '.
1084: $env{'form.person_'.$i.'_last'}.'</td>'.
1085: '<td>'.$env{'form.person_'.$i.'_uname'}.':'.
1086: $env{'form.person_'.$i.'_dom'}.'</td>'.
1087: '<td>'.&Apache::lonnet::plaintext($env{'form.person_'.$i.'_role'},
1088: $container).'</td>'.
1089: '<td>'.$env{'form.person_'.$i.'_sections'}.'</td></tr>';
1090: }
1091: }
1092: my $output = '<p>'.&mt('Review the details of the course request before submission.').'</p>'.
1093: '<div>'.&Apache::lonhtmlcommon::start_pick_box().
1094: &Apache::lonhtmlcommon::row_title(&mt('Owner')).
1.6 raeburn 1095: '<table class="LC_innerpickbox"><tr>'.
1.4 raeburn 1096: '<th>'.&mt('Name').'</th>'.
1097: '<th>'.&mt('Username:Domain').'</th>'.
1098: '<th>'.&mt('E-mail address').'</th>'.
1099: '</tr><tr>'."\n".
1100: '<td>'.$ownername.'</td><td>'.$owner.'</td>'.
1101: '<td>'.$owneremail.'</td>'.
1102: '</tr></table>'."\n".
1103: &Apache::lonhtmlcommon::row_closure().
1.5 raeburn 1104: &Apache::lonhtmlcommon::row_title(&mt('Description')).
1.4 raeburn 1105: '<table class="LC_innerpickbox"><tr>'.$inst_headers.'</tr>'."\n".
1106: '<tr>'.$inst_values.'</tr></table>'."\n".
1107: &Apache::lonhtmlcommon::row_closure().
1108: &Apache::lonhtmlcommon::row_title(&mt('Enrollment')).
1109: '<table class="LC_innerpickbox"><tr>'.$enroll_headers.'</tr>'."\n".
1110: '<tr>'.$enroll_values.'</tr></table>'."\n".
1111: &Apache::lonhtmlcommon::row_closure();
1112: if ($section_headers ne '') {
1113: $output .= &Apache::lonhtmlcommon::row_title(&mt('Sections')).
1114: '<table class="LC_innerpickbox"><tr>'.$section_headers.'</tr>'."\n".
1115: '<tr>'.$section_values.'</tr></table>'."\n".
1116: &Apache::lonhtmlcommon::row_closure();
1117: }
1118: $output .= &Apache::lonhtmlcommon::row_title(&mt('Personnel')).
1119: '<table class="LC_innerpickbox"><tr>'.$personnel_headers.'</tr>'."\n".
1120: $personnel_values.'</table>'."\n".
1121: &Apache::lonhtmlcommon::row_closure(1).
1122: &Apache::lonhtmlcommon::end_pick_box();
1123: return $output;
1124: }
1125:
1126: sub dates_from_form {
1127: my ($startname,$endname) = @_;
1128: my $startdate = &Apache::lonhtmlcommon::get_date_from_form($startname);
1129: my $enddate = &Apache::lonhtmlcommon::get_date_from_form($endname);
1130: if ($endname eq 'endaccess') {
1131: if (exists($env{'form.no_end_date'}) ) {
1132: $enddate = 0;
1133: }
1134: }
1135: return ($startdate,$enddate);
1.1 raeburn 1136: }
1137:
1138: sub courseinfo_form {
1.2 raeburn 1139: my ($dom,$formname,$crstype) = @_;
1140: my $output = '<div>'.&Apache::lonhtmlcommon::start_pick_box().
1141: &Apache::lonhtmlcommon::row_title('Course Description').
1142: '<input type="text" size="40" name="cdescr" />'.
1143: &Apache::lonhtmlcommon::row_closure(1).
1144: &Apache::lonhtmlcommon::end_pick_box().'</div>'.
1145: '<div>'.&clone_form($dom,$formname,$crstype).'</div>'."\n";
1.1 raeburn 1146: return $output;
1147: }
1148:
1149: sub clone_form {
1150: my ($dom,$formname,$crstype) = @_;
1151: my $type = 'Course';
1152: if ($crstype eq 'community') {
1153: $type = 'Community';
1154: }
1155: my $cloneform = &Apache::loncommon::select_dom_form($dom,'clonedomain').
1.2 raeburn 1156: &Apache::loncommon::selectcourse_link($formname,'clonecourse','clonedomain','','','',$type);
1.4 raeburn 1157: my %lt = &clone_text();
1.2 raeburn 1158: my $output .=
1159: &Apache::lonhtmlcommon::start_pick_box().
1160: &Apache::lonhtmlcommon::row_title($lt{'cid'}).'<label>'.
1161: '<input type="text" size="25" name="clonecourse" value="" onfocus="this.blur();'.
1162: 'opencrsbrowser('."'$formname','clonecourse','clonedomain','','','','$type'".');" />'.
1163: '</label>'.&Apache::lonhtmlcommon::row_closure(1).'<label>'.
1164: &Apache::lonhtmlcommon::row_title($lt{'dmn'}).'</label>'.
1165: $cloneform.'</label>'.&Apache::lonhtmlcommon::row_closure().
1166: &Apache::lonhtmlcommon::row_title($lt{'dsh'}).'<label>'.
1167: '<input type="radio" name="datemode" value="delete" /> '.$lt{'ncd'}.
1168: '</label><br /><label>'.
1169: '<input type="radio" name="datemode" value="preserve" /> '.$lt{'prd'}.
1170: '</label><br /><label>'.
1171: '<input type="radio" name="datemode" value="shift" checked="checked" /> '.
1172: $lt{'shd'}.'</label>'.
1173: '<input type="text" size="5" name="dateshift" value="365" />'.
1174: &Apache::lonhtmlcommon::row_closure(1).
1175: &Apache::lonhtmlcommon::end_pick_box();
1.1 raeburn 1176: return $output;
1177: }
1178:
1.4 raeburn 1179: sub clone_text {
1180: return &Apache::lonlocal::texthash(
1181: 'cid' => 'Course ID',
1182: 'dmn' => 'Domain',
1183: 'dsh' => 'Date Shift',
1184: 'ncd' => 'Do not clone date parameters',
1185: 'prd' => 'Clone date parameters as-is',
1186: 'shd' => 'Shift date parameters by number of days',
1187: );
1188: }
1189:
1.1 raeburn 1190: sub coursecode_form {
1.2 raeburn 1191: my ($dom,$context,$codetitles,$cat_titles,$cat_order,$num) = @_;
1.1 raeburn 1192: my $output;
1.2 raeburn 1193: my %rowtitle = (
1194: instcode => 'Course Category',
1195: crosslist => 'Cross Listed Course',
1196: );
1.1 raeburn 1197: if ((ref($codetitles) eq 'ARRAY') && (ref($cat_titles) eq 'HASH') &&
1198: (ref($cat_order))) {
1.2 raeburn 1199: my ($sel,$instsec,$lcsec);
1200: $sel = $context;
1201: if ($context eq 'crosslist') {
1202: $sel .= '_'.$num;
1203: $instsec = &mt('Institutional section').'<br />'.
1204: '<input type="text" size="10" name="'.$sel.'_instsec" />';
1205: $lcsec = &mt('LON-CAPA section').'<br />'.
1206: '<input type="text" size="10" name="'.$sel.'_lcsec" />';
1207: }
1.1 raeburn 1208: if (@{$codetitles} > 0) {
1209: my $lastitem = pop(@{$codetitles});
1.2 raeburn 1210: my $lastinput = '<input type="text" size="5" name="'.$sel.'_'. $lastitem.'" />';
1.1 raeburn 1211: if (@{$codetitles} > 0) {
1.2 raeburn 1212: $output = &Apache::lonhtmlcommon::row_title($rowtitle{$context}).
1213: '<table><tr>';
1.1 raeburn 1214: if ($context eq 'crosslist') {
1.2 raeburn 1215: $output .= '<td>'.&mt('Include?').'<br />'.
1216: '<input type="checkbox" name="'.$sel.'" value="1" /></td>';
1.1 raeburn 1217: }
1218: foreach my $title (@{$codetitles}) {
1219: if (ref($cat_order->{$title}) eq 'ARRAY') {
1220: if (@{$cat_order->{$title}} > 0) {
1221: $output .= '<td align="center">'.$title.'<br />'."\n".
1222: '<select name="'.$sel.'_'.$title.'">'."\n".
1223: ' <option value="" selected="selected">'.
1224: &mt('Select').'</option>'."\n";
1225: foreach my $item (@{$cat_order->{$title}}) {
1226: my $longitem = $item;
1227: if (ref($cat_titles->{$title}) eq 'HASH') {
1228: if ($cat_titles->{$title}{$item} ne '') {
1229: $longitem = $cat_titles->{$title}{$item};
1230: }
1231: }
1232: $output .= '<option value="'.$item.'">'.$longitem.
1233: '</option>'."\n";
1234: }
1235: }
1236: $output .= '</select></td>'."\n";
1237: }
1238: }
1239: if ($context eq 'crosslist') {
1240: $output .= '<td align="center">'.$lastitem.'<br />'."\n".
1.2 raeburn 1241: $lastinput.'</td><td align="center">'.$instsec.'</td>'.
1242: '<td align="center">'.$lcsec.'</td></tr></table>';
1.1 raeburn 1243: } else {
1244: $output .= '</tr></table>'.
1245: &Apache::lonhtmlcommon::row_closure().
1246: &Apache::lonhtmlcommon::row_title('Course '.$lastitem).
1247: $lastinput;
1248: }
1249: } else {
1250: if ($context eq 'crosslist') {
1251: $output .= &Apache::lonhtmlcommon::row_title($rowtitle{$context}).
1.2 raeburn 1252: '<table><tr>'.
1253: '<td align="center">'.$lastitem.'<br />'.$lastinput.'</td>'.
1254: '<td align="center">'.$instsec.'</td><td>'.$lcsec.'</td>'.
1255: '</tr></table>';
1.1 raeburn 1256: } else {
1257: $output .= &Apache::lonhtmlcommon::row_title('Course '.$lastitem).
1258: $lastinput;
1259: }
1260: }
1.2 raeburn 1261: $output .= &Apache::lonhtmlcommon::row_closure(1);
1262: push(@$codetitles,$lastitem);
1263: } elsif ($context eq 'crosslist') {
1264: $output .= &Apache::lonhtmlcommon::row_title($rowtitle{$context}).
1265: '<table><tr><td align="center">'.
1266: '<span class="LC_nobreak">'.&mt('Include?').
1267: '<input type="checkbox" name="'.$sel.'" value="1" /></span>'.
1268: '</td><td align="center">'.&mt('Institutional ID').'<br />'.
1269: '<input type="text" size="10" name="'.$sel.'_instsec" />'.
1270: '</td><td align="center">'.$lcsec.'</td></tr></table>'.
1271: &Apache::lonhtmlcommon::row_closure(1);
1.1 raeburn 1272: }
1273: }
1274: return $output;
1275: }
1276:
1277: sub get_course_dom {
1278: my $codedom = &Apache::lonnet::default_login_domain();
1279: if (($env{'user.domain'} ne '') && ($env{'user.domain'} ne 'public')) {
1280: $codedom = $env{'user.domain'};
1281: if ($env{'request.role.domain'} ne '') {
1282: $codedom = $env{'request.role.domain'};
1283: }
1284: }
1285: if ($env{'form.showdom'} ne '') {
1286: if (&Apache::lonnet::domain($env{'form.showdom'}) ne '') {
1287: $codedom = $env{'form.showdom'};
1288: }
1289: }
1290: return $codedom;
1291: }
1292:
1293: sub display_navbuttons {
1294: my ($r,$formname,$prev,$prevtext,$next,$nexttext) = @_;
1295: $r->print('<div class="LC_navbuttons">');
1296: if ($prev) {
1297: $r->print('
1298: <input type="button" name="previous" value = "'.$prevtext.'"
1299: onclick="javascript:backPage(document.'.$formname.','."'".$prev."'".')"/>
1300: ');
1301: } elsif ($prevtext) {
1302: $r->print('
1303: <input type="button" name="previous" value = "'.$prevtext.'"
1304: onclick="javascript:history.back()"/>
1305: ');
1306: }
1307: if ($next) {
1308: $r->print('
1309: <input type="button" name="next" value="'.$nexttext.'"
1310: onclick="javascript:nextPage(document.'.$formname.','."'".$next."'".')" />');
1311: }
1312: $r->print('</div>');
1313: }
1314:
1315: sub print_request_outcome {
1316: return;
1317: }
1318:
1.2 raeburn 1319: sub retrieve_settings {
1320: my ($dom,$request_id) = @_;
1321: my %reqinfo = &get_request_settings($request_id,$dom);
1322: my %stored;
1323: $stored{'cdescr'} = &unescape($reqinfo{'description'});
1324: $stored{'startaccess'} = $reqinfo{'startaccess'};
1325: $stored{'endaccess'} = $reqinfo{'endaccess'};
1326: if ($stored{'endaccess'} == 0) {
1327: $stored{'no_end_date'} = 1;
1328: }
1329: $stored{'startenroll'} = $reqinfo{'startenroll'};
1330: $stored{'endenroll'} = $reqinfo{'endenroll'};
1331: $stored{'crosslist'} = $reqinfo{'crosslist'};
1332: $stored{'clonecourse'} = $reqinfo{'clonecourse'};
1333: $stored{'clonedomain'} = $reqinfo{'clonedomain'};
1334: $stored{'sections'} = $reqinfo{'sections'};
1335: $stored{'personnel'} = $reqinfo{'personnel'};
1336:
1337: return %stored;
1338: }
1339:
1340: sub get_request_settings {
1341: my ($request_id,$dom);
1342: }
1343:
1.1 raeburn 1344: 1;
1345:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>