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