Annotation of loncom/interface/lonpickcourse.pm, revision 1.84
1.1 www 1: # The LearningOnline Network
2: # Pick a course
3: #
1.84 ! raeburn 4: # $Id: lonpickcourse.pm,v 1.83 2009/07/25 23:16:04 raeburn Exp $
1.1 www 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: #
28:
29: package Apache::lonpickcourse;
30:
31: use strict;
32: use Apache::Constants qw(:common);
33: use Apache::loncommon;
34: use Apache::loncoursedata;
35: use Apache::lonnet;
1.8 www 36: use Apache::lonlocal;
1.46 raeburn 37: use Apache::longroup;
1.78 raeburn 38: use Apache::courseclassifier;
1.47 www 39: use LONCAPA;
1.1 www 40:
41: sub handler {
42: my $r = shift;
1.8 www 43: &Apache::loncommon::content_type($r,'text/html');
1.1 www 44: $r->send_http_header;
45: return OK if $r->header_only;
46:
47: # ------------------------------------------------------------ Print the screen
1.40 albertel 48:
1.55 raeburn 49: # Get parameters from query string
1.1 www 50: &Apache::loncommon::get_unprocessed_cgi
1.55 raeburn 51: ($ENV{'QUERY_STRING'},['domainfilter','form','cnumelement',
1.19 raeburn 52: 'cdomelement','cnameelement','roleelement',
1.78 raeburn 53: 'multiple','type','setroles','fixeddom']);
1.55 raeburn 54: my ($type,$title,$jscript,$multelement,$multiple,$roleelement,
55: $lastaction,$autosubmit,$submitopener);
56:
1.83 raeburn 57: # Get course type - Course or Community.
1.54 raeburn 58: $type = $env{'form.type'};
59: if (!defined($env{'form.type'})) {
60: $type = 'Course';
61: }
1.82 bisitz 62: $title = 'Selecting a '.$type;
1.54 raeburn 63:
64: # Setup for multiple course selections, if flag for multiples set.
1.55 raeburn 65: $multiple = $env{'form.multiple'};
66: if ($multiple) {
67: ($jscript,$multelement) = &multiples_tag();
1.82 bisitz 68: $title = 'Selecting '.$type.'(s)';
1.54 raeburn 69: }
70:
1.55 raeburn 71: # if called when a DC is selecting a course
1.54 raeburn 72: my $roledom = $env{'form.roleelement'};
73: if ($roledom) {
74: $roleelement = '<input type="hidden" name="roleelement" value="'.$roledom.'" />';
1.66 raeburn 75: $submitopener = &processpick();
1.54 raeburn 76: $autosubmit = 'process_pick("'.$roledom.'")';
77: }
78:
79: my $onlyown = 0;
1.55 raeburn 80: # if called to assign course-based portfolio access control
1.59 raeburn 81: if ((($env{'form.form'} eq 'portform') && (!$env{'user.adv'}))) {
1.54 raeburn 82: $onlyown = 1;
1.49 raeburn 83: }
1.55 raeburn 84:
85: my %loaditem;
1.84 ! raeburn 86: if (($env{'form.type'} eq 'Course') && ($env{'form.numtitles'})) {
! 87: if (($env{'form.official'} eq 'on') && ($env{'form.state'} eq 'listing')) {
! 88: $loaditem{'onload'} = 'setElements(document.filterpicker); ';
! 89: }
1.78 raeburn 90: }
91:
1.66 raeburn 92: if ((($env{'form.form'} eq 'cu') || ($env{'form.form'} eq 'studentform')) &&
93: ($env{'form.pickedcourse'})) {
1.78 raeburn 94: $loaditem{'onload'} .= 'setSections()';
1.30 raeburn 95: }
1.41 albertel 96: $r->print(&Apache::loncommon::start_page($title,undef,
1.42 albertel 97: {'add_entries' => \%loaditem,
1.41 albertel 98: 'no_nav_bar' => 1, }));
1.55 raeburn 99:
100: if ($env{'form.form'} eq 'portform') {
101: $lastaction = 'document.courselist.submit()';
1.67 raeburn 102: } elsif ($env{'form.form'} eq 'cu' || ($env{'form.form'} eq 'studentform' &&
103: !$multiple)) {
1.55 raeburn 104: $lastaction =
105: 'document.courselist.pickedcourse.value = cdom+"_"+cname;'."\n".
106: 'document.courselist.submit();';
1.34 albertel 107: } else {
1.55 raeburn 108: $lastaction = 'self.close()';
1.1 www 109: }
1.19 raeburn 110:
1.55 raeburn 111: # if called to assign a role in a course to a user via CUSR
1.66 raeburn 112: if ($env{'form.form'} eq 'cu' || $env{'form.form'} eq 'studentform') {
1.68 raeburn 113: $r->print(&create_user_javascript($type));
1.55 raeburn 114: }
1.54 raeburn 115:
1.55 raeburn 116: # print javascript functions for choosing a course
1.84 ! raeburn 117: if (($env{'form.command'} eq 'gosearch') || $onlyown) {
1.58 raeburn 118: $r->print(&gochoose_javascript($type,$multiple,$autosubmit,$lastaction));
1.55 raeburn 119: }
1.79 raeburn 120: $r->print('<script type="text/javascript" language="Javascript">'.$jscript.
121: '</script>');
1.55 raeburn 122: $r->print($submitopener);
1.54 raeburn 123:
1.55 raeburn 124: # ------------------------------------------ Display of filters to limit search
1.57 raeburn 125: my $filter = {};
126: my $action = '/adm/pickcourse';
1.79 raeburn 127: my ($numtitles,$showroles,$nohost);
1.55 raeburn 128: if (!$onlyown) {
129: my $filterlist = ['domainfilter','descriptfilter',
1.79 raeburn 130: 'instcodefilter'];
131: if ($env{'form.form'} eq 'rules') {
132: push(@{$filterlist},'personfilter');
133: if (($env{'form.personfilter'} ne '') && ($env{'form.persondomfilter'} ne '')) {
134: if (&Apache::lonnet::homeserver($env{'form.personfilter'},
135: $env{'form.persondomfilter'}) eq 'no_host') {
136: $nohost = 1;
137: } else {
138: $showroles = 1;
139: }
140: }
141: } else {
142: push(@{$filterlist},'ownerfilter');
143: }
1.55 raeburn 144: # course ID filter for DCs only
145: if ($env{'user.adv'} && $env{'form.domainfilter'} &&
146: exists($env{'user.role.dc./'.$env{'form.domainfilter'}.'/'})) {
147: push(@{$filterlist},'coursefilter');
148: }
149: $r->print(&build_filters($filterlist,$type,$roleelement,$multelement,
1.78 raeburn 150: $filter,$action,\$numtitles));
1.55 raeburn 151: }
1.54 raeburn 152:
153: # ---------------------------------------------------------------- Get the data
1.84 ! raeburn 154: if (($env{'form.command'} eq 'gosearch') || $onlyown) {
1.78 raeburn 155: my %courses = &search_courses($r,$type,$onlyown,$filter,$numtitles);
1.79 raeburn 156: if ($nohost) {
157: $r->print ('<span class="LC_warning">'.
158: &mt('User does not exist - username: [_1], domain: [_2].',
159: '<b>'.$filter->{'personfilter'}.'</b>',
160: '<b>'.$filter->{'persondomfilter'}.'</b>').'</span>');
161: } else {
162: &display_matched_courses($r,$type,$multiple,$action,$showroles,%courses);
163: }
1.54 raeburn 164: }
165: $r->print(&Apache::loncommon::end_page());
166: return OK;
167: }
168:
1.66 raeburn 169: sub processpick {
170: my $openerform = 'rolechoice';
171: if ($env{'form.form'} eq 'studentform') {
172: $openerform = $env{'form.form'};
173: }
174: my $process_pick = <<"ENDONE";
175: <script type="text/javascript">
176: function process_pick(dom) {
177: var pickedCourse=opener.document.$openerform.$env{'form.cnumelement'}.value;
178: var pickedDomain=opener.document.$openerform.$env{'form.cdomelement'}.value;
179: var okDomain = 0;
180: ENDONE
181: if ($openerform eq 'rolechoice') {
182: $process_pick .= <<"ENDTWO";
183: if (pickedDomain == dom) {
184: if (pickedCourse != '') {
185: var courseTarget = "cc./"+pickedDomain+"/"+pickedCourse
186: opener.document.title='Role selected. Please stand by.';
187: opener.status='Role selected. Please stand by.';
188: opener.document.rolechoice.newrole.value=courseTarget
189: opener.document.rolechoice.submit();
190: }
191: }
192: else {
193: alert("You may only use this screen to select courses in the current domain: "+dom+"\\nPlease return to the roles page window and click the 'Select Course' link for domain: "+pickedDomain+",\\n if you are a Domain Coordinator in that domain, and wish to become a Course Coordinator in a course in the domain");
194: }
195: ENDTWO
196: } else {
197: $process_pick .= <<"ENDTHREE";
198: if (pickedDomain != dom) {
199: alert("You may only use this screen to select courses in the current domain: "+dom+"\\nPlease return to the roles page window and click the 'Select Course' link for domain: "+pickedDomain+",\\n if you are a Domain Coordinator in that domain, and wish to become a Course Coordinator in a course in the domain");
200: return;
201: }
202: ENDTHREE
203: }
204: $process_pick .= "
205: }
206:
207: </script>
208: ";
209: return $process_pick;
210: }
211:
1.55 raeburn 212: sub create_user_javascript {
213: my ($type) = @_;
214: my $output;
215: #javascript for reporting sections and groups then closing
216: if ($env{'form.pickedcourse'}) {
217: my ($cdom,$cnum) = split/_/,$env{'form.pickedcourse'};
218: my $sec_element = 'currsec';
219: my $grplist_element = 'groups';
220: my ($sections,$groups) =
221: &Apache::loncommon::get_secgrprole_info($cdom,$cnum,'',$type);
222: my $num_sections = scalar(@{$sections});
223: my $seclist = join(',',@{$sections});
224: my $num_groups = scalar(@{$groups});
225: my $groupslist = join(',',@{$groups});
226: $output = qq|
227: <script type="text/javascript">
228: function setSections() {
229: opener.document.$env{"form.form"}.$grplist_element.value='$groupslist';
230: window.opener.setSect('$seclist');
231: self.close()
232: }
233: </script>
234: |;
235: ;
236: }
237: return $output;
238: }
239:
1.54 raeburn 240: sub display_matched_courses {
1.79 raeburn 241: my ($r,$type,$multiple,$action,$showroles,%courses) = @_;
1.55 raeburn 242: if ($env{'form.form'} eq 'portform') {
243: $action = '/adm/portfolio';
244: }
1.68 raeburn 245: my $numcourses = keys(%courses);
1.55 raeburn 246: $r->print('<form name="courselist" method="post" action="'.$action.'">');
1.68 raeburn 247: if ($env{'form.form'} eq 'modifycourse') {
248: if ($numcourses > 0) {
249: my $cctitle = &Apache::lonnet::plaintext('cc',$type);
250: my $dctitle = &Apache::lonnet::plaintext('dc');
251: my $ccrolechk = ' checked="checked" ';
252: my $menuchk = ' ';
253: if ($env{'form.prevphase'} ne '') {
254: $ccrolechk = ' ';
255: $menuchk = ' checked="checked" ';
256: }
257: $r->print(
1.75 bisitz 258: '<fieldset>'
259: .'<legend>'.&mt('Action').'</legend>'
260: .'<div class="LC_nobreak"><label>'
261: .'<input type="radio" name="phase" value="ccrole"'.$ccrolechk.'/>'
262: .' '.&mt('Enter the course with the role of [_1].',$cctitle)
263: .'</label></div>'
264: .'<div class="LC_nobreak"><label>'
265: .'<input type="radio" name="phase" value="menu"'.$menuchk.'/> '
266: .&mt('View or modify course settings which only a [_1] may modify.',$dctitle)
267: .'</label></div>'
268: .'</fieldset>'
269: .'<br />'
270: );
1.68 raeburn 271: }
272: }
1.54 raeburn 273: my %by_descrip;
274: foreach my $course (keys(%courses)) {
275: my $descr;
1.64 raeburn 276: if (ref($courses{$course}) eq 'HASH') {
1.65 raeburn 277: $descr = $courses{$course}{'description'};
1.64 raeburn 278: } elsif ($courses{$course} =~ m/^([^:]*):/i) {
1.54 raeburn 279: $descr = &unescape($1);
1.34 albertel 280: } else {
1.54 raeburn 281: $descr = &unescape($courses{$course});
282: }
283: my $description = $descr;
284: push (@{$by_descrip{$description}}, $course);
285: }
1.71 bisitz 286:
1.54 raeburn 287: if ($numcourses > 1 && $multiple) {
288: $r->print('<input type="button" value="check all"
289: onclick="javascript:checkAll(document.courselist.course_id)" />
290: <input type="button" value="uncheck all"
291: onclick="javascript:uncheckAll(document.courselist.course_id)" />
292: <br /><br />');
293: }
1.71 bisitz 294:
295: if (%courses) {
296: $r->print(&Apache::loncommon::start_data_table());
297: $r->print(&Apache::loncommon::start_data_table_header_row());
298: $r->print('<th>'.&mt('Select').'</th>'
1.76 bisitz 299: .'<th>'.&mt('Course Title').'</th>'
1.71 bisitz 300: .'<th>'.&mt('Domain').'</th>'
301: .'<th>'.&mt('Course Code').'</th>'
1.72 raeburn 302: .'<th>'.&mt('Owner/Co-owner(s)').'</th>'
1.71 bisitz 303: .'<th>'.&mt('Type').'</th>'
304: );
1.79 raeburn 305: if ($showroles) {
306: $r->print('<th>'.&mt("Role(s) for [_1]",
307: &Apache::loncommon::plainname($env{'form.personfilter'},
308: $env{'form.persondomfilter'},'firstname')).'</th>');
309: }
1.71 bisitz 310: $r->print(&Apache::loncommon::end_data_table_header_row());
311: }
1.54 raeburn 312: foreach my $description (sort { lc($a) cmp lc($b) } (keys(%by_descrip))) {
313: foreach my $course (@{$by_descrip{$description}}) {
1.72 raeburn 314: $r->print(&Apache::loncommon::start_data_table_row());
1.54 raeburn 315: my $cleandesc=&HTML::Entities::encode($description,'<>&"');
316: $cleandesc=~s/'/\\'/g;
317: my ($cdom,$cnum)=split(/\_/,$course);
1.64 raeburn 318: my ($descr,$instcode,$ttype,@owners);
319: if (ref($courses{$course}) eq 'HASH') {
320: $descr = $courses{$course}{'description'};
1.65 raeburn 321: $instcode = $courses{$course}{'inst_code'};
1.64 raeburn 322: $ttype = $courses{$course}{'type'};
323: push(@owners,&unescape($courses{$course}{'owner'}));
324: if (ref($courses{$course}{'co-owners'}) eq 'ARRAY') {
325: foreach my $item (@{$courses{$course}{'co-owners'}}) {
326: push(@owners,&unescape($item));
327: }
328: }
329: } else {
330: my $singleowner;
331: ($descr,$instcode,$singleowner,$ttype)=split(/:/,$courses{$course});
332: push(@owners,&unescape($singleowner));
333: }
1.72 raeburn 334: my $ownerstr = join(', ',@owners);
1.71 bisitz 335: $r->print('<td>'.&course_chooser($multiple,$cdom,$cnum,$cleandesc).'</td>');
336: $r->print('<td>'.$description.'</td>');
337: $r->print('<td>');
338: $r->print(&Apache::lonnet::domain($cdom,'description')?
339: $cdom.' ('.&Apache::lonnet::domain($cdom,'description').')':$cdom);
340: $r->print('</td>');
341: $r->print('<td>');
1.64 raeburn 342: if ($instcode ne '') {
1.71 bisitz 343: $r->print(&unescape($instcode));
344: } else {
345: $r->print(' ');
1.54 raeburn 346: }
1.71 bisitz 347: $r->print('</td>');
1.72 raeburn 348: $r->print('<td>'.$ownerstr.'</td>');
1.71 bisitz 349: $r->print('<td>');
1.64 raeburn 350: if ($ttype ne '') {
1.71 bisitz 351: $r->print(&mt(&unescape($ttype)));
352: } else {
353: $r->print(' ');
1.23 raeburn 354: }
1.71 bisitz 355: $r->print('</td>');
1.79 raeburn 356: if ($showroles) {
357: $r->print('<td>');
358: my $rolestr;
359: if (ref($courses{$course}{'roles'}) eq 'ARRAY') {
360: my @roles = sort(@{$courses{$course}{'roles'}});
361: foreach my $role (@roles) {
362: if ($role =~ /^cr/) {
363: my (undef,$crdom,$crname,$crtitle) = split('/',$role);
364: $rolestr .= $crtitle.', ';
365: } else {
366: $rolestr .= &Apache::lonnet::plaintext($role,$ttype).', ';
367: }
368: }
369: $rolestr =~ s/\, $//;
370: }
371: $r->print($rolestr.'</td>');
372: }
1.54 raeburn 373: if ($multiple) { $r->print("</label>\n"); }
1.72 raeburn 374: $r->print(&Apache::loncommon::end_data_table_row());
1.71 bisitz 375: # $r->print("<br />\n");
1.19 raeburn 376: }
377: }
1.72 raeburn 378: if (%courses) {
379: $r->print(&Apache::loncommon::end_data_table());
380: }
1.71 bisitz 381:
1.54 raeburn 382: if (!%courses) {
383: $r->print(&mt('None found'));
384: } elsif ($multiple) {
1.57 raeburn 385: $r->print('<input type="button" value="Submit" onClick="gochoose('."'','','')".'" />');
1.54 raeburn 386: }
387: $r->print('<input type="hidden" name="form" value="'.$env{'form.form'}.'" />'.
388: "\n".'<input type="hidden" name="pickedcourse" value="" />'."\n".
389: '<input type="hidden" name="type" value="'.$type.'" />'."\n");
390: if ((exists($env{'form.roleelement'})) && ($env{'form.form'} eq 'rolechoice')) {
391: $r->print('<input type="hidden" name="roleelement" value="'.
392: $env{'form.roleelement'}.'" />'."\n");
393: }
1.55 raeburn 394: if ($env{'form.form'} eq 'portform') {
395: $r->print('<input type="hidden" name="cnum" value="" />');
396: $r->print('<input type="hidden" name="cdom" value="" />');
397: $r->print('<input type="hidden" name="setroles" value="'.$env{'form.setroles'}.'" />');
398: $r->print('<input type="hidden" name="action" value="rolepicker" />');
1.57 raeburn 399: } elsif ($env{'form.form'} eq 'modifycourse') {
1.84 ! raeburn 400: $r->print(&Apache::lonhtmlcommon::echo_form_input(['phase','pickedcourse','type','form','numtitles','state','command']));
1.57 raeburn 401: } else {
402: $r->print('<input type="hidden" name="cnumelement" value="'.
403: $env{'form.cnumelement'}.'" />'."\n".
404: '<input type="hidden" name="cdomelement" value="'.
405: $env{'form.cdomelement'}.'" />'."\n");
1.55 raeburn 406: }
1.78 raeburn 407: if ((exists($env{'form.fixeddom'})) && ($env{'form.form'} eq 'rules')) {
408: $r->print('<input type="hidden" name="fixeddom" value="'.
409: $env{'form.fixeddom'}.'" />');
410: }
411: if ($env{'form.numtitles'}) {
412: $r->print('<input type="hidden" name="numtitles" value="'.
413: $env{'form.numtitles'}.'" />');
414: }
1.54 raeburn 415: $r->print("</form>\n");
416: return;
417: }
418:
419: sub multiples_tag {
1.55 raeburn 420: my $jscript = &Apache::loncommon::check_uncheck_jscript();
421: my $multelement = '<input type="hidden" name="multiple" value="1" />';
422: return ($jscript,$multelement);
1.1 www 423: }
1.30 raeburn 424:
1.54 raeburn 425: sub build_filters {
1.57 raeburn 426: my ($filterlist,$type,$roleelement,$multelement,$filter,$action,
1.81 raeburn 427: $numtitlesref,$caller) = @_;
1.55 raeburn 428: my $list;
1.57 raeburn 429: my $formname;
1.78 raeburn 430: my ($fixeddom,$codedom,$jscript);
1.57 raeburn 431: if (defined($env{'form.form'})) {
1.81 raeburn 432: $formname = $env{'form.form'};
433: } else {
434: $formname = $caller;
1.57 raeburn 435: }
1.84 ! raeburn 436: my $onchange;
! 437: unless ($env{'form.interface'} eq 'textual') {
! 438: $onchange = 1;
! 439: }
1.79 raeburn 440: my ($domainselectform,$sincefilterform,$ownerdomselectform,$persondomselectform,
1.78 raeburn 441: $instcodeform,$typeselectform,$instcodetitle);
1.55 raeburn 442: foreach my $item (@{$filterlist}) {
1.54 raeburn 443: $filter->{$item} = $env{'form.'.$item};
444: if ($item ne 'descriptfilter' && $item ne 'instcodefilter') {
1.79 raeburn 445: if ($item eq 'domainfilter') {
1.61 albertel 446: $filter->{$item} = &LONCAPA::clean_domain($filter->{$item});
447: } elsif ($item eq 'coursefilter') {
448: $filter->{$item} = &LONCAPA::clean_courseid($filter->{$item});
449: } elsif ($item eq 'ownerfilter') {
450: $filter->{$item} = &LONCAPA::clean_username($filter->{$item});
1.79 raeburn 451: $filter->{'ownerdomfilter'} =
452: &LONCAPA::clean_domain($env{'form.ownerdomfilter'});
453: $ownerdomselectform =
454: &Apache::loncommon::select_dom_form($filter->{'ownerdomfilter'},
455: 'ownerdomfilter',1);
456: } elsif ($item eq 'personfilter') {
457: $filter->{$item} = &LONCAPA::clean_username($filter->{$item});
458: if ($env{'form.persondomfilter'} eq '') {
1.84 ! raeburn 459: unless ($env{'form.command'} eq 'gosearch') {
1.79 raeburn 460: $filter->{'persondomfilter'} = $env{'request.role.domain'};
461: }
462: } else {
463: $filter->{'persondomfilter'} =
464: &LONCAPA::clean_domain($env{'form.persondomfilter'});
465: }
466: $persondomselectform =
467: &Apache::loncommon::select_dom_form($filter->{'persondomfilter'},
468: 'persondomfilter',1);
1.61 albertel 469: } else {
470: $filter->{$item} =~ s/\W//g;
471: }
1.54 raeburn 472: if (!$filter->{$item}) {
473: $filter->{$item} = '';
474: }
475: }
476: if ($item eq 'domainfilter') {
1.63 albertel 477: my $allow_blank = 1;
478: if ($formname eq 'portform') {
479: $filter->{$item} ||= $env{'user.domain'};
480: $allow_blank=0;
1.67 raeburn 481: } elsif ($formname eq 'studentform') {
482: $filter->{$item} ||= $env{'request.role.domain'};
483: $allow_blank=0;
484: }
1.78 raeburn 485: if ($env{'form.fixeddom'}) {
486: $domainselectform = '<input type="hidden" name="domainfilter"'.
487: 'value="'.$env{'request.role.domain'}.'" />'.
488: &Apache::lonnet::domain($env{'request.role.domain'},
489: 'description');
490: $codedom = $env{'request.role.domain'};
1.79 raeburn 491: } else {
1.78 raeburn 492: $domainselectform =
493: &Apache::loncommon::select_dom_form($filter->{$item},
494: 'domainfilter',
1.84 ! raeburn 495: $allow_blank,'',$onchange);
1.78 raeburn 496: $codedom = $filter->{'domainfilter'};
497: }
1.54 raeburn 498: } else {
499: $list->{$item} = &HTML::Entities::encode($filter->{$item},'<>&"');
500: }
501: }
502:
503: # last course activity filter and selection
504: $filter->{'sincefilter'} = $env{'form.sincefilter'};
505: $filter->{'sincefilter'} =~ s/[^\d-]//g;
506: if (!$filter->{'sincefilter'}) { $filter->{'sincefilter'}=-1; }
507: $sincefilterform=&Apache::loncommon::select_form($filter->{'sincefilter'},
508: 'sincefilter',('-1'=>'',
509: '86400' => 'today',
510: '604800' => 'last week',
511: '2592000' => 'last month',
512: '7776000' => 'last three months',
513: '15552000' => 'last six months',
514: '31104000' => 'last year',
515: 'select_form_order' =>
516: ['-1','86400','604800','2592000','7776000',
517: '15552000','31104000']));
518:
519: my %lt = (
1.74 bisitz 520: 'cac' => &mt("$type Activity"),
1.76 bisitz 521: 'cde' => &mt("$type Title"),
1.74 bisitz 522: 'cdo' => &mt("$type Domain"),
1.78 raeburn 523: 'ins' => &mt('Institutional Code'),
524: 'inc' => &mt('Institutional Categorization'),
1.79 raeburn 525: 'cow' => &mt("$type Owner/Co-owner"),
526: 'cop' => &mt("$type Personnel Includes"),
1.84 ! raeburn 527: 'cog' => &mt('Type')
1.54 raeburn 528: );
1.49 raeburn 529:
1.84 ! raeburn 530: $typeselectform = '<select name="type" size="1"';
! 531: if ($onchange) {
! 532: $typeselectform .= 'onchange=" javascript:submit()"';
! 533: }
! 534: $typeselectform .= '>'."\n";
1.80 raeburn 535: my $officialjs;
1.54 raeburn 536: if ($type eq 'Course') {
1.84 ! raeburn 537: if (($env{'form.fixeddom'}) || ($env{'form.form'} eq 'requestcrs')) {
1.80 raeburn 538: $officialjs = 1;
1.78 raeburn 539: ($instcodeform,$jscript,$$numtitlesref) =
1.80 raeburn 540: &instcode_selectors($codedom,'filterpicker',$officialjs);
1.78 raeburn 541: }
542: if ($instcodeform eq '') {
543: $instcodeform =
1.57 raeburn 544: '<input type="text" name="instcodefilter" size="10" value="'.
545: $list->{'instcodefilter'}.'" />';
1.78 raeburn 546: $instcodetitle = $lt{'ins'};
547: } else {
548: $instcodetitle = $lt{'inc'};
549: }
550: if ($env{'form.fixeddom'}) {
551: $instcodetitle .= '<br />('.$codedom.')';
552: }
1.54 raeburn 553: }
1.84 ! raeburn 554: $jscript .= <<"END_JS";
! 555:
! 556: function setCommand() {
! 557: document.filterpicker.command.value = 'gosearch';
! 558: return;
! 559: }
! 560:
! 561: END_JS
! 562:
! 563: $jscript = '<script type="text/javascript" language="Javascript">'.$jscript.
! 564: '</script>'."\n";
! 565:
1.83 raeburn 566: foreach my $posstype ('Course','Community') {
1.72 raeburn 567: $typeselectform.='<option value="'.$posstype.'"'.
1.73 bisitz 568: ($posstype eq $type ? ' selected="selected" ' : ''). ">".&mt($posstype)."</option>\n";
1.54 raeburn 569: }
570: $typeselectform.="</select>";
1.57 raeburn 571: my $output = qq|
1.84 ! raeburn 572: <form method="post" name="filterpicker" action="$action" onsubmit="setCommand()">
1.57 raeburn 573: <input type="hidden" name="form" value="$formname" />
574: |;
575: if ($formname eq 'modifycourse') {
1.68 raeburn 576: $output .= '<input type="hidden" name="phase" value="courselist" />'."\n".
577: '<input type="hidden" name="prevphase" value="'.
578: $env{'form.prevphase'}.'" />'."\n";
579: } else {
1.57 raeburn 580: my $name_input;
581: if ($env{'form.cnameelement'} ne '') {
582: $name_input = '<input type="hidden" name="cnameelement" value="'.
583: $env{'form.cnameelement'}.'" />';
584: }
585: $output .= qq|
1.27 albertel 586: <input type="hidden" name="cnumelement" value="$env{'form.cnumelement'}" />
587: <input type="hidden" name="cdomelement" value="$env{'form.cdomelement'}" />
1.13 albertel 588: $name_input
1.18 raeburn 589: $roleelement
1.35 raeburn 590: $multelement
1.57 raeburn 591: |;
1.59 raeburn 592: if ($formname eq 'portform') {
1.78 raeburn 593: $output .= '<input type="hidden" name="setroles" value="'.$env{'form.setroles'}.'" />'."\n";
1.59 raeburn 594: }
1.57 raeburn 595: }
1.78 raeburn 596: if ($env{'form.fixeddom'}) {
597: $output .= '<input type="hidden" name="fixeddom" value="'.$env{'form.fixeddom'}.'" />'."\n";
598: }
1.74 bisitz 599: $output .= "<br />\n".&Apache::lonhtmlcommon::start_pick_box();
1.57 raeburn 600: if ($sincefilterform) {
1.74 bisitz 601: $output .= &Apache::lonhtmlcommon::row_title($lt{'cac'})
602: .$sincefilterform
603: .&Apache::lonhtmlcommon::row_closure();
1.57 raeburn 604: }
605: if ($domainselectform) {
1.74 bisitz 606: $output .= &Apache::lonhtmlcommon::row_title($lt{'cdo'})
607: .$domainselectform
608: .&Apache::lonhtmlcommon::row_closure();
1.78 raeburn 609: }
1.57 raeburn 610: if ($typeselectform) {
1.74 bisitz 611: $output .= &Apache::lonhtmlcommon::row_title($lt{'cog'})
612: .$typeselectform
613: .&Apache::lonhtmlcommon::row_closure();
1.57 raeburn 614: }
615: if ($instcodeform) {
1.78 raeburn 616: $output .= &Apache::lonhtmlcommon::row_title($instcodetitle)
1.74 bisitz 617: .$instcodeform
618: .&Apache::lonhtmlcommon::row_closure();
1.57 raeburn 619: }
620: if (exists($filter->{'ownerfilter'})) {
1.79 raeburn 621: $output .= &Apache::lonhtmlcommon::row_title($lt{'cow'}).
622: '<table><tr><td>'.&mt('Username').'<br />'.
623: '<input type="text" name="ownerfilter" size="20" value="'.
624: $list->{'ownerfilter'}.'" /></td><td>'.&mt('Domain').'<br />'.
625: $ownerdomselectform.'</td></tr></table>'.
626: &Apache::lonhtmlcommon::row_closure();
627: }
628: if (exists($filter->{'personfilter'})) {
629: $output .= &Apache::lonhtmlcommon::row_title($lt{'cop'}).
630: '<table><tr><td>'.&mt('Username').'<br />'.
631: '<input type="text" name="personfilter" size="20" value="'.
632: $list->{'personfilter'}.'" /></td><td>'.&mt('Domain').'<br />'.
633: $persondomselectform.'</td></tr></table>'.
634: &Apache::lonhtmlcommon::row_closure();
1.57 raeburn 635: }
636: if (exists($filter->{'coursefilter'})) {
1.74 bisitz 637: $output .= &Apache::lonhtmlcommon::row_title(&mt('LON-CAPA course ID'))
638: .'<input type="text" name="coursefilter" size="25" value="'
639: .$list->{'coursefilter'}.'" />'
640: .&Apache::lonhtmlcommon::row_closure();
1.57 raeburn 641: }
642: if (exists($filter->{'descriptfilter'})) {
1.74 bisitz 643: $output .= &Apache::lonhtmlcommon::row_title($lt{'cde'})
644: .'<input type="text" name="descriptfilter" size="40" value="'
645: .$list->{'descriptfilter'}.'" />'
646: .&Apache::lonhtmlcommon::row_closure(1);
1.57 raeburn 647: }
1.74 bisitz 648: $output .= &Apache::lonhtmlcommon::end_pick_box();
1.84 ! raeburn 649: $output .= '<p><input type="hidden" name="command" value="">'."\n".
! 650: '<input type="submit" name="gosearch" value="'.
1.70 raeburn 651: &mt('Search').'" /></p>'."\n".'</form>'."\n".'<hr />'."\n";
1.78 raeburn 652: return $jscript.$output;
653: }
654:
655: sub instcode_selectors {
1.80 raeburn 656: my ($codedom,$formname,$officialjs) = @_;
1.78 raeburn 657: my ($output,@codetitles,%cat_titles,%cat_order,%cat_items);
658: my ($jscript,$totcodes,$numtitles,$lasttitle) =
659: &Apache::courseclassifier::instcode_selectors_data($codedom,$formname,
1.80 raeburn 660: \%cat_items,\@codetitles,\%cat_titles,\%cat_order,$officialjs);
1.78 raeburn 661: if ($numtitles > 0) {
1.84 ! raeburn 662: my $official = ' checked="checked" ';
! 663: my $unofficial = '';
! 664: if ($env{'form.official'} eq 'off') {
! 665: $unofficial = $official;
! 666: $official = '';
1.80 raeburn 667: }
668: $output .= '<span class="LC_nobreak">'.&mt('Official course:').' <label>'.
1.84 ! raeburn 669: '<input type="radio" name="official" value="on"'.$official.' />'.
1.80 raeburn 670: &mt('Yes').'</label>'.(' 'x3).'<label>'.
1.84 ! raeburn 671: '<input type="radio" name="official" value="off"'.$unofficial.
1.80 raeburn 672: ' onclick="toggleOfficial();" />'.&mt('No').'</label></span><br />'.
673: &Apache::courseclassifier::build_instcode_selectors($numtitles,
674: $lasttitle,\%cat_items,\@codetitles,\%cat_titles,\%cat_order)."\n".
675: '<input type="hidden" name="numtitles" value="'.$numtitles.'" />'."\n".
676: '<input type="hidden" name="state" value="listing" />'."\n";
1.78 raeburn 677:
678: }
679: return ($output,$jscript,$numtitles);
1.54 raeburn 680: }
681:
682: sub search_courses {
1.78 raeburn 683: my ($r,$type,$onlyown,$filter,$numtitles) = @_;
1.79 raeburn 684: my (%courses,%showcourses);
1.54 raeburn 685: if (!$onlyown) {
1.71 bisitz 686: $r->print(&mt('Searching ...').'<br /> <br />');
1.6 www 687: $r->rflush();
1.54 raeburn 688: if (($filter->{'ownerfilter'} ne '') ||
689: ($filter->{'ownerdomfilter'} ne '')) {
690: $filter->{'combownerfilter'} = $filter->{'ownerfilter'}.':'.
691: $filter->{'ownerdomfilter'};
692: }
1.80 raeburn 693: foreach my $item ('descriptfilter','coursefilter','combownerfilter') {
1.54 raeburn 694: if (!$filter->{$item}) {
695: $filter->{$item}='.';
696: }
1.52 raeburn 697: }
1.54 raeburn 698: my $timefilter =
699: ($filter->{'sincefilter'}==-1?1:time-$filter->{'sincefilter'});
1.78 raeburn 700: my ($instcodefilter,$regexpok);
701: if ($numtitles) {
1.84 ! raeburn 702: if ($env{'form.official'} eq 'on') {
1.80 raeburn 703: $instcodefilter =
1.84 ! raeburn 704: &Apache::courseclassifier::instcode_search_str($filter->{'domainfilter'},$numtitles);
1.80 raeburn 705: $regexpok = 1;
1.84 ! raeburn 706: } elsif ($env{'form.official'} eq 'off') {
! 707: $instcodefilter = &Apache::courseclassifier::instcode_search_str($filter->{'domainfilter'},$numtitles);
! 708: unless ($instcodefilter eq '') {
! 709: $regexpok = -1;
! 710: }
1.80 raeburn 711: }
1.78 raeburn 712: } else {
713: $instcodefilter = $filter->{'instcodefilter'};
714: }
1.80 raeburn 715: if ($instcodefilter eq '') { $instcodefilter = '.'; }
716: if ($type eq '') { $type = '.'; }
1.54 raeburn 717: %courses =
718: &Apache::lonnet::courseiddump($filter->{'domainfilter'},
719: $filter->{'descriptfilter'},
720: $timefilter,
1.78 raeburn 721: $instcodefilter,
1.54 raeburn 722: $filter->{'combownerfilter'},
723: $filter->{'coursefilter'},
1.78 raeburn 724: undef,undef,$type,$regexpok);
1.79 raeburn 725: if (($filter->{'personfilter'} ne '') && ($filter->{'persondomfilter'} ne '')) {
726: my %rolehash = &Apache::lonnet::get_my_roles($filter->{'personfilter'},
727: $filter->{'persondomfilter'},
728: 'userroles',undef,
729: ['cc','in','ad','ep','ta','cr'],
730: $filter->{'domainfilter'});
731: foreach my $role (keys(%rolehash)) {
732: my ($cnum,$cdom,$courserole) = split(':',$role);
733: my $cid = $cdom.'_'.$cnum;
734: if (exists($courses{$cid})) {
735: if (ref($courses{$cid}) eq 'HASH') {
736: if (ref($courses{$cid}{roles}) eq 'ARRAY') {
737: if (!grep(/^\Q$courserole\E$/,@{$courses{$cid}{roles}})) {
738: push (@{$courses{$cid}{roles}},$courserole);
739: }
740: } else {
741: $courses{$cid}{roles} = [$courserole];
742: }
743: $showcourses{$cid} = $courses{$cid};
744: }
745: }
746: }
747: %courses = %showcourses;
748: }
1.54 raeburn 749: } else {
750: $r->print('<br />');
1.60 raeburn 751: my %coursehash = &Apache::loncommon::findallcourses();
752: foreach my $cid (sort(keys(%coursehash))) {
1.65 raeburn 753: $courses{$cid}{'description'} = $env{'course.'.$cid.'.description'};
1.36 raeburn 754: }
1.2 www 755: }
1.54 raeburn 756: return %courses;
1.18 raeburn 757: }
1.1 www 758:
1.30 raeburn 759: sub course_chooser {
1.35 raeburn 760: my ($multiple,$cdom,$cnum,$cleandesc) = @_;
1.30 raeburn 761: my $output;
1.35 raeburn 762: if ($multiple) {
1.32 albertel 763: $output = '<label><input type="checkbox" name="course_id" value="'.$cdom.'_'.$cnum.'" />'."\n";
1.30 raeburn 764: } else {
1.71 bisitz 765: $output = '<input type="button" value="'.&mt('Select').'" onClick="gochoose('.
1.30 raeburn 766: "'".$cnum."','".$cdom."','".$cleandesc."')".'" />'."\n";
767: }
768: return $output;
1.49 raeburn 769: }
770:
1.55 raeburn 771: sub gochoose_javascript {
1.57 raeburn 772: my ($type,$multiple,$autosubmit,$lastaction) = @_;
1.55 raeburn 773: my %elements = (
774: 'Course' => {
775: name => 'coursepick',
776: total => 'coursetotal',
777: list => 'courselist',
778: },
1.83 raeburn 779: 'Community' => {
1.55 raeburn 780: name => 'grouppick',
781: total => 'grouptotal',
782: list => 'grouplist',
783: },
784: );
1.57 raeburn 785: my $output .= qq|
1.55 raeburn 786: <script type="text/javascript">
1.57 raeburn 787: function gochoose(cname,cdom,cdesc) {
1.55 raeburn 788: var openerForm = "$env{'form.form'}";
789: courseCount = 0;
790: var courses = '';
1.57 raeburn 791: |;
792: if ($multiple) {
793: $output .= <<"ENDSCRIPT";
794: courseCount = 0;
795: var courses = '';
796: if (typeof(document.courselist.course_id.length) == 'undefined') {
797: // only 1 course checkbox was created
798: if (document.courselist.course_id.checked) {
799: courses = courses + document.courselist.course_id.value + "&&";
800: courseCount ++;
801: }
802: } else {
803: for (var j=0; j<document.courselist.course_id.length; j++) {
804: if (document.courselist.course_id[j].checked) {
805: courses = courses + document.courselist.course_id[j].value + "&&";
1.55 raeburn 806: courseCount ++;
807: }
1.57 raeburn 808: }
809: }
810: opener.document.$env{'form.form'}.$elements{$type}{'total'}.value = courseCount;
811: if (typeof(opener.document.$env{'form.form'}.$elements{$type}{'name'}.length) ==
812: 'undefined') {
813: if (opener.document.$env{'form.form'}.$elements{$type}{'name'}.value == 'specific') {
814: opener.document.$env{'form.form'}.$elements{$type}{'name'}.checked = true;
1.55 raeburn 815: } else {
1.57 raeburn 816: opener.document.$env{'form.form'}.$elements{$type}{'name'}.checked = false;
1.55 raeburn 817: }
1.57 raeburn 818: } else {
819: for (var j=0; j<opener.document.$env{'form.form'}.$elements{$type}{'name'}.length; j++) {
820: if (opener.document.$env{'form.form'}.$elements{$type}{'name'}\[j].value == 'specific') {
821: opener.document.$env{'form.form'}.$elements{$type}{'name'}\[j].checked = true;
1.55 raeburn 822: } else {
1.57 raeburn 823: opener.document.$env{'form.form'}.$elements{$type}{'name'}\[j].checked = false;
1.54 raeburn 824: }
1.55 raeburn 825: }
1.57 raeburn 826: }
827: if (courseCount > 0) {
828: courses = courses.substr(0,courses.length-2);
829: opener.document.$env{'form.form'}.$elements{$type}{'list'}.value = courses;
830: }
831: ENDSCRIPT
832: } else {
833: my $name_code;
834: if ($env{'form.cnameelement'} ne '') {
835: $name_code = 'opener.document.'.$env{'form.form'}.'.'.
836: $env{'form.cnameelement'}.'.value=cdesc;';
1.55 raeburn 837: }
1.57 raeburn 838: $output .= qq|
1.55 raeburn 839: $name_code
840: opener.document.$env{'form.form'}.$env{'form.cnumelement'}.value=cname;
841: var slct=opener.document.$env{'form.form'}.$env{'form.cdomelement'};
842: if (slct.options == undefined) {
843: opener.document.$env{'form.form'}.$env{'form.cdomelement'}.value=cdom;
844: }
845: else {
846: var i;
847: for (i=0;i<slct.length;i++) {
848: if (slct.options[i].value==cdom) { slct.selectedIndex=i; }
1.54 raeburn 849: }
850: }
1.57 raeburn 851: |;
1.54 raeburn 852: }
1.57 raeburn 853: $output .= qq|
1.55 raeburn 854: if (openerForm == 'portform') {
855: document.courselist.cnum.value = cname;
856: document.courselist.cdom.value = cdom;
857: }
858: $autosubmit
859: $lastaction
1.54 raeburn 860: }
1.55 raeburn 861: </script>
1.57 raeburn 862: |;
1.55 raeburn 863: return $output;
1.54 raeburn 864: }
865:
1.55 raeburn 866: 1;
867: __END__
868:
869: =pod
870:
871: =head1 NAME
872:
873: Apache::lonpickcourse - Search for course(s) based on user-specified criteria.
874:
875: =head1 SYNOPSIS
876:
877: Invoked by other LON-CAPA modules, when course(s) need to be selected by the user.
878:
879: =head1 OVERVIEW
880:
881: Two screens are typically displayed to the user. The first is a set of criteria which are used to constrain the search for courses.
882:
883: =head2 Search Criteria (Screen One)
884:
885: =head3 Criteria:
886:
887: =over 4
888:
889: =item *
890: Course Activity - how recently was course last visited by anyone.
891:
892: =item *
893: Course Domain - the domain of the course
894:
895: =item *
1.84 ! raeburn 896: Type - Course or Community
1.55 raeburn 897:
898: =item *
899: Course Institutional Code - the institutional identifier assigned to the course
900:
901: =item *
902: Course Owner's Username - the username of the owner of the course (assigned by the Domain Coordinator and/or when the course was created).
903:
904: =item *
905: Course Owner's Domain - the domain of the owner of the course
906:
907: =item *
1.76 bisitz 908: Course Title - text which appears in the Course Title, as set in the Course Parameters.
1.55 raeburn 909:
910: =item *
911: Course ID - the internal course number (course ID part after initial 'domain_') used by LON-CAPA (this criterion is only displayed to Domain Coordinators selecting a course in the same domain as their DC role).
912:
913: =back
914:
915: The criteria setting screen is not displayed if course picking is done by a user who does not have advanced privileges (as defined by $env{'user.adv'}).
916:
917: =head2 Course Display (Screen Two)
918:
919: A list of courses matching the search criteria is displayed. If the user is not an advanced user, screen one will have been skipped and the courses displayed will be all courses in which the user has currently active roles. The information displayed for each course is:
920:
921: =over 4
922:
923: =item *
924: Course description
925:
926: =item *
927: Domain description of course domain
928:
929: =item *
930: Course institutional code
931:
932: =item *
933: Course owner (username:domain)
934:
935: =back
936:
937: Depending on context, the display may include a single select box for each course, allowing selection of only a single course, or may include checkboxes allowing selection of more than one course.
938:
939: Following selection, and/or submission, the course description, number and domain are transferred to the browser window from which the course picker window was opened. In most cases, the child window containing the course picker screens will be closed. However, in some cases closure will be delayed until a third screen has been displayed (e.g., setting of course-based conditional access controls for portfolio files). In this case the page is generated via /adm/portfolio and the page features select boxes to allow the user to select roles, access types, sections and groups.
940:
941: =head1 SUBROUTINES
942:
943: =over 4
944:
945: =item *
946: X<create_user_javascript()>
947: B<create_user_javascript($type)>:
948:
1.83 raeburn 949: Input: 1 - $type - the course type - Course or Community
1.55 raeburn 950:
951: Output: 1 - $output - javascript wrapped in E<lt>scriptE<gt>E<lt>/scriptE<gt> tags
952:
953: Side Effects: None
954:
955: javascript code for reporting selected sections (as a string of comma separated sections) and groups in the selected course (as a comma separated list) then calling setSect() javscript function in the opener window (to populate section select box) then closing current window.
956:
957:
958: =item *
959: X<display_matched_courses()>
1.79 raeburn 960: B<display_matched_courses($r,$type,$multiple,$action,$showroles,%courses)>:
1.55 raeburn 961:
1.79 raeburn 962: Input: 7 - request object, course type, multiple (0 or 1), form action, whether to show roles (for course personnel filter), hash of courses.
1.55 raeburn 963:
964: Output: 0
965:
966: Side Effects: prints select buttons (multiple = 0) or checkboxes (multiple = 1) and hidden form elements for selection of one or more courses which met search criteria.
967:
968: =item *
969: X<multiples_tag()>
970: B<multiples_tag()>:
971:
972:
973: Input: 0
974:
975: Output: 2 - $jscript - javascript for check all/uncheck all checkboxes; $multelement - hidden form element with multiple set to 1.
976:
977: Side Effects: None
978:
979: =item *
980: X<build_filters()>
1.81 raeburn 981: B<build_filters($filterlist,$type,$roleelement,$multelement,$filter,$action,$numfiltersref,$caller)>:
1.55 raeburn 982:
983:
1.81 raeburn 984: Input: 7 - anonymous array of search criteria; course type; $roleelement ; $multelement ; anonymous hash of criteria and their values; form action; ref to scalar (count of number of elements in institutional codes -- e.g., 4 for year, semester, department, and number); caller context (e.g., set to 'modifycourse' when routine is called from lonmodifycourse.pm).
1.55 raeburn 985:
986: Output: 1 - $output - HTML for display of search criteria, and hidden form elements.
987:
988: Side Effects: None
989:
990: =item *
991: X<search_courses()>
1.78 raeburn 992: B<search_courses($r,$type,$onlyown,$filter,$numtitles)>:
1.55 raeburn 993:
994:
1.78 raeburn 995: Input: 5 - request object, course type, search scope: only courses in which user has active role (1), or any course (0); anonymous hash of criteria and their values; for institutional codes - number of categories).
1.55 raeburn 996:
997: Output: 1 - %courses - hash of courses satisfying search criteria, keys = course IDs, values are corresponding colon-separated escaped description, institutional code, owner and type.
998:
999: Side Effects: None
1000:
1001:
1002: =item *
1003: X<course_chooser()>
1004: B<course_chooser($multiple,$cdom,$cnum,$cleandesc)>:
1005:
1006: Input: 4 - single (0) or multiple (1) courses; course domain, course number; course description.
1007:
1008: Output: 1 - HTML for either checkbox (multiple=1) or select button (multiple=0) for user yo indicate course selection.
1009:
1010: Side Effects: None
1011:
1012:
1013: =item *
1014: X<gochoose_javascript()>
1.57 raeburn 1015: B<gochoose_javascript($type,$multiple,$autosubmit,$lastaction)>:
1.55 raeburn 1016:
1.66 raeburn 1017: Input: 4 - course type; single (0) or multiple courses (1); in context of DC selecting a CC role in a course: javascript code from &processpick(); final action to take after user chooses course(s): either close window, or submit form for display of next page etc.
1.55 raeburn 1018:
1019: Output: 1 $output - javascript wrapped in E<lt>scriptE<gt>E<lt>/scriptE<gt> tags
1020:
1021: Side Effects: None
1022:
1023: javascript functions used when user selects a course(s). Different behavior depending on context:
1024:
1025: =back
1026:
1027: =over 8
1028:
1029: =item
1030:
1031: (a) Domain Coordinator using MAIL to select recipients of broadcast e-mail - && separated list of selected courses written to hidden form element in opener window. Child window closes.
1032:
1033: =item
1034:
1035: (b) Domain Coordinator choosing a course for adoption of a CC role from roles screen - write course identifying information to hidden form elements in opener window and automatically submit role selection form in opener window. Child window closes.
1036:
1037: =item
1038:
1039: (c) Domain Coordinator creating a course, and selecting a course to clone - course number and domain written to visible form elements in opener window. Child window closes.
1040:
1041: =item
1.54 raeburn 1042:
1.55 raeburn 1043: (d) User selecting a course for course-based conditional access control for a portfolio file - form is submitted, and new page is displayed for selection of roles, access types, sections and groups to be used in conditional ACL. New page is generated by /adm/portfolio.
1.54 raeburn 1044:
1.55 raeburn 1045: =item
1.54 raeburn 1046:
1.55 raeburn 1047: (e) Domain Coordinator assigning a role to a user - form is submitted, and new page does an onload call to a javascript function to (a) write lists of sections and groups to hidden elements in opener window, (b) call function in opener window to dynamically populate select box showing current sections.
1.54 raeburn 1048:
1.55 raeburn 1049: =item
1.54 raeburn 1050:
1.55 raeburn 1051: (f) Author modifying a rights entry in a .rights file - selected course number and domain are witten to visible form elements in opener window. Child window closes.
1.54 raeburn 1052:
1.55 raeburn 1053: =item
1.49 raeburn 1054:
1.55 raeburn 1055: (g) Scantron Operator uploading a scantron file to a course - course number is written to visible form element in opener window. Child window closes.
1.30 raeburn 1056:
1.84 ! raeburn 1057: =item
! 1058:
! 1059: (h) User requesting creation of a course, and selecting a course to clone - course number and domain written to visible form elements in opener window. Child window closes.
! 1060:
1.55 raeburn 1061: =back
1062:
1063: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>