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