File:  [LON-CAPA] / loncom / interface / lonpickresource.pm
Revision 1.3: download - view: text, annotated - select for diffs
Mon Jul 15 14:32:45 2013 UTC (10 years, 9 months ago) by bisitz
Branches: MAIN
CVS tags: version_2_12_X, HEAD
XHTML: JavaScript event handlers in lower case

# The LearningOnline Network with CAPA
# Pick resource or folder in the course
#
# $Id: lonpickresource.pm,v 1.3 2013/07/15 14:32:45 bisitz Exp $
#
# Copyright Michigan State University Board of Trustees
#
# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
#
# LON-CAPA is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# LON-CAPA is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LON-CAPA; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# /home/httpd/html/adm/gpl.txt
#
# http://www.lon-capa.org/
#
#
###############################################################
###############################################################

package Apache::lonpickresource;

use strict;
use Apache::Constants qw(:common);
use Apache::loncommon;
use Apache::lonnet;
use Apache::lonlocal;
use Apache::lonroles;
use Apache::lonuserutils;
use Apache::lonstathelpers;
use LONCAPA;

sub handler {
    my $r = shift;
    &Apache::loncommon::content_type($r,'text/html');
    $r->send_http_header;
    return OK if $r->header_only;

# ------------------------------------------------------------ Print the screen
    $r->print(&Apache::loncommon::start_page("Selecting Resource",undef,
                                             {'no_nav_bar' => 1}));

    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['form','reslink']);
    my $form='opener.document.forms.'.$env{'form.form'};
    my $reslink=$env{'form.reslink'};

    $r->print('<form name="pickresource" action="/adm/pickresource">');
    $r->print(&Apache::lonstathelpers::problem_selector('.',undef,1,1,'resource'));
    $r->print(<<ENDGETVALUE);
<script type="text/javascript">
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}
</script>
ENDGETVALUE
    $r->print('<input type="button" value="'.&mt('Pick').
      '" onclick="val=getCheckedValue(this.form.resourcesymb);if (val) { '.
                    $form.'.resourcesymb.value=val;'.
                    $form.".cmd.value='".$reslink."';".
                    $form.".submit();} window.close();".'" />');
    $r->print('</form>');
    $r->print(&Apache::loncommon::end_page());
    return OK;
}

1;

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>