Source for file CourseSelectForm.class.php
Documentation is available at CourseSelectForm.class.php
// $Id: CourseSelectForm.class.php 15429 2008-05-26 20:34:37Z yannoo $
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004-2008 Dokeos SPRL
Copyright (c) 2003 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
Copyright (c) Bart Mollet (bart.mollet@hogent.be)
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program 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.
See the GNU General Public License for more details.
Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
==============================================================================
require_once ('Course.class.php');
* Class to show a form to select resources
* @author Bart Mollet <bart.mollet@hogent.be>
* @param array $hidden_fiels Hidden fields to add to the form.
<script language="JavaScript" type="text/javascript">
el = document.getElementById('div_'+item);
if (el.style.display=='none'){
document.getElementById('img_'+item).src='../img/1.gif';
document.getElementById('img_'+item).src='../img/0.gif';
function setCheckbox(type,value) {
d = document.course_select_form;
for (i = 0; i < d.elements.length; i++) {
if (d.elements[i].type == "checkbox") {
var name = d.elements[i].attributes.getNamedItem('name').nodeValue;
if( name.indexOf(type) > 0 || type == 'all' ){
d.elements[i].checked = value;
function checkLearnPath(message){
d = document.course_select_form;
for (i = 0; i < d.elements.length; i++) {
if (d.elements[i].type == "checkbox") {
var name = d.elements[i].attributes.getNamedItem('name').nodeValue;
if( name.indexOf('learnpath') > 0){
if(d.elements[i].checked == true){
setCheckbox('document',true);
echo '<script language="javascript" src="'. api_get_path(WEB_CODE_PATH). 'inc/lib/javascript/upload.js" type="text/javascript"></script>';
echo '<script type="text/javascript">var myUpload = new upload(1000);</script>';
echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="myUpload.start(\'dynamic_div\',\''. api_get_path(WEB_CODE_PATH). 'img/progress_bar.gif\',\''. get_lang('PleaseStandBy'). '\',\'upload_form\')">';
echo '<input type="hidden" name="action" value="course_select_form"/>';
foreach ($course->resources as $type => $resources)
if (count($resources) > 0)
echo ' <img id="img_'. $type. '" src="../img/1.gif" onclick="javascript:exp('. "'$type'". ');" >';
echo ' <b onclick="javascript:exp('. "'$type'". ');" >'. $resource_titles[$type]. '</b><br />';
echo '<div id="div_'. $type. '">';
echo "[<a href=\"#\" onclick=\"javascript:setCheckbox('$type',true);\" >". get_lang('All'). "</a> - <a href=\"#\" onclick=\"javascript:setCheckbox('$type',false);\" >". get_lang('None'). "</a>]";
foreach ($resources as $id => $resource)
echo '<input type="checkbox" name="resource['. $type. ']['. $id. ']" id="resource['. $type. ']['. $id. ']"/>';
echo ' <label for="resource['. $type. ']['. $id. ']">';
echo '<script language="javascript">exp('. "'$type'". ')</script>';
foreach ($hidden_fields as $key => $value)
echo '<input type="hidden" name="'. $key. '" value="'. $value. '"/>';
echo '<br /><input type="submit" value="'. get_lang('Ok'). '" onclick="checkLearnPath(\''. addslashes(get_lang('DocumentsWillBeAddedToo')). '\')"/>';
echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>';
foreach ($course->resources as $type => $resources)
if (count($resources) > 0)
foreach ($resources as $id => $resource)
foreach ($course->resources as $type => $resources)
if(count($resources) > 0)
foreach ($resources as $id=> $resource)
* @return course The course-object with all resources selected by the user
* in the form given by display_form(...)
foreach ($course->resources as $type => $resources)
foreach($resources as $id => $obj)
unset ($course->resources[$type][$id]);
// Mark folders to import which are not selected by the user to import,
// but in which a document was selected.
foreach($resources as $id => $obj)
foreach($documents as $id_to_check => $post_value)
$obj_to_check = $resources[$id_to_check];
$shared_path_part = substr($obj_to_check->path,0,strlen($obj->path));
if($id_to_check != $id && $obj->path == $shared_path_part)
foreach ($resources as $id => $obj)
$resource_is_used_elsewhere = $course->is_linked_resource($obj);
// check if document is in a quiz (audio/video)
$resource_is_used_elsewhere = true;
if (!isset ($_POST['resource'][$type][$id]) && !$resource_is_used_elsewhere)
unset ($course->resources[$type][$id]);
|