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