Annotation of loncom/interface/loncreatecourse.pm, revision 1.111
1.65 raeburn 1: # The LearningOnline Network
1.1 www 2: # Create a course
1.5 albertel 3: #
1.111 ! jms 4: # $Id: loncreatecourse.pm,v 1.110 2008/10/08 11:03:53 bisitz Exp $
1.5 albertel 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
1.48 www 28: ###
29:
1.111 ! jms 30: =head1 NAME
! 31:
! 32: Apache::loncreatecourse.pm
! 33:
! 34: =head1 SYNOPSIS
! 35:
! 36: Allows domain coordinators to create new
! 37: courses and assign course coordinators.
! 38:
! 39: This is part of the LearningOnline Network with CAPA project
! 40: described at http://www.lon-capa.org.
! 41:
! 42: =head1 HANDLER SUBROUTINE
! 43:
! 44: handler()
! 45:
! 46: =head1 OTHER SUBROUTINES
! 47:
! 48: =over
! 49:
! 50: =item *
! 51:
! 52: print_course_creation_page()
! 53:
! 54: =item *
! 55:
! 56: create_course()
! 57:
! 58: =item *
! 59:
! 60: print_intro_page()
! 61:
! 62: =item *
! 63:
! 64: upload_batchfile()
! 65:
! 66: =item *
! 67:
! 68: process_batchfile()
! 69:
! 70: =back
! 71:
! 72: =cut
! 73:
1.1 www 74: package Apache::loncreatecourse;
75:
76: use strict;
77: use Apache::Constants qw(:common :http);
78: use Apache::lonnet;
1.12 www 79: use Apache::loncommon;
1.13 www 80: use Apache::londocs;
1.38 www 81: use Apache::lonlocal;
1.105 raeburn 82: use Apache::lonuserutils;
1.96 albertel 83: use Apache::lonclonecourse;
1.90 raeburn 84: use LONCAPA::batchcreatecourse;
1.89 www 85: use LONCAPA;
1.28 www 86:
1.2 www 87: # ===================================================== Phase one: fill-in form
88:
1.10 matthew 89: sub print_course_creation_page {
1.2 www 90: my $r=shift;
1.90 raeburn 91: my $crstype = 'Group';
92: if ($env{'form.phase'} eq 'courseone') {
93: $crstype = 'Course';
94: }
1.78 albertel 95: my $defdom=$env{'request.role.domain'};
1.101 albertel 96: my %host_servers = &Apache::lonnet::get_servers($defdom,'library');
1.10 matthew 97: my $course_home = '<select name="course_home" size="1">'."\n";
98: foreach my $server (sort(keys(%host_servers))) {
1.14 matthew 99: $course_home .= qq{<option value="$server"};
100: if ($server eq $Apache::lonnet::perlvar{'lonHostID'}) {
101: $course_home .= " selected ";
102: }
103: $course_home .= qq{>$server $host_servers{$server}</option>};
1.10 matthew 104: }
105: $course_home .= "\n</select>\n";
1.9 matthew 106: my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain');
1.32 www 107: my $cloneform=&Apache::loncommon::select_dom_form
1.78 albertel 108: ($env{'request.role.domain'},'clonedomain').
1.32 www 109: &Apache::loncommon::selectcourse_link
1.90 raeburn 110: ('ccrs','clonecourse','clonedomain',undef,undef,undef,$crstype);
1.78 albertel 111: my $coursebrowserjs=&Apache::loncommon::coursebrowser_javascript($env{'request.role.domain'});
1.90 raeburn 112: my ($enroll_table,$access_table,$krbdef,$krbdefdom,$krbform,$intform,$locform,
113: $javascript_validations);
114: if ($crstype eq 'Course') {
115: my $starttime = time;
116: my $endtime = time+(6*30*24*60*60); # 6 months from now, approx
1.105 raeburn 117: $enroll_table = &Apache::lonuserutils::date_setting_table($starttime,
118: $endtime,'create_enrolldates');
119: $access_table = &Apache::lonuserutils::date_setting_table($starttime,
120: $endtime,'create_defaultdates');
1.90 raeburn 121: ($krbdef,$krbdefdom) =
122: &Apache::loncommon::get_kerberos_defaults($defdom);
1.105 raeburn 123: $javascript_validations=&Apache::lonuserutils::javascript_validations(
1.90 raeburn 124: 'createcourse',$krbdefdom);
125: my %param = ( formname => 'document.ccrs',
126: kerb_def_dom => $krbdefdom,
127: kerb_def_auth => $krbdef
128: );
129: $krbform = &Apache::loncommon::authform_kerberos(%param);
130: $intform = &Apache::loncommon::authform_internal(%param);
131: $locform = &Apache::loncommon::authform_local(%param);
132: } else {
133: $javascript_validations = qq|
134: function validate(formname) {
135: if (formname.title == '') {
136: alert("A group title is required");
137: return;
138: }
139: if (formname.ccuname == '') {
140: alert("The username of the group coordinator is required");
141: }
142: formname.submit();
143: }
144: |;
145: }
1.46 sakharuk 146: my %lt=&Apache::lonlocal::texthash(
147: 'cinf' => "Course Information",
148: 'ctit' => "Course Title",
149: 'chsr' => "Course Home Server",
150: 'cidn' => "Course ID/Number",
151: 'opt' => "optional",
152: 'iinf' => "Institutional Information",
153: 'stat' => "The following entries will be used to identify the course according to the naming scheme adopted by your institution. Your choices will be used to map an internal LON-CAPA course ID to the corresponding course section ID(s) used by the office responsible for providing official class lists for courses at your institution. This mapping is required if you choose to employ automatic population of class lists.",
154: 'ccod' => "Course Code",
155: 'toin' => "to interface with institutional data, e.g., fs03glg231 for Fall 2003 Geology 231",
1.90 raeburn 156: 'snid' => "Section Numbers and corresponding LON-CAPA section IDs",
157: 'csli' => "a comma separated list of institutional section numbers, each separated by a colon from the (optional) corresponding section ID to be used in LON-CAPA e.g., 001:1,002:2",
1.46 sakharuk 158: 'crcs' => "Crosslisted courses",
1.90 raeburn 159: 'cscs' => "a comma separated list of course sections crosslisted with the current course, with each entry including the institutional course section name followed by a colon and then the (optional) sectionID to be used in LON-CAPA, e.g., fs03ent231001:ent1,fs03bot231001:bot1,fs03zol231002:zol2",
1.46 sakharuk 160: 'crco' => "Course Content",
161: 'cncr' => "Completely new course",
162: 'cecr' => "Clone an existing course",
163: 'map' => "Map",
164: 'smap' => "Select Map",
165: 'sacr' => "Do NOT generate as standard course",
166: 'ocik' => "only check if you know what you are doing",
167: 'fres' => "First Resource",
168: 'stco' => "standard courses only",
169: 'blnk' => "Blank",
170: 'sllb' => "Syllabus",
171: 'navi' => "Navigate",
172: 'cid' => "Course ID",
173: 'dmn' => "Domain",
1.110 bisitz 174: 'dsh' => "Date Shift",
1.46 sakharuk 175: 'asov' => "Additional settings, if specified below, will override cloned settings",
1.106 www 176: 'ncd' => "Do not clone date parameters",
177: 'prd' => 'Clone date parameters as-is',
178: 'shd' => 'Shift date parameters by number of days',
1.46 sakharuk 179: 'assp' => "Assessment Parameters",
180: 'oaas' => "Open all assessments",
181: 'mssg' => "Messaging",
182: 'scpf' => "Set course policy feedback to Course Coordinator",
183: 'scfc' => "Set content feedback to Course Coordinator",
184: 'cmmn' => "Communication",
185: 'dsrd' => "Disable student resource discussion",
186: 'dsuc' => "Disable student use of chatrooms",
187: 'acco' => "Access Control",
188: 'snak' => "Students need access key to enter course",
1.56 www 189: 'kaut' =>
190: 'Key authority (<tt>id@domain</tt>) if other than course',
1.46 sakharuk 191: 'cc' => "Course Coordinator",
192: 'user' => "Username",
193: 'aens' => "Automated enrollment settings",
194: 'aesc' => "The following settings control automatic enrollment of students in this class based on information available for this specific course from your institution's official classlists.",
195: 'aadd' => "Automated adds",
196: 'yes' => "Yes",
197: 'no' => "No",
198: 'audr' => "Automated drops",
199: 'dacu' => "Duration of automated classlist updates",
1.60 raeburn 200: 'dacc' => "Default start and end dates for student access",
1.109 bisitz 201: 'psam' => "Please select the Authentication mechanism",
1.46 sakharuk 202: 'pcda' => "Please choose the default authentication method to be used by new users added to this LON-CAPA domain by the automated enrollment process",
203: 'nech' => "Notification of enrollment changes",
204: 'nccl' => "Notification to course coordinator via LON-CAPA message when enrollment changes occur during the automated update?",
1.77 raeburn 205: 'ndcl' => "Notification to domain coordinator via LON-CAPA message when enrollment changes occur during the automated update?",
1.46 sakharuk 206: 'irsp' => "Include retrieval of student photographs?",
1.55 www 207: 'rshm' => 'Resource Space Home',
1.93 raeburn 208: 'cgrs' => "Course Group Settings",
209: 'cgrq' => "Set a quota for the total disk space available for storage of course group portfolio files.",
1.90 raeburn 210: 'opco' => "Open Course",
211: 'ginf' => "Group Information",
212: 'gtit' => "Group Title",
213: 'ghsr' => "Group Home Server",
214: 'gidn' => "Group ID/Number",
215: 'grco' => "Group Content",
216: 'cngr' => "Completely new group",
217: 'cegr' => "Clone an existing group",
218: 'sagr' => "Do NOT generate as standard group",
219: 'stgo' => "standard groups only",
220: 'sgpf' => "Set group policy feedback to Group Coordinator",
221: 'scfg' => "Set content feedback to Group Coordinator",
222: 'dmrd' => "Disable member resource discussion",
223: 'dmuc' => "Disable member use of chatrooms",
224: 'mnak' => "Members need access key to enter group",
225: 'kaug' =>
226: 'Key authority (<tt>id@domain</tt>) if other than group',
227: 'gc' => "Group Coordinator",
228: 'gid' => "Group ID",
229: 'crgr' => "Create Group",
1.93 raeburn 230: 'grts' => "Group Teams Settings",
231: 'grtq' => "Set a quota for the total disk space available for storage of group team portfolio files.",
232:
1.46 sakharuk 233: );
1.86 albertel 234: my $js = <<END;
235: <script type="text/javascript">
1.6 matthew 236: var editbrowser = null;
237: function openbrowser(formname,elementname) {
238: var url = '/res/?';
239: if (editbrowser == null) {
240: url += 'launch=1&';
241: }
242: url += 'catalogmode=interactive&';
243: url += 'mode=edit&';
244: url += 'form=' + formname + '&';
1.7 matthew 245: url += 'element=' + elementname + '&';
246: url += 'only=sequence' + '';
1.6 matthew 247: var title = 'Browser';
248: var options = 'scrollbars=1,resizable=1,menubar=0';
249: options += ',width=700,height=600';
250: editbrowser = open(url,title,options,'1');
251: editbrowser.focus();
252: }
1.41 raeburn 253: $javascript_validations
1.6 matthew 254: </script>
1.32 www 255: $coursebrowserjs
1.86 albertel 256: END
257:
1.90 raeburn 258: my %titles = &Apache::lonlocal::texthash(
259: courseone => 'Create a New Course',
260: groupone => 'Create a New Group',
261: );
1.86 albertel 262: my $start_page =
1.90 raeburn 263: &Apache::loncommon::start_page($titles{$env{'form.phase'}},$js);
1.86 albertel 264: my $end_page =
265: &Apache::loncommon::end_page();
1.91 albertel 266: my $crumbs =
267: &Apache::lonhtmlcommon::breadcrumbs($crstype.' Information',
268: 'Create_Course',undef,
269: 'Create_Courses');
1.90 raeburn 270: $r->print($start_page.$crumbs);
1.110 bisitz 271:
1.90 raeburn 272: if ($crstype eq 'Course') {
1.109 bisitz 273: $r->print('<form action="/adm/createcourse" method="post" name="ccrs">'
274: .&Apache::lonhtmlcommon::start_pick_box()
275:
276: .&Apache::lonhtmlcommon::row_headline()
277: .'<h3>'.$lt{'cinf'}.'</h3>'
278: .&Apache::lonhtmlcommon::row_closure()
279:
280: .&Apache::lonhtmlcommon::row_title($lt{'ctit'})
281: .'<input type="text" size="50" name="title" />'
282: .&Apache::lonhtmlcommon::row_closure()
283:
284: .&Apache::lonhtmlcommon::row_title($lt{'chsr'})
285: .$course_home
286: .&Apache::lonhtmlcommon::row_closure()
287:
288: .&Apache::lonhtmlcommon::row_title($lt{'cidn'}.' ('.$lt{'opt'}.')')
289: .'<input type="text" size="30" name="crsid" />'
290: .&Apache::lonhtmlcommon::row_closure()
291:
292: .&Apache::lonhtmlcommon::row_headline()
293: .'<h3>'.$lt{'iinf'}.'</h3>'
294: .$lt{'stat'}
295: .&Apache::lonhtmlcommon::row_closure()
296:
297: .&Apache::lonhtmlcommon::row_title($lt{'ccod'})
298: .'<input type="text" size="30" name="crscode" />'
299: .'<br />('.$lt{'toin'}.')'
300: .&Apache::lonhtmlcommon::row_closure()
301:
302: .&Apache::lonhtmlcommon::row_title($lt{'snid'})
303: .'<input type="text" size="30" name="crssections" />'
304: .'<br />('.$lt{'csli'}.')'
305: .&Apache::lonhtmlcommon::row_closure()
306:
307: .&Apache::lonhtmlcommon::row_title($lt{'crcs'})
308: .'<input type="text" size="30" name="crsxlist" />'
309: .'<br />('.$lt{'cscs'}.')'
310: .&Apache::lonhtmlcommon::row_closure()
1.110 bisitz 311: );
1.109 bisitz 312:
1.110 bisitz 313: # Table: New Course / Clone Course
314: $r->print(&Apache::lonhtmlcommon::row_headline()
1.109 bisitz 315: .'<h3>'.$lt{'crco'}.'</h3>'
1.110 bisitz 316: .&Apache::loncommon::start_data_table()
317: .&Apache::loncommon::start_data_table_header_row()
318: .'<th>'.$lt{'cncr'}.'</th>'
319: .'<th> '.&mt('or').' </th>'
320: .'<th>'.$lt{'cecr'}.'</th>'
321: .&Apache::loncommon::end_data_table_header_row()
322: .&Apache::loncommon::start_data_table_row()
323:
324: # New Course:
325: .'<td>'
326: .&Apache::lonhtmlcommon::start_pick_box()
327: .&Apache::lonhtmlcommon::row_title($lt{'map'})
328: .'<input type="text" size="50" name="topmap" />'
329: .'<a href="javascript:openbrowser(\'ccrs\',\'topmap\')">'.$lt{'smap'}.'</a>'
330: .&Apache::lonhtmlcommon::row_closure()
331: .&Apache::lonhtmlcommon::row_title('<label for="nonstd">'.$lt{'sacr'}.'</label>')
332: .'<input id="nonstd" type="checkbox" name="nonstandard" />'
333: .'<br />('.$lt{'ocik'}.')'
334: .&Apache::lonhtmlcommon::row_closure()
335: .&Apache::lonhtmlcommon::row_title($lt{'fres'})
336: .'<label>'
337: .'<input type="radio" name="firstres" value="blank" />'.$lt{'blnk'}
338: .'</label>'
339: .' '
340: .'<label>'
341: .'<input type="radio" name="firstres" value="syl" checked="checked" />'.$lt{'sllb'}
342: .'</label>'
343: .' '
344: .'<label>'
345: .'<input type="radio" name="firstres" value="nav" />'.$lt{'navi'}
346: .'</label>'
347: .'<br />('.$lt{'stco'}.')'
348: .&Apache::lonhtmlcommon::row_closure(1)
349: .&Apache::lonhtmlcommon::end_pick_box()
1.109 bisitz 350:
1.110 bisitz 351: .'<td> </td>'
1.109 bisitz 352:
1.110 bisitz 353: # Clone Course:
354: .'<td>'
355: .&Apache::lonhtmlcommon::start_pick_box()
356: .&Apache::lonhtmlcommon::row_title($lt{'cid'})
357: .'<label>'
358: .'<input type="text" size="25" name="clonecourse" value="" />'
359: .'</label>'
360: .&Apache::lonhtmlcommon::row_closure(1)
361: .&Apache::lonhtmlcommon::row_title($lt{'dmn'})
362: .'<label>'
363: .$cloneform
364: .'</label>'
365: .&Apache::lonhtmlcommon::row_closure()
366: .&Apache::lonhtmlcommon::row_title($lt{'dsh'})
367: .'<label>'
368: .'<input type="radio" name="datemode" value="delete" /> '.$lt{'ncd'}
369: .'</label><br />'
370: .'<label>'
371: .'<input type="radio" name="datemode" value="preserve" /> '.$lt{'prd'}
372: .'</label><br />'
373: .'<label>'
374: .'<input type="radio" name="datemode" value="shift" checked="checked" /> '.$lt{'shd'}
375: .'</label>'
376: .' <input type="text" size="5" name="dateshift" value="365" />'
377: .&Apache::lonhtmlcommon::row_closure()
378: .&Apache::lonhtmlcommon::row_headline()
379: .$lt{'asov'}
380: .&Apache::lonhtmlcommon::row_closure(1)
381: .&Apache::lonhtmlcommon::end_pick_box()
382: .'</td>'
383: .&Apache::loncommon::end_data_table_row()
384: .&Apache::loncommon::end_data_table()
1.109 bisitz 385: .&Apache::lonhtmlcommon::row_closure()
1.110 bisitz 386: );
1.109 bisitz 387:
1.110 bisitz 388: $r->print(&Apache::lonhtmlcommon::row_headline()
1.109 bisitz 389: .'<h3>'.$lt{'assp'}.'</h3>'
390: .&Apache::lonhtmlcommon::row_closure()
391:
392: .&Apache::lonhtmlcommon::row_title($lt{'oaas'})
393: .'<input type="checkbox" name="openall" />'
394: .&Apache::lonhtmlcommon::row_closure()
395:
396: .&Apache::lonhtmlcommon::row_headline()
397: .'<h3>'.$lt{'mssg'}.'</h3>'
398: .&Apache::lonhtmlcommon::row_closure()
399:
400: .&Apache::lonhtmlcommon::row_title($lt{'scpf'})
401: .'<input type="checkbox" name="setpolicy" checked="checked" />'
402: .&Apache::lonhtmlcommon::row_closure()
403:
404: .&Apache::lonhtmlcommon::row_title($lt{'scfc'})
405: .'<input type="checkbox" name="setcontent" checked="checked" />'
406: .&Apache::lonhtmlcommon::row_closure()
407:
408: .&Apache::lonhtmlcommon::row_headline()
409: .'<h3>'.$lt{'cmmn'}.'</h3>'
410: .&Apache::lonhtmlcommon::row_closure()
411:
412: .&Apache::lonhtmlcommon::row_title($lt{'dsrd'})
413: .'<input type="checkbox" name="disresdis" />'
414: .&Apache::lonhtmlcommon::row_closure()
415:
416: .&Apache::lonhtmlcommon::row_title($lt{'dsuc'})
417: .'<input type="checkbox" name="disablechat" /'
418: .&Apache::lonhtmlcommon::row_closure()
419:
420: .&Apache::lonhtmlcommon::row_headline()
421: .'<h3>'.$lt{'acco'}.'</h3>'
422: .&Apache::lonhtmlcommon::row_closure()
423:
424: .&Apache::lonhtmlcommon::row_title($lt{'snak'})
425: .'<input type="checkbox" name="setkeys" />'
426: .&Apache::lonhtmlcommon::row_closure()
427:
428: .&Apache::lonhtmlcommon::row_title($lt{'kaut'})
429: .'<input type="text" size="30" name="keyauth" />'
430: .&Apache::lonhtmlcommon::row_closure()
431:
432: .&Apache::lonhtmlcommon::row_headline()
433: .'<h3>'.$lt{'rshm'}.'</h3>'
434: .&Apache::lonhtmlcommon::row_closure()
435:
436: .&Apache::lonhtmlcommon::row_title($lt{'rshm'})
437: .'<input type="text" name="reshome" size="30" value="/res/'.$defdom.'/" />'
438: .&Apache::lonhtmlcommon::row_closure()
439:
440: .&Apache::lonhtmlcommon::row_headline()
441: .'<h3>'.$lt{'aens'}.'</h3>'
442: .&Apache::lonhtmlcommon::row_closure()
443:
444: .&Apache::lonhtmlcommon::row_title($lt{'aadd'})
445: .'<label><input type="radio" name="autoadds" value="1" />'.$lt{'yes'}.'</label>'
446: .'<label><input type="radio" name="autoadds" value="0" checked="checked" />'.$lt{'no'}.'</label>'
447: .&Apache::lonhtmlcommon::row_closure()
448:
449: .&Apache::lonhtmlcommon::row_title($lt{'audr'})
450: .'<label><input type="radio" name="autodrops" value="1" />'.$lt{'yes'}.'</label>'
451: .'<label><input type="radio" name="autodrops" value="0" checked="checked" />'.$lt{'no'}.'</label>'
452: .&Apache::lonhtmlcommon::row_closure()
453:
454: .&Apache::lonhtmlcommon::row_title($lt{'dacu'})
455: .$enroll_table
456: .&Apache::lonhtmlcommon::row_closure()
457:
458: .&Apache::lonhtmlcommon::row_title($lt{'dacc'})
459: .$access_table
460: .&Apache::lonhtmlcommon::row_closure()
461:
462: .&Apache::lonhtmlcommon::row_title($lt{'psam'})
463: .$lt{'pcda'}.'<br />'
464: .$krbform.'<br />'
465: .$intform.'<br />'
466: .$locform
467: .&Apache::lonhtmlcommon::row_closure()
468:
469: .&Apache::lonhtmlcommon::row_title($lt{'nech'})
470: .$lt{'nccl'}.'<br/>'
471: .'<label><input type="radio" name="notify_owner" value="1" />'.$lt{'yes'}.'</label>'
472: .'<label><input type="radio" name="notify_owner" value="0" checked="checked" />'.$lt{'no'}.'</label>'
473: .'<br />'
474: .$lt{'ndcl'}.'<br/>'
475: .'<label><input type="radio" name="notify_dc" value="1" />'.$lt{'yes'}.'</label>'
476: .'<label><input type="radio" name="notify_dc" value="0" checked="checked" />'.$lt{'no'}.'</label>'
477: .&Apache::lonhtmlcommon::row_closure()
478:
479: .&Apache::lonhtmlcommon::row_title($lt{'irsp'})
480: .'<label>'
481: .'<input type="radio" name="showphotos" value="1" />'.$lt{'yes'}
482: .'</label> '
483: .'<label>'
484: .'<input type="radio" name="showphotos" value="0" checked="checked" />'.$lt{'no'}
485: .'</label> '
486: .&Apache::lonhtmlcommon::row_closure()
487:
488: .&Apache::lonhtmlcommon::row_headline()
489: .'<h3>'.$lt{'cgrs'}.'</h3>'
490: .&Apache::lonhtmlcommon::row_closure()
491:
492: .&Apache::lonhtmlcommon::row_title($lt{'cgrq'})
493: .'<input type="text" name="crsquota" value="20" size="6" />Mb'
494: .&Apache::lonhtmlcommon::row_closure()
495:
496: .&Apache::lonhtmlcommon::row_headline()
497: .'<h3>'.$lt{'cc'}.'</h3>'
498: .&Apache::lonhtmlcommon::row_closure()
499:
500: .&Apache::lonhtmlcommon::row_title($lt{'user'})
501: .'<input type="text" size="15" name="ccuname" />'
502: .&Apache::lonhtmlcommon::row_closure()
503:
504: .&Apache::lonhtmlcommon::row_title($lt{'dmn'},"","LC_odd_row_value")
505: .$domform
506: .&Apache::lonhtmlcommon::row_closure(1)
507:
508: .&Apache::lonhtmlcommon::end_pick_box()
1.110 bisitz 509: );
1.109 bisitz 510:
511: $r->print(<<ENDDOCUMENT);
1.55 www 512: <p>
1.90 raeburn 513: <input type="hidden" name="prevphase" value="courseone" />
514: <input type="hidden" name="phase" value="coursetwo" />
1.68 matthew 515: <input type="button" onClick="verify_message(this.form)" value="$lt{'opco'}" />
1.10 matthew 516: </p>
1.2 www 517: </form>
518: ENDDOCUMENT
1.109 bisitz 519:
1.90 raeburn 520: } elsif ($crstype eq 'Group') {
521: $r->print(<<ENDDOCUMENT);
522: <form action="/adm/createcourse" method="post" name="ccrs">
523: <h2>$lt{'ginf'}</h2>
524: <p>
525: <label><b>$lt{'gtit'}:</b>
526: <input type="text" size="50" name="title" /></label>
527: </p><p>
528: <label>
529: <b>$lt{'ghsr'}:</b>$course_home
530: </label>
531: </p><p>
532: <label>
533: <b>$lt{'gidn'} ($lt{'opt'})</b>
534: <input type="text" size="30" name="crsid" />
535: </label>
536: </p>
537: <h2>$lt{'grco'}</h2>
538: <table border="2">
539: <tr><th>$lt{'cngr'}</th><th>$lt{'cegr'}</th></tr>
540: <tr><td>
541: <p>
542: <label>
543: <b>$lt{'map'}:</b>
544: <input type="text" size="50" name="topmap" />
545: </label>
546: <a href="javascript:openbrowser('ccrs','topmap')">$lt{'smap'}</a>
547: </p><p>
548: <label for="nonstd"><b>$lt{'sagr'}</b></label>
549: <br />
550: ($lt{'ocik'}):
551: <input id="nonstd" type="checkbox" name="nonstandard" />
552: </p><p>
553: <b>$lt{'fres'}</b><br />($lt{'stgo'}):
554: <label>
555: <input type="radio" name="firstres" value="blank" />$lt{'blnk'}
556: </label>
557:
558: <label>
1.109 bisitz 559: <input type="radio" name="firstres" value="syl" checked="checked" />$lt{'sllb'}
1.90 raeburn 560: </label>
561:
562: <label>
563: <input type="radio" name="firstres" value="nav" />$lt{'navi'}
564: </label>
565: </p>
566: </td><td>
567: <label>
568: $lt{'gid'}: <input type="text" size="25" name="clonecourse" value="" />
569: </label>
570: <br />
571: <label>
572: $lt{'dmn'}: $cloneform
573: </label>
574: <br />
1.106 www 575: <label><input type="radio" name="datemode" value="delete" /> $lt{'ncd'}</label><br />
576: <label><input type="radio" name="datemode" value="preserve" /> $lt{'prd'}</label><br />
577: <label><input type="radio" name="datemode" value="shift" checked="checked" /> $lt{'shd'}</label>
578: <input type="text" size="5" name="dateshift" value="365" /><br /> <br />
1.90 raeburn 579: $lt{'asov'}.
580: </td></tr>
581: </table>
582: </p>
583: <p>
584: <h2>$lt{'mssg'}</h2>
585: <p>
586: <label>
587: <b>$lt{'sgpf'}: </b>
1.109 bisitz 588: <input type="checkbox" name="setpolicy" checked="checked" />
1.90 raeburn 589: </label>
590: <br />
591: <label>
592: <b>$lt{'scfg'}: </b>
1.109 bisitz 593: <input type="checkbox" name="setcontent" checked="checked" />
1.90 raeburn 594: </label>
595: </p>
596: <h2>$lt{'cmmn'}</h2>
597: <p>
598: <label>
599: <b>$lt{'dmrd'}: </b>
600: <input type="checkbox" name="disresdis" />
601: </label>
602: <br />
603: <label>
604: <b>$lt{'dmuc'}: </b>
605: <input type="checkbox" name="disablechat" />
606: </label>
607: </p>
608: <h2>$lt{'acco'}</h2>
609: <p>
610: <label>
611: <b>$lt{'mnak'}: </b>
612: <input type="checkbox" name="setkeys" />
613: </label>
614: <br />
615: <label>
616: <b>$lt{'kaug'}: </b>
617: <input type="text" size="30" name="keyauth" />
618: </label>
619: </p>
620: <h2>$lt{'rshm'}</h2>
621: <p>
622: <label>
623: <b>$lt{'rshm'}: </b>
624: <input type="text" name="reshome" size="30" value="/res/$defdom/" />
625: </label>
626: </p>
1.93 raeburn 627: <p>
628: <h2>$lt{'grts'}</h2>
629: $lt{'grtq'}
630: <input type="text" name="crsquota" value="20" />Mb
631: </p>
1.90 raeburn 632: <hr />
633: <h2>$lt{'gc'}</h2>
634: <p>
635: <label>
636: <b>$lt{'user'}:</b> <input type="text" size="15" name="ccuname" />
637: </label>
638: </p><p>
639: <label>
640: <b>$lt{'dmn'}:</b> $domform
641: </label>
642: </p>
643: <p>
644: <input type="hidden" name="prevphase" value="groupone" />
645: <input type="hidden" name="phase" value="grouptwo" />
646: <input type="button" onClick="validate(this.form)" value="$lt{'crgr'}" />
647: </p>
648: </form>
649: ENDDOCUMENT
650: }
651: $r->print($end_page);
1.40 raeburn 652: }
653:
1.2 www 654: # ====================================================== Phase two: make course
655:
1.10 matthew 656: sub create_course {
1.2 www 657: my $r=shift;
1.99 albertel 658: my $ccuname =&LONCAPA::clean_username($env{'form.ccuname'});
659: my $ccdomain=&LONCAPA::clean_domain($env{'form.ccdomain'});
1.90 raeburn 660: my $crstype = 'Group';
661: my ($enrollstart,$enrollend,$startaccess,$endaccess);
1.74 raeburn 662:
1.90 raeburn 663: if ($env{'form.phase'} eq 'coursetwo') {
664: $crstype='Course';
665: $enrollstart=&Apache::lonhtmlcommon::get_date_from_form('startenroll');
666: $enrollend=&Apache::lonhtmlcommon::get_date_from_form('endenroll');
667: }
668: $startaccess = &Apache::lonhtmlcommon::get_date_from_form('startaccess');
669: $endaccess = &Apache::lonhtmlcommon::get_date_from_form('endaccess');
1.74 raeburn 670:
671: my $autharg;
672: my $authtype;
673:
1.78 albertel 674: if ($env{'form.login'} eq 'krb') {
1.74 raeburn 675: $authtype = 'krb';
1.78 albertel 676: $authtype .=$env{'form.krbver'};
677: $autharg = $env{'form.krbarg'};
678: } elsif ($env{'form.login'} eq 'int') {
1.74 raeburn 679: $authtype ='internal';
1.78 albertel 680: if ((defined($env{'form.intarg'})) && ($env{'form.intarg'})) {
681: $autharg = $env{'form.intarg'};
1.74 raeburn 682: }
1.78 albertel 683: } elsif ($env{'form.login'} eq 'loc') {
1.74 raeburn 684: $authtype = 'localauth';
1.78 albertel 685: if ((defined($env{'form.locarg'})) && ($env{'form.locarg'})) {
686: $autharg = $env{'form.locarg'};
1.74 raeburn 687: }
688: }
1.90 raeburn 689: my $logmsg;
1.91 albertel 690: my $start_page=&Apache::loncommon::start_page('Create a New '.$crstype);
1.90 raeburn 691: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Outcome','Create_Course',undef,'Create_Courses');
1.74 raeburn 692:
1.90 raeburn 693: $r->print($start_page.$crumbs);
1.74 raeburn 694:
695: my $args = {
1.90 raeburn 696: crstype => $crstype,
1.74 raeburn 697: ccuname => $ccuname,
698: ccdomain => $ccdomain,
1.78 albertel 699: cdescr => $env{'form.title'},
700: curl => $env{'form.topmap'},
701: course_domain => $env{'request.role.domain'},
702: course_home => $env{'form.course_home'},
703: nonstandard => $env{'form.nonstandard'},
704: crscode => $env{'form.crscode'},
1.93 raeburn 705: crsquota => $env{'form.crsquota'},
1.103 raeburn 706: clonecourse => $env{'form.clonecourse'},
707: clonedomain => $env{'form.clonedomain'},
1.106 www 708: datemode => $env{'form.datemode'},
709: dateshift => $env{'form.dateshift'},
1.78 albertel 710: crsid => $env{'form.crsid'},
1.94 raeburn 711: curruser => $env{'user.name'}.':'.$env{'user.domain'},
1.78 albertel 712: crssections => $env{'form.crssections'},
713: crsxlist => $env{'form.crsxlist'},
714: autoadds => $env{'form.autoadds'},
715: autodrops => $env{'form.autodrops'},
716: notify_owner => $env{'form.notify_owner'},
717: notify_dc => $env{'form.notify_dc'},
718: no_end_date => $env{'form.no_end_date'},
719: showphotos => $env{'form.showphotos'},
1.74 raeburn 720: authtype => $authtype,
721: autharg => $autharg,
722: enrollstart => $enrollstart,
723: enrollend => $enrollend,
724: startaccess => $startaccess,
725: endaccess => $endaccess,
1.78 albertel 726: setpolicy => $env{'form.setpolicy'},
727: setcontent => $env{'form.setcontent'},
728: reshome => $env{'form.reshome'},
729: setkeys => $env{'form.setkeys'},
730: keyauth => $env{'form.keyauth'},
731: disresdis => $env{'form.disresdis'},
732: disablechat => $env{'form.disablechat'},
733: openall => $env{'form.openall'},
734: firstres => $env{'form.firstres'}
1.74 raeburn 735: };
736:
1.10 matthew 737: #
738: # Verify data
739: #
740: # Check the veracity of the course coordinator
1.2 www 741: if (&Apache::lonnet::homeserver($ccuname,$ccdomain) eq 'no_host') {
1.52 albertel 742: $r->print('<form action="/adm/createuser" method="post" name="crtuser">');
1.108 bisitz 743: $r->print('<div class="LC_warning">'
744: .&mt('No such user [_1] at domain [_2].','<tt>'.$ccuname.'</tt>','<tt>'.$ccdomain.'</tt>')
745: .'</div>');
746: $r->print(&mt('Please click Back on your browser and select another user, or [_1]Create User[_2]'
747: , '<input type="hidden" name="phase" value="get_user_info" />'
748: .'<input type="hidden" name="ccuname" value="'.$ccuname.'" />'
749: .'<input type="hidden" name="ccdomain" value="'.$ccdomain.'" />'
750: .'<input name="userrole" type="submit" value="'
751: , '" />'
752: )
753: .'</form>'.&Apache::loncommon::end_page()
754: );
1.2 www 755: return;
756: }
1.10 matthew 757: # Check the proposed home server for the course
1.101 albertel 758: my %host_servers =
759: &Apache::lonnet::get_servers($env{'request.role.domain'},'library');
1.78 albertel 760: if (! exists($host_servers{$env{'form.course_home'}})) {
1.108 bisitz 761: $r->print(&mt('Invalid home server for course: [_1]'
762: ,$env{'form.course_home'}.&Apache::loncommon::end_page()));
1.10 matthew 763: return;
764: }
1.74 raeburn 765: my ($courseid,$crsudom,$crsunum);
1.104 albertel 766: my ($success,$output) =
767: &Apache::loncommon::construct_course($args,\$logmsg,\$courseid,
768: \$crsudom,\$crsunum,
769: $env{'user.domain'},
770: $env{'user.name'});
771: $r->print($output);
772: if ($success) {
773: #
774: # Make the requested user a course coordinator or group coordinator
775: #
776: if (($ccdomain) && ($ccuname)) {
777: $r->print(&mt('Assigning role of [_1] Coordinator to [_2] at [_3]: ',
778: $crstype,$ccuname,$ccdomain).
779: &Apache::lonnet::assignrole($ccdomain,$ccuname,$courseid,
1.107 raeburn 780: 'cc','','','','','createcourse').'<p>');
1.104 albertel 781: }
782: if ($env{'form.setkeys'}) {
783: $r->print(
784: '<p><a href="/adm/managekeys?cid='.$crsudom.'_'.$crsunum.'">'.&mt('Manage Access Keys').'</a></p>');
785: }
786: # Flush the course logs so reverse user roles immediately updated
787: &Apache::lonnet::flushcourselogs();
788: $r->print('<p>'.&mt('Roles will be active at next login').'.</p>');
789: }
790: $r->print('<p><a href="/adm/createcourse?phase='.lc($crstype).'one">'.
1.90 raeburn 791: &mt('Create Another [_1]',$crstype).'</a></p>'.
1.86 albertel 792: &Apache::loncommon::end_page());
1.74 raeburn 793: }
794:
1.90 raeburn 795: sub print_intro_page {
796: my $r = shift;
797: my $start_page =
798: &Apache::loncommon::start_page('Create a New Course or Group Space');
799: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Options','Create_Course',undef,'Create_Courses');
800: my $end_page =
801: &Apache::loncommon::end_page();
802: my $helplink=&Apache::loncommon::help_open_topic('Create_Course_GroupSpace',&mt('Help on Creating Courses and Groups'));
803:
804: my @choices = ({ internal_name => 'courseone',
805: name => &mt('Create a single course'),
806: short_description =>
807: &mt('Create a new course by completing an online form.'),
808: },
809: { internal_name => 'groupone',
1.108 bisitz 810: name => &mt('Create a single collaborative group space'),
1.90 raeburn 811: short_description =>
1.108 bisitz 812: &mt('Create a new group space for non-course use by completing an online form.'),
1.90 raeburn 813: },
814: { internal_name => 'batchone',
815: name => &mt('Create courses/groups by uploading an attributes file'),
816: short_description =>
1.108 bisitz 817: &mt('Upload an attributes file containing specifications for one or more courses or groups in XML format.'),
1.97 raeburn 818: help => 'Batch_Creation',
1.90 raeburn 819: },
820: );
821: my $options;
822: foreach my $choice (@choices) {
823: $options .=' <h3><a href="/adm/createcourse?phase='.
824: $choice->{'internal_name'}.'" >'.
1.97 raeburn 825: $choice->{'name'}.'</a>';
826: if (exists($choice->{'help'})) {
827: $options .= &Apache::loncommon::help_open_topic($choice->{'help'});
828: }
829: $options .= "</h3>\n".' '.(' 'x8).$choice->{'short_description'}.
1.90 raeburn 830: "\n";
831: }
832:
833: $r->print(<<ENDDOCUMENT);
834: $start_page
835: $crumbs
836: $options
837: $end_page
838: ENDDOCUMENT
839: }
840:
841: sub upload_batchfile {
842: my $r = shift;
843: my $start_page =
844: &Apache::loncommon::start_page('Create a New Course or Group Space');
845: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Upload Course/Group Attributes File','Create_Course',undef,'Create_Courses');
846: my $end_page =
847: &Apache::loncommon::end_page();
848: $r->print($start_page.$crumbs);
849: $r->print('<h3>'.&mt('Upload a courses or groups attributes file').'</h3>');
850: $r->print('<form name="batchcreate" method="post" '.
851: 'enctype="multipart/form-data" action="/adm/createcourse">'.
852: '<input type="file" name="coursecreatorxml" />'.
853: '<input type="hidden" name="phase" value="batchtwo"><br /><br />'.
854: '<input type="submit" name="batchsubmit" '.
855: 'value="Create Courses/Groups" /></form>');
856: $r->print($end_page);
857: return;
858: }
859:
860: sub process_batchfile {
861: my $r = shift;
862: my $start_page =
863: &Apache::loncommon::start_page('Create a New Course or Group Space');
864: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Outcome','Create_Course',undef,'Create_Courses');
865: my $end_page =
866: &Apache::loncommon::end_page();
867: my $defdom=$env{'request.role.domain'};
868: my $batchfilepath=&Apache::lonnet::userfileupload('coursecreatorxml',undef,
869: 'batchupload',undef,undef,
870: undef,undef,$defdom);
871: my ($batchdir,$filename) = ($batchfilepath =~ m-^(.+)/pending/([^/]+)$-);
872: my ($result,$logmsg);
873: if (-e "$batchfilepath") {
874: open(FILE,"<$batchfilepath");
875: my @buffer = <FILE>;
876: close(FILE);
877: if ((defined($filename)) && (defined($batchdir))) {
878: my @requests = ($filename);
879: my %courseids = ();
880: ($result,$logmsg) = &LONCAPA::batchcreatecourse::create_courses(
881: \@requests,\%courseids,'web',$defdom,
882: $env{'user.name'},$env{'user.domain'});
883: if ($result) {
884: if (!-e "$batchdir/processed") {
885: mkdir("$batchdir/processed", 0755);
886: open(FILE,">$batchdir/processed/$filename");
887: print FILE @buffer;
888: close(FILE);
889: if (-e "$batchdir/processed/$filename") {
890: unlink("$batchdir/pending/$filename");
891: }
892: }
893: }
894: }
895: }
1.103 raeburn 896: $r->print($start_page.$crumbs.$logmsg.$result.'<br /><a href="/adm/createcourse">'.
897: &mt('Creation options menu').'</a>'.$end_page);
1.90 raeburn 898:
899: }
900:
1.2 www 901: # ===================================================================== Handler
1.1 www 902: sub handler {
903: my $r = shift;
904:
905: if ($r->header_only) {
1.38 www 906: &Apache::loncommon::content_type($r,'text/html');
1.1 www 907: $r->send_http_header;
908: return OK;
909: }
910:
1.78 albertel 911: if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {
1.38 www 912: &Apache::loncommon::content_type($r,'text/html');
1.1 www 913: $r->send_http_header;
914:
1.90 raeburn 915: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
916: ['phase']);
917: &Apache::lonhtmlcommon::clear_breadcrumbs();
918: &Apache::lonhtmlcommon::add_breadcrumb
919: ({href=>"/adm/createcourse",
920: text=>"Creation Options",
921: faq=>79,bug=>'Dom Coord Interface',});
922: if (($env{'form.phase'} eq 'coursetwo') ||
923: ($env{'form.phase'} eq 'grouptwo')) {
924: &Apache::lonhtmlcommon::add_breadcrumb
925: ({href=>"/adm/createcourse?phase=$env{'form.prevphase'}",
926: text=>&mt('[_1] Creation Settings',),
927: faq=>9,bug=>'Dom Coord Interface',});
928: &Apache::lonhtmlcommon::add_breadcrumb
929: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
930: text=>"Creation Outcome",
931: faq=>9,bug=>'Dom Coord Interface',});
1.10 matthew 932: &create_course($r);
1.90 raeburn 933: } elsif (($env{'form.phase'} eq 'courseone') ||
934: ($env{'form.phase'} eq 'groupone')) {
935: &Apache::lonhtmlcommon::add_breadcrumb
936: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
937: text=>&mt('[_1] Creation Settings',),
938: faq=>9,bug=>'Dom Coord Interface',});
939: &print_course_creation_page($r);
940: } elsif ($env{'form.phase'} eq 'batchone') {
941: &Apache::lonhtmlcommon::add_breadcrumb
942: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
943: text=>"Upload Description File",
944: faq=>9,bug=>'Dom Coord Interface',});
945: &upload_batchfile($r);
946: } elsif ($env{'form.phase'} eq 'batchtwo') {
947: &Apache::lonhtmlcommon::add_breadcrumb
948: ({href=>"/adm/createcourse?phase=$env{'form.prevphase'}",
949: text=>"Upload Description File",
950: faq=>9,bug=>'Dom Coord Interface',});
951: &Apache::lonhtmlcommon::add_breadcrumb
952: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
953: text=>"Creation Outcome",
954: faq=>9,bug=>'Dom Coord Interface',});
955: &process_batchfile($r);
1.2 www 956: } else {
1.90 raeburn 957: &print_intro_page($r);
1.2 www 958: }
1.1 www 959: } else {
1.78 albertel 960: $env{'user.error.msg'}=
1.90 raeburn 961: "/adm/createcourse:ccc:0:0:Cannot create courses or groups";
1.1 www 962: return HTTP_NOT_ACCEPTABLE;
963: }
964: return OK;
1.90 raeburn 965: }
1.1 www 966:
967: 1;
968: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>