diff --git a/main/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php index a667ddeca9..492ab11098 100755 --- a/main/newscorm/learnpath.class.php +++ b/main/newscorm/learnpath.class.php @@ -1104,7 +1104,7 @@ class learnpath */ public function delete_children_items($id) { - $course_id = api_get_course_int_id(); + $course_id = $this->course_info['real_id']; if ($this->debug > 0) { error_log('New LP - In learnpath::delete_children_items(' . $id . ')', 0); } @@ -4534,7 +4534,7 @@ class learnpath $this->name = $name; $lp_table = Database :: get_course_table(TABLE_LP_MAIN); $lp_id = $this->get_id(); - $course_id = api_get_course_int_id(); + $course_id = $this->course_info['real_id']; $sql = "UPDATE $lp_table SET name = '" . Database::escape_string($this->name). "' WHERE c_id = ".$course_id." AND id = '$lp_id'"; @@ -5983,18 +5983,39 @@ class learnpath $tmp_filename = $filename . '_' . ++ $i; $filename = $tmp_filename . '.'.$extension; - $content = stripslashes($content); - - $content = str_replace(api_get_path(WEB_COURSE_PATH), api_get_path(REL_PATH).'courses/', $content); + if ($extension == 'html') { + $content = stripslashes($content); + $content = str_replace( + api_get_path(WEB_COURSE_PATH), + api_get_path(REL_PATH).'courses/', + $content + ); - // Change the path of mp3 to absolute. + // Change the path of mp3 to absolute. - // The first regexp deals with :// urls. - $content = preg_replace("|(flashvars=\"file=)([^:/]+)/|", "$1" . api_get_path(REL_COURSE_PATH) . $courseInfo['path'] . '/document/', $content); - // The second regexp deals with audio/ urls. - $content = preg_replace("|(flashvars=\"file=)([^/]+)/|", "$1" . api_get_path(REL_COURSE_PATH) . $courseInfo['path'] . '/document/$2/', $content); - // For flv player: To prevent edition problem with firefox, we have to use a strange tip (don't blame me please). - $content = str_replace('', '', $content); + // The first regexp deals with :// urls. + $content = preg_replace( + "|(flashvars=\"file=)([^:/]+)/|", + "$1".api_get_path( + REL_COURSE_PATH + ).$courseInfo['path'].'/document/', + $content + ); + // The second regexp deals with audio/ urls. + $content = preg_replace( + "|(flashvars=\"file=)([^/]+)/|", + "$1".api_get_path( + REL_COURSE_PATH + ).$courseInfo['path'].'/document/$2/', + $content + ); + // For flv player: To prevent edition problem with firefox, we have to use a strange tip (don't blame me please). + $content = str_replace( + '', + '', + $content + ); + } if (!file_exists($filepath . $filename)) { if ($fp = @ fopen($filepath . $filename, 'w')) { diff --git a/main/newscorm/scorm.class.php b/main/newscorm/scorm.class.php index ff218b1a78..04ac514de0 100755 --- a/main/newscorm/scorm.class.php +++ b/main/newscorm/scorm.class.php @@ -41,9 +41,8 @@ class scorm extends learnpath if ($this->debug > 0) { error_log('New LP - scorm::scorm('.$course_code.','.$resource_id.','.$user_id.') - In scorm constructor', 0); } - if (!empty($course_code) && !empty($resource_id) && !empty($user_id)) { - parent::__construct($course_code, $resource_id, $user_id); - } + + parent::__construct($course_code, $resource_id, $user_id); } /** diff --git a/main/webservices/client_soap.php b/main/webservices/client_soap.php index 044710840d..3e99361d72 100755 --- a/main/webservices/client_soap.php +++ b/main/webservices/client_soap.php @@ -69,7 +69,7 @@ $params = array( // third party user id 'original_user_id_value' => $random_user_id, 'secret_key' => $secret_key, - //Extra fields + // Extra fields 'extra' => array( array('field_name' => 'ruc', 'field_value' => '123'), array('field_name' => 'DNI', 'field_value' => '4200000') diff --git a/main/webservices/lp.php b/main/webservices/lp.php index ef227de227..8e798fc3cc 100644 --- a/main/webservices/lp.php +++ b/main/webservices/lp.php @@ -110,6 +110,7 @@ $server->wsdl->addComplexType( ), 'file_data' => array('name' => 'file', 'type' => 'xsd:string'), 'filename' => array('name' => 'filename', 'type' => 'xsd:string'), + 'lp_name' => array('name' => 'lp_name', 'type' => 'xsd:string'), 'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string'), ) ); @@ -142,6 +143,8 @@ function WSImportLP($params) $sessionIdName = isset($params['session_id_name']) ? $params['session_id_name'] : null; $sessionIdValue = isset($params['session_id_value']) ? $params['session_id_value'] : null; + $lpName = $params['lp_name']; + $courseCode = CourseManager::get_course_id_from_original_id( $courseIdValue, $courseIdName @@ -173,7 +176,7 @@ function WSImportLP($params) $maker = 'Scorm'; $maxScore = ''; //$_REQUEST['use_max_score'] - $oScorm = new scorm(); + $oScorm = new scorm($courseCode); $fileData = base64_decode($params['file_data']); $uniqueFile = uniqid(); @@ -184,7 +187,7 @@ function WSImportLP($params) $fileInfo = array( 'tmp_name' => $filePath, - 'name' => $fileName + 'name' => $fileName, ); $manifest = $oScorm->import_package($fileInfo, '', $courseInfo); @@ -203,7 +206,7 @@ function WSImportLP($params) $maxScore, $sessionId ); - + $oScorm->set_name($lpName); $oScorm->set_proximity($proximity, $courseId); $oScorm->set_maker($maker, $courseId); //$oScorm->set_jslib('scorm_api.php'); @@ -329,7 +332,7 @@ function WSGetLpList($params) foreach ($flatList as $id => $lp) { $result[] = array( 'id' => $id, - 'name' => $lp['lp_name'] + 'name' => $lp['lp_name'], ); } @@ -399,14 +402,16 @@ function WSDeleteLp($params) ); $courseInfo = api_get_course_info($courseCode); - //$courseId = $courseInfo['real_id']; + $courseId = $courseInfo['real_id']; if (empty($courseInfo)) { if ($debug) error_log("Course not found: $courseIdName : $courseIdValue"); return 'Course not found'; } - /*$sessionId = 0; + $sessionId = 0; + + /* if (!empty($sessionIdName) && !empty($sessionIdValue)) { $sessionId = SessionManager::get_session_id_from_original_id( $sessionIdValue, @@ -424,7 +429,54 @@ function WSDeleteLp($params) $lp = new learnpath($courseInfo['code'], $lpId, null); if ($lp) { if ($debug) error_log("LP deleted $lpId"); + + $course_dir = $courseInfo['directory'] . '/document'; + $sys_course_path = api_get_path(SYS_COURSE_PATH); + $base_work_dir = $sys_course_path . $course_dir; + + $items = $lp->get_flat_ordered_items_list($lpId, 0, $courseId); + + if (!empty($items)) { + /** @var $item learnpathItem */ + foreach ($items as $itemId) { + $item = new learnpathItem($itemId, null, $courseId); + + if ($item) { + $documentId = $item->get_path(); + + if ($debug) error_log("lp item id found #$itemId"); + + $documentInfo = DocumentManager::get_document_data_by_id( + $documentId, + $courseInfo['code'], + false, + $sessionId + ); + + if (!empty($documentInfo)) { + if ($debug) { + error_log("Document id deleted #$documentId"); + } + DocumentManager::delete_document( + $courseInfo, + null, + $base_work_dir, + $sessionId, + $documentId + ); + } else { + if ($debug) { + error_log("No document found for id #$documentId"); + } + } + } else { + if ($debug) error_log("Document not found #$itemId"); + } + } + } + $lp->delete($courseInfo, $lpId, 'remove'); + return 1; } @@ -453,7 +505,7 @@ $server->wsdl->addComplexType( 'SOAP-ENC:Array', array(), array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:lpItem[]')), - 'tns:lpItemList' + 'tns:lpItem' ); $server->wsdl->addComplexType( diff --git a/main/webservices/registration.soap.php b/main/webservices/registration.soap.php index f01847b676..8c82592d17 100755 --- a/main/webservices/registration.soap.php +++ b/main/webservices/registration.soap.php @@ -2682,20 +2682,23 @@ function WSCreateCourse($params) $title = $course_param['title']; $category_code = isset($course_param['category_code']) ? $course_param['category_code'] : ''; $wanted_code = $course_param['wanted_code']; - $tutor_name = $course_param['tutor_name']; + $tutor_name = isset($course_param['tutor_name']) ? $course_param['tutor_name'] : ''; $course_language = 'english'; // TODO: A hard-coded value. $original_course_id_name = $course_param['original_course_id_name']; $original_course_id_value = $course_param['original_course_id_value']; $orig_course_id_value[] = $course_param['original_course_id_value']; $visibility = null; - if ($course_param['visibility'] && - $course_param['visibility'] >= 0 && - $course_param['visibility'] <= 3 - ) { - $visibility = $course_param['visibility']; + if (isset($course_param['visibility'])) { + if ($course_param['visibility'] && + $course_param['visibility'] >= 0 && + $course_param['visibility'] <= 3 + ) { + $visibility = $course_param['visibility']; + } } - $extra_list = $course_param['extra']; + $extra_list = isset($course_param['extra']) ? $course_param['extra'] : ''; + // Check whether exits $x_course_code into user_field_values table. $courseInfo = CourseManager::getCourseInfoFromOriginalId( @@ -2747,12 +2750,21 @@ function WSCreateCourse($params) $values['course_language'] = api_get_setting('platformLanguage'); } - $values['tutor_name'] = api_get_person_name($_user['firstName'], $_user['lastName'], null, null, $values['course_language']); + if (isset($_user['firstName'])) { + $values['tutor_name'] = api_get_person_name( + $_user['firstName'], + $_user['lastName'], + null, + null, + $values['course_language'] + ); + } $params = array(); $params['title'] = $title; $params['wanted_code'] = $wanted_code; $params['category_code'] = $category_code; + $params['course_category'] = $category_code; $params['tutor_name'] = $tutor_name; $params['course_language'] = $course_language; $params['user_id'] = api_get_user_id();