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