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