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