Annotation of loncom/interface/lonrequestcourse.pm, revision 1.5
1.1 raeburn 1: # The LearningOnline Network
2: # Request a course
3: #
1.5 ! raeburn 4: # $Id: lonrequestcourse.pm,v 1.4 2009/08/05 23:44:52 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) {
193: $jscript = '<script type="text/javascript">'.
194: $jscript.'</script>'."\n";
195: }
196: if ($loaditems) {
1.3 raeburn 197: $loaditems = {'add_entries' => $loaditems,};
198: return &Apache::loncommon::start_page($bodytitle,$jscript.$jsextra,$loaditems);
199: } else {
200: return &Apache::loncommon::start_page($bodytitle,$jscript.$jsextra);
201: }
1.2 raeburn 202: }
203:
204: sub form_elements {
205: my ($dom) = @_;
206: my %elements =
207: (
208: new => {
209: crstype => {
210: crstype => 'selectbox',
211: action => 'selectbox',
212: },
213: courseinfo => {
214: cdescr => 'text',
215: clonecourse => 'text',
216: clonedomain => 'selectbox',
217: datemode => 'radio',
218: dateshift => 'text',
219: },
220: enrollment => {
221: startaccess_month => 'selectbox',
222: startaccess_hour => 'selectbox',
223: endaccess_month => 'selectbox',
224: endaccess_hour => 'selectbox',
225: startaccess_day => 'text',
226: startaccess_year => 'text',
227: startaccess_minute => 'text',
228: startaccess_second => 'text',
229: endaccess_day => 'text',
230: endaccess_year => 'text',
231: endaccess_minute => 'text',
232: endaccess_second => 'text',
233: no_end_date => 'checkbox',
234: },
235: personnel => {
236: persontotal => 'hidden',
237: addperson => 'checkbox',
238: },
239: },
240: view => {
241: crstype => {
242: crstype => 'selectbox',
243: action => 'selectbox',
244: },
245: },
246: );
247: my (@codetitles,%cat_titles,%cat_order,@code_order,$lastitem);
248: &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
249: \%cat_order,\@code_order);
250: my $numtitles = scalar(@codetitles);
251: if ($numtitles) {
252: my %extras;
253: $lastitem = pop(@codetitles);
254: $extras{'instcode_'.$lastitem} = 'text';
255: foreach my $item (@codetitles) {
256: $extras{'instcode_'.$item} = 'selectbox';
257: }
258: $elements{'new'}{'codepick'} = \%extras;
259: }
260: if (&Apache::lonnet::auto_run('',$dom)) {
261: my %extras = (
262: sectotal => 'hidden',
263: startenroll_month => 'selectbox',
264: startenroll_hour => 'selectbox',
265: endenroll_month => 'selectbox',
266: endenroll_hour => 'selectbox',
267: startenroll_day => 'text',
268: startenroll_year => 'text',
269: startenroll_minute => 'text',
270: startenroll_second => 'text',
271: endenroll_day => 'text',
272: endenroll_year => 'text',
273: endenroll_minute => 'text',
274: endenroll_second => 'text',
275: crosslisttotal => 'hidden',
276: addcrosslist => 'checkbox',
277: autoadds => 'radio',
278: autodrops => 'radio',
279: );
280: if ($env{'form.sectotal'} > 0) {
281: for (my $i=0; $i<$env{'form.sectotal'}; $i++) {
282: $extras{'sec_'.$i} = 'checkbox',
283: $extras{'secnum_'.$i} = 'text',
284: $extras{'loncapasec_'.$i} = 'checkbox',
285: }
286: }
287: my $crosslisttotal = $env{'form.crosslisttotal'};
288: if (!defined($crosslisttotal)) {
289: $crosslisttotal = 1;
290: }
291: if ($crosslisttotal > 0) {
292: for (my $i=0; $i<$env{'form.crosslisttotal'}; $i++) {
293: if ($numtitles) {
294: $extras{'crosslist_'.$i.'_'.$lastitem} = 'text';
295: }
296: if (@codetitles > 0) {
297: foreach my $item (@codetitles) {
298: $extras{'crosslist_'.$i.'_'.$item} = 'selectbox';
299: }
300: }
301: $extras{'crosslist_'.$i} = 'checkbox';
302: $extras{'crosslist_'.$i.'_instsec'} = 'text',
303: $extras{'crosslist_'.$i.'_lcsec'} = 'text',
304: }
305: }
306: my %mergedhash = (%{$elements{'new'}{'enrollment'}},%extras);
307: %{$elements{'new'}{'enrollment'}} = %mergedhash;
308: }
309: my %people;
310: my $persontotal = $env{'form.persontotal'};
311: if (!defined($persontotal)) {
312: $persontotal = 1;
313: }
314: for (my $i=0; $i<$persontotal; $i++) {
315: $people{'person_'.$i.'_uname'} = 'text',
316: $people{'person_'.$i.'_dom'} = 'selectbox',
317: $people{'person_'.$i.'_hidedom'} = 'hidden',
318: $people{'person_'.$i.'_first'} = 'text',
319: $people{'person_'.$i.'_last'} = 'text',
320: $people{'person_'.$i.'_email'} = 'text',
321: $people{'person_'.$i.'_role'} = 'selectbox',
322: $people{'person_'.$i.'_sec'} = 'selectbox',
323: $people{'person_'.$i.'_newsec'} = 'text',
324: $people{'person_'.$i.'_sections'} = 'hidden',
325: }
326: my %personnelhash = (%{$elements{'new'}{'personnel'}},%people);
327: %{$elements{'new'}{'personnel'}} = %personnelhash;
328: return %elements;
329: }
330:
331: sub onload_action {
332: my ($action,$state) = @_;
333: my %loaditems;
334: if (($action eq 'new') || ($action eq 'view')) {
335: $loaditems{'onload'} = 'javascript:setFormElements(document.requestcrs)';
336: }
337: return \%loaditems;
338: }
339:
1.1 raeburn 340: sub check_can_request {
341: my ($dom,$can_request) = @_;
342: my $canreq = 0;
1.4 raeburn 343: my ($types,$typename) = &course_types();
344: if ((ref($can_request) eq 'HASH') && (ref($types) eq 'ARRAY')) {
345: foreach my $type (@{$types}) {
1.1 raeburn 346: if (&Apache::lonnet::usertools_access($env{'user.name'},
347: $env{'user.domain'},
348: $type,undef,'requestcourses')) {
349: $canreq ++;
350: if ($dom eq $env{'user.domain'}) {
351: $can_request->{$type} = 1;
352: }
353: }
354: if ($env{'environment.reqcrsotherdom.'.$type} ne '') {
355: my @curr = split(',',$env{'environment.reqcrsotherdom.'.$type});
356: if (@curr > 0) {
357: $canreq ++;
358: unless ($dom eq $env{'user.domain'}) {
359: if (grep(/^\Q$dom\E$/,@curr)) {
360: $can_request->{$type} = 1;
361: }
362: }
363: }
364: }
365: }
366: }
367: return $canreq;
368: }
369:
1.4 raeburn 370: sub course_types {
371: my @types = ('official','unofficial','community');
372: my %typename = (
373: official => 'Official course',
374: unofficial => 'Unofficial course',
375: community => 'Community',
376: );
377: return (\@types,\%typename);
378: }
379:
380:
1.1 raeburn 381: sub print_main_menu {
1.3 raeburn 382: my ($r,$can_request,$states,$dom,$jscript,$loaditems,$crumb) = @_;
1.4 raeburn 383: my ($types,$typename) = &course_types();
1.1 raeburn 384: my $onchange;
385: unless ($env{'form.interface'} eq 'textual') {
386: $onchange = 1;
387: }
388:
1.2 raeburn 389: my $nextstate_setter = "\n";
390: if (ref($states) eq 'HASH') {
391: foreach my $key (keys(%{$states})) {
392: if (ref($states->{$key}) eq 'ARRAY') {
393: $nextstate_setter .=
394: " if (actionchoice == '$key') {
395: nextstate = '".$states->{$key}[1]."';
396: }
397: ";
398: }
399: }
400: }
1.1 raeburn 401:
1.2 raeburn 402: my $js = <<"END";
1.1 raeburn 403:
1.2 raeburn 404: function nextPage(formname) {
405: var crschoice = document.requestcrs.crstype.value;
406: var actionchoice = document.requestcrs.action.value;
407: if (check_can_request(crschoice,actionchoice) == true) {
408: if ((actionchoice == 'new') && (crschoice == 'official')) {
409: nextstate = 'codepick';
410: } else {
411: $nextstate_setter
412: }
1.1 raeburn 413: formname.state.value= nextstate;
414: formname.submit();
415: }
416: return;
417: }
418:
1.2 raeburn 419: function check_can_request(crschoice,actionchoice) {
1.1 raeburn 420: var official = '';
421: var unofficial = '';
422: var community = '';
423: END
424:
425: foreach my $item (keys(%{$can_request})) {
426: $js .= "
427: $item = 1;
428: ";
429: }
430: my %lt = &Apache::lonlocal::texthash(
431: official => 'You are not permitted to request creation of an official course in this domain.',
432: unofficial => 'You are not permitted to request creation of an unofficial course in this domain.',
433: community => 'You are not permitted to request creation of a community this domain.',
434: all => 'You must choose a specific course type when making a new course request.\\nAll types is not allowed.',
435: );
436: $js .= <<END;
437: if (crschoice == 'official') {
438: if (official != 1) {
439: alert("$lt{'official'}");
440: return false;
441: }
442: } else {
443: if (crschoice == 'unofficial') {
444: if (unofficial != 1) {
445: alert("$lt{'unofficial'}");
446: return false;
447: }
448: } else {
449: if (crschoice == 'community') {
450: if (community != 1) {
451: alert("$lt{'community'}");
452: return false;
453: }
454: } else {
455: if (actionchoice == 'new') {
456: alert("$lt{'all'}");
457: return false;
458: }
459: }
460: }
461: }
462: return true;
463: }
464:
465: END
466:
1.3 raeburn 467: $r->print(&header('Course Requests',$js.$jscript,$loaditems).$crumb.
468: '<div>'.
1.1 raeburn 469: '<form name="domforcourse" method="post" action="/adm/requestcourse">'.
470: &Apache::lonhtmlcommon::start_pick_box().
471: &Apache::lonhtmlcommon::row_title('Domain').
472: &Apache::loncommon::select_dom_form($dom,'showdom','',1,$onchange));
473: if (!$onchange) {
474: $r->print(' <input type="submit" name="godom" value="'.
475: &mt('Change').'" />');
476: }
477: $r->print(&Apache::lonhtmlcommon::row_closure(1).
478: &Apache::lonhtmlcommon::end_pick_box().'</form></div>');
479:
1.2 raeburn 480: my $formname = 'requestcrs';
1.1 raeburn 481: my $nexttext = &mt('Next');
482: $r->print('<div><form name="'.$formname.'" method="post" action="/adm/requestcourse">'.
483: &Apache::lonhtmlcommon::start_pick_box().
484: &Apache::lonhtmlcommon::row_title('Action').'
485: <input type="hidden" name="showdom" value="'.$dom.'" />
486: <select size="1" name="action" >
1.2 raeburn 487: <option value="new">'.&mt('New request').'</option>
1.1 raeburn 488: <option value="view">'.&mt('View/Modify/Cancel pending requests').'</option>
489: <option value="log">'.&mt('View request history').'</option>
490: </select>'.
491: &Apache::lonhtmlcommon::row_closure().
492: &Apache::lonhtmlcommon::row_title('Course Type').'
493: <select size="1" name="crstype">
1.4 raeburn 494: <option value="any">'.&mt('All types').'</option>');
495: if ((ref($types) eq 'ARRAY') && (ref($typename) eq 'HASH')) {
496: foreach my $type (@{$types}) {
497: my $selected = '';
498: if ($type eq 'official') {
499: $selected = ' selected="selected"';
500: }
501: $r->print('<option value="'.$type.'"'.$selected.'>'.$typename->{$type}.
502: '</option>'."\n");
503: }
504: }
505: $r->print('</select>
1.1 raeburn 506: <input type="hidden" name="state" value="crstype" />'.
507: &Apache::lonhtmlcommon::row_closure(1).
508: &Apache::lonhtmlcommon::end_pick_box().'<br />
1.2 raeburn 509: <input type="button" name="next" value="'.$nexttext.'" onclick="javascript:nextPage(document.'.$formname.')" />
1.1 raeburn 510: </form></div>');
511: $r->print(&Apache::loncommon::end_page());
512: return;
513: }
514:
515: sub request_administration {
1.3 raeburn 516: my ($r,$action,$state,$page,$states,$dom,$jscript,$loaditems,$crumb) = @_;
1.2 raeburn 517: my $js;
518: if (($action eq 'new') || ($action eq 'view')) {
519: $js = <<END;
1.1 raeburn 520:
521: function nextPage(formname,nextstate) {
522: formname.state.value= nextstate;
523: formname.submit();
524: }
525: function backPage(formname,prevstate) {
526: formname.state.value = prevstate;
527: formname.submit();
528: }
529:
530: END
1.2 raeburn 531: }
532: if ($action eq 'new') {
533: my $jsextra;
1.1 raeburn 534: unless (($state eq 'review') || ($state eq 'process')) {
1.2 raeburn 535: $jsextra = "\n".&Apache::loncommon::coursebrowser_javascript($dom);
1.1 raeburn 536: }
1.3 raeburn 537: $r->print(&header('Request a course',$js.$jscript,$loaditems,$jsextra).$crumb);
1.4 raeburn 538: if ($state eq 'process') {
1.1 raeburn 539: &print_request_outcome($r,$state,$dom);
540: } else {
1.2 raeburn 541: &print_request_form($r,$action,$state,$page,$states,$dom);
1.1 raeburn 542: }
1.2 raeburn 543: } elsif ($action eq 'view') {
1.3 raeburn 544: $r->print(&header('Manage course requests',$js.$jscript,$loaditems).$crumb);
1.1 raeburn 545: } elsif ($action eq 'log') {
1.3 raeburn 546: $r->print(&coursereq_log('View request log',$jscript,$loaditems).$crumb);
1.1 raeburn 547: }
1.2 raeburn 548: $r->print(&Apache::loncommon::end_page());
1.1 raeburn 549: return;
550: }
551:
552: sub print_request_form {
1.2 raeburn 553: my ($r,$action,$state,$page,$states,$dom) = @_;
1.1 raeburn 554: my $formname = 'requestcrs';
1.2 raeburn 555: my ($next,$prev,$message,$output,$codepicker,$crstype);
556: $prev = $states->{$action}[$page-1];
557: $next = $states->{$action}[$page+1];
1.4 raeburn 558: my %navtxt = &Apache::lonlocal::texthash (
559: prev => 'Previous',
560: next => 'Next',
561: );
1.2 raeburn 562: $crstype = $env{'form.crstype'};
1.1 raeburn 563: $r->print('<form name="'.$formname.'" method="post" action="/adm/requestcourse">');
1.2 raeburn 564: my (@codetitles,%cat_titles,%cat_order,@code_order,$instcode,$code_chk);
1.1 raeburn 565: if ($crstype eq 'official') {
1.2 raeburn 566: if ($env{'form.instcode'} ne '') {
567: $instcode = $env{'form.instcode'};
568: }
569: }
570: if ($prev eq 'codepick') {
1.4 raeburn 571: if ($crstype eq 'official') {
572: &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
573: \%cat_order,\@code_order);
574: }
1.2 raeburn 575: if (@code_order > 0) {
576: my $message;
577: if ($instcode eq '') {
1.1 raeburn 578: foreach my $item (@code_order) {
1.2 raeburn 579: $instcode .= $env{'form.instcode_'.$item};
1.1 raeburn 580: }
1.2 raeburn 581: $r->print('<input type="hidden" name="instcode" value="'.$instcode.'" />'."\n");
1.1 raeburn 582: }
583: if ($instcode ne '') {
1.2 raeburn 584: $code_chk = &Apache::lonnet::auto_validate_instcode('',$dom,$instcode);
1.1 raeburn 585: if ($code_chk eq 'ok') {
586: $message = '<div class="LC_info">'.
587: &mt('The chosen course category [_1] is valid.','<b>'.
1.2 raeburn 588: $instcode.'</b>').'</div>';
1.1 raeburn 589: } else {
590: $message = '<div class="LC_warning">'.
591: &mt('No course was found matching your choice of institutional course category.');
592: if ($code_chk ne '') {
593: $message .= '<br />'.$code_chk;
594: }
595: $message .= '</div>';
596: }
1.2 raeburn 597: } else {
598: $message = '<div class="LC_warning">'.
599: &mt('No course was found matching your choice of institutional course category.');
1.1 raeburn 600: }
1.2 raeburn 601: unless ($code_chk eq 'ok') {
602: $prev = 'crstype';
603: }
604: $r->print($message);
1.1 raeburn 605: }
1.2 raeburn 606: }
607: if ($prev eq 'crstype') {
1.4 raeburn 608: if ($crstype eq 'official') {
609: &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
610: \%cat_order,\@code_order);
611: }
1.2 raeburn 612: if (@code_order > 0) {
1.1 raeburn 613: $codepicker = &coursecode_form($dom,'instcode',\@codetitles,
614: \%cat_titles,\%cat_order);
1.2 raeburn 615: if ($codepicker) {
616: $r->print('<div>'.&Apache::lonhtmlcommon::start_pick_box().$codepicker.
617: &Apache::lonhtmlcommon::end_pick_box().'</div>');
618: } else {
619: $r->print(&courseinfo_form($dom,$formname,$crstype));
620: }
621: } else {
622: $r->print(&courseinfo_form($dom,$formname,$crstype));
1.1 raeburn 623: }
1.2 raeburn 624: } elsif ($prev eq 'codepick') {
625: $r->print(&courseinfo_form($dom,$formname,$crstype));
626: } elsif ($state eq 'enrollment') {
1.4 raeburn 627: if ($crstype eq 'official') {
628: &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
629: \%cat_order,\@code_order);
630: }
1.2 raeburn 631: $r->print(&print_enrollment_menu($formname,$instcode,$dom,\@codetitles,
632: \%cat_titles,\%cat_order,\@code_order));
633: } elsif ($state eq 'personnel') {
634: $r->print(&print_personnel_menu($dom,$formname));
1.4 raeburn 635: } elsif ($state eq 'review') {
636: &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
637: \%cat_order,\@code_order);
638: $r->print(&print_review($formname,$dom,\@codetitles,\%cat_titles,\%cat_order,
639: \@code_order));
640: $navtxt{'next'} = &mt('Submit course request');
1.1 raeburn 641: }
1.2 raeburn 642: my @excluded = ('counter');
643: my %elements = &form_elements($dom);
644: if (ref($states) eq 'HASH') {
645: if (ref($states->{$action}) eq 'ARRAY') {
646: my @items = @{$states->{$action}};
647: my $numitems = scalar(@items);
648: if ($numitems) {
649: for (my $i=$numitems-1; $i>=0; $i--) {
650: if (ref($elements{$action}) eq 'HASH') {
651: if (ref($elements{$action}{$items[$i]}) eq 'HASH') {
652: foreach my $key (keys(%{$elements{$action}{$items[$i]}})) {
653: push(@excluded,$key);
654: }
655: }
656: }
657: last if ($items[$i] eq $state);
658: }
659: }
660: }
661: }
662: if (grep(/^instcode_/,@excluded)) {
663: push(@excluded,'instcode');
1.1 raeburn 664: }
1.2 raeburn 665: $r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'</form>');
1.4 raeburn 666: &display_navbuttons($r,$formname,$prev,$navtxt{'prev'},$next,$navtxt{'next'});
1.1 raeburn 667: return;
668: }
669:
1.2 raeburn 670: sub print_enrollment_menu {
671: my ($formname,$instcode,$dom,$codetitles,$cat_titles,$cat_order,$code_order) =@_;
672: my ($sections,$autoenroll,$access_dates);
673: my $starttime = time;
674: my $endtime = time+(6*30*24*60*60); # 6 months from now, approx
675:
676: my %accesstitles = (
677: 'start' => 'Default start access',
678: 'end' => 'Default end accss',
679: );
680: my %enrolltitles = (
681: 'start' => 'Start auto-enrollment',
682: 'end' => 'End auto-enrollment',
683: );
684: if ($env{'form.crstype'} eq 'official') {
685: if (&Apache::lonnet::auto_run('',$dom)) {
686: my ($section_form,$crosslist_form,$autoenroll_form);
687: $section_form = &inst_section_selector($dom,$instcode);
688: my $crosslisttotal = $env{'form.crosslisttotal'};
689: if (!defined($crosslisttotal)) {
690: $crosslisttotal = 1;
691: }
692: if ($env{'form.addcrosslist'}) {
693: $crosslisttotal ++;
694: }
695: for (my $i=0; $i<$crosslisttotal; $i++) {
696: $crosslist_form .= &coursecode_form($dom,'crosslist',$codetitles,
697: $cat_titles,$cat_order,$i);
698: }
699: if ($crosslist_form) {
700: $crosslist_form .=
701: &Apache::lonhtmlcommon::row_title(&mt('Add another?')).
702: '<input name="crosslisttotal" type="hidden" value="'.$crosslisttotal.'" />'.
703: '<input name="addcrosslist" type="checkbox" value="'.$crosslisttotal.'"'.
704: ' onclick="javascript:nextPage(document.'.$formname.",'".$env{'form.state'}.
705: "'".');" />'.&mt('Add?').&Apache::lonhtmlcommon::row_closure(1);
706: }
707: if ($section_form || $crosslist_form) {
708: $sections = '<div>'.&Apache::lonhtmlcommon::start_pick_box().
709: $section_form.$crosslist_form.
710: &Apache::lonhtmlcommon::end_pick_box().'</div>'."\n";
711: }
712: $autoenroll_form =
713: &Apache::lonhtmlcommon::row_title(&mt('Add registered students automatically')).
714: '<span class="LC_nobreak"><label>'.
715: '<input type="radio" name="autoadds" value="1">'.
716: &mt('Yes').'</label>'.(' 'x3).'<label>'.
717: '<input type="radio" name="autoadds" value="0" checked="checked">'.
718: &mt('No').'</label></span>'.
719: &Apache::lonhtmlcommon::row_closure().
720: &Apache::lonhtmlcommon::row_title(&mt('Drop unregistered students automatically')).
721: '<span class="LC_nobreak"><label>'.
722: '<input type="radio" name="autodrops" value="1">'.
723: &mt('Yes').'</label>'.(' 'x3).'<label>'.
724: '<input type="radio" name="autodrops" value="0" checked="checked">'.
725: &mt('No').'</label></span>'.
726: &Apache::lonhtmlcommon::row_closure().
727: &date_setting_table($starttime,$endtime,$formname,'enroll',%enrolltitles);
728: if ($autoenroll_form) {
729: $autoenroll = '<div>'.&Apache::lonhtmlcommon::start_pick_box().
730: $autoenroll_form.
731: &Apache::lonhtmlcommon::end_pick_box().'</div>'."\n";
732: }
733: }
734: }
735: my $access_dates_form =
736: &date_setting_table($starttime,$endtime,$formname,'access',%accesstitles);
737: if ($access_dates_form) {
738: $access_dates = '<div>'.&Apache::lonhtmlcommon::start_pick_box().
739: $access_dates_form.
740: &Apache::lonhtmlcommon::end_pick_box().'</div>'."\n";
741: }
742: return $sections.$autoenroll.$access_dates;
743: }
744:
1.1 raeburn 745: sub inst_section_selector {
1.2 raeburn 746: my ($dom,$instcode) = @_;
747: my @sections = &Apache::lonnet::auto_get_sections(undef,$dom,$instcode);
748: my $sectotal = scalar(@sections);
1.1 raeburn 749: my $output;
1.2 raeburn 750: if ($sectotal) {
751: $output .= &Apache::lonhtmlcommon::row_title('Sections').
752: &Apache::loncommon::start_data_table().
753: &Apache::loncommon::start_data_table_row().
754: '<th>'.&mt('Include?').'<input type="hidden" name="sectotal" '.
755: 'value="'.$sectotal.'"</th>'.
756: '<th>'.&mt('Institutional Section').'</th>'.
757: '<th>'.&mt('LON-CAPA section').'</th>'.
758: &Apache::loncommon::end_data_table_row();
759: for (my $i=0; $i<@sections; $i++) {
1.1 raeburn 760: my $colflag = $i%2;
761: $output .= &Apache::loncommon::start_data_table_row().
1.2 raeburn 762: '<td><input type="checkbox" name="sec_'.$i.
763: '" checked="checked" /></td>'.
764: '<td>'.$sections[$i].
1.1 raeburn 765: '<input type="hidden" name="secnum_'.$i.'" value="'.
1.2 raeburn 766: $sections[$i].'" /></td>'.
1.1 raeburn 767: '<td><input type="text" size="10" name="loncapasec_'.$i.
1.2 raeburn 768: '" value="'.$sections[$i].'" /></td>'.
1.1 raeburn 769: &Apache::loncommon::end_data_table_row();
770: }
1.2 raeburn 771: $output .= &Apache::loncommon::end_data_table().
772: &Apache::lonhtmlcommon::row_closure();
1.1 raeburn 773: }
774: return $output;
775: }
776:
1.2 raeburn 777: sub date_setting_table {
778: my ($starttime,$endtime,$formname,$suffix,%datetitles) = @_;
779: my ($perpetual,$table);
780: my $startform = &Apache::lonhtmlcommon::date_setter($formname,'start'.$suffix,
781: $starttime,'','','',1,'','','',1);
782: my $endform = &Apache::lonhtmlcommon::date_setter($formname,'end'.$suffix,
783: $endtime,'','','',1,'','','',1);
784: if ($suffix eq 'access') {
785: $perpetual = ' <span class="LC_nobreak"><label>'.
786: '<input type="checkbox" name="no_end_date" />'.
787: &mt('No end date').'</label></span>';
788: }
789: $table = &Apache::lonhtmlcommon::row_title($datetitles{'start'}).
790: $startform.
791: &Apache::lonhtmlcommon::row_closure().
792: &Apache::lonhtmlcommon::row_title($datetitles{'end'}).
793: $endform.$perpetual.
794: &Apache::lonhtmlcommon::row_closure(1);
795: return $table;
796: }
797:
798: sub print_personnel_menu {
799: my ($dom,$formname) = @_;
800: my $output = '<div>'.&Apache::lonhtmlcommon::start_pick_box();
801: my $persontotal = $env{'form.persontotal'};
802: if (!defined($persontotal)) {
803: $persontotal = 1;
804: }
805: if ($env{'form.addperson'}) {
806: $persontotal ++;
807: }
808: my $userlinktxt = &mt('Set User');
809: my @items = ('uname','dom','last','first','email','hidedom');
810:
811: my $roleoptions;
812: my @roles = &Apache::lonuserutils::roles_by_context('course');
813: foreach my $role (@roles) {
814: my $plrole=&Apache::lonnet::plaintext($role);
815: $roleoptions .= ' <option value="'.$role.'">'.$plrole.'</option>'."\n";
816: }
817: my %customroles=&Apache::lonuserutils::my_custom_roles();
818: if (keys(%customroles) > 0) {
819: foreach my $cust (sort(keys(%customroles))) {
820: my $custrole='cr_cr_'.$env{'user.domain'}.
821: '_'.$env{'user.name'}.'_'.$cust;
822: $roleoptions .= ' <option value="'.$custrole.'">'.$cust.'</option>'."\n";
823: }
824: }
825:
826: my @currsecs;
827: if ($env{'form.sectotal'}) {
828: for (my $i=0; $i<$env{'form.sectotal'}; $i++) {
829: if (defined($env{'form.loncapasec_'.$i})) {
830: my $lcsec = $env{'form.loncapasec_'.$i};
831: unless (grep(/^\Q$lcsec\E$/,@currsecs)) {
832: push(@currsecs,$lcsec);
833: }
834: }
835: }
836: }
837:
838: my ($existtitle,$existops,$existmult,$newtitle,$seccolspan);
839: if (@currsecs) {
840: my $existsize = scalar(@currsecs);
841: if ($existsize > 3) {
842: $existsize = 3;
843: }
844: if ($existsize > 1) {
845: $existmult = ' multiple="multiple" size="'.$existsize.'" ';
846: }
847: @currsecs = sort { $a <=> $b } (@currsecs);
848: $existtitle = &mt('Official').': ';
849: $existops = '<option value="">'.&mt('None').'</option>';
850: foreach my $sec (@currsecs) {
851: $existops .= '<option value="'.$sec.'">'.$sec.'</option>'."\n";
852: }
853: $seccolspan = ' colspan="2"';
854: $newtitle = &mt('Other').': ';
855: }
856:
857: for (my $i=0; $i<$persontotal; $i++) {
858: my @linkargs = map { 'person_'.$i.'_'.$_ } (@items);
859: my $linkargstr = join("','",@linkargs);
860: my $userlink = &Apache::loncommon::selectuser_link($formname,@linkargs,$userlinktxt);
861: my $uname_form = '<input type="text" name="person_'.$i.'_uname" value=""'.
862: ' onFocus="this.blur();'.
863: 'openuserbrowser('."'$formname','$linkargstr'".');" />';
864: my $onchange = 'javascript:fix_domain('."'$formname','person_".$i."_dom',".
865: "'person_".$i."_hidedom'".');'.
866: 'openuserbrowser('."'$formname','$linkargstr'".');';
867: my $udom_form = &Apache::loncommon::select_dom_form($dom,'person_'.$i.'_dom','',
868: 1,$onchange).
869: '<input type="hidden" name="person_'.$i.'_hidedom" value="'.$dom.'" />';
870: my %form_elems;
871: foreach my $item (@items) {
872: next if (($item eq 'dom') || ($item eq 'uname') || ($item eq 'hidedom'));
873: $form_elems{$item} = '<input type="text" name="person_'.$i.'_'.$item.'" '.
874: 'value="" readonly="readonly" />';
875: }
876: my $roleselector = '<select name="person_'.$i.'_role">'."\n".
877: $roleoptions.'</select>';
878: my $sectionselector;
879: if (@currsecs) {
880: $sectionselector = $existtitle.'<select name="person_'.$i.'_sec"'.
881: $existmult.'>'."\n".$existops.'</select>'.(' ' x3);
882: }
883: $sectionselector .= $newtitle.
884: '<input type="text" name="person_'.$i.'_newsec" size="15" value="" />'.
885: '<input type="hidden" name="person_'.$i.'_sections" value="" />'."\n";
886:
887: $output .=
888: &Apache::lonhtmlcommon::row_title(&mt('Additional Personnel').'<br />'.
889: '<span class="LC_nobreak">'.$userlink.
890: '</span>').
891: '<table><tr><td align="center" valign="top">'.&mt('Username').'<br />'.$uname_form.'</td>'."\n".
892: '<td align="center" valign="top" colspan="2">'.&mt('Domain').'<br />'.$udom_form.'</td></tr><tr>'."\n".
893: '<td align="center" valign="top">'.&mt('First Name').'<br />'.$form_elems{'first'}.'</td>'."\n".
894: '<td align="center" valign="top">'.&mt('Last Name').'<br />'.$form_elems{'last'}.'</td>'."\n".
895: '<td align="center" valign="top">'.&mt('E-mail').'<br />'.$form_elems{email}.'</td></tr>'."\n".
896: '<tr><td align="center" valign="top">'.&mt('Role').'<br />'.$roleselector.'</td>'."\n".
897: '<td'.$seccolspan.' align="center" valign="top">'.&mt('Section(s)').'<br />'.$sectionselector.'</td>'."\n".
898: '</tr></table>'.&Apache::lonhtmlcommon::row_closure();
899: }
900: $output .= &Apache::lonhtmlcommon::row_title(&mt('Add another?')).
901: '<input name="persontotal" type="hidden" value="'.$persontotal.'" />'.
902: '<input name="addperson" type="checkbox" value="'.$persontotal.'"'.
903: ' onclick="javascript:nextPage(document.'.$formname.",'".$env{'form.state'}.
904: "'".');" />'.&mt('Add?').&Apache::lonhtmlcommon::row_closure(1).
905: &Apache::lonhtmlcommon::end_pick_box().'</div>';
906: return $output;
907: }
908:
1.1 raeburn 909: sub print_request_status {
910: return;
911: }
912:
913: sub print_request_logs {
914: return;
915: }
916:
917: sub print_review {
1.4 raeburn 918: my ($formname,$dom,$codetitles,$cat_titles,$cat_order,$code_order) = @_;
919: my ($types,$typename) = &course_types();
920: my ($owner,$ownername,$owneremail);
921: $owner = $env{'user.name'}.':'.$env{'user.domain'};
922: $ownername = &Apache::loncommon::plainname($env{'user.name'},
923: $env{'user.domain'},'first');
924: my %emails = &Apache::loncommon::getemails();
925: foreach my $email ('permanentemail','critnotification','notification') {
926: $owneremail = $emails{$email};
927: last if ($owneremail ne '');
928: }
929: my ($inst_headers,$inst_values,$crstypename,$enroll_headers,$enroll_values,
930: $section_headers,$section_values,$personnel_headers,$personnel_values);
931:
932: $crstypename = $env{'form.crstype'};
933: if (ref($typename) eq 'HASH') {
934: unless ($typename->{$env{'form.crstype'}} eq '') {
935: $crstypename = $typename->{$env{'form.crstype'}};
936: }
937: }
938:
939: $inst_headers = '<th>'.&mt('Description').'</th><th>'.&mt('Type').'</th>';
940: $inst_values = '<td>'.$env{'form.cdescr'}.'</td><td>'.$crstypename.'</td>';
941:
942: if ($env{'form.crstype'} eq 'official') {
943: if ((ref($codetitles) eq 'ARRAY') && (ref($cat_titles) eq 'HASH')) {
944: foreach my $title (@{$codetitles}) {
945: if ($env{'form.instcode_'.$title} ne '') {
946: $inst_headers .= '<th>'.$title.'</th>';
947: my $longitem = $env{'form.instcode_'.$title};
948: if (ref($cat_titles->{$title}) eq 'HASH') {
949: if ($cat_titles->{$title}{$env{'form.instcode_'.$title}} ne '') {
950: $longitem = $cat_titles->{$title}{$env{'form.instcode_'.$title}};
951: }
952: }
953: $inst_values .= '<td>'.$longitem.'</td>';
954: }
955: }
956: }
957: if (&Apache::lonnet::auto_run('',$dom)) {
958: $enroll_headers = '<th>'.&mt('Automatic Adds').'</th>'.
959: '<th>'.&mt('Automatic Drops').'</th>'.
960: '<th>'.&mt('Enrollment Starts').'</th>'.
961: '<th>'.&mt('Enrollment Ends').'</th>';
962: $section_headers = '<th>'.&mt('Sections').'</th>'.
963: '<th>'.&mt('Crosslistings').'</th>';
964:
965: my ($startenroll,$endenroll) = &dates_from_form('startenroll','endenroll');
966: my @autoroster = (&mt('No'),&mt('Yes'));
967: $enroll_values = '<td>'.$autoroster[$env{'form.autoadds'}].'</td>'.
968: '<td>'.$autoroster[$env{'form.autodrops'}].'</td>'.
969: '<td>'.&Apache::lonlocal::locallocaltime($startenroll).'</td>'.
970: '<td>'.&Apache::lonlocal::locallocaltime($endenroll).'</td>';
971: $section_values = '<td>';
1.5 ! raeburn 972: my $secinfo;
1.4 raeburn 973: if ($env{'form.sectotal'} > 0) {
974: for (my $i=0; $i<$env{'form.sectotal'}; $i++) {
975: if ($env{'form.sec_'.$i}) {
1.5 ! raeburn 976: $secinfo .= '<tr><td>'.$env{'form.secnum_'.$i}.'</td><td>';
1.4 raeburn 977: if ($env{'form.loncapasec_'.$i} ne '') {
1.5 ! raeburn 978: $secinfo .= $env{'form.loncapasec_'.$i};
! 979: } else {
! 980: $secinfo .= &mt('None');
1.4 raeburn 981: }
1.5 ! raeburn 982: $secinfo .= '</td></tr>';
1.4 raeburn 983: }
984: }
985: }
1.5 ! raeburn 986: if ($secinfo) {
! 987: $section_values .= '<table class="LC_innerpickbox"><tr><th>'.
! 988: &mt('Institutional section').'</th>'.
! 989: '<th>'.&mt('LON-CAPA section').'</th></tr>'.$secinfo.
! 990: '</table>';
! 991: }
1.4 raeburn 992: $section_values .= '</td><td>';
1.5 ! raeburn 993: my $xlistinfo;
1.4 raeburn 994: if ($env{'form.crosslisttotal'}) {
995: for (my $i=0; $i<$env{'form.crosslisttotal'}; $i++) {
996: if ($env{'form.crosslist_'.$i}) {
1.5 ! raeburn 997: $xlistinfo .= '<tr><td>';
! 998: if (ref($code_order) eq 'ARRAY') {
! 999: if (@{$code_order} > 0) {
! 1000: foreach my $item (@{$code_order}) {
! 1001: $xlistinfo .= $env{'form.crosslist_'.$i.'_'.$item};
1.4 raeburn 1002: }
1003: }
1004: }
1.5 ! raeburn 1005: $xlistinfo .= $env{'form.crosslist_'.$i.'_instsec'}.'</td><td>';
1.4 raeburn 1006: if ($env{'form.crosslist_'.$i.'_lcsec'}) {
1.5 ! raeburn 1007: $xlistinfo .= $env{'form.crosslist_'.$i.'_lcsec'};
! 1008: } else {
! 1009: $xlistinfo .= &mt('None');
1.4 raeburn 1010: }
1.5 ! raeburn 1011: $xlistinfo .= '</td></tr>';
1.4 raeburn 1012: }
1013: }
1014: }
1.5 ! raeburn 1015: if ($xlistinfo) {
! 1016: $section_values .= '<table class="LC_innerpickbox"><tr><th>'.
! 1017: &mt('Institutional course/section').'</th>'.
! 1018: '<th>'.&mt('LON-CAPA section').'</th></tr>'.$xlistinfo.
! 1019: '</table>';
! 1020: }
1.4 raeburn 1021: $section_values .= '</td>';
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')).
1095: '<table class="LC_innerpickbox">'.
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>