Annotation of loncom/interface/loncreatecourse.pm, revision 1.110
1.65 raeburn 1: # The LearningOnline Network
1.1 www 2: # Create a course
1.5 albertel 3: #
1.110 ! bisitz 4: # $Id: loncreatecourse.pm,v 1.109 2008/09/25 17:44:11 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">'
230: .&Apache::lonhtmlcommon::start_pick_box()
231:
232: .&Apache::lonhtmlcommon::row_headline()
233: .'<h3>'.$lt{'cinf'}.'</h3>'
234: .&Apache::lonhtmlcommon::row_closure()
235:
236: .&Apache::lonhtmlcommon::row_title($lt{'ctit'})
237: .'<input type="text" size="50" name="title" />'
238: .&Apache::lonhtmlcommon::row_closure()
239:
240: .&Apache::lonhtmlcommon::row_title($lt{'chsr'})
241: .$course_home
242: .&Apache::lonhtmlcommon::row_closure()
243:
244: .&Apache::lonhtmlcommon::row_title($lt{'cidn'}.' ('.$lt{'opt'}.')')
245: .'<input type="text" size="30" name="crsid" />'
246: .&Apache::lonhtmlcommon::row_closure()
247:
248: .&Apache::lonhtmlcommon::row_headline()
249: .'<h3>'.$lt{'iinf'}.'</h3>'
250: .$lt{'stat'}
251: .&Apache::lonhtmlcommon::row_closure()
252:
253: .&Apache::lonhtmlcommon::row_title($lt{'ccod'})
254: .'<input type="text" size="30" name="crscode" />'
255: .'<br />('.$lt{'toin'}.')'
256: .&Apache::lonhtmlcommon::row_closure()
257:
258: .&Apache::lonhtmlcommon::row_title($lt{'snid'})
259: .'<input type="text" size="30" name="crssections" />'
260: .'<br />('.$lt{'csli'}.')'
261: .&Apache::lonhtmlcommon::row_closure()
262:
263: .&Apache::lonhtmlcommon::row_title($lt{'crcs'})
264: .'<input type="text" size="30" name="crsxlist" />'
265: .'<br />('.$lt{'cscs'}.')'
266: .&Apache::lonhtmlcommon::row_closure()
1.110 ! bisitz 267: );
1.109 bisitz 268:
1.110 ! bisitz 269: # Table: New Course / Clone Course
! 270: $r->print(&Apache::lonhtmlcommon::row_headline()
1.109 bisitz 271: .'<h3>'.$lt{'crco'}.'</h3>'
1.110 ! bisitz 272: .&Apache::loncommon::start_data_table()
! 273: .&Apache::loncommon::start_data_table_header_row()
! 274: .'<th>'.$lt{'cncr'}.'</th>'
! 275: .'<th> '.&mt('or').' </th>'
! 276: .'<th>'.$lt{'cecr'}.'</th>'
! 277: .&Apache::loncommon::end_data_table_header_row()
! 278: .&Apache::loncommon::start_data_table_row()
! 279:
! 280: # New Course:
! 281: .'<td>'
! 282: .&Apache::lonhtmlcommon::start_pick_box()
! 283: .&Apache::lonhtmlcommon::row_title($lt{'map'})
! 284: .'<input type="text" size="50" name="topmap" />'
! 285: .'<a href="javascript:openbrowser(\'ccrs\',\'topmap\')">'.$lt{'smap'}.'</a>'
! 286: .&Apache::lonhtmlcommon::row_closure()
! 287: .&Apache::lonhtmlcommon::row_title('<label for="nonstd">'.$lt{'sacr'}.'</label>')
! 288: .'<input id="nonstd" type="checkbox" name="nonstandard" />'
! 289: .'<br />('.$lt{'ocik'}.')'
! 290: .&Apache::lonhtmlcommon::row_closure()
! 291: .&Apache::lonhtmlcommon::row_title($lt{'fres'})
! 292: .'<label>'
! 293: .'<input type="radio" name="firstres" value="blank" />'.$lt{'blnk'}
! 294: .'</label>'
! 295: .' '
! 296: .'<label>'
! 297: .'<input type="radio" name="firstres" value="syl" checked="checked" />'.$lt{'sllb'}
! 298: .'</label>'
! 299: .' '
! 300: .'<label>'
! 301: .'<input type="radio" name="firstres" value="nav" />'.$lt{'navi'}
! 302: .'</label>'
! 303: .'<br />('.$lt{'stco'}.')'
! 304: .&Apache::lonhtmlcommon::row_closure(1)
! 305: .&Apache::lonhtmlcommon::end_pick_box()
1.109 bisitz 306:
1.110 ! bisitz 307: .'<td> </td>'
1.109 bisitz 308:
1.110 ! bisitz 309: # Clone Course:
! 310: .'<td>'
! 311: .&Apache::lonhtmlcommon::start_pick_box()
! 312: .&Apache::lonhtmlcommon::row_title($lt{'cid'})
! 313: .'<label>'
! 314: .'<input type="text" size="25" name="clonecourse" value="" />'
! 315: .'</label>'
! 316: .&Apache::lonhtmlcommon::row_closure(1)
! 317: .&Apache::lonhtmlcommon::row_title($lt{'dmn'})
! 318: .'<label>'
! 319: .$cloneform
! 320: .'</label>'
! 321: .&Apache::lonhtmlcommon::row_closure()
! 322: .&Apache::lonhtmlcommon::row_title($lt{'dsh'})
! 323: .'<label>'
! 324: .'<input type="radio" name="datemode" value="delete" /> '.$lt{'ncd'}
! 325: .'</label><br />'
! 326: .'<label>'
! 327: .'<input type="radio" name="datemode" value="preserve" /> '.$lt{'prd'}
! 328: .'</label><br />'
! 329: .'<label>'
! 330: .'<input type="radio" name="datemode" value="shift" checked="checked" /> '.$lt{'shd'}
! 331: .'</label>'
! 332: .' <input type="text" size="5" name="dateshift" value="365" />'
! 333: .&Apache::lonhtmlcommon::row_closure()
! 334: .&Apache::lonhtmlcommon::row_headline()
! 335: .$lt{'asov'}
! 336: .&Apache::lonhtmlcommon::row_closure(1)
! 337: .&Apache::lonhtmlcommon::end_pick_box()
! 338: .'</td>'
! 339: .&Apache::loncommon::end_data_table_row()
! 340: .&Apache::loncommon::end_data_table()
1.109 bisitz 341: .&Apache::lonhtmlcommon::row_closure()
1.110 ! bisitz 342: );
1.109 bisitz 343:
1.110 ! bisitz 344: $r->print(&Apache::lonhtmlcommon::row_headline()
1.109 bisitz 345: .'<h3>'.$lt{'assp'}.'</h3>'
346: .&Apache::lonhtmlcommon::row_closure()
347:
348: .&Apache::lonhtmlcommon::row_title($lt{'oaas'})
349: .'<input type="checkbox" name="openall" />'
350: .&Apache::lonhtmlcommon::row_closure()
351:
352: .&Apache::lonhtmlcommon::row_headline()
353: .'<h3>'.$lt{'mssg'}.'</h3>'
354: .&Apache::lonhtmlcommon::row_closure()
355:
356: .&Apache::lonhtmlcommon::row_title($lt{'scpf'})
357: .'<input type="checkbox" name="setpolicy" checked="checked" />'
358: .&Apache::lonhtmlcommon::row_closure()
359:
360: .&Apache::lonhtmlcommon::row_title($lt{'scfc'})
361: .'<input type="checkbox" name="setcontent" checked="checked" />'
362: .&Apache::lonhtmlcommon::row_closure()
363:
364: .&Apache::lonhtmlcommon::row_headline()
365: .'<h3>'.$lt{'cmmn'}.'</h3>'
366: .&Apache::lonhtmlcommon::row_closure()
367:
368: .&Apache::lonhtmlcommon::row_title($lt{'dsrd'})
369: .'<input type="checkbox" name="disresdis" />'
370: .&Apache::lonhtmlcommon::row_closure()
371:
372: .&Apache::lonhtmlcommon::row_title($lt{'dsuc'})
373: .'<input type="checkbox" name="disablechat" /'
374: .&Apache::lonhtmlcommon::row_closure()
375:
376: .&Apache::lonhtmlcommon::row_headline()
377: .'<h3>'.$lt{'acco'}.'</h3>'
378: .&Apache::lonhtmlcommon::row_closure()
379:
380: .&Apache::lonhtmlcommon::row_title($lt{'snak'})
381: .'<input type="checkbox" name="setkeys" />'
382: .&Apache::lonhtmlcommon::row_closure()
383:
384: .&Apache::lonhtmlcommon::row_title($lt{'kaut'})
385: .'<input type="text" size="30" name="keyauth" />'
386: .&Apache::lonhtmlcommon::row_closure()
387:
388: .&Apache::lonhtmlcommon::row_headline()
389: .'<h3>'.$lt{'rshm'}.'</h3>'
390: .&Apache::lonhtmlcommon::row_closure()
391:
392: .&Apache::lonhtmlcommon::row_title($lt{'rshm'})
393: .'<input type="text" name="reshome" size="30" value="/res/'.$defdom.'/" />'
394: .&Apache::lonhtmlcommon::row_closure()
395:
396: .&Apache::lonhtmlcommon::row_headline()
397: .'<h3>'.$lt{'aens'}.'</h3>'
398: .&Apache::lonhtmlcommon::row_closure()
399:
400: .&Apache::lonhtmlcommon::row_title($lt{'aadd'})
401: .'<label><input type="radio" name="autoadds" value="1" />'.$lt{'yes'}.'</label>'
402: .'<label><input type="radio" name="autoadds" value="0" checked="checked" />'.$lt{'no'}.'</label>'
403: .&Apache::lonhtmlcommon::row_closure()
404:
405: .&Apache::lonhtmlcommon::row_title($lt{'audr'})
406: .'<label><input type="radio" name="autodrops" value="1" />'.$lt{'yes'}.'</label>'
407: .'<label><input type="radio" name="autodrops" value="0" checked="checked" />'.$lt{'no'}.'</label>'
408: .&Apache::lonhtmlcommon::row_closure()
409:
410: .&Apache::lonhtmlcommon::row_title($lt{'dacu'})
411: .$enroll_table
412: .&Apache::lonhtmlcommon::row_closure()
413:
414: .&Apache::lonhtmlcommon::row_title($lt{'dacc'})
415: .$access_table
416: .&Apache::lonhtmlcommon::row_closure()
417:
418: .&Apache::lonhtmlcommon::row_title($lt{'psam'})
419: .$lt{'pcda'}.'<br />'
420: .$krbform.'<br />'
421: .$intform.'<br />'
422: .$locform
423: .&Apache::lonhtmlcommon::row_closure()
424:
425: .&Apache::lonhtmlcommon::row_title($lt{'nech'})
426: .$lt{'nccl'}.'<br/>'
427: .'<label><input type="radio" name="notify_owner" value="1" />'.$lt{'yes'}.'</label>'
428: .'<label><input type="radio" name="notify_owner" value="0" checked="checked" />'.$lt{'no'}.'</label>'
429: .'<br />'
430: .$lt{'ndcl'}.'<br/>'
431: .'<label><input type="radio" name="notify_dc" value="1" />'.$lt{'yes'}.'</label>'
432: .'<label><input type="radio" name="notify_dc" value="0" checked="checked" />'.$lt{'no'}.'</label>'
433: .&Apache::lonhtmlcommon::row_closure()
434:
435: .&Apache::lonhtmlcommon::row_title($lt{'irsp'})
436: .'<label>'
437: .'<input type="radio" name="showphotos" value="1" />'.$lt{'yes'}
438: .'</label> '
439: .'<label>'
440: .'<input type="radio" name="showphotos" value="0" checked="checked" />'.$lt{'no'}
441: .'</label> '
442: .&Apache::lonhtmlcommon::row_closure()
443:
444: .&Apache::lonhtmlcommon::row_headline()
445: .'<h3>'.$lt{'cgrs'}.'</h3>'
446: .&Apache::lonhtmlcommon::row_closure()
447:
448: .&Apache::lonhtmlcommon::row_title($lt{'cgrq'})
449: .'<input type="text" name="crsquota" value="20" size="6" />Mb'
450: .&Apache::lonhtmlcommon::row_closure()
451:
452: .&Apache::lonhtmlcommon::row_headline()
453: .'<h3>'.$lt{'cc'}.'</h3>'
454: .&Apache::lonhtmlcommon::row_closure()
455:
456: .&Apache::lonhtmlcommon::row_title($lt{'user'})
457: .'<input type="text" size="15" name="ccuname" />'
458: .&Apache::lonhtmlcommon::row_closure()
459:
460: .&Apache::lonhtmlcommon::row_title($lt{'dmn'},"","LC_odd_row_value")
461: .$domform
462: .&Apache::lonhtmlcommon::row_closure(1)
463:
464: .&Apache::lonhtmlcommon::end_pick_box()
1.110 ! bisitz 465: );
1.109 bisitz 466:
467: $r->print(<<ENDDOCUMENT);
1.55 www 468: <p>
1.90 raeburn 469: <input type="hidden" name="prevphase" value="courseone" />
470: <input type="hidden" name="phase" value="coursetwo" />
1.68 matthew 471: <input type="button" onClick="verify_message(this.form)" value="$lt{'opco'}" />
1.10 matthew 472: </p>
1.2 www 473: </form>
474: ENDDOCUMENT
1.109 bisitz 475:
1.90 raeburn 476: } elsif ($crstype eq 'Group') {
477: $r->print(<<ENDDOCUMENT);
478: <form action="/adm/createcourse" method="post" name="ccrs">
479: <h2>$lt{'ginf'}</h2>
480: <p>
481: <label><b>$lt{'gtit'}:</b>
482: <input type="text" size="50" name="title" /></label>
483: </p><p>
484: <label>
485: <b>$lt{'ghsr'}:</b>$course_home
486: </label>
487: </p><p>
488: <label>
489: <b>$lt{'gidn'} ($lt{'opt'})</b>
490: <input type="text" size="30" name="crsid" />
491: </label>
492: </p>
493: <h2>$lt{'grco'}</h2>
494: <table border="2">
495: <tr><th>$lt{'cngr'}</th><th>$lt{'cegr'}</th></tr>
496: <tr><td>
497: <p>
498: <label>
499: <b>$lt{'map'}:</b>
500: <input type="text" size="50" name="topmap" />
501: </label>
502: <a href="javascript:openbrowser('ccrs','topmap')">$lt{'smap'}</a>
503: </p><p>
504: <label for="nonstd"><b>$lt{'sagr'}</b></label>
505: <br />
506: ($lt{'ocik'}):
507: <input id="nonstd" type="checkbox" name="nonstandard" />
508: </p><p>
509: <b>$lt{'fres'}</b><br />($lt{'stgo'}):
510: <label>
511: <input type="radio" name="firstres" value="blank" />$lt{'blnk'}
512: </label>
513:
514: <label>
1.109 bisitz 515: <input type="radio" name="firstres" value="syl" checked="checked" />$lt{'sllb'}
1.90 raeburn 516: </label>
517:
518: <label>
519: <input type="radio" name="firstres" value="nav" />$lt{'navi'}
520: </label>
521: </p>
522: </td><td>
523: <label>
524: $lt{'gid'}: <input type="text" size="25" name="clonecourse" value="" />
525: </label>
526: <br />
527: <label>
528: $lt{'dmn'}: $cloneform
529: </label>
530: <br />
1.106 www 531: <label><input type="radio" name="datemode" value="delete" /> $lt{'ncd'}</label><br />
532: <label><input type="radio" name="datemode" value="preserve" /> $lt{'prd'}</label><br />
533: <label><input type="radio" name="datemode" value="shift" checked="checked" /> $lt{'shd'}</label>
534: <input type="text" size="5" name="dateshift" value="365" /><br /> <br />
1.90 raeburn 535: $lt{'asov'}.
536: </td></tr>
537: </table>
538: </p>
539: <p>
540: <h2>$lt{'mssg'}</h2>
541: <p>
542: <label>
543: <b>$lt{'sgpf'}: </b>
1.109 bisitz 544: <input type="checkbox" name="setpolicy" checked="checked" />
1.90 raeburn 545: </label>
546: <br />
547: <label>
548: <b>$lt{'scfg'}: </b>
1.109 bisitz 549: <input type="checkbox" name="setcontent" checked="checked" />
1.90 raeburn 550: </label>
551: </p>
552: <h2>$lt{'cmmn'}</h2>
553: <p>
554: <label>
555: <b>$lt{'dmrd'}: </b>
556: <input type="checkbox" name="disresdis" />
557: </label>
558: <br />
559: <label>
560: <b>$lt{'dmuc'}: </b>
561: <input type="checkbox" name="disablechat" />
562: </label>
563: </p>
564: <h2>$lt{'acco'}</h2>
565: <p>
566: <label>
567: <b>$lt{'mnak'}: </b>
568: <input type="checkbox" name="setkeys" />
569: </label>
570: <br />
571: <label>
572: <b>$lt{'kaug'}: </b>
573: <input type="text" size="30" name="keyauth" />
574: </label>
575: </p>
576: <h2>$lt{'rshm'}</h2>
577: <p>
578: <label>
579: <b>$lt{'rshm'}: </b>
580: <input type="text" name="reshome" size="30" value="/res/$defdom/" />
581: </label>
582: </p>
1.93 raeburn 583: <p>
584: <h2>$lt{'grts'}</h2>
585: $lt{'grtq'}
586: <input type="text" name="crsquota" value="20" />Mb
587: </p>
1.90 raeburn 588: <hr />
589: <h2>$lt{'gc'}</h2>
590: <p>
591: <label>
592: <b>$lt{'user'}:</b> <input type="text" size="15" name="ccuname" />
593: </label>
594: </p><p>
595: <label>
596: <b>$lt{'dmn'}:</b> $domform
597: </label>
598: </p>
599: <p>
600: <input type="hidden" name="prevphase" value="groupone" />
601: <input type="hidden" name="phase" value="grouptwo" />
602: <input type="button" onClick="validate(this.form)" value="$lt{'crgr'}" />
603: </p>
604: </form>
605: ENDDOCUMENT
606: }
607: $r->print($end_page);
1.40 raeburn 608: }
609:
1.2 www 610: # ====================================================== Phase two: make course
611:
1.10 matthew 612: sub create_course {
1.2 www 613: my $r=shift;
1.99 albertel 614: my $ccuname =&LONCAPA::clean_username($env{'form.ccuname'});
615: my $ccdomain=&LONCAPA::clean_domain($env{'form.ccdomain'});
1.90 raeburn 616: my $crstype = 'Group';
617: my ($enrollstart,$enrollend,$startaccess,$endaccess);
1.74 raeburn 618:
1.90 raeburn 619: if ($env{'form.phase'} eq 'coursetwo') {
620: $crstype='Course';
621: $enrollstart=&Apache::lonhtmlcommon::get_date_from_form('startenroll');
622: $enrollend=&Apache::lonhtmlcommon::get_date_from_form('endenroll');
623: }
624: $startaccess = &Apache::lonhtmlcommon::get_date_from_form('startaccess');
625: $endaccess = &Apache::lonhtmlcommon::get_date_from_form('endaccess');
1.74 raeburn 626:
627: my $autharg;
628: my $authtype;
629:
1.78 albertel 630: if ($env{'form.login'} eq 'krb') {
1.74 raeburn 631: $authtype = 'krb';
1.78 albertel 632: $authtype .=$env{'form.krbver'};
633: $autharg = $env{'form.krbarg'};
634: } elsif ($env{'form.login'} eq 'int') {
1.74 raeburn 635: $authtype ='internal';
1.78 albertel 636: if ((defined($env{'form.intarg'})) && ($env{'form.intarg'})) {
637: $autharg = $env{'form.intarg'};
1.74 raeburn 638: }
1.78 albertel 639: } elsif ($env{'form.login'} eq 'loc') {
1.74 raeburn 640: $authtype = 'localauth';
1.78 albertel 641: if ((defined($env{'form.locarg'})) && ($env{'form.locarg'})) {
642: $autharg = $env{'form.locarg'};
1.74 raeburn 643: }
644: }
1.90 raeburn 645: my $logmsg;
1.91 albertel 646: my $start_page=&Apache::loncommon::start_page('Create a New '.$crstype);
1.90 raeburn 647: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Outcome','Create_Course',undef,'Create_Courses');
1.74 raeburn 648:
1.90 raeburn 649: $r->print($start_page.$crumbs);
1.74 raeburn 650:
651: my $args = {
1.90 raeburn 652: crstype => $crstype,
1.74 raeburn 653: ccuname => $ccuname,
654: ccdomain => $ccdomain,
1.78 albertel 655: cdescr => $env{'form.title'},
656: curl => $env{'form.topmap'},
657: course_domain => $env{'request.role.domain'},
658: course_home => $env{'form.course_home'},
659: nonstandard => $env{'form.nonstandard'},
660: crscode => $env{'form.crscode'},
1.93 raeburn 661: crsquota => $env{'form.crsquota'},
1.103 raeburn 662: clonecourse => $env{'form.clonecourse'},
663: clonedomain => $env{'form.clonedomain'},
1.106 www 664: datemode => $env{'form.datemode'},
665: dateshift => $env{'form.dateshift'},
1.78 albertel 666: crsid => $env{'form.crsid'},
1.94 raeburn 667: curruser => $env{'user.name'}.':'.$env{'user.domain'},
1.78 albertel 668: crssections => $env{'form.crssections'},
669: crsxlist => $env{'form.crsxlist'},
670: autoadds => $env{'form.autoadds'},
671: autodrops => $env{'form.autodrops'},
672: notify_owner => $env{'form.notify_owner'},
673: notify_dc => $env{'form.notify_dc'},
674: no_end_date => $env{'form.no_end_date'},
675: showphotos => $env{'form.showphotos'},
1.74 raeburn 676: authtype => $authtype,
677: autharg => $autharg,
678: enrollstart => $enrollstart,
679: enrollend => $enrollend,
680: startaccess => $startaccess,
681: endaccess => $endaccess,
1.78 albertel 682: setpolicy => $env{'form.setpolicy'},
683: setcontent => $env{'form.setcontent'},
684: reshome => $env{'form.reshome'},
685: setkeys => $env{'form.setkeys'},
686: keyauth => $env{'form.keyauth'},
687: disresdis => $env{'form.disresdis'},
688: disablechat => $env{'form.disablechat'},
689: openall => $env{'form.openall'},
690: firstres => $env{'form.firstres'}
1.74 raeburn 691: };
692:
1.10 matthew 693: #
694: # Verify data
695: #
696: # Check the veracity of the course coordinator
1.2 www 697: if (&Apache::lonnet::homeserver($ccuname,$ccdomain) eq 'no_host') {
1.52 albertel 698: $r->print('<form action="/adm/createuser" method="post" name="crtuser">');
1.108 bisitz 699: $r->print('<div class="LC_warning">'
700: .&mt('No such user [_1] at domain [_2].','<tt>'.$ccuname.'</tt>','<tt>'.$ccdomain.'</tt>')
701: .'</div>');
702: $r->print(&mt('Please click Back on your browser and select another user, or [_1]Create User[_2]'
703: , '<input type="hidden" name="phase" value="get_user_info" />'
704: .'<input type="hidden" name="ccuname" value="'.$ccuname.'" />'
705: .'<input type="hidden" name="ccdomain" value="'.$ccdomain.'" />'
706: .'<input name="userrole" type="submit" value="'
707: , '" />'
708: )
709: .'</form>'.&Apache::loncommon::end_page()
710: );
1.2 www 711: return;
712: }
1.10 matthew 713: # Check the proposed home server for the course
1.101 albertel 714: my %host_servers =
715: &Apache::lonnet::get_servers($env{'request.role.domain'},'library');
1.78 albertel 716: if (! exists($host_servers{$env{'form.course_home'}})) {
1.108 bisitz 717: $r->print(&mt('Invalid home server for course: [_1]'
718: ,$env{'form.course_home'}.&Apache::loncommon::end_page()));
1.10 matthew 719: return;
720: }
1.74 raeburn 721: my ($courseid,$crsudom,$crsunum);
1.104 albertel 722: my ($success,$output) =
723: &Apache::loncommon::construct_course($args,\$logmsg,\$courseid,
724: \$crsudom,\$crsunum,
725: $env{'user.domain'},
726: $env{'user.name'});
727: $r->print($output);
728: if ($success) {
729: #
730: # Make the requested user a course coordinator or group coordinator
731: #
732: if (($ccdomain) && ($ccuname)) {
733: $r->print(&mt('Assigning role of [_1] Coordinator to [_2] at [_3]: ',
734: $crstype,$ccuname,$ccdomain).
735: &Apache::lonnet::assignrole($ccdomain,$ccuname,$courseid,
1.107 raeburn 736: 'cc','','','','','createcourse').'<p>');
1.104 albertel 737: }
738: if ($env{'form.setkeys'}) {
739: $r->print(
740: '<p><a href="/adm/managekeys?cid='.$crsudom.'_'.$crsunum.'">'.&mt('Manage Access Keys').'</a></p>');
741: }
742: # Flush the course logs so reverse user roles immediately updated
743: &Apache::lonnet::flushcourselogs();
744: $r->print('<p>'.&mt('Roles will be active at next login').'.</p>');
745: }
746: $r->print('<p><a href="/adm/createcourse?phase='.lc($crstype).'one">'.
1.90 raeburn 747: &mt('Create Another [_1]',$crstype).'</a></p>'.
1.86 albertel 748: &Apache::loncommon::end_page());
1.74 raeburn 749: }
750:
1.90 raeburn 751: sub print_intro_page {
752: my $r = shift;
753: my $start_page =
754: &Apache::loncommon::start_page('Create a New Course or Group Space');
755: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Options','Create_Course',undef,'Create_Courses');
756: my $end_page =
757: &Apache::loncommon::end_page();
758: my $helplink=&Apache::loncommon::help_open_topic('Create_Course_GroupSpace',&mt('Help on Creating Courses and Groups'));
759:
760: my @choices = ({ internal_name => 'courseone',
761: name => &mt('Create a single course'),
762: short_description =>
763: &mt('Create a new course by completing an online form.'),
764: },
765: { internal_name => 'groupone',
1.108 bisitz 766: name => &mt('Create a single collaborative group space'),
1.90 raeburn 767: short_description =>
1.108 bisitz 768: &mt('Create a new group space for non-course use by completing an online form.'),
1.90 raeburn 769: },
770: { internal_name => 'batchone',
771: name => &mt('Create courses/groups by uploading an attributes file'),
772: short_description =>
1.108 bisitz 773: &mt('Upload an attributes file containing specifications for one or more courses or groups in XML format.'),
1.97 raeburn 774: help => 'Batch_Creation',
1.90 raeburn 775: },
776: );
777: my $options;
778: foreach my $choice (@choices) {
779: $options .=' <h3><a href="/adm/createcourse?phase='.
780: $choice->{'internal_name'}.'" >'.
1.97 raeburn 781: $choice->{'name'}.'</a>';
782: if (exists($choice->{'help'})) {
783: $options .= &Apache::loncommon::help_open_topic($choice->{'help'});
784: }
785: $options .= "</h3>\n".' '.(' 'x8).$choice->{'short_description'}.
1.90 raeburn 786: "\n";
787: }
788:
789: $r->print(<<ENDDOCUMENT);
790: $start_page
791: $crumbs
792: $options
793: $end_page
794: ENDDOCUMENT
795: }
796:
797: sub upload_batchfile {
798: my $r = shift;
799: my $start_page =
800: &Apache::loncommon::start_page('Create a New Course or Group Space');
801: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Upload Course/Group Attributes File','Create_Course',undef,'Create_Courses');
802: my $end_page =
803: &Apache::loncommon::end_page();
804: $r->print($start_page.$crumbs);
805: $r->print('<h3>'.&mt('Upload a courses or groups attributes file').'</h3>');
806: $r->print('<form name="batchcreate" method="post" '.
807: 'enctype="multipart/form-data" action="/adm/createcourse">'.
808: '<input type="file" name="coursecreatorxml" />'.
809: '<input type="hidden" name="phase" value="batchtwo"><br /><br />'.
810: '<input type="submit" name="batchsubmit" '.
811: 'value="Create Courses/Groups" /></form>');
812: $r->print($end_page);
813: return;
814: }
815:
816: sub process_batchfile {
817: my $r = shift;
818: my $start_page =
819: &Apache::loncommon::start_page('Create a New Course or Group Space');
820: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Outcome','Create_Course',undef,'Create_Courses');
821: my $end_page =
822: &Apache::loncommon::end_page();
823: my $defdom=$env{'request.role.domain'};
824: my $batchfilepath=&Apache::lonnet::userfileupload('coursecreatorxml',undef,
825: 'batchupload',undef,undef,
826: undef,undef,$defdom);
827: my ($batchdir,$filename) = ($batchfilepath =~ m-^(.+)/pending/([^/]+)$-);
828: my ($result,$logmsg);
829: if (-e "$batchfilepath") {
830: open(FILE,"<$batchfilepath");
831: my @buffer = <FILE>;
832: close(FILE);
833: if ((defined($filename)) && (defined($batchdir))) {
834: my @requests = ($filename);
835: my %courseids = ();
836: ($result,$logmsg) = &LONCAPA::batchcreatecourse::create_courses(
837: \@requests,\%courseids,'web',$defdom,
838: $env{'user.name'},$env{'user.domain'});
839: if ($result) {
840: if (!-e "$batchdir/processed") {
841: mkdir("$batchdir/processed", 0755);
842: open(FILE,">$batchdir/processed/$filename");
843: print FILE @buffer;
844: close(FILE);
845: if (-e "$batchdir/processed/$filename") {
846: unlink("$batchdir/pending/$filename");
847: }
848: }
849: }
850: }
851: }
1.103 raeburn 852: $r->print($start_page.$crumbs.$logmsg.$result.'<br /><a href="/adm/createcourse">'.
853: &mt('Creation options menu').'</a>'.$end_page);
1.90 raeburn 854:
855: }
856:
1.2 www 857: # ===================================================================== Handler
1.1 www 858: sub handler {
859: my $r = shift;
860:
861: if ($r->header_only) {
1.38 www 862: &Apache::loncommon::content_type($r,'text/html');
1.1 www 863: $r->send_http_header;
864: return OK;
865: }
866:
1.78 albertel 867: if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {
1.38 www 868: &Apache::loncommon::content_type($r,'text/html');
1.1 www 869: $r->send_http_header;
870:
1.90 raeburn 871: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
872: ['phase']);
873: &Apache::lonhtmlcommon::clear_breadcrumbs();
874: &Apache::lonhtmlcommon::add_breadcrumb
875: ({href=>"/adm/createcourse",
876: text=>"Creation Options",
877: faq=>79,bug=>'Dom Coord Interface',});
878: if (($env{'form.phase'} eq 'coursetwo') ||
879: ($env{'form.phase'} eq 'grouptwo')) {
880: &Apache::lonhtmlcommon::add_breadcrumb
881: ({href=>"/adm/createcourse?phase=$env{'form.prevphase'}",
882: text=>&mt('[_1] Creation Settings',),
883: faq=>9,bug=>'Dom Coord Interface',});
884: &Apache::lonhtmlcommon::add_breadcrumb
885: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
886: text=>"Creation Outcome",
887: faq=>9,bug=>'Dom Coord Interface',});
1.10 matthew 888: &create_course($r);
1.90 raeburn 889: } elsif (($env{'form.phase'} eq 'courseone') ||
890: ($env{'form.phase'} eq 'groupone')) {
891: &Apache::lonhtmlcommon::add_breadcrumb
892: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
893: text=>&mt('[_1] Creation Settings',),
894: faq=>9,bug=>'Dom Coord Interface',});
895: &print_course_creation_page($r);
896: } elsif ($env{'form.phase'} eq 'batchone') {
897: &Apache::lonhtmlcommon::add_breadcrumb
898: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
899: text=>"Upload Description File",
900: faq=>9,bug=>'Dom Coord Interface',});
901: &upload_batchfile($r);
902: } elsif ($env{'form.phase'} eq 'batchtwo') {
903: &Apache::lonhtmlcommon::add_breadcrumb
904: ({href=>"/adm/createcourse?phase=$env{'form.prevphase'}",
905: text=>"Upload Description File",
906: faq=>9,bug=>'Dom Coord Interface',});
907: &Apache::lonhtmlcommon::add_breadcrumb
908: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
909: text=>"Creation Outcome",
910: faq=>9,bug=>'Dom Coord Interface',});
911: &process_batchfile($r);
1.2 www 912: } else {
1.90 raeburn 913: &print_intro_page($r);
1.2 www 914: }
1.1 www 915: } else {
1.78 albertel 916: $env{'user.error.msg'}=
1.90 raeburn 917: "/adm/createcourse:ccc:0:0:Cannot create courses or groups";
1.1 www 918: return HTTP_NOT_ACCEPTABLE;
919: }
920: return OK;
1.90 raeburn 921: }
1.1 www 922:
923: 1;
924: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>