Remove calls to unused field target_course_code

1.10.x
Julio Montoya 10 years ago
parent b10ed8504a
commit eb8924cbea
  1. 7
      main/coursecopy/copy_course.php
  2. 21
      main/inc/lib/course.lib.php
  3. 1
      main/install/database.sql
  4. 31
      main/reports/templates/courseArticulate.reports.php
  5. 31
      src/Chamilo/CoreBundle/Entity/Course.php
  6. 1
      src/Chamilo/CoreBundle/Migrations/Schema/V110/Version110.php

@ -91,10 +91,9 @@ if (Security::check_token('post') && (
$sql .= ' AND cu.status=1 ';
}
$sql .= ' AND
target_course_code IS NULL AND
cu.user_id = '.$user_info['user_id'].' AND
c.c_id != '."'".$course_info['real_id']."'".'
ORDER BY title ASC';
cu.user_id = '.$user_info['user_id'].' AND
c.c_id != '."'".$course_info['real_id']."'".'
ORDER BY title ASC';
$res = Database::query($sql);
if (Database::num_rows($res) == 0) {
Display::display_normal_message(get_lang('NoDestinationCoursesAvailable'));

@ -14,8 +14,6 @@ use Chamilo\CoreBundle\Entity\ExtraField as EntityExtraField;
* virtual/linked/combined courses (this was already used in several universities
* but not available in standard Chamilo).
*
* The implementation changed, initially a course was a real course
* if target_course_code was 0 , this was changed to NULL.
* There are probably some places left with the wrong code.
*
* @package chamilo.library
@ -819,23 +817,6 @@ class CourseManager
return $result['number'] > 0;
}
/**
* @return an array with the course info of all real courses on the platform
*@deprecate don't use this function
*/
public static function get_real_course_list()
{
$sql_result = Database::query(
"SELECT * FROM " . Database::get_main_table(TABLE_MAIN_COURSE) . "
WHERE target_course_code IS NULL"
);
$real_course_list = array();
while ($result = Database::fetch_array($sql_result)) {
$real_course_list[$result['code']] = $result;
}
return $real_course_list;
}
/**
* Get course list as coach
*
@ -1153,7 +1134,7 @@ class CourseManager
WHERE
course_user.user_id = '$user_id' AND
course_user.relation_type<>" . COURSE_RELATION_TYPE_RRHH . " AND
( course.code = '$course_code' OR target_course_code = '$course_code')"
( course.code = '$course_code')"
)
);
return !empty($result);

@ -142,7 +142,6 @@ CREATE TABLE IF NOT EXISTS course (
last_edit datetime default NULL,
creation_date datetime default NULL,
expiration_date datetime default NULL,
target_course_code varchar(40) default NULL,
subscribe tinyint NOT NULL default '1',
unsubscribe tinyint NOT NULL default '1',
registration_code varchar(255) NOT NULL default '',

@ -65,27 +65,31 @@ function reports_template_CourseArticulate_getSQL() {
// SCORM Data
$scormData = array();
$course_list = CourseManager::get_real_course_list();
$course_list = CourseManager::get_courses_list();
foreach ($course_list as $code => $details) {
$courseId = $details['id'];
$list = Database::query('SELECT l.id as lid, l.name as lname, li.id as liid, li.title as lititle '.
' FROM '.Database::get_course_table(TABLE_LP_MAIN).' l, '.Database::get_course_table(TABLE_LP_ITEM).' li '.
' WHERE l.c_id = '.$details['real_id'].' AND li.c_id = '.$details['real_id'].' AND l.id = li.lp_id');
' WHERE l.c_id = '.$courseId.' AND li.c_id = '.$courseId.' AND l.id = li.lp_id');
while ($lpItem = Database::fetch_assoc($list)) {
$scormData[] = array('coursedb' => $details['db_name'],
$scormData[] = array(
//'coursedb' => $details['db_name'],
'lid' => $lpItem['lid'],
'liid' => $lpItem['liid'],
'target_view_count' => 1,
'target_indicator' => 'score',
'title' => $details['title'].'/'.$lpItem['lname'].'/'.$lpItem['lititle'].'/1/score',
'sql' => 'FIELD');
$scormData[] = array('coursedb' => $details['db_name'],
$scormData[] = array(
//'coursedb' => $details['db_name'],
'lid' => $lpItem['lid'],
'liid' => $lpItem['liid'],
'target_view_count' => 2,
'target_indicator' => 'score',
'title' => $details['title'].'/'.$lpItem['lname'].'/'.$lpItem['lititle'].'/2/score',
'sql' => 'FIELD');
$scormData[] = array('coursedb' => $details['db_name'],
$scormData[] = array(
//'coursedb' => $details['db_name'],
'lid' => $lpItem['lid'],
'liid' => $lpItem['liid'],
'target_view_count' => null,
@ -95,15 +99,16 @@ function reports_template_CourseArticulate_getSQL() {
}
}
foreach($scormData as $v) {
if (!isset($v['sql']))
$v['sql'] = 'FIELD';
$sqlField = str_replace('FIELD', $v['target_indicator'], $v['sql']);
$query = 'select '.$sqlField.' as "'.$v['title'].'" ';
$query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
$query .= 'left outer join '.Database::get_course_table(TABLE_LP_VIEW, $details['db_name']).' lv ';
foreach ($scormData as $v) {
if (!isset($v['sql'])) {
$v['sql'] = 'FIELD';
}
$sqlField = str_replace('FIELD', $v['target_indicator'], $v['sql']);
$query = 'select '.$sqlField.' as "'.$v['title'].'" ';
$query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
$query .= 'left outer join '.Database::get_course_table(TABLE_LP_VIEW).' lv ';
$query .= ' on u.user_id = lv.user_id and lv.lp_id = '.$v['lid'];
$query .= ' left outer join '.Database::get_course_table(TABLE_LP_ITEM_VIEW, $details['db_name']).' liv ';
$query .= ' left outer join '.Database::get_course_table(TABLE_LP_ITEM_VIEW).' liv ';
$query .= ' on lv.id = liv.lp_view_id ';
if ($v['target_view_count'])
$query .= ' and liv.view_count = '.$v['target_view_count'];

@ -165,13 +165,6 @@ class Course
*/
private $expirationDate;
/**
* @var string
*
* @ORM\Column(name="target_course_code", type="string", length=40, nullable=true, unique=false)
*/
private $targetCourseCode;
/**
* @var boolean
*
@ -951,30 +944,6 @@ class Course
return $this->expirationDate;
}
/**
* Set targetCourseCode
*
* @param string $targetCourseCode
*
* @return Course
*/
public function setTargetCourseCode($targetCourseCode)
{
$this->targetCourseCode = $targetCourseCode;
return $this;
}
/**
* Get targetCourseCode
*
* @return string
*/
public function getTargetCourseCode()
{
return $this->targetCourseCode;
}
/**
* Set subscribe
*

@ -86,6 +86,7 @@ class Version110 extends AbstractMigrationChamilo
$this->addSql("ALTER TABLE user MODIFY COLUMN registration_date datetime NOT NULL");
$this->addSql("ALTER TABLE course ADD COLUMN add_teachers_to_sessions_courses tinyint NOT NULL default 0");
$this->addSql("ALTER TABLE course DROP COLUMN target_course_code");
$this->addSql("ALTER TABLE session MODIFY COLUMN name char(100) NOT NULL DEFAULT ''");
$this->addSql("ALTER TABLE course_rel_user ADD COLUMN c_id int default NULL");
$this->addSql("ALTER TABLE course_field_values ADD COLUMN c_id int default NULL");

Loading…
Cancel
Save