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