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