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