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