Minor - Format code, replace deprecated function

- Deprecated function: CourseManager::get_course_information
pull/2487/head
jmontoyaa 9 years ago
parent 0a29721eca
commit 08da1c793b
  1. 682
      src/Chamilo/CourseBundle/Component/CourseCopy/CourseSelectForm.php

@ -51,61 +51,61 @@ class CourseSelectForm
$resource_titles[RESOURCE_ATTENDANCE] = get_lang('Attendance');
$resource_titles[RESOURCE_WORK] = get_lang('ToolStudentPublication');
?>
<script>
function exp(item) {
el = document.getElementById('div_'+item);
<script>
function exp(item) {
el = document.getElementById('div_'+item);
if (el.style.display == 'none') {
el.style.display = '';
if (document.getElementById('img_'+item).length)
document.getElementById('img_'+item).className = 'fa fa-minus-square-o fa-lg';
} else {
el.style.display='none';
if (document.getElementById('img_'+item).length)
document.getElementById('img_'+item).className ='fa fa-plus-square-o fa-lg';
}
}
document.getElementById('img_'+item).className = 'fa fa-minus-square-o fa-lg';
} else {
el.style.display='none';
if (document.getElementById('img_'+item).length)
document.getElementById('img_'+item).className ='fa fa-plus-square-o fa-lg';
}
}
function setCheckboxForum(type, value, item_id) {
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 = 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') {
if ($(d.elements[i]).attr('rel') == item_id) {
d.elements[i].checked = value;
}
}
}
}
}
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){
setCheckbox('document',true);
alert(message);
break;
}
}
}
}
}
}
}
}
}
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){
setCheckbox('document',true);
alert(message);
break;
}
}
}
}
}
function check_forum(obj) {
var id = $(obj).attr('rel');
@ -143,48 +143,48 @@ class CourseSelectForm
$('#resource_Forum_Category_'+my_id).attr('checked','checked');
$('#resource_forum_'+forum_id).attr('checked','checked');
}
</script>
<?php
// get destination course title
</script>
<?php
// get destination course title
if (!empty($hidden_fields['destination_course'])) {
$sessionTitle = !empty($hidden_fields['destination_session']) ? ' ('.api_get_session_name($hidden_fields['destination_session']).')' : null;
$course_infos = CourseManager::get_course_information($hidden_fields['destination_course']);
echo '<h3>';
echo get_lang('DestinationCourse').' : '.$course_infos['title'].' ('.$course_infos['code'].') '.$sessionTitle;
echo '</h3>';
}
$courseInfo = api_get_course_info($hidden_fields['destination_course']);
echo '<h3>';
echo get_lang('DestinationCourse').' : '.$courseInfo['title'].' ('.$courseInfo['code'].') '.$sessionTitle;
echo '</h3>';
}
echo '<script src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/upload.js" type="text/javascript"></script>';
echo '<div class="tool-backups-options">';
echo '<form method="post" id="upload_form" name="course_select_form">';
echo '<input type="hidden" name="action" value="course_select_form"/>';
echo '<form method="post" id="upload_form" name="course_select_form">';
echo '<input type="hidden" name="action" value="course_select_form"/>';
if (!empty($hidden_fields['destination_course']) &&
if (!empty($hidden_fields['destination_course']) &&
!empty($hidden_fields['origin_course']) &&
!empty($hidden_fields['destination_session']) &&
!empty($hidden_fields['origin_session'])
) {
echo '<input type="hidden" name="destination_course" value="'.$hidden_fields['destination_course'].'"/>';
echo '<input type="hidden" name="origin_course" value="'.$hidden_fields['origin_course'].'"/>';
echo '<input type="hidden" name="destination_session" value="'.$hidden_fields['destination_session'].'"/>';
echo '<input type="hidden" name="origin_session" value="'.$hidden_fields['origin_session'].'"/>';
}
echo '<input type="hidden" name="destination_course" value="'.$hidden_fields['destination_course'].'"/>';
echo '<input type="hidden" name="origin_course" value="'.$hidden_fields['origin_course'].'"/>';
echo '<input type="hidden" name="destination_session" value="'.$hidden_fields['destination_session'].'"/>';
echo '<input type="hidden" name="origin_session" value="'.$hidden_fields['origin_session'].'"/>';
}
$element_count = 0;
$element_count = 0;
$forum_categories = array();
$forums = array();
$forum_topics = array();
echo '<p>';
echo get_lang('SelectResources');
echo '</p>';
echo get_lang('SelectResources');
echo '</p>';
echo Display::return_message(get_lang('DontForgetToSelectTheMediaFilesIfYourResourceNeedIt'));
foreach ($course->resources as $type => $resources) {
if (count($resources) > 0) {
switch ($type) {
//Resources to avoid
case RESOURCE_FORUMCATEGORY:
switch ($type) {
//Resources to avoid
case RESOURCE_FORUMCATEGORY:
foreach ($resources as $id => $resource) {
$forum_categories[$id] = $resource;
}
@ -211,29 +211,44 @@ class CourseSelectForm
break;
default:
echo '<div class="item-backup" onclick="javascript:exp('."'$type'".');">';
echo '<em id="img_'.$type.'" class="fa fa-minus-square-o fa-lg" ></em>';
echo '<span class="title">'.$resource_titles[$type].'</span></div>';
echo '<div class="item-content" id="div_'.$type.'">';
if ($type == RESOURCE_LEARNPATH) {
echo Display::return_message(get_lang('ToExportLearnpathWithQuizYouHaveToSelectQuiz'), 'warning');
echo Display::return_message(get_lang('IfYourLPsHaveAudioFilesIncludedYouShouldSelectThemFromTheDocuments'), 'warning');
}
if ($type == RESOURCE_DOCUMENT) {
echo '<em id="img_'.$type.'" class="fa fa-minus-square-o fa-lg" ></em>';
echo '<span class="title">'.$resource_titles[$type].'</span></div>';
echo '<div class="item-content" id="div_'.$type.'">';
if ($type == RESOURCE_LEARNPATH) {
echo Display::return_message(
get_lang(
'ToExportLearnpathWithQuizYouHaveToSelectQuiz'
),
'warning'
);
echo Display::return_message(
get_lang(
'IfYourLPsHaveAudioFilesIncludedYouShouldSelectThemFromTheDocuments'
),
'warning'
);
}
if ($type == RESOURCE_DOCUMENT) {
if (api_get_setting('show_glossary_in_documents') != 'none') {
echo Display::return_message(get_lang('ToExportDocumentsWithGlossaryYouHaveToSelectGlossary'), 'warning');
echo Display::return_message(
get_lang(
'ToExportDocumentsWithGlossaryYouHaveToSelectGlossary'
),
'warning'
);
}
}
}
echo '<div class="well">';
echo '<div class="well">';
echo '<div class="btn-group">';
echo "<a class=\"btn btn-default\" href=\"javascript: void(0);\" onclick=\"javascript: setCheckbox('$type',true);\" >".get_lang('All')."</a>";
echo "<a class=\"btn btn-default\" href=\"javascript: void(0);\" onclick=\"javascript: setCheckbox('$type',true);\" >".get_lang('All')."</a>";
echo "<a class=\"btn btn-default\" href=\"javascript: void(0);\" onclick=\"javascript:setCheckbox('$type',false);\" >".get_lang('None')."</a>";
echo '</div>';
echo '</div>';
echo '<ul class="list-backups-options">';
foreach ($resources as $id => $resource) {
foreach ($resources as $id => $resource) {
if ($resource) {
echo '<li>';
// Event obj in 1.9.x in 1.10.x the class is CalendarEvent
// Event obj in 1.9.x in 1.10.x the class is CalendarEvent
Resource::setClassType($resource);
echo '<label class="checkbox">';
echo '<input type="checkbox" name="resource['.$type.']['.$id.']" id="resource['.$type.']['.$id.']" />';
@ -241,15 +256,15 @@ class CourseSelectForm
echo '</label>';
echo '</li>';
}
}
}
echo '</ul>';
echo '</div>';
echo '</div>';
echo '<script language="javascript">exp('."'$type'".')</script>';
$element_count++;
echo '</div>';
echo '</div>';
echo '<script language="javascript">exp('."'$type'".')</script>';
$element_count++;
}
}
}
}
}
//Fixes forum order
if (!empty($forum_categories)) {
@ -303,66 +318,65 @@ class CourseSelectForm
echo '<script language="javascript">exp('."'$type'".')</script>';
}
if ($avoid_serialize) {
/*Documents are avoided due the huge amount of memory that the serialize php function "eats"
(when there are directories with hundred/thousand of files) */
// this is a known issue of serialize
$course->resources['document'] = null;
}
echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>';
if ($avoid_serialize) {
/*Documents are avoided due the huge amount of memory that the serialize php function "eats"
(when there are directories with hundred/thousand of files) */
// this is a known issue of serialize
$course->resources['document'] = null;
}
if (is_array($hidden_fields)) {
foreach ($hidden_fields as $key => $value) {
echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>';
}
}
echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>';
if (is_array($hidden_fields)) {
foreach ($hidden_fields as $key => $value) {
echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>';
}
}
$recycleOption = isset($_POST['recycle_option']) ? true : false;
if (empty($element_count)) {
echo Display::return_message(get_lang('NoDataAvailable'), 'warning');
} else {
if (!empty($hidden_fields['destination_session'])) {
echo '<br /><button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset))."'".')) return false;" >'.
if (empty($element_count)) {
echo Display::return_message(get_lang('NoDataAvailable'), 'warning');
} else {
if (!empty($hidden_fields['destination_session'])) {
echo '<br /><button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset))."'".')) return false;" >'.
get_lang('Ok').'</button>';
} else {
} else {
if ($recycleOption) {
echo '<br /><button class="save" type="submit">'.
get_lang('Ok').'</button>';
} else {
echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'.
echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'.
get_lang('Ok').'</button>';
}
}
}
}
}
self::display_hidden_quiz_questions($course);
self::display_hidden_scorm_directories($course);
echo '</form>';
self::display_hidden_quiz_questions($course);
self::display_hidden_scorm_directories($course);
echo '</form>';
echo '</div>';
echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>';
}
echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>';
}
/**
* @param $course
*/
public static function display_hidden_quiz_questions($course)
{
if (is_array($course->resources)) {
foreach ($course->resources as $type => $resources) {
if (count($resources) > 0) {
switch ($type) {
case RESOURCE_QUIZQUESTION:
foreach ($resources as $id => $resource) {
echo '<input type="hidden" name="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" id="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" value="On" />';
}
break;
}
}
}
}
}
if (is_array($course->resources)) {
foreach ($course->resources as $type => $resources) {
if (count($resources) > 0) {
switch ($type) {
case RESOURCE_QUIZQUESTION:
foreach ($resources as $id => $resource) {
echo '<input type="hidden" name="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" id="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" value="On" />';
}
break;
}
}
}
}
}
/**
* @param $course
@ -370,30 +384,30 @@ class CourseSelectForm
public static function display_hidden_scorm_directories($course)
{
if (is_array($course->resources)) {
foreach ($course->resources as $type => $resources) {
if (count($resources) > 0) {
switch ($type) {
case RESOURCE_SCORM:
foreach ($resources as $id => $resource) {
echo '<input type="hidden" name="resource['.RESOURCE_SCORM.']['.$id.']" id="resource['.RESOURCE_SCORM.']['.$id.']" value="On" />';
}
break;
}
}
}
}
}
/**
* Get the posted course
* @param string $from who calls the function?
foreach ($course->resources as $type => $resources) {
if (count($resources) > 0) {
switch ($type) {
case RESOURCE_SCORM:
foreach ($resources as $id => $resource) {
echo '<input type="hidden" name="resource['.RESOURCE_SCORM.']['.$id.']" id="resource['.RESOURCE_SCORM.']['.$id.']" value="On" />';
}
break;
}
}
}
}
}
/**
* Get the posted course
* @param string $from who calls the function?
* It can be copy_course, create_backup, import_backup or recycle_course
* @param int $session_id
* @param string $course_code
* @return course The course-object with all resources selected by the user
* in the form given by display_form(...)
*/
public static function get_posted_course($from = '', $session_id = 0, $course_code = '')
* @return course The course-object with all resources selected by the user
* in the form given by display_form(...)
*/
public static function get_posted_course($from = '', $session_id = 0, $course_code = '')
{
$course = null;
if (isset($_POST['course'])) {
@ -402,40 +416,40 @@ class CourseSelectForm
return false;
}
// Create the resource DOCUMENT objects
// Loading the results from the checkboxes of ethe javascript
$resource = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null;
// Create the resource DOCUMENT objects
// Loading the results from the checkboxes of ethe javascript
$resource = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null;
$course_info = api_get_course_info($course_code);
$table_doc = Database::get_course_table(TABLE_DOCUMENT);
$table_prop = Database::get_course_table(TABLE_ITEM_PROPERTY);
$course_id = $course_info['real_id'];
$course_info = api_get_course_info($course_code);
$table_doc = Database::get_course_table(TABLE_DOCUMENT);
$table_prop = Database::get_course_table(TABLE_ITEM_PROPERTY);
$course_id = $course_info['real_id'];
/* Searching the documents resource that have been set to null because
/* Searching the documents resource that have been set to null because
$avoid_serialize is true in the display_form() function*/
if ($from === 'copy_course') {
if (is_array($resource)) {
$resource = array_keys($resource);
foreach ($resource as $resource_item) {
$conditionSession = '';
if (!empty($session_id)) {
$session_id = intval($session_id);
$conditionSession = ' AND d.session_id ='.$session_id;
}
$sql = 'SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size
FROM '.$table_doc.' d
INNER JOIN '.$table_prop.' p
ON (d.c_id = p.c_id)
WHERE
d.c_id = '.$course_id.' AND
if ($from === 'copy_course') {
if (is_array($resource)) {
$resource = array_keys($resource);
foreach ($resource as $resource_item) {
$conditionSession = '';
if (!empty($session_id)) {
$session_id = intval($session_id);
$conditionSession = ' AND d.session_id ='.$session_id;
}
$sql = 'SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size
FROM '.$table_doc.' d
INNER JOIN '.$table_prop.' p
ON (d.c_id = p.c_id)
WHERE
d.c_id = '.$course_id.' AND
p.c_id = '.$course_id.' AND
tool = \''.TOOL_DOCUMENT.'\' AND
p.ref = d.id AND p.visibility != 2 AND
d.id = '.$resource_item.$conditionSession.'
ORDER BY path';
$db_result = Database::query($sql);
while ($obj = Database::fetch_object($db_result)) {
ORDER BY path';
$db_result = Database::query($sql);
while ($obj = Database::fetch_object($db_result)) {
$doc = new Document(
$obj->id,
$obj->path,
@ -459,24 +473,24 @@ class CourseSelectForm
}
$course->resources[RESOURCE_DOCUMENT][$resource_item]->item_properties = $all_properties;
}
}
}
}
}
if (is_array($course->resources)) {
foreach ($course->resources as $type => $resources) {
switch ($type) {
case RESOURCE_SURVEYQUESTION:
foreach ($resources as $id => $obj) {
if (isset($_POST['resource'][RESOURCE_SURVEY]) &&
}
}
}
}
if (is_array($course->resources)) {
foreach ($course->resources as $type => $resources) {
switch ($type) {
case RESOURCE_SURVEYQUESTION:
foreach ($resources as $id => $obj) {
if (isset($_POST['resource'][RESOURCE_SURVEY]) &&
is_array($_POST['resource'][RESOURCE_SURVEY]) &&
!in_array($obj->survey_id, array_keys($_POST['resource'][RESOURCE_SURVEY]))
) {
unset($course->resources[$type][$id]);
}
}
break;
unset($course->resources[$type][$id]);
}
}
break;
case RESOURCE_FORUMTOPIC:
case RESOURCE_FORUMPOST:
//Add post from topic
@ -529,24 +543,24 @@ class CourseSelectForm
}
}
// no break
case RESOURCE_LINKCATEGORY:
// no break
case RESOURCE_FORUMCATEGORY:
// no break
case RESOURCE_QUIZQUESTION:
// no break
case RESOURCE_DOCUMENT:
// Mark folders to import which are not selected by the user to import,
// but in which a document was selected.
$documents = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null;
if (!empty($resources) && is_array($resources))
foreach ($resources as $id => $obj) {
if (isset($obj->file_type) && $obj->file_type == 'folder' &&
case RESOURCE_LINKCATEGORY:
// no break
case RESOURCE_FORUMCATEGORY:
// no break
case RESOURCE_QUIZQUESTION:
// no break
case RESOURCE_DOCUMENT:
// Mark folders to import which are not selected by the user to import,
// but in which a document was selected.
$documents = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null;
if (!empty($resources) && is_array($resources))
foreach ($resources as $id => $obj) {
if (isset($obj->file_type) && $obj->file_type == 'folder' &&
!isset($_POST['resource'][RESOURCE_DOCUMENT][$id]) &&
is_array($documents)
) {
foreach ($documents as $id_to_check => $post_value) {
if (isset($resources[$id_to_check])) {
foreach ($documents as $id_to_check => $post_value) {
if (isset($resources[$id_to_check])) {
$obj_to_check = $resources[$id_to_check];
$shared_path_part = substr(
$obj_to_check->path,
@ -558,151 +572,153 @@ class CourseSelectForm
break;
}
}
}
}
}
}
}
}
// no break
default:
if (!empty($resources) && is_array($resources)) {
foreach ($resources as $id => $obj) {
$resource_is_used_elsewhere = $course->is_linked_resource($obj);
// check if document is in a quiz (audio/video)
if ($type == RESOURCE_DOCUMENT && $course->has_resources(RESOURCE_QUIZ)) {
foreach ($course->resources[RESOURCE_QUIZ] as $quiz) {
default:
if (!empty($resources) && is_array($resources)) {
foreach ($resources as $id => $obj) {
$resource_is_used_elsewhere = $course->is_linked_resource($obj);
// check if document is in a quiz (audio/video)
if ($type == RESOURCE_DOCUMENT && $course->has_resources(RESOURCE_QUIZ)) {
foreach ($course->resources[RESOURCE_QUIZ] as $quiz) {
$quiz = $quiz->obj;
if (isset($quiz->media) && $quiz->media == $id) {
$resource_is_used_elsewhere = true;
}
}
}
if (!isset($_POST['resource'][$type][$id]) && !$resource_is_used_elsewhere) {
unset($course->resources[$type][$id]);
}
}
}
}
}
}
return $course;
}
/**
* Display the form session export
if (isset($quiz->media) && $quiz->media == $id) {
$resource_is_used_elsewhere = true;
}
}
}
if (!isset($_POST['resource'][$type][$id]) && !$resource_is_used_elsewhere) {
unset($course->resources[$type][$id]);
}
}
}
}
}
}
return $course;
}
/**
* Display the form session export
* @param array $list_course
* @param array $hidden_fields Hidden fields to add to the form.
* @param array $hidden_fields Hidden fields to add to the form.
* @param boolean $avoid_serialize the document array will be serialize. This is used in the course_copy.php file
*/
*/
public static function display_form_session_export(
$list_course,
$hidden_fields = null,
$avoid_serialize = false
) {
?>
<script>
function exp(item) {
el = document.getElementById('div_'+item);
<script>
function exp(item) {
el = document.getElementById('div_'+item);
if (el.style.display == 'none') {
el.style.display = '';
if (document.getElementById('img_'+item).length)
document.getElementById('img_'+item).className('fa fa-minus-square-o fa-lg');
}
else{
document.getElementById('img_'+item).className('fa fa-minus-square-o fa-lg');
}
else{
el.style.display = 'none';
if (document.getElementById('img_'+item).length)
document.getElementById('img_'+item).className('fa fa-plus-square-o fa-lg');
}
}
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){
setCheckbox('document',true);
alert(message);
break;
}
}
}
}
}
</script>
<?php
//get destination course title
if (!empty($hidden_fields['destination_course'])) {
if (!empty($hidden_fields['destination_session'])) {
$sessionTitle = ' ('.api_get_session_name($hidden_fields['destination_session']).')';
} else {
$sessionTitle = null;
}
$course_infos = CourseManager::get_course_information($hidden_fields['destination_course']);
echo '<h3>';
echo get_lang('DestinationCourse').' : '.$course_infos['title'].$sessionTitle;
echo '</h3>';
}
echo '<script src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/upload.js" type="text/javascript"></script>';
document.getElementById('img_'+item).className('fa fa-plus-square-o fa-lg');
}
}
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){
setCheckbox('document',true);
alert(message);
break;
}
}
}
}
}
</script>
<?php
//get destination course title
if (!empty($hidden_fields['destination_course'])) {
if (!empty($hidden_fields['destination_session'])) {
$sessionTitle = ' ('.api_get_session_name($hidden_fields['destination_session']).')';
} else {
$sessionTitle = null;
}
$courseInfo = api_get_course_info(
$hidden_fields['destination_course']
);
echo '<h3>';
echo get_lang('DestinationCourse').' : '.$courseInfo['title'].$sessionTitle;
echo '</h3>';
}
echo '<script src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/upload.js" type="text/javascript"></script>';
$icon = Display::returnIconPath('progress_bar.gif');
echo '<div class="tool-backups-options">';
echo '<form method="post" id="upload_form" name="course_select_form">';
echo '<input type="hidden" name="action" value="course_select_form"/>';
foreach ($list_course as $course) {
foreach ($course->resources as $type => $resources) {
if (count($resources) > 0) {
echo '<form method="post" id="upload_form" name="course_select_form">';
echo '<input type="hidden" name="action" value="course_select_form"/>';
foreach ($list_course as $course) {
foreach ($course->resources as $type => $resources) {
if (count($resources) > 0) {
echo '<div class="item-backup" onclick="javascript:exp('."'$course->code'".');">';
echo '<em id="img_'.$course->code.'" class="fa fa-minus-square-o fa-lg"></em>';
echo '<span class="title"> '.$course->code.'</span></div>';
echo '<div class="item-content" id="div_'.$course->code.'">';
echo '<blockquote>';
echo '<em id="img_'.$course->code.'" class="fa fa-minus-square-o fa-lg"></em>';
echo '<span class="title"> '.$course->code.'</span></div>';
echo '<div class="item-content" id="div_'.$course->code.'">';
echo '<blockquote>';
echo '<div class="btn-group">';
echo "<a class=\"btn\" href=\"#\" onclick=\"javascript:setCheckbox('".$course->code."',true);\" >".get_lang('All')."</a>";
echo "<a class=\"btn\" href=\"#\" onclick=\"javascript:setCheckbox('".$course->code."',true);\" >".get_lang('All')."</a>";
echo "<a class=\"btn\" href=\"#\" onclick=\"javascript:setCheckbox('".$course->code."',false);\" >".get_lang('None')."</a>";
echo '</div>';
echo '</div>';
foreach ($resources as $id => $resource) {
echo '<label class="checkbox" for="resource['.$course->code.']['.$id.']">';
foreach ($resources as $id => $resource) {
echo '<label class="checkbox" for="resource['.$course->code.']['.$id.']">';
echo '<input type="checkbox" name="resource['.$course->code.']['.$id.']" id="resource['.$course->code.']['.$id.']"/>';
$resource->show();
echo '</label>';
}
echo '</blockquote>';
echo '</div>';
echo '<script type="text/javascript">exp('."'$course->code'".')</script>';
}
}
}
if ($avoid_serialize) {
//Documents are avoided due the huge amount of memory that the serialize php function "eats" (when there are directories with hundred/thousand of files)
// this is a known issue of serialize
$course->resources['document'] = null;
}
echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>';
if (is_array($hidden_fields)) {
foreach ($hidden_fields as $key => $value) {
echo "\n";
echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>';
}
}
echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'.get_lang('Ok').'</button>';
self::display_hidden_quiz_questions($course);
self::display_hidden_scorm_directories($course);
echo '</form>';
$resource->show();
echo '</label>';
}
echo '</blockquote>';
echo '</div>';
echo '<script type="text/javascript">exp('."'$course->code'".')</script>';
}
}
}
if ($avoid_serialize) {
//Documents are avoided due the huge amount of memory that the serialize php function "eats" (when there are directories with hundred/thousand of files)
// this is a known issue of serialize
$course->resources['document'] = null;
}
echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>';
if (is_array($hidden_fields)) {
foreach ($hidden_fields as $key => $value) {
echo "\n";
echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>';
}
}
echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'.get_lang('Ok').'</button>';
self::display_hidden_quiz_questions($course);
self::display_hidden_scorm_directories($course);
echo '</form>';
echo '</div>';
echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>';
}
echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>';
}
}

Loading…
Cancel
Save