Annotation of loncom/interface/loncreatecourse.pm, revision 1.122
1.65 raeburn 1: # The LearningOnline Network
1.1 www 2: # Create a course
1.5 albertel 3: #
1.122 ! www 4: # $Id: loncreatecourse.pm,v 1.121 2009/04/04 21:47:40 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" />'
1.122 ! www 495: .&Apache::loncommon::studentbrowser_javascript()
! 496: .&Apache::loncommon::selectstudent_link('ccrs','ccuname','ccdomain')
1.109 bisitz 497: .&Apache::lonhtmlcommon::row_closure()
498:
499: .&Apache::lonhtmlcommon::row_title($lt{'dmn'},"","LC_odd_row_value")
500: .$domform
501: .&Apache::lonhtmlcommon::row_closure(1)
502:
503: .&Apache::lonhtmlcommon::end_pick_box()
1.110 bisitz 504: );
1.109 bisitz 505:
506: $r->print(<<ENDDOCUMENT);
1.113 raeburn 507: </div>
1.55 www 508: <p>
1.90 raeburn 509: <input type="hidden" name="prevphase" value="courseone" />
510: <input type="hidden" name="phase" value="coursetwo" />
1.68 matthew 511: <input type="button" onClick="verify_message(this.form)" value="$lt{'opco'}" />
1.10 matthew 512: </p>
1.2 www 513: </form>
514: ENDDOCUMENT
1.109 bisitz 515:
1.90 raeburn 516: } elsif ($crstype eq 'Group') {
517: $r->print(<<ENDDOCUMENT);
518: <form action="/adm/createcourse" method="post" name="ccrs">
519: <h2>$lt{'ginf'}</h2>
520: <p>
521: <label><b>$lt{'gtit'}:</b>
522: <input type="text" size="50" name="title" /></label>
523: </p><p>
524: <label>
525: <b>$lt{'ghsr'}:</b>$course_home
526: </label>
527: </p><p>
528: <label>
529: <b>$lt{'gidn'} ($lt{'opt'})</b>
530: <input type="text" size="30" name="crsid" />
531: </label>
532: </p>
533: <h2>$lt{'grco'}</h2>
534: <table border="2">
535: <tr><th>$lt{'cngr'}</th><th>$lt{'cegr'}</th></tr>
536: <tr><td>
537: <p>
538: <label>
539: <b>$lt{'map'}:</b>
540: <input type="text" size="50" name="topmap" />
541: </label>
542: <a href="javascript:openbrowser('ccrs','topmap')">$lt{'smap'}</a>
543: </p><p>
544: <label for="nonstd"><b>$lt{'sagr'}</b></label>
545: <br />
546: ($lt{'ocik'}):
547: <input id="nonstd" type="checkbox" name="nonstandard" />
548: </p><p>
549: <b>$lt{'fres'}</b><br />($lt{'stgo'}):
550: <label>
551: <input type="radio" name="firstres" value="blank" />$lt{'blnk'}
552: </label>
553:
554: <label>
1.109 bisitz 555: <input type="radio" name="firstres" value="syl" checked="checked" />$lt{'sllb'}
1.90 raeburn 556: </label>
557:
558: <label>
559: <input type="radio" name="firstres" value="nav" />$lt{'navi'}
560: </label>
561: </p>
562: </td><td>
563: <label>
564: $lt{'gid'}: <input type="text" size="25" name="clonecourse" value="" />
565: </label>
566: <br />
567: <label>
568: $lt{'dmn'}: $cloneform
569: </label>
570: <br />
1.106 www 571: <label><input type="radio" name="datemode" value="delete" /> $lt{'ncd'}</label><br />
572: <label><input type="radio" name="datemode" value="preserve" /> $lt{'prd'}</label><br />
573: <label><input type="radio" name="datemode" value="shift" checked="checked" /> $lt{'shd'}</label>
574: <input type="text" size="5" name="dateshift" value="365" /><br /> <br />
1.90 raeburn 575: $lt{'asov'}.
576: </td></tr>
577: </table>
578: </p>
579: <p>
580: <h2>$lt{'mssg'}</h2>
581: <p>
582: <label>
583: <b>$lt{'sgpf'}: </b>
1.109 bisitz 584: <input type="checkbox" name="setpolicy" checked="checked" />
1.90 raeburn 585: </label>
586: <br />
587: <label>
588: <b>$lt{'scfg'}: </b>
1.109 bisitz 589: <input type="checkbox" name="setcontent" checked="checked" />
1.90 raeburn 590: </label>
591: </p>
592: <h2>$lt{'cmmn'}</h2>
593: <p>
594: <label>
595: <b>$lt{'dmrd'}: </b>
596: <input type="checkbox" name="disresdis" />
597: </label>
598: <br />
599: <label>
600: <b>$lt{'dmuc'}: </b>
601: <input type="checkbox" name="disablechat" />
602: </label>
603: </p>
604: <h2>$lt{'acco'}</h2>
605: <p>
606: <label>
607: <b>$lt{'mnak'}: </b>
608: <input type="checkbox" name="setkeys" />
609: </label>
610: <br />
611: <label>
612: <b>$lt{'kaug'}: </b>
613: <input type="text" size="30" name="keyauth" />
614: </label>
615: </p>
616: <h2>$lt{'rshm'}</h2>
617: <p>
618: <label>
619: <b>$lt{'rshm'}: </b>
620: <input type="text" name="reshome" size="30" value="/res/$defdom/" />
621: </label>
622: </p>
1.93 raeburn 623: <p>
624: <h2>$lt{'grts'}</h2>
625: $lt{'grtq'}
626: <input type="text" name="crsquota" value="20" />Mb
627: </p>
1.90 raeburn 628: <hr />
629: <h2>$lt{'gc'}</h2>
630: <p>
631: <label>
632: <b>$lt{'user'}:</b> <input type="text" size="15" name="ccuname" />
633: </label>
634: </p><p>
635: <label>
636: <b>$lt{'dmn'}:</b> $domform
637: </label>
638: </p>
639: <p>
640: <input type="hidden" name="prevphase" value="groupone" />
641: <input type="hidden" name="phase" value="grouptwo" />
642: <input type="button" onClick="validate(this.form)" value="$lt{'crgr'}" />
643: </p>
644: </form>
645: ENDDOCUMENT
646: }
647: $r->print($end_page);
1.40 raeburn 648: }
649:
1.2 www 650: # ====================================================== Phase two: make course
651:
1.10 matthew 652: sub create_course {
1.2 www 653: my $r=shift;
1.99 albertel 654: my $ccuname =&LONCAPA::clean_username($env{'form.ccuname'});
655: my $ccdomain=&LONCAPA::clean_domain($env{'form.ccdomain'});
1.90 raeburn 656: my $crstype = 'Group';
657: my ($enrollstart,$enrollend,$startaccess,$endaccess);
1.74 raeburn 658:
1.90 raeburn 659: if ($env{'form.phase'} eq 'coursetwo') {
660: $crstype='Course';
661: $enrollstart=&Apache::lonhtmlcommon::get_date_from_form('startenroll');
662: $enrollend=&Apache::lonhtmlcommon::get_date_from_form('endenroll');
663: }
664: $startaccess = &Apache::lonhtmlcommon::get_date_from_form('startaccess');
665: $endaccess = &Apache::lonhtmlcommon::get_date_from_form('endaccess');
1.74 raeburn 666:
667: my $autharg;
668: my $authtype;
669:
1.78 albertel 670: if ($env{'form.login'} eq 'krb') {
1.74 raeburn 671: $authtype = 'krb';
1.78 albertel 672: $authtype .=$env{'form.krbver'};
673: $autharg = $env{'form.krbarg'};
674: } elsif ($env{'form.login'} eq 'int') {
1.74 raeburn 675: $authtype ='internal';
1.78 albertel 676: if ((defined($env{'form.intarg'})) && ($env{'form.intarg'})) {
677: $autharg = $env{'form.intarg'};
1.74 raeburn 678: }
1.78 albertel 679: } elsif ($env{'form.login'} eq 'loc') {
1.74 raeburn 680: $authtype = 'localauth';
1.78 albertel 681: if ((defined($env{'form.locarg'})) && ($env{'form.locarg'})) {
682: $autharg = $env{'form.locarg'};
1.74 raeburn 683: }
684: }
1.90 raeburn 685: my $logmsg;
1.91 albertel 686: my $start_page=&Apache::loncommon::start_page('Create a New '.$crstype);
1.90 raeburn 687: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Outcome','Create_Course',undef,'Create_Courses');
1.74 raeburn 688:
1.90 raeburn 689: $r->print($start_page.$crumbs);
1.74 raeburn 690:
691: my $args = {
1.90 raeburn 692: crstype => $crstype,
1.74 raeburn 693: ccuname => $ccuname,
694: ccdomain => $ccdomain,
1.78 albertel 695: cdescr => $env{'form.title'},
696: curl => $env{'form.topmap'},
697: course_domain => $env{'request.role.domain'},
698: course_home => $env{'form.course_home'},
699: nonstandard => $env{'form.nonstandard'},
700: crscode => $env{'form.crscode'},
1.93 raeburn 701: crsquota => $env{'form.crsquota'},
1.103 raeburn 702: clonecourse => $env{'form.clonecourse'},
703: clonedomain => $env{'form.clonedomain'},
1.106 www 704: datemode => $env{'form.datemode'},
705: dateshift => $env{'form.dateshift'},
1.78 albertel 706: crsid => $env{'form.crsid'},
1.94 raeburn 707: curruser => $env{'user.name'}.':'.$env{'user.domain'},
1.78 albertel 708: crssections => $env{'form.crssections'},
709: crsxlist => $env{'form.crsxlist'},
710: autoadds => $env{'form.autoadds'},
711: autodrops => $env{'form.autodrops'},
712: notify_owner => $env{'form.notify_owner'},
713: notify_dc => $env{'form.notify_dc'},
714: no_end_date => $env{'form.no_end_date'},
715: showphotos => $env{'form.showphotos'},
1.74 raeburn 716: authtype => $authtype,
717: autharg => $autharg,
718: enrollstart => $enrollstart,
719: enrollend => $enrollend,
720: startaccess => $startaccess,
721: endaccess => $endaccess,
1.78 albertel 722: setpolicy => $env{'form.setpolicy'},
723: setcontent => $env{'form.setcontent'},
724: reshome => $env{'form.reshome'},
725: setkeys => $env{'form.setkeys'},
726: keyauth => $env{'form.keyauth'},
727: disresdis => $env{'form.disresdis'},
728: disablechat => $env{'form.disablechat'},
729: openall => $env{'form.openall'},
730: firstres => $env{'form.firstres'}
1.74 raeburn 731: };
732:
1.10 matthew 733: #
734: # Verify data
735: #
736: # Check the veracity of the course coordinator
1.2 www 737: if (&Apache::lonnet::homeserver($ccuname,$ccdomain) eq 'no_host') {
1.52 albertel 738: $r->print('<form action="/adm/createuser" method="post" name="crtuser">');
1.108 bisitz 739: $r->print('<div class="LC_warning">'
740: .&mt('No such user [_1] at domain [_2].','<tt>'.$ccuname.'</tt>','<tt>'.$ccdomain.'</tt>')
741: .'</div>');
742: $r->print(&mt('Please click Back on your browser and select another user, or [_1]Create User[_2]'
743: , '<input type="hidden" name="phase" value="get_user_info" />'
744: .'<input type="hidden" name="ccuname" value="'.$ccuname.'" />'
745: .'<input type="hidden" name="ccdomain" value="'.$ccdomain.'" />'
746: .'<input name="userrole" type="submit" value="'
747: , '" />'
748: )
749: .'</form>'.&Apache::loncommon::end_page()
750: );
1.2 www 751: return;
752: }
1.10 matthew 753: # Check the proposed home server for the course
1.101 albertel 754: my %host_servers =
755: &Apache::lonnet::get_servers($env{'request.role.domain'},'library');
1.78 albertel 756: if (! exists($host_servers{$env{'form.course_home'}})) {
1.108 bisitz 757: $r->print(&mt('Invalid home server for course: [_1]'
758: ,$env{'form.course_home'}.&Apache::loncommon::end_page()));
1.10 matthew 759: return;
760: }
1.74 raeburn 761: my ($courseid,$crsudom,$crsunum);
1.104 albertel 762: my ($success,$output) =
763: &Apache::loncommon::construct_course($args,\$logmsg,\$courseid,
764: \$crsudom,\$crsunum,
765: $env{'user.domain'},
766: $env{'user.name'});
767: $r->print($output);
768: if ($success) {
769: #
770: # Make the requested user a course coordinator or group coordinator
771: #
772: if (($ccdomain) && ($ccuname)) {
1.114 bisitz 773: $r->print(&mt('Assigning role of '.$crstype.' Coordinator to [_1]:',
774: ,'<i>'.$ccuname.':'.$ccdomain.'</i>')
775: .&Apache::lonnet::assignrole($ccdomain,$ccuname,$courseid,
1.107 raeburn 776: 'cc','','','','','createcourse').'<p>');
1.104 albertel 777: }
778: if ($env{'form.setkeys'}) {
779: $r->print(
780: '<p><a href="/adm/managekeys?cid='.$crsudom.'_'.$crsunum.'">'.&mt('Manage Access Keys').'</a></p>');
781: }
782: # Flush the course logs so reverse user roles immediately updated
783: &Apache::lonnet::flushcourselogs();
784: $r->print('<p>'.&mt('Roles will be active at next login').'.</p>');
785: }
786: $r->print('<p><a href="/adm/createcourse?phase='.lc($crstype).'one">'.
1.114 bisitz 787: &mt("Create Another $crstype").'</a></p>'.
1.86 albertel 788: &Apache::loncommon::end_page());
1.74 raeburn 789: }
790:
1.90 raeburn 791: sub print_intro_page {
792: my $r = shift;
793: my $start_page =
794: &Apache::loncommon::start_page('Create a New Course or Group Space');
795: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Options','Create_Course',undef,'Create_Courses');
796: my $end_page =
797: &Apache::loncommon::end_page();
798: my $helplink=&Apache::loncommon::help_open_topic('Create_Course_GroupSpace',&mt('Help on Creating Courses and Groups'));
799:
800: my @choices = ({ internal_name => 'courseone',
801: name => &mt('Create a single course'),
802: short_description =>
803: &mt('Create a new course by completing an online form.'),
804: },
805: { internal_name => 'groupone',
1.108 bisitz 806: name => &mt('Create a single collaborative group space'),
1.90 raeburn 807: short_description =>
1.108 bisitz 808: &mt('Create a new group space for non-course use by completing an online form.'),
1.90 raeburn 809: },
810: { internal_name => 'batchone',
811: name => &mt('Create courses/groups by uploading an attributes file'),
812: short_description =>
1.108 bisitz 813: &mt('Upload an attributes file containing specifications for one or more courses or groups in XML format.'),
1.97 raeburn 814: help => 'Batch_Creation',
1.90 raeburn 815: },
816: );
817: my $options;
818: foreach my $choice (@choices) {
819: $options .=' <h3><a href="/adm/createcourse?phase='.
820: $choice->{'internal_name'}.'" >'.
1.97 raeburn 821: $choice->{'name'}.'</a>';
822: if (exists($choice->{'help'})) {
823: $options .= &Apache::loncommon::help_open_topic($choice->{'help'});
824: }
825: $options .= "</h3>\n".' '.(' 'x8).$choice->{'short_description'}.
1.90 raeburn 826: "\n";
827: }
828:
829: $r->print(<<ENDDOCUMENT);
830: $start_page
831: $crumbs
832: $options
833: $end_page
834: ENDDOCUMENT
835: }
836:
837: sub upload_batchfile {
838: my $r = shift;
839: my $start_page =
840: &Apache::loncommon::start_page('Create a New Course or Group Space');
841: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Upload Course/Group Attributes File','Create_Course',undef,'Create_Courses');
842: my $end_page =
843: &Apache::loncommon::end_page();
844: $r->print($start_page.$crumbs);
845: $r->print('<h3>'.&mt('Upload a courses or groups attributes file').'</h3>');
846: $r->print('<form name="batchcreate" method="post" '.
847: 'enctype="multipart/form-data" action="/adm/createcourse">'.
848: '<input type="file" name="coursecreatorxml" />'.
1.121 bisitz 849: '<input type="hidden" name="phase" value="batchtwo" /><br /><br />'.
1.90 raeburn 850: '<input type="submit" name="batchsubmit" '.
851: 'value="Create Courses/Groups" /></form>');
852: $r->print($end_page);
853: return;
854: }
855:
856: sub process_batchfile {
857: my $r = shift;
858: my $start_page =
859: &Apache::loncommon::start_page('Create a New Course or Group Space');
860: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Outcome','Create_Course',undef,'Create_Courses');
861: my $end_page =
862: &Apache::loncommon::end_page();
863: my $defdom=$env{'request.role.domain'};
864: my $batchfilepath=&Apache::lonnet::userfileupload('coursecreatorxml',undef,
865: 'batchupload',undef,undef,
866: undef,undef,$defdom);
867: my ($batchdir,$filename) = ($batchfilepath =~ m-^(.+)/pending/([^/]+)$-);
868: my ($result,$logmsg);
869: if (-e "$batchfilepath") {
870: open(FILE,"<$batchfilepath");
871: my @buffer = <FILE>;
872: close(FILE);
873: if ((defined($filename)) && (defined($batchdir))) {
874: my @requests = ($filename);
875: my %courseids = ();
876: ($result,$logmsg) = &LONCAPA::batchcreatecourse::create_courses(
877: \@requests,\%courseids,'web',$defdom,
878: $env{'user.name'},$env{'user.domain'});
879: if ($result) {
880: if (!-e "$batchdir/processed") {
881: mkdir("$batchdir/processed", 0755);
882: open(FILE,">$batchdir/processed/$filename");
883: print FILE @buffer;
884: close(FILE);
885: if (-e "$batchdir/processed/$filename") {
886: unlink("$batchdir/pending/$filename");
887: }
888: }
889: }
890: }
891: }
1.103 raeburn 892: $r->print($start_page.$crumbs.$logmsg.$result.'<br /><a href="/adm/createcourse">'.
893: &mt('Creation options menu').'</a>'.$end_page);
1.90 raeburn 894:
895: }
896:
1.2 www 897: # ===================================================================== Handler
1.1 www 898: sub handler {
899: my $r = shift;
900:
901: if ($r->header_only) {
1.38 www 902: &Apache::loncommon::content_type($r,'text/html');
1.1 www 903: $r->send_http_header;
904: return OK;
905: }
906:
1.78 albertel 907: if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {
1.38 www 908: &Apache::loncommon::content_type($r,'text/html');
1.1 www 909: $r->send_http_header;
910:
1.90 raeburn 911: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
912: ['phase']);
913: &Apache::lonhtmlcommon::clear_breadcrumbs();
914: &Apache::lonhtmlcommon::add_breadcrumb
915: ({href=>"/adm/createcourse",
916: text=>"Creation Options",
917: faq=>79,bug=>'Dom Coord Interface',});
918: if (($env{'form.phase'} eq 'coursetwo') ||
919: ($env{'form.phase'} eq 'grouptwo')) {
920: &Apache::lonhtmlcommon::add_breadcrumb
921: ({href=>"/adm/createcourse?phase=$env{'form.prevphase'}",
922: text=>&mt('[_1] Creation Settings',),
923: faq=>9,bug=>'Dom Coord Interface',});
924: &Apache::lonhtmlcommon::add_breadcrumb
925: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
926: text=>"Creation Outcome",
927: faq=>9,bug=>'Dom Coord Interface',});
1.10 matthew 928: &create_course($r);
1.90 raeburn 929: } elsif (($env{'form.phase'} eq 'courseone') ||
930: ($env{'form.phase'} eq 'groupone')) {
931: &Apache::lonhtmlcommon::add_breadcrumb
932: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
933: text=>&mt('[_1] Creation Settings',),
934: faq=>9,bug=>'Dom Coord Interface',});
935: &print_course_creation_page($r);
936: } elsif ($env{'form.phase'} eq 'batchone') {
937: &Apache::lonhtmlcommon::add_breadcrumb
938: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
939: text=>"Upload Description File",
940: faq=>9,bug=>'Dom Coord Interface',});
941: &upload_batchfile($r);
942: } elsif ($env{'form.phase'} eq 'batchtwo') {
943: &Apache::lonhtmlcommon::add_breadcrumb
944: ({href=>"/adm/createcourse?phase=$env{'form.prevphase'}",
945: text=>"Upload Description File",
946: faq=>9,bug=>'Dom Coord Interface',});
947: &Apache::lonhtmlcommon::add_breadcrumb
948: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
949: text=>"Creation Outcome",
950: faq=>9,bug=>'Dom Coord Interface',});
951: &process_batchfile($r);
1.2 www 952: } else {
1.90 raeburn 953: &print_intro_page($r);
1.2 www 954: }
1.1 www 955: } else {
1.78 albertel 956: $env{'user.error.msg'}=
1.90 raeburn 957: "/adm/createcourse:ccc:0:0:Cannot create courses or groups";
1.1 www 958: return HTTP_NOT_ACCEPTABLE;
959: }
960: return OK;
1.90 raeburn 961: }
1.1 www 962:
963: 1;
964: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>