Update from 1.11.x

pull/3733/head
Julio Montoya 5 years ago
parent 33021ff34b
commit 0b0f569324
  1. 3
      public/main/lp/blank.php
  2. 83
      public/main/lp/learnpathItem.class.php
  3. 29
      public/main/lp/lp_ajax_save_item.php
  4. 8
      public/main/lp/lp_ajax_switch_item.php
  5. 17
      public/main/lp/lp_content.php
  6. 4
      public/main/lp/lp_view.php
  7. 7
      src/CoreBundle/Entity/User.php
  8. 2
      src/CoreBundle/Migrations/Schema/V200/Version20180927172830.php
  9. 1
      src/CourseBundle/Entity/CForumForum.php

@ -20,6 +20,9 @@ body { background: none;}
$message = ''; $message = '';
if (isset($_GET['error'])) { if (isset($_GET['error'])) {
switch ($_GET['error']) { switch ($_GET['error']) {
case 'document_protected':
$message = Display::return_message(get_lang('ProtectedDocument'), 'warning');
break;
case 'document_deleted': case 'document_deleted':
$message = Display::return_message(get_lang('The document cannot be displayed because it has been deleted'), 'error'); $message = Display::return_message(get_lang('The document cannot be displayed because it has been deleted'), 'error');
break; break;

@ -13,7 +13,7 @@ use Chamilo\CoreBundle\Framework\Container;
*/ */
class learnpathItem class learnpathItem
{ {
const DEBUG = 0; // Logging parameter. public const DEBUG = 0; // Logging parameter.
public $iId; public $iId;
public $attempt_id; // Also called "objectives" SCORM-wise. public $attempt_id; // Also called "objectives" SCORM-wise.
public $audio; // The path to an audio file (stored in document/audio/). public $audio; // The path to an audio file (stored in document/audio/).
@ -252,26 +252,43 @@ class learnpathItem
* Closes/stops the item viewing. Finalises runtime values. * Closes/stops the item viewing. Finalises runtime values.
* If required, save to DB. * If required, save to DB.
* *
* @param bool $prerequisitesCheck Needed to check if asset can be set as completed or not
*
* @return bool True on success, false otherwise * @return bool True on success, false otherwise
*/ */
public function close() public function close()
{ {
$debug = self::DEBUG;
$this->current_stop_time = time(); $this->current_stop_time = time();
$type = $this->get_type(); $type = $this->get_type();
if ('sco' != $type) { if ($debug) {
if (TOOL_QUIZ == $type || TOOL_HOTPOTATOES == $type) { error_log('Start - learnpathItem:close');
error_log("Type: ".$type);
error_log("get_id: ".$this->get_id());
}
if ($type !== 'sco') {
if ($type == TOOL_QUIZ || $type == TOOL_HOTPOTATOES) {
$this->get_status( $this->get_status(
true, true,
true true
); // Update status (second option forces the update). ); // Update status (second option forces the update).
} else { } else {
$this->status = $this->possible_status[2]; /*$this->status = $this->possible_status[2];
if (self::DEBUG) {
error_log("STATUS changed to: ".$this->status);
}*/
} }
} }
if ($this->save_on_close) { if ($this->save_on_close) {
if ($debug) {
error_log('save_on_close');
}
$this->save(); $this->save();
} }
if ($debug) {
error_log('End - learnpathItem:close');
}
return true; return true;
} }
@ -850,10 +867,7 @@ class learnpathItem
} }
} }
if (self::DEBUG > 2) { if (self::DEBUG > 2) {
error_log( error_log('End of learnpathItem::get_prevent_reinit() - Returned '.$this->prevent_reinit);
'New LP - End of learnpathItem::get_prevent_reinit() - Returned '.$this->prevent_reinit,
0
);
} }
return $this->prevent_reinit; return $this->prevent_reinit;
@ -1464,12 +1478,12 @@ class learnpathItem
{ {
$courseId = $this->courseId; $courseId = $this->courseId;
$debug = self::DEBUG; $debug = self::DEBUG;
if ($debug > 0) { if ($debug) {
error_log('learnpathItem::get_status() on item '.$this->db_id, 0); error_log('learnpathItem::get_status() on item '.$this->db_id);
} }
if ($check_db) { if ($check_db) {
if ($debug > 2) { if ($debug) {
error_log('learnpathItem::get_status(): checking db', 0); error_log('learnpathItem::get_status(): checking db');
} }
if (!empty($this->db_item_view_id) && !empty($courseId)) { if (!empty($this->db_item_view_id) && !empty($courseId)) {
$table = Database::get_course_table(TABLE_LP_ITEM_VIEW); $table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
@ -2437,7 +2451,10 @@ class learnpathItem
return $returnstatus; return $returnstatus;
} else { } else {
$status = $itemToCheck->get_status(false); $status = $itemToCheck->get_status(true);
if (self::DEBUG) {
error_log('Status:'.$status);
}
$returnstatus = $status == $this->possible_status[2] || $status == $this->possible_status[3]; $returnstatus = $status == $this->possible_status[2] || $status == $this->possible_status[3];
// Check results from another sessions. // Check results from another sessions.
@ -2515,7 +2532,7 @@ class learnpathItem
} }
$orstatus = false; $orstatus = false;
foreach ($list as $condition) { foreach ($list as $condition) {
if (self::DEBUG > 1) { if (self::DEBUG) {
error_log( error_log(
'New LP - Found OR, adding it ('.$condition.')', 'New LP - Found OR, adding it ('.$condition.')',
0 0
@ -2805,10 +2822,7 @@ class learnpathItem
} }
if ($debug) { if ($debug) {
error_log( error_log('End of learnpathItem::save() - Calling write_to_db() now');
'New LP - End of learnpathItem::save() - Calling write_to_db()',
0
);
} }
return $this->write_to_db(); return $this->write_to_db();
@ -3112,12 +3126,11 @@ class learnpathItem
if ($found) { if ($found) {
$this->status = $status; $this->status = $status;
if (self::DEBUG > 1) { if (self::DEBUG) {
error_log( error_log(
'learnpathItem::set_status() - '. 'learnpathItem::set_status() - '.
'Updated object status of item '.$this->db_id. 'Updated object status of item '.$this->db_id.
' to '.$this->status, ' to '.$this->status
0
); );
} }
@ -3643,10 +3656,7 @@ class learnpathItem
lp_view_id = ".$this->view_id." AND lp_view_id = ".$this->view_id." AND
view_count = ".$this->get_attempt_id(); view_count = ".$this->get_attempt_id();
if ($debug) { if ($debug) {
error_log( error_log('learnpathItem::write_to_db() - Querying item_view: '.$sql);
'learnpathItem::write_to_db() - Querying item_view: '.$sql,
0
);
} }
$check_res = Database::query($sql); $check_res = Database::query($sql);
@ -4081,30 +4091,27 @@ class learnpathItem
/** /**
* Adds an audio file to the current item, using a file already in documents. * Adds an audio file to the current item, using a file already in documents.
* *
* @param int $doc_id * @param int $documentId
* *
* @return string * @return string
*/ */
public function add_audio_from_documents($doc_id) public function add_audio_from_documents($documentId)
{ {
$course_info = api_get_course_info(); $courseInfo = api_get_course_info();
$document_data = DocumentManager::get_document_data_by_id( $documentData = DocumentManager::get_document_data_by_id($documentId, $courseInfo['code']);
$doc_id,
$course_info['code']
);
$file_path = ''; $path = '';
if (!empty($document_data)) { if (!empty($documentData)) {
$file_path = basename($document_data['path']); $path = $documentData['path'];
// Store the mp3 file in the lp_item table. // Store the mp3 file in the lp_item table.
$table = Database::get_course_table(TABLE_LP_ITEM); $table = Database::get_course_table(TABLE_LP_ITEM);
$sql = "UPDATE $table SET $sql = "UPDATE $table SET
audio = '".Database::escape_string($file_path)."' audio = '".Database::escape_string($path)."'
WHERE iid = ".intval($this->db_id); WHERE iid = ".$this->db_id;
Database::query($sql); Database::query($sql);
} }
return $file_path; return $path;
} }
/** /**

@ -62,22 +62,23 @@ function save_item(
) { ) {
$debug = 0; $debug = 0;
$return = null; $return = null;
$courseCode = api_get_course_id();
if (!empty($courseId)) {
$courseInfo = api_get_course_info_by_id($courseId);
if ($courseInfo) {
$courseCode = $courseInfo['code'];
}
}
if ($debug > 0) { if ($debug > 0) {
error_log('--------------------------------------'); error_log('--------------------------------------');
error_log('SAVE ITEM - lp_ajax_save_item.php : save_item() params: '); error_log('SAVE ITEM - lp_ajax_save_item.php');
error_log('--------------------------------------');
error_log("item_id: $item_id - lp_id: $lp_id - user_id: - $user_id - view_id: $view_id - item_id: $item_id"); error_log("item_id: $item_id - lp_id: $lp_id - user_id: - $user_id - view_id: $view_id - item_id: $item_id");
error_log("SCORE: $score - max:$max - min: $min - status:$status"); error_log("SCORE: $score - max:$max - min: $min - status:$status");
error_log("TIME: $time - suspend: $suspend - location: $location - core_exit: $core_exit"); error_log("TIME: $time - suspend: $suspend - location: $location - core_exit: $core_exit");
error_log("finish: $lmsFinish - navigatesAway: $userNavigatesAway"); error_log("finish: $lmsFinish - navigatesAway: $userNavigatesAway");
} error_log("courseCode: $courseCode");
$courseCode = api_get_course_id();
if (!empty($courseId)) {
$courseInfo = api_get_course_info_by_id($courseId);
if ($courseInfo) {
$courseCode = $courseInfo['code'];
}
} }
$myLP = learnpath::getLpFromSession($courseCode, $lp_id, $user_id); $myLP = learnpath::getLpFromSession($courseCode, $lp_id, $user_id);
@ -487,9 +488,11 @@ function save_item(
if (true === $scoreAsProgressSetting) { if (true === $scoreAsProgressSetting) {
$scoreAsProgress = $myLP->getUseScoreAsProgress(); $scoreAsProgress = $myLP->getUseScoreAsProgress();
if ($scoreAsProgress) { if ($scoreAsProgress) {
$score = $myLPI->get_score(); if (isset($score) && $score != -1) {
$maxScore = $myLPI->get_max(); $score = $myLPI->get_score();
$return .= "update_progress_bar('$score', '$maxScore', '$myProgressMode');"; $maxScore = $myLPI->get_max();
$return .= "update_progress_bar('$score', '$maxScore', '$myProgressMode');";
}
$progressBarSpecial = true; $progressBarSpecial = true;
} }
} }
@ -524,7 +527,7 @@ function save_item(
} }
// To be sure progress is updated. // To be sure progress is updated.
$myLP->save_last(); $myLP->save_last($score);
Session::write('lpobject', serialize($myLP)); Session::write('lpobject', serialize($myLP));
Session::write('oLP', $myLP); Session::write('oLP', $myLP);

@ -29,10 +29,9 @@ function switch_item_details($lp_id, $user_id, $view_id, $current_item, $next_it
$debug = 0; $debug = 0;
$return = ''; $return = '';
if ($debug > 0) { if ($debug > 0) {
error_log( error_log('--------------------------------------');
'In xajax_switch_item_details('.$lp_id.','.$user_id.','.$view_id.','.$current_item.','.$next_item.')', error_log('SWITCH');
0 error_log('Params('.$lp_id.','.$user_id.','.$view_id.','.$current_item.','.$next_item.')');
);
} }
//$objResponse = new xajaxResponse(); //$objResponse = new xajaxResponse();
/*$item_id may be one of: /*$item_id may be one of:
@ -268,6 +267,7 @@ function switch_item_details($lp_id, $user_id, $view_id, $current_item, $next_it
$mylp->set_error_msg(''); $mylp->set_error_msg('');
$mylp->prerequisites_match(); // Check the prerequisites are all complete. $mylp->prerequisites_match(); // Check the prerequisites are all complete.
if ($debug > 1) { if ($debug > 1) {
error_log($return);
error_log('Prereq_match() returned '.htmlentities($mylp->error), 0); error_log('Prereq_match() returned '.htmlentities($mylp->error), 0);
} }
// Save the new item ID for the exercise tool to use. // Save the new item ID for the exercise tool to use.

@ -55,10 +55,7 @@ if ($dir) {
case 1: case 1:
$learnPath->stop_previous_item(); $learnPath->stop_previous_item();
$prerequisiteCheck = $learnPath->prerequisites_match($lpItemId); $prerequisiteCheck = $learnPath->prerequisites_match($lpItemId);
if (true === $prerequisiteCheck) { if ($prerequisiteCheck === true) {
$src = $learnPath->get_link('http', $lpItemId);
$learnPath->start_current_item(); // starts time counter manually if asset
$src = $learnPath->fixBlockedLinks($src);
if (WhispeakAuthPlugin::isLpItemMarked($lpItemId)) { if (WhispeakAuthPlugin::isLpItemMarked($lpItemId)) {
ChamiloSession::write( ChamiloSession::write(
@ -67,10 +64,18 @@ if ($dir) {
); );
$src = api_get_path(WEB_PLUGIN_PATH).'whispeakauth/authentify.php'; $src = api_get_path(WEB_PLUGIN_PATH).'whispeakauth/authentify.php';
break;
} }
$src = $learnPath->get_link('http', $lpItemId);
if (empty($src)) {
$src = 'blank.php?'.api_get_cidreq().'&error=document_protected';
break;
}
$learnPath->start_current_item(); // starts time counter manually if asset
$src = $learnPath->fixBlockedLinks($src);
break; break;
} }
$src = 'blank.php?error=prerequisites&prerequisite_message='.Security::remove_XSS($learnPath->error); $src = 'blank.php?'.api_get_cidreq().'&error=prerequisites&prerequisite_message='.Security::remove_XSS($learnPath->error);
break; break;
case 2: case 2:
$learnPath->stop_previous_item(); $learnPath->stop_previous_item();
@ -80,7 +85,7 @@ if ($dir) {
$src = $learnPath->get_link('http', $lpItemId); $src = $learnPath->get_link('http', $lpItemId);
$learnPath->start_current_item(); // starts time counter manually if asset $learnPath->start_current_item(); // starts time counter manually if asset
} else { } else {
$src = 'blank.php?error=prerequisites&prerequisite_message='.Security::remove_XSS($learnPath->error); $src = 'blank.php?'.api_get_cidreq().'&error=prerequisites&prerequisite_message='.Security::remove_XSS($learnPath->error);
} }
break; break;
case 3: case 3:

@ -297,9 +297,9 @@ $autostart = 'true';
if ($debug) { if ($debug) {
error_log('$type_quiz: '.$type_quiz); error_log('$type_quiz: '.$type_quiz);
error_log('$_REQUEST[exeId]: '.intval($_REQUEST['exeId'])); error_log('$_REQUEST[exeId]: '.intval($_REQUEST['exeId'] ?? 0));
error_log('$lp_id: '.$lp_id); error_log('$lp_id: '.$lp_id);
error_log('$_REQUEST[lp_item_id]: '.intval($_REQUEST['lp_item_id'])); error_log('$_REQUEST[lp_item_id]: '.intval($_REQUEST['lp_item_id'] ?? 0));
} }
if (!empty($_REQUEST['exeId']) && if (!empty($_REQUEST['exeId']) &&

@ -769,7 +769,6 @@ class User implements UserInterface, EquatableInterface, ResourceInterface
$this->expired = false; $this->expired = false;
$this->roles = []; $this->roles = [];
$this->credentialsExpired = false; $this->credentialsExpired = false;
} }
/** /**
@ -2458,8 +2457,8 @@ class User implements UserInterface, EquatableInterface, ResourceInterface
$this->setUsername($name); $this->setUsername($name);
} }
public function setParent(AbstractResource $parent) { public function setParent(AbstractResource $parent)
{
} }
/** /**
@ -2486,7 +2485,7 @@ class User implements UserInterface, EquatableInterface, ResourceInterface
? 0 ? 0
: max( : max(
$categoryCourses->map( $categoryCourses->map(
/** @var CourseRelUser $courseRelUser */ /** @var CourseRelUser $courseRelUser */
function ($courseRelUser) { function ($courseRelUser) {
return $courseRelUser->getSort(); return $courseRelUser->getSort();
} }

@ -60,8 +60,6 @@ class Version20180927172830 extends AbstractMigrationChamilo
$this->addSql('CREATE INDEX IDX_47A9C99F2E82C87 ON c_forum_forum (forum_last_post);'); $this->addSql('CREATE INDEX IDX_47A9C99F2E82C87 ON c_forum_forum (forum_last_post);');
} }
$table = $schema->getTable('c_forum_thread'); $table = $schema->getTable('c_forum_thread');
if (false === $table->hasForeignKey('FK_5DA7884C29CCBAD0')) { if (false === $table->hasForeignKey('FK_5DA7884C29CCBAD0')) {
$this->addSql('ALTER TABLE c_forum_thread ADD CONSTRAINT FK_5DA7884C29CCBAD0 FOREIGN KEY (forum_id) REFERENCES c_forum_forum (iid)'); $this->addSql('ALTER TABLE c_forum_thread ADD CONSTRAINT FK_5DA7884C29CCBAD0 FOREIGN KEY (forum_id) REFERENCES c_forum_forum (iid)');

@ -6,7 +6,6 @@ namespace Chamilo\CourseBundle\Entity;
use Chamilo\CoreBundle\Entity\AbstractResource; use Chamilo\CoreBundle\Entity\AbstractResource;
use Chamilo\CoreBundle\Entity\ResourceInterface; use Chamilo\CoreBundle\Entity\ResourceInterface;
use Chamilo\CoreBundle\Entity\User;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo; use Gedmo\Mapping\Annotation as Gedmo;

Loading…
Cancel
Save