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