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