Annotation of loncom/interface/loncreatecourse.pm, revision 1.174
1.65 raeburn 1: # The LearningOnline Network
1.1 www 2: # Create a course
1.5 albertel 3: #
1.174 ! raeburn 4: # $Id: loncreatecourse.pm,v 1.173 2020/05/22 15:05:30 raeburn 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.111 jms 30: =head1 NAME
31:
32: Apache::loncreatecourse.pm
33:
34: =head1 SYNOPSIS
35:
36: Allows domain coordinators to create new
37: courses and assign course coordinators.
38:
39: This is part of the LearningOnline Network with CAPA project
40: described at http://www.lon-capa.org.
41:
1.112 jms 42: =head1 SUBROUTINES
1.111 jms 43:
44: =over
45:
1.112 jms 46: =item handler()
1.111 jms 47:
1.112 jms 48: =item print_course_creation_page()
1.111 jms 49:
1.112 jms 50: =item create_course()
1.111 jms 51:
1.112 jms 52: =item print_intro_page()
1.111 jms 53:
1.112 jms 54: =item upload_batchfile()
1.111 jms 55:
1.112 jms 56: =item process_batchfile()
1.111 jms 57:
1.127 raeburn 58: =item courserequestbrowser_javascript()
59:
60: =item print_creation_logs()
61:
62: =item creation_display_filter()
63:
64: =item context_names()
65:
66: =item instcode_srchstr()
67:
68: =item syllabuslink_javascript()
69:
1.111 jms 70: =back
71:
72: =cut
73:
1.1 www 74: package Apache::loncreatecourse;
75:
76: use strict;
77: use Apache::Constants qw(:common :http);
78: use Apache::lonnet;
1.12 www 79: use Apache::loncommon;
1.13 www 80: use Apache::londocs;
1.38 www 81: use Apache::lonlocal;
1.105 raeburn 82: use Apache::lonuserutils;
1.96 albertel 83: use Apache::lonclonecourse;
1.90 raeburn 84: use LONCAPA::batchcreatecourse;
1.168 raeburn 85: use LONCAPA qw(:DEFAULT :match);
1.28 www 86:
1.171 raeburn 87: my $registered_flush;
88: my $registered_instcats;
89: my $modified_dom;
90:
1.2 www 91: # ===================================================== Phase one: fill-in form
92:
1.10 matthew 93: sub print_course_creation_page {
1.2 www 94: my $r=shift;
1.123 raeburn 95: my $crstype = 'Community';
1.90 raeburn 96: if ($env{'form.phase'} eq 'courseone') {
97: $crstype = 'Course';
1.159 raeburn 98: } elsif ($env{'form.phase'} eq 'placementone') {
99: $crstype = 'Placement';
1.90 raeburn 100: }
1.78 albertel 101: my $defdom=$env{'request.role.domain'};
1.147 raeburn 102: my %domdefaults = &Apache::lonnet::get_domain_defaults($defdom);
1.101 albertel 103: my %host_servers = &Apache::lonnet::get_servers($defdom,'library');
1.10 matthew 104: my $course_home = '<select name="course_home" size="1">'."\n";
105: foreach my $server (sort(keys(%host_servers))) {
1.14 matthew 106: $course_home .= qq{<option value="$server"};
107: if ($server eq $Apache::lonnet::perlvar{'lonHostID'}) {
1.174 ! raeburn 108: $course_home .= ' selected="selected"';
1.14 matthew 109: }
110: $course_home .= qq{>$server $host_servers{$server}</option>};
1.10 matthew 111: }
112: $course_home .= "\n</select>\n";
1.167 raeburn 113: my ($trusted,$untrusted) = &Apache::lonnet::trusted_domains('enroll',$defdom);
114: my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain',undef,undef,undef,$trusted,$untrusted);
1.32 www 115: my $cloneform=&Apache::loncommon::select_dom_form
1.78 albertel 116: ($env{'request.role.domain'},'clonedomain').
1.32 www 117: &Apache::loncommon::selectcourse_link
1.90 raeburn 118: ('ccrs','clonecourse','clonedomain',undef,undef,undef,$crstype);
1.78 albertel 119: my $coursebrowserjs=&Apache::loncommon::coursebrowser_javascript($env{'request.role.domain'});
1.134 raeburn 120: my ($enroll_table,$krbdef,$krbdefdom,$krbform,$intform,$locform,
1.90 raeburn 121: $javascript_validations);
1.134 raeburn 122: my $starttime = time;
123: my $endtime = time+(6*30*24*60*60); # 6 months from now, approx
124: my $access_table = &Apache::lonuserutils::date_setting_table($starttime,
125: $endtime,'create_defaultdates');
1.173 raeburn 126: my $openallfrom =
127: &Apache::lonhtmlcommon::date_setter('ccrs','openallfrom',$starttime);
1.162 raeburn 128: if (($crstype eq 'Course') || ($crstype eq 'Placement')) {
1.105 raeburn 129: $enroll_table = &Apache::lonuserutils::date_setting_table($starttime,
130: $endtime,'create_enrolldates');
1.90 raeburn 131: ($krbdef,$krbdefdom) =
132: &Apache::loncommon::get_kerberos_defaults($defdom);
1.105 raeburn 133: $javascript_validations=&Apache::lonuserutils::javascript_validations(
1.90 raeburn 134: 'createcourse',$krbdefdom);
135: my %param = ( formname => 'document.ccrs',
136: kerb_def_dom => $krbdefdom,
137: kerb_def_auth => $krbdef
138: );
139: $krbform = &Apache::loncommon::authform_kerberos(%param);
140: $intform = &Apache::loncommon::authform_internal(%param);
141: $locform = &Apache::loncommon::authform_local(%param);
1.162 raeburn 142: } else {
1.123 raeburn 143: my $title_alert = &mt('A Community title is required');
144: my $coord_alert = &mt('The username of the Coordinator is required');
1.158 damieng 145: &js_escape(\$title_alert);
146: &js_escape(\$coord_alert);
1.90 raeburn 147: $javascript_validations = qq|
148: function validate(formname) {
149: if (formname.title == '') {
1.123 raeburn 150: alert("$title_alert");
1.90 raeburn 151: return;
152: }
153: if (formname.ccuname == '') {
1.123 raeburn 154: alert("$coord_alert");
1.90 raeburn 155: }
156: formname.submit();
157: }
158: |;
159: }
1.46 sakharuk 160: my %lt=&Apache::lonlocal::texthash(
161: 'cinf' => "Course Information",
162: 'ctit' => "Course Title",
163: 'chsr' => "Course Home Server",
164: 'cidn' => "Course ID/Number",
165: 'opt' => "optional",
166: 'iinf' => "Institutional Information",
167: '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.",
168: 'ccod' => "Course Code",
1.90 raeburn 169: 'snid' => "Section Numbers and corresponding LON-CAPA section IDs",
170: '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 171: 'crcs' => "Crosslisted courses",
1.157 bisitz 172: '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) section ID to be used in LON-CAPA, e.g., fs03ent231001:ent1,fs03bot231001:bot1,fs03zol231002:zol2",
1.147 raeburn 173: 'ccre' => "Course credits",
1.154 bisitz 174: 'crcd' => "Create six character course identifier to share with students",
1.147 raeburn 175: 'cred' => "the number of institutional credits students will earn by completing this course",
1.46 sakharuk 176: 'crco' => "Course Content",
177: 'cncr' => "Completely new course",
178: 'cecr' => "Clone an existing course",
179: 'map' => "Map",
180: 'smap' => "Select Map",
181: 'sacr' => "Do NOT generate as standard course",
182: 'ocik' => "only check if you know what you are doing",
183: 'fres' => "First Resource",
184: 'stco' => "standard courses only",
185: 'blnk' => "Blank",
186: 'sllb' => "Syllabus",
1.132 raeburn 187: 'navi' => "Course Contents",
1.46 sakharuk 188: 'cid' => "Course ID",
189: 'dmn' => "Domain",
1.110 bisitz 190: 'dsh' => "Date Shift",
1.46 sakharuk 191: 'asov' => "Additional settings, if specified below, will override cloned settings",
1.106 www 192: 'ncd' => "Do not clone date parameters",
193: 'prd' => 'Clone date parameters as-is',
194: 'shd' => 'Shift date parameters by number of days',
1.46 sakharuk 195: 'assp' => "Assessment Parameters",
196: 'oaas' => "Open all assessments",
1.173 raeburn 197: 'sta' => "starting from:",
1.46 sakharuk 198: 'mssg' => "Messaging",
199: 'scpf' => "Set course policy feedback to Course Coordinator",
1.163 raeburn 200: 'scfc' => "Set resource content feedback to Course Coordinator",
201: 'scof' => "Set course content feedback to Course Coordinator",
1.46 sakharuk 202: 'cmmn' => "Communication",
203: 'dsrd' => "Disable student resource discussion",
1.117 hauer 204: 'dsuc' => "Disable student use of chat rooms",
1.46 sakharuk 205: 'acco' => "Access Control",
206: 'snak' => "Students need access key to enter course",
1.124 raeburn 207: 'ow' => "Course Owner",
208: 'cc' => "(will be assigned Course Coordinator role)",
1.46 sakharuk 209: 'user' => "Username",
210: 'aens' => "Automated enrollment settings",
211: '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.",
212: 'aadd' => "Automated adds",
213: 'yes' => "Yes",
214: 'no' => "No",
215: 'audr' => "Automated drops",
216: 'dacu' => "Duration of automated classlist updates",
1.119 bisitz 217: 'dads' => 'Default Access Dates for Students',
1.60 raeburn 218: 'dacc' => "Default start and end dates for student access",
1.134 raeburn 219: 'psam' => "Authentication mechanism",
220: 'pcda' => "Default authentication method for new users added to this domain by the automated enrollment process",
1.46 sakharuk 221: 'nech' => "Notification of enrollment changes",
222: 'irsp' => "Include retrieval of student photographs?",
1.55 www 223: 'rshm' => 'Resource Space Home',
1.93 raeburn 224: 'cgrs' => "Course Group Settings",
1.119 bisitz 225: 'cgrq' => 'Set a quota for the total disk space available for storage of course group portfolio files',
1.133 raeburn 226: 'opco' => 'Open Course',
227: 'opcm' => 'Open Community',
1.161 raeburn 228: 'oppt' => 'Open Placement Test',
1.133 raeburn 229: );
230: $lt{'kaut'} = &mt('Key authority ([_1]id:domain[_2]) if other than course','<tt>','</tt>');
1.150 bisitz 231: $lt{'toin'} = &mt('to interface with institutional data, e.g., [_1]fs13glg231[_2] for [_3]Fall 2013 Geology 231[_4]','<tt>','</tt>','<i>','</i>');
232: $lt{'nccl'} = &mt('Notification to [_1]course coordinator[_2] via LON-CAPA message when enrollment changes occur during the automated update?','<b>','</b>');
233: $lt{'ndcl'} = &mt('Notification to [_1]domain coordinator[_2] via LON-CAPA message when enrollment changes occur during the automated update?','<b>','</b>');
1.133 raeburn 234:
235: if ($crstype eq 'Community') {
236: $lt{'cinf'} = &mt('Community Information');
237: $lt{'ctit'} = &mt('Community Title');
238: $lt{'chsr'} = &mt('Community Home Server');
239: $lt{'cidn'} = &mt('Community ID/Number');
240: $lt{'crco'} = &mt('Community Content');
241: $lt{'cncr'} = &mt('Completely new community');
242: $lt{'cecr'} = &mt('Clone an existing community');
243: $lt{'sacr'} = &mt('Do NOT generate as standard community');
244: $lt{'stco'} = &mt('standard communities only');
245: $lt{'navi'} = &mt('Community Contents');
246: $lt{'cid'} = &mt('Community ID');
247: $lt{'scpf'} = &mt('Set community policy feedback to Coordinator');
1.163 raeburn 248: $lt{'scfc'} = &mt('Set resource content feedback to Coordinator');
249: $lt{'scof'} = &mt('Set community content feedback to Coordinator');
1.133 raeburn 250: $lt{'dsrd'} = &mt('Disable member resource discussion');
251: $lt{'dsuc'} = &mt('Disable member use of chat rooms');
252: $lt{'dads'} = &mt('Default Access Dates for Members');
253: $lt{'dacc'} = &mt('Default start and end dates for member access');
254: $lt{'snak'} = &mt('Members need access key to enter course');
255: $lt{'kaut'} = &mt('Key authority ([_1]id:domain[_2]) if other than community','<tt>','</tt>');
256: $lt{'ow'} = &mt('Community Owner');
257: $lt{'cc'} = &mt('(will be assigned Coordinator role)');
258: $lt{'cgrs'} = &mt('Community Group Settings');
259: $lt{'cgrq'} = &mt('Set a quota for the total disk space available for storage of community group portfolio files');
1.159 raeburn 260: } elsif ($crstype eq 'Placement') {
261: $lt{'cinf'} = &mt('Placement Test Information');
262: $lt{'ctit'} = &mt('Placement Test Title');
263: $lt{'chsr'} = &mt('Placement Test Home Server');
264: $lt{'cidn'} = &mt('Placement Test ID/Number');
265: $lt{'crco'} = &mt('Placement Test Content');
266: $lt{'cncr'} = &mt('Completely new placement test');
267: $lt{'cecr'} = &mt('Clone an existing placement test');
268: $lt{'sacr'} = &mt('Do NOT generate as standard placement test');
269: $lt{'stco'} = &mt('standard placement tests only');
270: $lt{'navi'} = &mt('Placement Test Contents');
271: $lt{'cid'} = &mt('Placement Test ID');
1.133 raeburn 272: }
1.86 albertel 273: my $js = <<END;
274: <script type="text/javascript">
1.174 ! raeburn 275: // <![CDATA[
! 276:
1.6 matthew 277: var editbrowser = null;
278: function openbrowser(formname,elementname) {
279: var url = '/res/?';
280: if (editbrowser == null) {
281: url += 'launch=1&';
282: }
283: url += 'catalogmode=interactive&';
284: url += 'mode=edit&';
285: url += 'form=' + formname + '&';
1.7 matthew 286: url += 'element=' + elementname + '&';
287: url += 'only=sequence' + '';
1.6 matthew 288: var title = 'Browser';
289: var options = 'scrollbars=1,resizable=1,menubar=0';
290: options += ',width=700,height=600';
291: editbrowser = open(url,title,options,'1');
292: editbrowser.focus();
293: }
1.41 raeburn 294: $javascript_validations
1.174 ! raeburn 295:
! 296: // ]]>
1.6 matthew 297: </script>
1.32 www 298: $coursebrowserjs
1.86 albertel 299: END
300:
1.90 raeburn 301: my %titles = &Apache::lonlocal::texthash(
302: courseone => 'Create a New Course',
1.123 raeburn 303: groupone => 'Create a New Community',
1.159 raeburn 304: placementone=> 'Create a New Placement Test',
1.90 raeburn 305: );
1.86 albertel 306: my $start_page =
1.90 raeburn 307: &Apache::loncommon::start_page($titles{$env{'form.phase'}},$js);
1.86 albertel 308: my $end_page =
309: &Apache::loncommon::end_page();
1.91 albertel 310: my $crumbs =
311: &Apache::lonhtmlcommon::breadcrumbs($crstype.' Information',
312: 'Create_Course',undef,
313: 'Create_Courses');
1.90 raeburn 314: $r->print($start_page.$crumbs);
1.110 bisitz 315:
1.174 ! raeburn 316: $r->print('<form action="/adm/createcourse" method="post" name="ccrs"><div class="LC_createcourse">'
1.133 raeburn 317: .&Apache::lonhtmlcommon::start_pick_box()
318:
319: .&Apache::lonhtmlcommon::row_headline()
320: .'<h3>'.$lt{'ow'}.' '.$lt{'cc'}.'</h3>'
321: .&Apache::lonhtmlcommon::row_closure()
322:
323: .&Apache::lonhtmlcommon::row_title($lt{'user'})
324: .'<input type="text" size="15" name="ccuname" />'
325: .&Apache::loncommon::studentbrowser_javascript()
326: .&Apache::loncommon::selectstudent_link('ccrs','ccuname','ccdomain')
327: .&Apache::lonhtmlcommon::row_closure()
328:
329: .&Apache::lonhtmlcommon::row_title($lt{'dmn'},"","LC_odd_row_value")
330: .$domform
331: .&Apache::lonhtmlcommon::row_closure()
332:
333: .&Apache::lonhtmlcommon::row_headline()
334: .'<h3>'.$lt{'cinf'}.'</h3>'
335: .&Apache::lonhtmlcommon::row_closure()
336:
337: .&Apache::lonhtmlcommon::row_title($lt{'ctit'})
1.145 www 338: .'<input type="text" size="80" name="title" />'
1.133 raeburn 339: .&Apache::lonhtmlcommon::row_closure()
340:
341: .&Apache::lonhtmlcommon::row_title($lt{'chsr'})
342: .$course_home
343: .&Apache::lonhtmlcommon::row_closure()
344:
345: .&Apache::lonhtmlcommon::row_title($lt{'cidn'}.' ('.$lt{'opt'}.')')
346: .'<input type="text" size="30" name="crsid" />'
347: .&Apache::lonhtmlcommon::row_closure()
348: );
1.161 raeburn 349: if (($crstype eq 'Course') || ($crstype eq 'Placement')) {
1.133 raeburn 350: $r->print(&Apache::lonhtmlcommon::row_headline()
1.109 bisitz 351: .'<h3>'.$lt{'iinf'}.'</h3>'
1.161 raeburn 352: .$lt{'stat'});
353: if ($crstype eq 'Course') {
354: $r->print(' '
355: .&mt('Default credits can also be specified, if different from the domain defaults (official courses: [_1]; unofficial courses: [_2]; textbook courses: [_3]).',
356: $domdefaults{'officialcredits'},$domdefaults{'unofficialcredits'},$domdefaults{'textbookcredits'}));
357: }
358: $r->print(&Apache::lonhtmlcommon::row_closure()
1.109 bisitz 359: .&Apache::lonhtmlcommon::row_title($lt{'ccod'})
360: .'<input type="text" size="30" name="crscode" />'
361: .'<br />('.$lt{'toin'}.')'
362: .&Apache::lonhtmlcommon::row_closure()
363:
364: .&Apache::lonhtmlcommon::row_title($lt{'snid'})
365: .'<input type="text" size="30" name="crssections" />'
366: .'<br />('.$lt{'csli'}.')'
367: .&Apache::lonhtmlcommon::row_closure()
368:
369: .&Apache::lonhtmlcommon::row_title($lt{'crcs'})
370: .'<input type="text" size="30" name="crsxlist" />'
371: .'<br />('.$lt{'cscs'}.')'
372: .&Apache::lonhtmlcommon::row_closure()
1.110 bisitz 373: );
1.161 raeburn 374: if (($crstype eq 'Course') && ($domdefaults{'officialcredits'} ||
375: $domdefaults{'unofficialcredits'} || $domdefaults{'textbookcredits'})) {
1.147 raeburn 376: $r->print(&Apache::lonhtmlcommon::row_title($lt{'ccre'})
377: .'<input type="text" size="3" name="defaultcredits" />'
378: .'<br />('.$lt{'cred'}.')'
379: .&Apache::lonhtmlcommon::row_closure()
380: );
381: }
1.153 raeburn 382: $r->print(&Apache::lonhtmlcommon::row_title($lt{'crcd'})
383: .'<span class="LC_nobreak">'
384: .'<input type="radio" name="uniquecode" value="1" />'.&mt('Yes').(' 'x2)
385: .'<input type="radio" name="uniquecode" value="0" checked="checked" />'.&mt('No')
1.174 ! raeburn 386: .'</span>'
1.153 raeburn 387: .&Apache::lonhtmlcommon::row_closure()
1.159 raeburn 388: );
389: }
390: my $blankchk;
391: if ($crstype eq 'Placement') {
392: $blankchk = ' checked="checked"';
1.133 raeburn 393: }
394: # Table: New Course / Clone Course
395: $r->print(&Apache::lonhtmlcommon::row_headline()
1.109 bisitz 396: .'<h3>'.$lt{'crco'}.'</h3>'
1.110 bisitz 397: .&Apache::loncommon::start_data_table()
398: .&Apache::loncommon::start_data_table_header_row()
399: .'<th>'.$lt{'cncr'}.'</th>'
400: .'<th> '.&mt('or').' </th>'
401: .'<th>'.$lt{'cecr'}.'</th>'
402: .&Apache::loncommon::end_data_table_header_row()
403: .&Apache::loncommon::start_data_table_row()
404:
405: # New Course:
406: .'<td>'
407: .&Apache::lonhtmlcommon::start_pick_box()
408: .&Apache::lonhtmlcommon::row_title($lt{'map'})
409: .'<input type="text" size="50" name="topmap" />'
410: .'<a href="javascript:openbrowser(\'ccrs\',\'topmap\')">'.$lt{'smap'}.'</a>'
411: .&Apache::lonhtmlcommon::row_closure()
412: .&Apache::lonhtmlcommon::row_title('<label for="nonstd">'.$lt{'sacr'}.'</label>')
413: .'<input id="nonstd" type="checkbox" name="nonstandard" />'
414: .'<br />('.$lt{'ocik'}.')'
415: .&Apache::lonhtmlcommon::row_closure()
416: .&Apache::lonhtmlcommon::row_title($lt{'fres'})
417: .'<label>'
1.159 raeburn 418: .'<input type="radio" name="firstres" value="blank"'.$blankchk.' />'.$lt{'blnk'}
419: .'</label>');
1.139 raeburn 420: if ($crstype eq 'Community') {
1.159 raeburn 421: $r->print(' <label>'
1.139 raeburn 422: .'<input type="radio" name="firstres" value="nav" checked="checked" />'.$lt{'navi'}
423: .'</label>');
1.159 raeburn 424: } elsif ($crstype eq 'Course') {
425: $r->print(' <label>'
1.110 bisitz 426: .'<input type="radio" name="firstres" value="syl" checked="checked" />'.$lt{'sllb'}
427: .'</label>'
428: .' '
429: .'<label>'
430: .'<input type="radio" name="firstres" value="nav" />'.$lt{'navi'}
1.139 raeburn 431: .'</label>');
432: }
433: $r->print('<br />('.$lt{'stco'}.')'
1.110 bisitz 434: .&Apache::lonhtmlcommon::row_closure(1)
435: .&Apache::lonhtmlcommon::end_pick_box()
1.109 bisitz 436:
1.174 ! raeburn 437: .'</td><td> </td>'
1.109 bisitz 438:
1.110 bisitz 439: # Clone Course:
440: .'<td>'
441: .&Apache::lonhtmlcommon::start_pick_box()
442: .&Apache::lonhtmlcommon::row_title($lt{'cid'})
443: .'<label>'
444: .'<input type="text" size="25" name="clonecourse" value="" />'
445: .'</label>'
446: .&Apache::lonhtmlcommon::row_closure(1)
447: .&Apache::lonhtmlcommon::row_title($lt{'dmn'})
448: .'<label>'
449: .$cloneform
450: .'</label>'
451: .&Apache::lonhtmlcommon::row_closure()
452: .&Apache::lonhtmlcommon::row_title($lt{'dsh'})
453: .'<label>'
454: .'<input type="radio" name="datemode" value="delete" /> '.$lt{'ncd'}
455: .'</label><br />'
456: .'<label>'
457: .'<input type="radio" name="datemode" value="preserve" /> '.$lt{'prd'}
458: .'</label><br />'
459: .'<label>'
460: .'<input type="radio" name="datemode" value="shift" checked="checked" /> '.$lt{'shd'}
461: .'</label>'
462: .' <input type="text" size="5" name="dateshift" value="365" />'
463: .&Apache::lonhtmlcommon::row_closure()
464: .&Apache::lonhtmlcommon::row_headline()
1.146 bisitz 465: .'<span class="LC_info">'.$lt{'asov'}.'</span>'
1.110 bisitz 466: .&Apache::lonhtmlcommon::row_closure(1)
467: .&Apache::lonhtmlcommon::end_pick_box()
468: .'</td>'
469: .&Apache::loncommon::end_data_table_row()
470: .&Apache::loncommon::end_data_table()
1.109 bisitz 471: .&Apache::lonhtmlcommon::row_closure()
1.133 raeburn 472: );
1.109 bisitz 473:
1.133 raeburn 474: $r->print(&Apache::lonhtmlcommon::row_headline()
1.119 bisitz 475: .'<h3>'.$lt{'dads'}.'</h3>'
476: .&Apache::lonhtmlcommon::row_closure()
477: .&Apache::lonhtmlcommon::row_title($lt{'dacc'})
478: .$access_table
479: .&Apache::lonhtmlcommon::row_closure()
1.133 raeburn 480: );
1.119 bisitz 481:
1.133 raeburn 482: $r->print(&Apache::lonhtmlcommon::row_headline()
1.109 bisitz 483: .'<h3>'.$lt{'assp'}.'</h3>'
484: .&Apache::lonhtmlcommon::row_closure()
485:
486: .&Apache::lonhtmlcommon::row_title($lt{'oaas'})
1.173 raeburn 487: .'<span class="LC_nobreak">'
488: .'<label><input type="radio" name="openall" value="0" checked="checked" />'.$lt{'no'}.'</label>'.(' 'x2)
489: .'<label><input type="radio" name="openall" value="1" />'.$lt{'yes'}.'</label>'.', '
1.174 ! raeburn 490: .$lt{'sta'}.' '.$openallfrom.'</span>'
1.109 bisitz 491: .&Apache::lonhtmlcommon::row_closure()
492:
493: .&Apache::lonhtmlcommon::row_headline()
494: .'<h3>'.$lt{'mssg'}.'</h3>'
495: .&Apache::lonhtmlcommon::row_closure()
496:
497: .&Apache::lonhtmlcommon::row_title($lt{'scpf'})
498: .'<input type="checkbox" name="setpolicy" checked="checked" />'
499: .&Apache::lonhtmlcommon::row_closure()
500:
501: .&Apache::lonhtmlcommon::row_title($lt{'scfc'})
502: .'<input type="checkbox" name="setcontent" checked="checked" />'
503: .&Apache::lonhtmlcommon::row_closure()
504:
1.163 raeburn 505: .&Apache::lonhtmlcommon::row_title($lt{'scof'})
506: .'<input type="checkbox" name="setcomment" checked="checked" />'
507: .&Apache::lonhtmlcommon::row_closure()
508:
1.109 bisitz 509: .&Apache::lonhtmlcommon::row_headline()
510: .'<h3>'.$lt{'cmmn'}.'</h3>'
511: .&Apache::lonhtmlcommon::row_closure()
512:
513: .&Apache::lonhtmlcommon::row_title($lt{'dsrd'})
514: .'<input type="checkbox" name="disresdis" />'
515: .&Apache::lonhtmlcommon::row_closure()
516:
517: .&Apache::lonhtmlcommon::row_title($lt{'dsuc'})
1.120 bisitz 518: .'<input type="checkbox" name="disablechat" />'
1.109 bisitz 519: .&Apache::lonhtmlcommon::row_closure()
520:
521: .&Apache::lonhtmlcommon::row_headline()
522: .'<h3>'.$lt{'acco'}.'</h3>'
523: .&Apache::lonhtmlcommon::row_closure()
524:
525: .&Apache::lonhtmlcommon::row_title($lt{'snak'})
526: .'<input type="checkbox" name="setkeys" />'
527: .&Apache::lonhtmlcommon::row_closure()
528:
529: .&Apache::lonhtmlcommon::row_title($lt{'kaut'})
530: .'<input type="text" size="30" name="keyauth" />'
531: .&Apache::lonhtmlcommon::row_closure()
532:
533: .&Apache::lonhtmlcommon::row_headline()
534: .'<h3>'.$lt{'rshm'}.'</h3>'
535: .&Apache::lonhtmlcommon::row_closure()
536:
537: .&Apache::lonhtmlcommon::row_title($lt{'rshm'})
538: .'<input type="text" name="reshome" size="30" value="/res/'.$defdom.'/" />'
539: .&Apache::lonhtmlcommon::row_closure()
1.133 raeburn 540: );
1.161 raeburn 541: unless ($crstype eq 'Community') {
1.133 raeburn 542: $r->print(&Apache::lonhtmlcommon::row_headline()
1.109 bisitz 543: .'<h3>'.$lt{'aens'}.'</h3>'
544: .&Apache::lonhtmlcommon::row_closure()
545:
546: .&Apache::lonhtmlcommon::row_title($lt{'aadd'})
547: .'<label><input type="radio" name="autoadds" value="1" />'.$lt{'yes'}.'</label>'
548: .'<label><input type="radio" name="autoadds" value="0" checked="checked" />'.$lt{'no'}.'</label>'
549: .&Apache::lonhtmlcommon::row_closure()
550:
551: .&Apache::lonhtmlcommon::row_title($lt{'audr'})
552: .'<label><input type="radio" name="autodrops" value="1" />'.$lt{'yes'}.'</label>'
553: .'<label><input type="radio" name="autodrops" value="0" checked="checked" />'.$lt{'no'}.'</label>'
554: .&Apache::lonhtmlcommon::row_closure()
555:
556: .&Apache::lonhtmlcommon::row_title($lt{'dacu'})
557: .$enroll_table
558: .&Apache::lonhtmlcommon::row_closure()
559:
560: .&Apache::lonhtmlcommon::row_title($lt{'psam'})
561: .$lt{'pcda'}.'<br />'
562: .$krbform.'<br />'
563: .$intform.'<br />'
564: .$locform
565: .&Apache::lonhtmlcommon::row_closure()
566:
567: .&Apache::lonhtmlcommon::row_title($lt{'nech'})
568: .$lt{'nccl'}.'<br/>'
569: .'<label><input type="radio" name="notify_owner" value="1" />'.$lt{'yes'}.'</label>'
570: .'<label><input type="radio" name="notify_owner" value="0" checked="checked" />'.$lt{'no'}.'</label>'
571: .'<br />'
572: .$lt{'ndcl'}.'<br/>'
573: .'<label><input type="radio" name="notify_dc" value="1" />'.$lt{'yes'}.'</label>'
574: .'<label><input type="radio" name="notify_dc" value="0" checked="checked" />'.$lt{'no'}.'</label>'
575: .&Apache::lonhtmlcommon::row_closure()
576:
577: .&Apache::lonhtmlcommon::row_title($lt{'irsp'})
578: .'<label>'
579: .'<input type="radio" name="showphotos" value="1" />'.$lt{'yes'}
580: .'</label> '
581: .'<label>'
582: .'<input type="radio" name="showphotos" value="0" checked="checked" />'.$lt{'no'}
583: .'</label> '
584: .&Apache::lonhtmlcommon::row_closure()
1.133 raeburn 585: );
586: }
587:
588: $r->print(&Apache::lonhtmlcommon::row_headline()
1.109 bisitz 589: .'<h3>'.$lt{'cgrs'}.'</h3>'
590: .&Apache::lonhtmlcommon::row_closure()
591:
592: .&Apache::lonhtmlcommon::row_title($lt{'cgrq'})
593: .'<input type="text" name="crsquota" value="20" size="6" />Mb'
594: .&Apache::lonhtmlcommon::row_closure(1)
595:
596: .&Apache::lonhtmlcommon::end_pick_box()
1.133 raeburn 597: .'</div>'
598: );
599: if ($crstype eq 'Course') {
600: $r->print('
1.55 www 601: <p>
1.90 raeburn 602: <input type="hidden" name="prevphase" value="courseone" />
603: <input type="hidden" name="phase" value="coursetwo" />
1.174 ! raeburn 604: <input type="button" onclick="verify_message(this.form)" value="'.$lt{'opco'}.'" />
! 605: </p>'
1.133 raeburn 606: );
1.123 raeburn 607: } elsif ($crstype eq 'Community') {
1.133 raeburn 608: $r->print('
1.90 raeburn 609: <p>
610: <input type="hidden" name="prevphase" value="groupone" />
611: <input type="hidden" name="phase" value="grouptwo" />
1.133 raeburn 612: <input type="submit" value="'.$lt{'opcm'}.'" />
613: </p>'
614: );
1.159 raeburn 615: } elsif ($crstype eq 'Placement') {
616: $r->print('
617: <p>
618: <input type="hidden" name="prevphase" value="placementone" />
619: <input type="hidden" name="phase" value="placementtwo" />
1.162 raeburn 620: <input type="button" onclick="verify_message(this.form)" value="'.$lt{'oppt'}.'" />
1.159 raeburn 621: </p>'
622: );
1.90 raeburn 623: }
1.133 raeburn 624: $r->print('</form>'.
625: $end_page);
1.40 raeburn 626: }
627:
1.2 www 628: # ====================================================== Phase two: make course
629:
1.10 matthew 630: sub create_course {
1.2 www 631: my $r=shift;
1.99 albertel 632: my $ccuname =&LONCAPA::clean_username($env{'form.ccuname'});
633: my $ccdomain=&LONCAPA::clean_domain($env{'form.ccdomain'});
1.123 raeburn 634: my $crstype = 'Community';
1.173 raeburn 635: my ($enrollstart,$enrollend,$startaccess,$endaccess,$openallfrom);
1.147 raeburn 636: my %domdefaults =
637: &Apache::lonnet::get_domain_defaults($env{'request.role.domain'});
1.74 raeburn 638:
1.90 raeburn 639: if ($env{'form.phase'} eq 'coursetwo') {
640: $crstype='Course';
641: $enrollstart=&Apache::lonhtmlcommon::get_date_from_form('startenroll');
642: $enrollend=&Apache::lonhtmlcommon::get_date_from_form('endenroll');
1.159 raeburn 643: } elsif ($env{'form.phase'} eq 'placementtwo') {
644: $crstype='Placement';
1.90 raeburn 645: }
646: $startaccess = &Apache::lonhtmlcommon::get_date_from_form('startaccess');
647: $endaccess = &Apache::lonhtmlcommon::get_date_from_form('endaccess');
1.173 raeburn 648: $openallfrom = &Apache::lonhtmlcommon::get_date_from_form('openallfrom');
1.74 raeburn 649:
650: my $autharg;
651: my $authtype;
652:
1.78 albertel 653: if ($env{'form.login'} eq 'krb') {
1.74 raeburn 654: $authtype = 'krb';
1.78 albertel 655: $authtype .=$env{'form.krbver'};
656: $autharg = $env{'form.krbarg'};
657: } elsif ($env{'form.login'} eq 'int') {
1.74 raeburn 658: $authtype ='internal';
1.78 albertel 659: if ((defined($env{'form.intarg'})) && ($env{'form.intarg'})) {
660: $autharg = $env{'form.intarg'};
1.74 raeburn 661: }
1.78 albertel 662: } elsif ($env{'form.login'} eq 'loc') {
1.74 raeburn 663: $authtype = 'localauth';
1.78 albertel 664: if ((defined($env{'form.locarg'})) && ($env{'form.locarg'})) {
665: $autharg = $env{'form.locarg'};
1.74 raeburn 666: }
667: }
1.90 raeburn 668: my $logmsg;
1.91 albertel 669: my $start_page=&Apache::loncommon::start_page('Create a New '.$crstype);
1.90 raeburn 670: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Outcome','Create_Course',undef,'Create_Courses');
1.74 raeburn 671:
1.90 raeburn 672: $r->print($start_page.$crumbs);
1.74 raeburn 673:
674: my $args = {
1.90 raeburn 675: crstype => $crstype,
1.74 raeburn 676: ccuname => $ccuname,
677: ccdomain => $ccdomain,
1.78 albertel 678: cdescr => $env{'form.title'},
679: curl => $env{'form.topmap'},
680: course_domain => $env{'request.role.domain'},
681: course_home => $env{'form.course_home'},
682: nonstandard => $env{'form.nonstandard'},
683: crscode => $env{'form.crscode'},
1.93 raeburn 684: crsquota => $env{'form.crsquota'},
1.103 raeburn 685: clonecourse => $env{'form.clonecourse'},
686: clonedomain => $env{'form.clonedomain'},
1.106 www 687: datemode => $env{'form.datemode'},
688: dateshift => $env{'form.dateshift'},
1.78 albertel 689: crsid => $env{'form.crsid'},
1.94 raeburn 690: curruser => $env{'user.name'}.':'.$env{'user.domain'},
1.78 albertel 691: crssections => $env{'form.crssections'},
692: crsxlist => $env{'form.crsxlist'},
693: autoadds => $env{'form.autoadds'},
694: autodrops => $env{'form.autodrops'},
695: notify_owner => $env{'form.notify_owner'},
696: notify_dc => $env{'form.notify_dc'},
697: no_end_date => $env{'form.no_end_date'},
698: showphotos => $env{'form.showphotos'},
1.74 raeburn 699: authtype => $authtype,
700: autharg => $autharg,
701: enrollstart => $enrollstart,
702: enrollend => $enrollend,
703: startaccess => $startaccess,
704: endaccess => $endaccess,
1.78 albertel 705: setpolicy => $env{'form.setpolicy'},
706: setcontent => $env{'form.setcontent'},
1.163 raeburn 707: setcomment => $env{'form.setcomment'},
1.78 albertel 708: reshome => $env{'form.reshome'},
709: setkeys => $env{'form.setkeys'},
710: keyauth => $env{'form.keyauth'},
711: disresdis => $env{'form.disresdis'},
712: disablechat => $env{'form.disablechat'},
713: openall => $env{'form.openall'},
1.173 raeburn 714: openallfrom => $openallfrom,
1.78 albertel 715: firstres => $env{'form.firstres'}
1.74 raeburn 716: };
717:
1.147 raeburn 718: if (($crstype eq 'Course') &&
1.152 raeburn 719: ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'} || $domdefaults{'textbookcredits'})) {
1.147 raeburn 720: $args->{'defaultcredits'} = $env{'form.defaultcredits'};
721: }
722:
1.153 raeburn 723: if ($env{'form.uniquecode'}) {
724: $args->{'uniquecode'} = 1;
725: }
726:
1.10 matthew 727: #
728: # Verify data
729: #
730: # Check the veracity of the course coordinator
1.2 www 731: if (&Apache::lonnet::homeserver($ccuname,$ccdomain) eq 'no_host') {
1.52 albertel 732: $r->print('<form action="/adm/createuser" method="post" name="crtuser">');
1.108 bisitz 733: $r->print('<div class="LC_warning">'
734: .&mt('No such user [_1] at domain [_2].','<tt>'.$ccuname.'</tt>','<tt>'.$ccdomain.'</tt>')
735: .'</div>');
736: $r->print(&mt('Please click Back on your browser and select another user, or [_1]Create User[_2]'
737: , '<input type="hidden" name="phase" value="get_user_info" />'
738: .'<input type="hidden" name="ccuname" value="'.$ccuname.'" />'
739: .'<input type="hidden" name="ccdomain" value="'.$ccdomain.'" />'
740: .'<input name="userrole" type="submit" value="'
741: , '" />'
742: )
743: .'</form>'.&Apache::loncommon::end_page()
744: );
1.2 www 745: return;
746: }
1.10 matthew 747: # Check the proposed home server for the course
1.101 albertel 748: my %host_servers =
749: &Apache::lonnet::get_servers($env{'request.role.domain'},'library');
1.78 albertel 750: if (! exists($host_servers{$env{'form.course_home'}})) {
1.108 bisitz 751: $r->print(&mt('Invalid home server for course: [_1]'
752: ,$env{'form.course_home'}.&Apache::loncommon::end_page()));
1.10 matthew 753: return;
754: }
1.153 raeburn 755: my ($courseid,$crsudom,$crsunum,$code);
1.104 albertel 756: my ($success,$output) =
757: &Apache::loncommon::construct_course($args,\$logmsg,\$courseid,
758: \$crsudom,\$crsunum,
759: $env{'user.domain'},
1.153 raeburn 760: $env{'user.name'},'dc_create',undef,undef,\$code);
1.104 albertel 761: $r->print($output);
762: if ($success) {
763: #
764: # Make the requested user a course coordinator or group coordinator
765: #
766: if (($ccdomain) && ($ccuname)) {
1.130 raeburn 767: my $ccrole = 'cc';
768: if ($crstype eq 'Community') {
769: $ccrole = 'co';
770: }
1.114 bisitz 771: $r->print(&mt('Assigning role of '.$crstype.' Coordinator to [_1]:',
772: ,'<i>'.$ccuname.':'.$ccdomain.'</i>')
773: .&Apache::lonnet::assignrole($ccdomain,$ccuname,$courseid,
1.130 raeburn 774: $ccrole,'','','','','createcourse').'<p>');
1.104 albertel 775: }
776: if ($env{'form.setkeys'}) {
777: $r->print(
778: '<p><a href="/adm/managekeys?cid='.$crsudom.'_'.$crsunum.'">'.&mt('Manage Access Keys').'</a></p>');
779: }
1.153 raeburn 780: if ($code) {
781: $r->print(
1.154 bisitz 782: '<p>'.&mt('Course identifier to share with students: [_1]',$code).'</p>'
1.153 raeburn 783: );
784: }
1.171 raeburn 785: if ($env{'form.crscode'} ne '') {
786: &Apache::lonnet::devalidate_cache_new('instcats',$crsudom);
787: }
788: ®ister_cleanups($r,$crsudom,$env{'form.crscode'});
1.104 albertel 789: $r->print('<p>'.&mt('Roles will be active at next login').'.</p>');
790: }
791: $r->print('<p><a href="/adm/createcourse?phase='.lc($crstype).'one">'.
1.114 bisitz 792: &mt("Create Another $crstype").'</a></p>'.
1.86 albertel 793: &Apache::loncommon::end_page());
1.74 raeburn 794: }
795:
1.90 raeburn 796: sub print_intro_page {
1.164 raeburn 797: my ($r,$show_all_choices,$cancreate,$permission) = @_;
1.90 raeburn 798: my $start_page =
1.159 raeburn 799: &Apache::loncommon::start_page('Create a New Course, Community or Placement Test');
1.90 raeburn 800: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Options','Create_Course',undef,'Create_Courses');
801: my $end_page =
802: &Apache::loncommon::end_page();
1.123 raeburn 803: my $helplink=&Apache::loncommon::help_open_topic('Create_Course_Community',&mt('Help on Creating Courses and Communities'));
1.138 bisitz 804:
805: # Create menu
1.164 raeburn 806: my $approve = 'Display requests awaiting approval';
807: if ($permission->{'create'}) {
808: $approve = 'Approve or reject requests';
809: }
1.138 bisitz 810: my @menu;
811: @menu =
812: ({ categorytitle => 'Course/Community Creation',
813: items => [
814: {
815: linktext => 'Create a single course',
816: url => '/adm/createcourse?phase=courseone',
1.164 raeburn 817: permission => $permission->{'create'},
1.138 bisitz 818: #help => '',
1.140 bisitz 819: icon => 'crsnew.png',
1.138 bisitz 820: linktitle => 'Create a new course by completing an online form.'
821: },
822: {
823: linktext => 'Create a single community',
824: url => '/adm/createcourse?phase=groupone',
1.164 raeburn 825: permission => $permission->{'create'} && $cancreate->{'Community'},
1.138 bisitz 826: #help => '',
1.140 bisitz 827: icon => 'crsnew.png',
1.138 bisitz 828: linktitle => 'Create a new collaborative community by completing an online form.'
829: },
830: {
1.159 raeburn 831: linktext => 'Create a single placement test',
832: url => '/adm/createcourse?phase=placementone',
1.164 raeburn 833: permission => $permission->{'create'} && $cancreate->{'Placement'},
1.159 raeburn 834: #help => '',
835: icon => 'crsnew.png',
836: linktitle => 'Create a new placement test by completing an online form.'
837: },
838: {
839: linktext => 'Create courses/communities/placement tests by uploading an attributes file',
1.138 bisitz 840: url => '/adm/createcourse?phase=batchone',
1.164 raeburn 841: permission => $permission->{'create'},
1.138 bisitz 842: help => 'Batch_Creation',
1.140 bisitz 843: icon => 'uplcrs.png',
1.159 raeburn 844: linktitle => 'Upload an attributes file containing specifications for one or more courses, communities or placement tests in XML format.'
1.138 bisitz 845: },
846: ]
847: },
848: { categorytitle => 'Course/Community Requests',
849: items => [
850: {
1.164 raeburn 851: linktext => $approve,
1.138 bisitz 852: url => '/adm/createcourse?phase=requestdisplay',
853: permission => $show_all_choices,
854: #help => '',
1.140 bisitz 855: icon => 'rcrs.png',
1.159 raeburn 856: linktitle => 'Display course, community creation and placement test requests submitted by authorized users, held pending approval by a Domain Coordinator.'
1.138 bisitz 857: },
858: {
1.142 raeburn 859: linktext => 'View pending official course requests',
1.138 bisitz 860: url => '/adm/createcourse?phase=pendingdisplay',
861: permission => $show_all_choices,
862: #help => '',
1.142 raeburn 863: icon => 'edit-find.png',
1.140 bisitz 864: alttext => '',
1.138 bisitz 865: linktitle => 'Display official course requests submitted by authorized users, held pending validation of instructor status.'
866: },
867: ]
868: },
869: { categorytitle => 'Administration',
870: items => [
871: {
872: linktext => 'View creation log',
873: url => '/adm/createcourse?phase=creationlog',
874: permission => $show_all_choices,
875: #help => '',
876: icon => 'document-properties.png',
1.159 raeburn 877: linktitle => 'Display information about when, how and by whom courses, communities and placement tests were created in this domain.'
1.138 bisitz 878: },
879: ]
880: },
881: );
882:
883: $r->print(
884: $start_page
885: .$crumbs
886: .&Apache::lonhtmlcommon::generate_menu(@menu)
887: .$end_page
888: );
1.90 raeburn 889: }
890:
891: sub upload_batchfile {
892: my $r = shift;
893: my $start_page =
1.159 raeburn 894: &Apache::loncommon::start_page('Create a New Course, Community, or Placement Test');
895: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Upload Course/Community/Placement Test Attributes File','Create_Course',undef,'Create_Courses');
1.90 raeburn 896: my $end_page =
897: &Apache::loncommon::end_page();
898: $r->print($start_page.$crumbs);
1.159 raeburn 899: $r->print('<h3>'.&mt('Upload a courses, communities or placement tests attributes file').'</h3>');
1.90 raeburn 900: $r->print('<form name="batchcreate" method="post" '.
901: 'enctype="multipart/form-data" action="/adm/createcourse">'.
902: '<input type="file" name="coursecreatorxml" />'.
1.121 bisitz 903: '<input type="hidden" name="phase" value="batchtwo" /><br /><br />'.
1.90 raeburn 904: '<input type="submit" name="batchsubmit" '.
1.159 raeburn 905: 'value="'.&mt('Create Courses/Communities/Placement Tests').'" /></form>');
1.90 raeburn 906: $r->print($end_page);
907: return;
908: }
909:
910: sub process_batchfile {
911: my $r = shift;
912: my $defdom=$env{'request.role.domain'};
1.168 raeburn 913: my $uname = $env{'user.name'};
914: my $udom = $env{'user.domain'};
915: my $dir = &LONCAPA::tempdir().'addcourse';
1.171 raeburn 916: my ($result,$logmsg,$keysmsg,$codesref,$instcodesref);
1.168 raeburn 917: if (($defdom =~ /^$match_domain$/) && ($uname =~ /^$match_username$/) && ($udom =~/^$match_domain$/)) {
918: my $batchfilepath=&Apache::lonnet::userfileupload('coursecreatorxml',undef,
919: 'batchupload',undef,undef,
920: undef,undef,$defdom);
1.170 raeburn 921: if ($batchfilepath =~ m{^(\Q$dir/$defdom/web/$uname\E_\Q$udom\E)/pending/([^/]+)$}) {
1.168 raeburn 922: my ($batchdir,$filename) = ($1,$2);
923: if (-e "$batchfilepath") {
1.169 raeburn 924: if (open(FILE,"<",$batchfilepath)) {
1.168 raeburn 925: my @buffer = <FILE>;
1.90 raeburn 926: close(FILE);
1.168 raeburn 927: if ((defined($filename)) && (defined($batchdir))) {
928: my @requests = ($filename);
929: my %courseids = ();
1.171 raeburn 930: ($result,$logmsg,$keysmsg,$codesref,$instcodesref) =
931: &LONCAPA::batchcreatecourse::create_courses(
932: \@requests,\%courseids,'web',$defdom,
933: $uname,$udom);
1.168 raeburn 934: if (keys(%courseids) > 0) {
935: if (!-e "$batchdir/processed") {
936: mkdir("$batchdir/processed", 0755);
937: }
938: if (-d "$batchdir/processed") {
1.169 raeburn 939: if (open(FILE,">","$batchdir/processed/$filename")) {
1.168 raeburn 940: print FILE @buffer;
941: close(FILE);
942: }
943: }
944: if (-e "$batchdir/processed/$filename") {
945: unlink("$batchdir/pending/$filename");
946: }
1.171 raeburn 947: my $updatecats;
948: if ((ref($instcodesref) eq 'HASH') && (keys(%{$instcodesref}) > 0)) {
1.172 raeburn 949: &Apache::lonnet::devalidate_cache_new('instcats',$defdom);
1.171 raeburn 950: $updatecats = 1;
951: }
952: ®ister_cleanups($r,$defdom,$updatecats);
1.168 raeburn 953: }
1.90 raeburn 954: }
1.168 raeburn 955: } else {
956: $result = '<p class="LC_error">'.&mt('Could not open attributes file.').'<br />'.&mt('No courses created.').'</p>';
1.90 raeburn 957: }
1.168 raeburn 958: } else {
959: $result = '<p class="LC_error">'.&mt('No uploaded attributes file found.').'<br />'.&mt('No courses created.').'</p>';
1.90 raeburn 960: }
1.168 raeburn 961: } else {
962: $result = '<p class="LC_error">'.&mt('Invalid path to attributes file.').'<br />'.&mt('No courses created.').'</p>';
1.90 raeburn 963: }
1.168 raeburn 964: } else {
965: $result = '<p class="LC_error">'.&mt("Your username, domain, and/or your current role's domain are missing or contain invalid characters.").
966: '<br />'.&mt('No courses created.').'</p>';
1.90 raeburn 967: }
1.168 raeburn 968: $r->print(&Apache::loncommon::start_page('Create a New Course, Community or Placement Test').
969: &Apache::lonhtmlcommon::breadcrumbs('Creation Outcome','Create_Course',undef,'Create_Courses').
970: $logmsg.$result.'<br /><a href="/adm/createcourse">'.
971: &mt('Creation options menu').'</a>'.
972: &Apache::loncommon::end_page());
1.90 raeburn 973:
974: }
975:
1.126 raeburn 976: sub courserequestbrowser_javascript {
977: return <<"ENDREQBRW";
978: <script type="text/javascript">
979: // <![CDATA[
980: var steditbrowser;
1.136 raeburn 981: function opencoursereqdisplay(cdom,cnum,queue) {
1.126 raeburn 982: var url = '/adm/requestcourse?action=display';
1.136 raeburn 983: url += '&showdom='+cdom+'&cnum='+cnum+'&queue='+queue;
1.126 raeburn 984: var title = 'Course_Request_Browser';
985: var options = 'scrollbars=1,resizable=1,menubar=0';
986: options += ',width=700,height=600';
987: var stdeditbrowser = open(url,title,options,'1');
988: stdeditbrowser.focus();
989: }
1.136 raeburn 990:
1.126 raeburn 991: // ]]>
992: </script>
993: ENDREQBRW
994: }
995:
1.127 raeburn 996: sub print_creation_logs {
997: my ($r) = @_;
998: my $formname = 'creationlog';
999: my $dom = $env{'request.role.domain'};
1000: $r->print('<form action="/adm/createcourse" method="post" name="'.$formname.'">');
1001: # set defaults
1002: my $now = time();
1003: my $defstart = $now - (7*24*3600); #7 days ago
1004: my %defaults = (
1005: page => '1',
1006: show => '10',
1007: type => 'any',
1008: context => 'any',
1009: created_before_date => $now,
1010: created_after_date => $defstart,
1011: );
1012: my ($contexts,$contextnames) = &context_names();
1013: my $more_records = 0;
1014: my %curr;
1015: foreach my $item ('show','page','type','context') {
1016: $curr{$item} = $env{'form.'.$item};
1017: }
1018: $curr{'created_after_date'} = &Apache::lonhtmlcommon::get_date_from_form('created_after_date');
1019: $curr{'created_before_date'} = &Apache::lonhtmlcommon::get_date_from_form('created_before_date');
1020: foreach my $key (keys(%defaults)) {
1021: if ($curr{$key} eq '') {
1022: $curr{$key} = $defaults{$key};
1023: }
1024: }
1.135 raeburn 1025: my %whodunit;
1026: $r->print(&creation_display_filter($formname,\%curr));
1.127 raeburn 1027: my $showntablehdr = 0;
1028: my $tablehdr = &Apache::loncommon::start_data_table().
1029: &Apache::loncommon::start_data_table_header_row().
1030: '<th> </th><th>'.&mt('Creation Date').'</th>'.
1031: '<th>'.&mt('Creator').'</th><th>'.&mt('Description').'</th>'.
1.131 raeburn 1032: '<th>'.&mt('Owner(s)').'</th>';
1.127 raeburn 1033: if (($curr{'type'} eq 'official') || ($curr{'type'} eq 'any')) {
1034: $tablehdr .= '<th>'.&mt('Institutional Code').'</th>';
1.128 raeburn 1035: }
1036: if ($curr{'type'} eq 'any') {
1037: $tablehdr .= '<th>'.&mt('Course Type').'</th>';
1038: }
1.129 raeburn 1039: if ($curr{'context'} eq 'any') {
1.128 raeburn 1040: $tablehdr .= '<th>'.&mt('Creation Context').'</th>';
1041: }
1042: $tablehdr .= &Apache::loncommon::end_data_table_header_row();
1.127 raeburn 1043: my ($minshown,$maxshown);
1044: $minshown = 1;
1045: my $count = 0;
1046: if ($curr{'show'} ne &mt('all')) {
1047: $maxshown = $curr{'page'} * $curr{'show'};
1048: if ($curr{'page'} > 1) {
1049: $minshown = 1 + ($curr{'page'} - 1) * $curr{'show'};
1050: }
1051: }
1052: my $crstype = 'Course';
1053: if ($curr{'type'} eq 'any') {
1054: $crstype = '.';
1055: } elsif ($curr{'type'} eq 'community') {
1056: $crstype = 'Community';
1.159 raeburn 1057: } elsif ($curr{'type'} eq 'placement') {
1058: $crstype = 'Placement';
1.127 raeburn 1059: }
1060:
1061: my ($instcodefilter,$regexpok);
1062: my (@codetitles,%cat_titles,%cat_order,%cat_items,$officialjs);
1063: my ($jscript,$totcodes,$numtitles,$lasttitle) =
1064: &Apache::courseclassifier::instcode_selectors_data($dom,$formname,
1065: \%cat_items,\@codetitles,\%cat_titles,\%cat_order,
1066: $officialjs);
1067: if ($numtitles) {
1068: if (($curr{'type'} eq 'official') || ($curr{'type'} eq 'unofficial')) {
1069: $instcodefilter = &instcode_srchstr($dom,$numtitles);
1.141 raeburn 1070: &Apache::courseclassifier::instcode_search_str($dom,$numtitles,\@codetitles);
1.127 raeburn 1071: if ($curr{'type'} eq 'official') {
1072: $regexpok = 1;
1073: } else {
1074: unless ($instcodefilter eq '') {
1075: $regexpok = -1;
1076: }
1077: }
1078: }
1079: }
1080: if ($instcodefilter eq '') { $instcodefilter = '.'; }
1081:
1082: my $creationcontext = '.';
1083: my $context_regexp = join('|',@{$contexts});
1084: if ($curr{'context'} =~ /^($context_regexp)$/) {
1085: $creationcontext = $curr{'context'};
1086: }
1087: my %courses =
1088: &Apache::lonnet::courseiddump($dom,'.',1,$instcodefilter,'.','.',undef,undef,
1089: $crstype,$regexpok,undef,undef,'1','creationlog',
1090: undef,undef,undef,$curr{'created_before_date'},
1091: $curr{'created_after_date'},$creationcontext);
1092: foreach my $cid (sort { $courses{$b}{'created'}<=>$courses{$a}{'created'} } (keys(%courses))) {
1.136 raeburn 1093: if ($curr{'show'} ne &mt('all')) {
1094: if ($count >= $curr{'page'} * $curr{'show'}) {
1095: $more_records = 1;
1096: last;
1097: }
1098: }
1.127 raeburn 1099: $count ++;
1100: next if ($count < $minshown);
1101: if (!$showntablehdr) {
1102: $r->print($tablehdr);
1103: $showntablehdr = 1;
1104: }
1105: if ($courses{$cid}{'creator'} ne '') {
1106: if ($whodunit{$courses{$cid}{'creator'}} eq '') {
1107: my ($uname,$udom) = split(':',$courses{$cid}{'creator'});
1108: $whodunit{$courses{$cid}{'creator'}} =
1109: &Apache::loncommon::plainname($uname,$udom);
1110: }
1111: }
1112: my $description = $courses{$cid}{'description'};
1113: my @owners;
1114: my $singleowner = $courses{$cid}{'owner'};
1115: push(@owners,$singleowner);
1116: if (ref($courses{$cid}{'co-owners'}) eq 'ARRAY') {
1117: foreach my $item (@{$courses{$cid}{'co-owners'}}) {
1118: push(@owners,$item);
1119: }
1120: }
1121: my %ownernames;
1122: foreach my $owner (@owners) {
1123: my ($ownername,$ownerdom);
1124: if ($owner =~ /:/) {
1125: ($ownername,$ownerdom) = split(/:/,$owner);
1126: } else {
1127: $ownername = $owner;
1128: if ($owner ne '') {
1129: $ownerdom = $dom;
1130: }
1131: }
1132: if ($ownername ne '' && $ownerdom ne '') {
1133: unless (ref($ownernames{$ownername.':'.$ownerdom}) eq 'HASH') {
1134: my %namehash=&Apache::loncommon::getnames($ownername,$ownerdom);
1135: $ownernames{$ownername.':'.$ownerdom} = \%namehash;
1136: }
1137: }
1138: }
1139: my @lastnames;
1140: foreach my $owner (keys(%ownernames)) {
1141: if (ref($ownernames{$owner}) eq 'HASH') {
1142: push(@lastnames,$ownernames{$owner}{'lastname'});
1143: }
1144: }
1145: my $ownerlastnames = join(', ',sort(@lastnames));
1146: my $showtype;
1147: if ($courses{$cid}{type} eq 'Community') {
1148: $showtype = &mt('community');
1.159 raeburn 1149: } elsif ($courses{$cid}{type} eq 'Placement') {
1150: $showtype = &mt('placement test');
1.127 raeburn 1151: } else {
1152: my $instcode = $courses{$cid}{inst_code};
1153: if ($instcode ne '') {
1154: $showtype = &mt('official');
1155: } else {
1156: $showtype = &mt('unofficial');
1157: }
1158: }
1159: my $showcontext;
1160:
1161: if ($courses{$cid}{context} =~ /^($context_regexp)$/) {
1162: $showcontext = $contextnames->{$courses{$cid}{context}};
1163: }
1164: my $created = &Apache::lonlocal::locallocaltime($courses{$cid}{'created'});
1165: my ($cdom,$cnum) = split('_',$cid);
1166: $r->print(&Apache::loncommon::start_data_table_row()."\n".
1167: '<td>'.$count.'</td><td>'.$created.'</td>'."\n".
1168: '<td>'.$whodunit{$courses{$cid}{creator}}.'</td>'."\n".
1169: '<td>'.$description.' <a href="javascript:ToSyllabus('."'$cdom','$cnum'".')">'.&mt('Syllabus').'</a></td><td>'.$ownerlastnames.'</td>');
1170: if (($curr{'type'} eq 'official') || ($curr{'type'} eq 'any')) {
1171: $r->print('<td>'.$courses{$cid}{'inst_code'}.'</td>');
1172: }
1.128 raeburn 1173: if ($curr{'type'} eq 'any') {
1174: $r->print('<td>'.$showtype.'</td>');
1175: }
1176: if ($curr{'context'} eq 'any') {
1177: $r->print('<td>'.$showcontext.'</td>');
1178: }
1179: $r->print('<td>'.&Apache::loncommon::end_data_table_row()."\n");
1.127 raeburn 1180: }
1181: if ($showntablehdr) {
1182: $r->print(&Apache::loncommon::end_data_table().'<br />');
1183: if (($curr{'page'} > 1) || ($more_records)) {
1184: $r->print('<table><tr>');
1185: if ($curr{'page'} > 1) {
1186: $r->print('<td><a href="javascript:chgPage('."'previous'".');">'.&mt('Previous [_1] changes',$curr{'show'}).'</a></td>');
1187: }
1188: if ($more_records) {
1189: $r->print('<td><a href="javascript:chgPage('."'next'".');">'.&mt('Next [_1] changes',$curr{'show'}).'</a></td>');
1190: }
1191: $r->print('</tr></table>');
1192: $r->print(<<"ENDSCRIPT");
1193: <script type="text/javascript">
1194: // <![CDATA[
1195: function chgPage(caller) {
1196: if (caller == 'previous') {
1197: document.$formname.page.value --;
1198: }
1199: if (caller == 'next') {
1200: document.$formname.page.value ++;
1201: }
1202: document.$formname.submit();
1203: return;
1204: }
1205: // ]]>
1206: </script>
1207: ENDSCRIPT
1208: }
1209: } else {
1210: $r->print('<p class="LC_info">'.
1211: &mt('There are no records to display').
1212: '</p>');
1213: }
1214: $r->print('<input type="hidden" name="page" value="'.$curr{'page'}.'" />'.
1215: '<input type="hidden" name="phase" value="creationlog" /></form>');
1216: return;
1217: }
1218:
1219: sub creation_display_filter {
1.135 raeburn 1220: my ($formname,$curr) = @_;
1.127 raeburn 1221: my $nolink = 1;
1222: my ($contexts,$contextnames) = &context_names();
1223: my $output = '<table><tr><td valign="top">'.
1224: '<span class="LC_nobreak"><b>'.&mt('Records/page:').'</b></span><br />'.
1225: &Apache::lonmeta::selectbox('show',$curr->{'show'},undef,
1226: (&mt('all'),5,10,20,50,100,1000,10000)).
1227: '</td><td> </td>';
1228: my $startform =
1229: &Apache::lonhtmlcommon::date_setter($formname,'created_after_date',
1230: $curr->{'created_after_date'},undef,
1231: undef,undef,undef,undef,undef,undef,$nolink);
1232: my $endform =
1233: &Apache::lonhtmlcommon::date_setter($formname,'created_before_date',
1234: $curr->{'created_before_date'},undef,
1235: undef,undef,undef,undef,undef,undef,$nolink);
1.136 raeburn 1236: $output .= '<td valign="top"><b>'.&mt('Window during which course/community was created:').'</b><br />'.
1.127 raeburn 1237: '<table><tr><td>'.&mt('After:').
1238: '</td><td>'.$startform.'</td></tr>'.
1239: '<tr><td>'.&mt('Before:').'</td>'.
1240: '<td>'.$endform.'</td></tr></table>'.
1241: '</td>'.
1242: '<td> </td>';
1.136 raeburn 1243: my ($types,$typenames) = &Apache::loncommon::course_types();
1.127 raeburn 1244: if (ref($types) eq 'ARRAY') {
1245: if (@{$types} > 1) {
1246: $output .= '<td valign="top"><b>'.
1247: &mt('Course Type:').'</b><br /><select name="type">';
1248: my $selstr = '';
1249: if ($curr->{'type'} eq 'any') {
1250: $selstr = ' selected="selected"';
1251: }
1252: $output .= '<option value="any"'.$selstr.'>'.&mt('Any').'</option>'."\n";
1253: foreach my $type (@{$types}) {
1254: my $selstr = '';
1255: if ($curr->{'type'} eq $type) {
1256: $selstr = ' selected="selected"';
1257: }
1258: my $typename = $type;
1259: if (ref($typenames) eq 'HASH') {
1260: if ($typenames->{$type} ne '') {
1261: $typename = $typenames->{$type};
1262: }
1263: }
1.155 bisitz 1264: $output .= '<option value="'.$type.'"'.$selstr.'>'.&mt($typename).'</option>'."\n";
1.127 raeburn 1265: }
1266: $output .= '</select></td>';
1267: }
1268: }
1269: $output .= '<td> </td>'.
1270: '<td valign="top"><b>'.
1271: &mt('Creation Context:').'</b><br /><select name="context">';
1272: foreach my $context ('any',@{$contexts}) {
1273: my $selstr = '';
1274: if ($curr->{'context'} eq $context) {
1275: $selstr = ' selected="selected"';
1276: }
1277: $output .= '<option value="'.$context.'"'.$selstr.'>';
1278: if ($context eq 'any') {
1279: $output .= &mt('Any');
1280: } else {
1281: $output .= $contextnames->{$context};
1282: }
1283: $output .= '</option>'."\n";
1284: }
1285: $output .= '</select></td>'.
1286: '</tr></table>';
1287:
1288: # Update Display button
1289: $output .= '<p>'.
1290: '<input type="submit" value="'.&mt('Update Display').'" />'.
1.135 raeburn 1291: '</p><hr />';
1.127 raeburn 1292: return $output;
1293: }
1294:
1295: sub context_names {
1.128 raeburn 1296: my @contexts = qw(auto web dc_create requestcourses);
1.127 raeburn 1297: my %contextnames =
1298: &Apache::lonlocal::texthash (
1.128 raeburn 1299: auto => 'Automated creation from batch file',
1300: web => 'Batch creation from uploaded file',
1.131 raeburn 1301: dc_create => 'Course or community created by Dom. Coord.',
1.128 raeburn 1302: requestcourses => 'Processing of submitted course request',
1.127 raeburn 1303: );
1304: return (\@contexts,\%contextnames);
1305: }
1306:
1307: sub instcode_srchstr {
1308: my ($domain,$numtitles) = @_;
1309: my $instcode;
1310: if (defined($numtitles) && $numtitles == 0) {
1311: $instcode = '.+';
1312: } else {
1313: my (%codedefaults,@code_order);
1314: my $defaults_result =
1315: &Apache::lonnet::auto_instcode_defaults($domain,\%codedefaults,
1316: \@code_order);
1317: if ($defaults_result eq 'ok') {
1318: $instcode ='^';
1319: foreach my $item (@code_order) {
1320: $instcode .= $codedefaults{$item};
1321: }
1322: $instcode .= '$';
1323: } else {
1324: $instcode = '.+';
1325: }
1326: }
1327: return $instcode;
1328: }
1329:
1330: sub syllabuslink_javascript {
1331: return <<"ENDJS";
1332:
1333: function ToSyllabus(cdom,cnum) {
1334: if (cdom == '' || cdom == null) {
1335: return;
1336: }
1337: if (cnum == '' || cnum == null) {
1338: return;
1339: }
1340: var options = 'height=600,width=800,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no';
1341: var url = "/public/"+cdom+"/"+cnum+"/syllabus";
1342: syllwin = window.open(url,'',options,1);
1343: syllwin.focus();
1344: return;
1345: }
1346:
1347: ENDJS
1348:
1349: }
1.126 raeburn 1350:
1.164 raeburn 1351: sub get_permission {
1352: my ($dom) = @_;
1353: my ($allowed,%permission);
1354: if (&Apache::lonnet::allowed('ccc',$dom)) {
1355: $allowed = 1;
1356: %permission = (
1357: create => 1,
1358: );
1359: } elsif (&Apache::lonnet::allowed('dcc',$dom)) {
1360: $allowed = 1;
1361: }
1362: return ($allowed,\%permission);
1363: }
1364:
1.171 raeburn 1365: sub register_cleanups {
1366: my ($r,$cdom,$updatecats) = @_;
1367: # Flush the course logs so reverse user roles immediately updated
1368: unless ($registered_flush) {
1369: my $handlers = $r->get_handlers('PerlCleanupHandler');
1370: $r->set_handlers('PerlCleanupHandler' => [\&Apache::lonnet::flushcourselogs,@{$handlers}]);
1371: $registered_flush=1;
1372: }
1373: # Update cache of self-cataloging courses on institution's server(s).
1374: if ($updatecats) {
1375: if (&Apache::lonnet::shared_institution($cdom)) {
1376: unless ($registered_instcats) {
1377: my $handlers = $r->get_handlers('PerlCleanupHandler');
1378: $r->set_handlers('PerlCleanupHandler' => [\&devalidate_remote_instcats,@{$handlers}]);
1379: $registered_instcats=1;
1380: $modified_dom = $cdom;
1381: }
1382: }
1383: }
1384: return;
1385: }
1386:
1387: sub devalidate_remote_instcats {
1388: if ($modified_dom ne '') {
1389: my %servers = &Apache::lonnet::internet_dom_servers($modified_dom);
1390: my %thismachine;
1391: map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids();
1392: if (keys(%servers)) {
1393: foreach my $server (keys(%servers)) {
1394: next if ($thismachine{$server});
1395: &Apache::lonnet::remote_devalidate_cache($server,['instcats:'.$modified_dom]);
1396: }
1397: }
1398: $modified_dom = '';
1399: }
1400: return;
1401: }
1402:
1.2 www 1403: # ===================================================================== Handler
1.1 www 1404: sub handler {
1405: my $r = shift;
1406:
1407: if ($r->header_only) {
1.38 www 1408: &Apache::loncommon::content_type($r,'text/html');
1.1 www 1409: $r->send_http_header;
1410: return OK;
1411: }
1412:
1.171 raeburn 1413: $registered_flush = 0;
1414: $registered_instcats = 0;
1415: $modified_dom = '';
1416:
1.164 raeburn 1417: my ($allowed,$permission) = &get_permission($env{'request.role.domain'});
1418: if ($allowed) {
1419: my $show_all_choices = 0;
1420: my $primary_rev = &Apache::lonnet::get_server_loncaparev($env{'request.role.domain'});
1421: my %cancreate = (
1422: Community => 0,
1423: Placement => 0,
1424: );
1425: if (($primary_rev ne 'refused') && ($primary_rev ne 'error') &&
1426: ($primary_rev ne 'unknown_cmd') && ($primary_rev ne 'no_such_host')) {
1427: $show_all_choices = 1;
1428: my ($primary_major,$primary_minor) = split(/\./,$primary_rev);
1429: foreach my $key (keys(%cancreate)) {
1430: my ($needsmajor,$needsminor) =
1431: split(/\./,$Apache::lonnet::needsrelease{'course:crstype:'.$key});
1432: unless (($needsmajor > $primary_major) ||
1433: (($needsmajor == $primary_major) && ($needsminor > $primary_minor))) {
1434: $cancreate{$key} = 1;
1435: }
1.159 raeburn 1436: }
1437: }
1.137 raeburn 1438:
1.38 www 1439: &Apache::loncommon::content_type($r,'text/html');
1.1 www 1440: $r->send_http_header;
1441:
1.90 raeburn 1442: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1443: ['phase']);
1444: &Apache::lonhtmlcommon::clear_breadcrumbs();
1445: &Apache::lonhtmlcommon::add_breadcrumb
1446: ({href=>"/adm/createcourse",
1447: text=>"Creation Options",
1448: faq=>79,bug=>'Dom Coord Interface',});
1.164 raeburn 1449: if (($permission->{'create'}) &&
1450: (($env{'form.phase'} eq 'coursetwo') ||
1451: (($env{'form.phase'} eq 'grouptwo') &&
1.159 raeburn 1452: ($cancreate{'Community'})) ||
1453: (($env{'form.phase'} eq 'placementtwo') &&
1.164 raeburn 1454: ($cancreate{'Placement'})))) {
1.90 raeburn 1455: &Apache::lonhtmlcommon::add_breadcrumb
1456: ({href=>"/adm/createcourse?phase=$env{'form.prevphase'}",
1457: text=>&mt('[_1] Creation Settings',),
1458: faq=>9,bug=>'Dom Coord Interface',});
1459: &Apache::lonhtmlcommon::add_breadcrumb
1460: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1461: text=>"Creation Outcome",
1462: faq=>9,bug=>'Dom Coord Interface',});
1.10 matthew 1463: &create_course($r);
1.164 raeburn 1464: } elsif (($permission->{'create'}) &&
1465: (($env{'form.phase'} eq 'courseone') ||
1466: (($env{'form.phase'} eq 'groupone') &&
1467: ($cancreate{'Community'})) ||
1468: (($env{'form.phase'} eq 'placementone') &&
1469: ($cancreate{'Placement'})))) {
1.90 raeburn 1470: &Apache::lonhtmlcommon::add_breadcrumb
1471: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1472: text=>&mt('[_1] Creation Settings',),
1473: faq=>9,bug=>'Dom Coord Interface',});
1474: &print_course_creation_page($r);
1.164 raeburn 1475: } elsif (($permission->{'create'}) &&
1476: ($env{'form.phase'} eq 'batchone')) {
1.90 raeburn 1477: &Apache::lonhtmlcommon::add_breadcrumb
1478: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1479: text=>"Upload Description File",
1480: faq=>9,bug=>'Dom Coord Interface',});
1481: &upload_batchfile($r);
1.164 raeburn 1482: } elsif (($permission->{'create'}) &&
1483: ($env{'form.phase'} eq 'batchtwo')) {
1.90 raeburn 1484: &Apache::lonhtmlcommon::add_breadcrumb
1485: ({href=>"/adm/createcourse?phase=$env{'form.prevphase'}",
1486: text=>"Upload Description File",
1487: faq=>9,bug=>'Dom Coord Interface',});
1488: &Apache::lonhtmlcommon::add_breadcrumb
1489: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1490: text=>"Creation Outcome",
1491: faq=>9,bug=>'Dom Coord Interface',});
1492: &process_batchfile($r);
1.137 raeburn 1493: } elsif (($env{'form.phase'} eq 'requestdisplay') && ($show_all_choices)) {
1.125 raeburn 1494: &Apache::lonhtmlcommon::add_breadcrumb
1495: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1496: text=>&mt('[_1] Display Request Queue',),
1497: faq=>9,bug=>'Dom Coord Interface',});
1.126 raeburn 1498: my $js = &courserequestbrowser_javascript();
1499: my $start_page=&Apache::loncommon::start_page('Display Requests',$js);
1.156 bisitz 1500: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Display Requests','Course_Requests',undef,'Course_Requests');
1.164 raeburn 1501: my $context = 'domain';
1502: unless ($permission->{'create'}) {
1503: $context = 'helpdesk';
1504: }
1.125 raeburn 1505: $r->print($start_page.$crumbs."\n".'<div>'.
1506: &Apache::loncoursequeueadmin::display_queued_requests(
1.165 raeburn 1507: $context,$env{'request.role.domain'}).'</div>'.
1.125 raeburn 1508: &Apache::loncommon::end_page());
1.164 raeburn 1509: } elsif (($permission->{'create'}) &&
1510: ($env{'form.phase'} eq 'requestchange') && ($show_all_choices)) {
1.136 raeburn 1511: if ($env{'form.queue'} eq 'pending') {
1512: &Apache::lonhtmlcommon::add_breadcrumb
1513: ({href=>"/adm/createcourse?phase=pendingdisplay",
1514: text=>&mt('Display Pending Queue',),
1515: faq=>9,bug=>'Dom Coord Interface',});
1516: } else {
1517: &Apache::lonhtmlcommon::add_breadcrumb
1518: ({href=>"/adm/createcourse?phase=requestdisplay",
1519: text=>&mt('[_1] Display Request Queue',),
1520: faq=>9,bug=>'Dom Coord Interface',});
1521: }
1.125 raeburn 1522: &Apache::lonhtmlcommon::add_breadcrumb
1.136 raeburn 1523: ({href=>"/adm/createcourse?phase=requestchange",
1524: text=>&mt('[_1] Requests Updated',),
1525: faq=>9,bug=>'Dom Coord Interface',},);
1.125 raeburn 1526: my $start_page=&Apache::loncommon::start_page('Update Requests Result');
1.156 bisitz 1527: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Requests Updated','Course_Requests',undef,'Course_Requests');
1.125 raeburn 1528: $r->print($start_page.$crumbs."\n".'<div>'.
1529: &Apache::loncoursequeueadmin::update_request_queue(
1530: 'domain',$env{'request.role.domain'}).'</div>'.
1531: &Apache::loncommon::end_page());
1.137 raeburn 1532: } elsif (($env{'form.phase'} eq 'pendingdisplay') && ($show_all_choices)) {
1.136 raeburn 1533: &Apache::lonhtmlcommon::add_breadcrumb
1534: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1535: text=>&mt('Display Pending Queue',),
1536: faq=>9,bug=>'Dom Coord Interface',});
1537: my $js = &courserequestbrowser_javascript();
1538: my $start_page=&Apache::loncommon::start_page('Display Pending Queue',$js);
1.156 bisitz 1539: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Display Pending Queue','Course_Requests',undef,'Course_Requests');
1.164 raeburn 1540: my $context = 'pending';
1541: unless ($permission->{'create'}) {
1542: $context = 'displaypending';
1543: }
1.136 raeburn 1544: $r->print($start_page.$crumbs."\n".'<div>'.
1545: &Apache::loncoursequeueadmin::display_queued_requests(
1.164 raeburn 1546: $context,$env{'request.role.domain'}).'</div>'.
1.136 raeburn 1547: &Apache::loncommon::end_page());
1.164 raeburn 1548: } elsif (($permission->{'create'}) &&
1549: ($env{'form.phase'} eq 'requestvalidation') && ($show_all_choices)) {
1.136 raeburn 1550: my $js = &courserequestbrowser_javascript();
1551: &Apache::lonhtmlcommon::add_breadcrumb
1552: ({href=>"/adm/createcourse?phase=pendingdisplay",
1553: text=>&mt('Display Pending Queue'),},
1554: {href=>"/adm/createcourse?phase=requestvalidation",
1555: text=>&mt('Validation Attempted'),},);
1556: my $start_page=&Apache::loncommon::start_page('Requests Validation Result',$js);
1.156 bisitz 1557: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Validation Attempted','Course_Requests',undef,'Course_Requests');
1.136 raeburn 1558: $r->print($start_page.$crumbs."\n".'<div>'.
1559: &Apache::loncoursequeueadmin::process_official_reqs('domain',$env{'request.role.domain'}).'</div>'.
1560: &Apache::loncommon::end_page());
1.137 raeburn 1561: } elsif (($env{'form.phase'} eq 'creationlog') && ($show_all_choices)) {
1.127 raeburn 1562: &Apache::lonhtmlcommon::add_breadcrumb
1563: ({href=>"/adm/createcourse?phase=creationlog",
1564: text=>&mt('[_1] Display Creation History',),});
1565: my $js = '<script type="text/javascript">'."\n".
1566: '// <![CDATA['."\n".
1567: &syllabuslink_javascript()."\n".
1568: '// ]]>'."\n".
1569: '</script>';
1.131 raeburn 1570: my $start_page=&Apache::loncommon::start_page('Course/Community Creation Logs',$js);
1.151 raeburn 1571: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Created Courses/Communities','Course_Creation_Log',undef,'Course_Creation_Log');
1.127 raeburn 1572: $r->print($start_page.$crumbs."\n".'<div>');
1573: &print_creation_logs($r);
1574: $r->print('</div>'.&Apache::loncommon::end_page());
1.2 www 1575: } else {
1.164 raeburn 1576: &print_intro_page($r,$show_all_choices,\%cancreate,$permission);
1.2 www 1577: }
1.1 www 1578: } else {
1.78 albertel 1579: $env{'user.error.msg'}=
1.127 raeburn 1580: "/adm/createcourse:ccc:0:0:Cannot create courses or communities";
1.1 www 1581: return HTTP_NOT_ACCEPTABLE;
1582: }
1583: return OK;
1.90 raeburn 1584: }
1.1 www 1585:
1586: 1;
1587: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>