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