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