Merge branch '1.11.x' of github.com:chamilo/chamilo-lms into 1.11.x

pull/2487/head
Yannick Warnier 9 years ago
commit adc85ff7d7
  1. 13
      app/Migrations/Schema/V110/Version110.php
  2. 8
      app/Migrations/Schema/V110/Version20150522112023.php
  3. 4
      app/Migrations/Schema/V110/Version20150603181728.php
  4. 13
      app/Migrations/Schema/V110/Version20151214170800.php
  5. 1
      app/Migrations/Schema/V111/Version111.php
  6. 2
      app/Migrations/Schema/V111/Version20160706182000.php
  7. 2
      app/Migrations/Schema/V111/Version20160930144400.php
  8. 1
      main/exercise/adminhp.php
  9. 5
      main/exercise/exercise_admin.php
  10. 10
      main/exercise/exercise_submit.php
  11. 15
      main/exercise/hotspot_answers.as.php
  12. 3
      main/exercise/hotspot_lang_conversion.php
  13. 14
      main/exercise/overview.php
  14. 49
      main/inc/lib/formvalidator/Element/DatePicker.php
  15. 55
      main/inc/lib/formvalidator/Element/DateTimePicker.php
  16. 28
      main/inc/lib/sessionmanager.lib.php
  17. 74
      main/inc/lib/usermanager.lib.php
  18. 57
      main/install/install.lib.php
  19. 1
      main/install/update-files-1.10.0-1.11.0.inc.php
  20. 4
      main/template/default/skill/issued.tpl
  21. 4
      main/template/default/skill/issued_all.tpl
  22. 2
      main/work/work.lib.php

@ -24,7 +24,7 @@ class Version110 extends AbstractMigrationChamilo
$this->addSql("ALTER TABLE session_rel_course ENGINE=InnoDB");
$this->addSql("ALTER TABLE session_rel_course_rel_user ENGINE=InnoDB");
$this->addSql("ALTER TABLE session_rel_user ENGINE=InnoDB");
$this->addSql("UPDATE session SET session.id_coach = 1 WHERE id_coach NOT IN ( SELECT user_id FROM user)");
$this->addSql("UPDATE session SET session.id_coach = (SELECT user_id FROM admin LIMIT 1) WHERE id_coach NOT IN (SELECT user_id FROM user)");
}
/**
@ -276,10 +276,13 @@ class Version110 extends AbstractMigrationChamilo
}
if ($schema->hasTable('c_attendance_calendar_rel_group')) {
$this->addSql("ALTER TABLE c_attendance_calendar_rel_group MODIFY COLUMN id INT NOT NULL");
$this->addSql("ALTER TABLE c_attendance_calendar_rel_group DROP PRIMARY KEY");
$this->addSql("ALTER TABLE c_attendance_calendar_rel_group MODIFY COLUMN id INT NULL DEFAULT NULL");
$this->addSql("ALTER TABLE c_attendance_calendar_rel_group ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
$table = $schema->getTable('c_attendance_calendar_rel_group');
if ($table->hasColumn('iid') === false) {
$this->addSql("ALTER TABLE c_attendance_calendar_rel_group MODIFY COLUMN id INT NOT NULL");
$this->addSql("ALTER TABLE c_attendance_calendar_rel_group DROP PRIMARY KEY");
$this->addSql("ALTER TABLE c_attendance_calendar_rel_group MODIFY COLUMN id INT NULL DEFAULT NULL");
$this->addSql("ALTER TABLE c_attendance_calendar_rel_group ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
}
}
$this->addSql("ALTER TABLE c_attendance_sheet MODIFY COLUMN c_id INT NOT NULL");

@ -21,7 +21,13 @@ class Version20150522112023 extends AbstractMigrationChamilo
$this->addSql('ALTER TABLE usergroup ADD group_type INT NOT NULL, ADD created_at DATETIME NOT NULL, ADD updated_at DATETIME NOT NULL');
$this->addSql('ALTER TABLE usergroup ADD picture VARCHAR(255) DEFAULT NULL, ADD url VARCHAR(255) DEFAULT NULL, ADD visibility VARCHAR(255) NOT NULL, ADD allow_members_leave_group INT NOT NULL, CHANGE description description LONGTEXT');
$this->addSql('CREATE TABLE usergroup_rel_usergroup (id INT AUTO_INCREMENT NOT NULL, group_id INT NOT NULL, subgroup_id INT NOT NULL, relation_type INT NOT NULL, PRIMARY KEY(id))');
if (!$schema->hasTable('usergroup_rel_usergroup')) {
$this->addSql(
'CREATE TABLE usergroup_rel_usergroup (id INT AUTO_INCREMENT NOT NULL, group_id INT NOT NULL, subgroup_id INT NOT NULL, relation_type INT NOT NULL, PRIMARY KEY(id))'
);
}
$this->addSql('ALTER TABLE usergroup_rel_user ADD relation_type INT');
if (!$schema->hasTable('access_url_rel_usergroup')) {

@ -60,8 +60,8 @@ class Version20150603181728 extends AbstractMigrationChamilo
$this->addSql("DELETE FROM c_item_property WHERE to_user_id IS NOT NULL AND to_user_id <> 0 AND to_user_id NOT IN (SELECT id FROM user)");
// Sometimes the user was deleted but we need to keep the document.
// Assuming user.id = 1 (admin)
$this->addSql("UPDATE c_item_property SET insert_user_id = 1 WHERE insert_user_id IS NOT NULL AND insert_user_id <> 0 AND insert_user_id NOT IN (SELECT id FROM user)");
// Taking first admin
$this->addSql("UPDATE c_item_property SET insert_user_id = (SELECT user_id FROM admin LIMIT 1) WHERE insert_user_id IS NOT NULL AND insert_user_id <> 0 AND insert_user_id NOT IN (SELECT id FROM user)");
// Remove inconsistencies about non-existing users
$this->addSql("DELETE FROM c_item_property WHERE c_id NOT IN (SELECT id FROM course)");

@ -31,15 +31,19 @@ class Version20151214170800 extends AbstractMigrationChamilo
SELECT a.iid, a.c_id, a.question_id, a.hotspot_coordinates, a.hotspot_type, q.picture, c.directory
FROM c_quiz_answer a
INNER JOIN c_quiz_question q
ON a.question_id = q.id
ON (a.question_id = q.id AND a.c_id = q.c_id)
INNER JOIN course c
ON (a.c_id = c.id AND q.c_id = c.id)
ON (a.c_id = c.id AND q.c_id = c.id)
WHERE a.hotspot_type IN ('square', 'circle', 'poly', 'delineation', 'oar')
");
foreach ($answers as $answer) {
// Recover the real image size to recalculate coordinates
$imagePath = api_get_path(SYS_PATH) . "courses/{$answer['directory']}/document/images/{$answer['picture']}";
if (!file_exists($imagePath)) {
error_log("Migration: Image does not exists: $imagePath");
continue;
}
$imageSize = getimagesize($imagePath);
$widthRatio = $imageSize[0] / 360;
$heightRatio = $imageSize[1] / 360;
@ -50,7 +54,6 @@ class Version20151214170800 extends AbstractMigrationChamilo
switch ($answer['hotspot_type']) {
case 'square':
$oldCenter = explode(';', $oldPairedString[0]);
$oldCenterX = intval($oldCenter[0]);
$oldCenterY = intval($oldCenter[1]);
$oldWidth = intval($oldPairedString[1]);
@ -65,10 +68,8 @@ class Version20151214170800 extends AbstractMigrationChamilo
$newPairedString[] = $newWidth;
$newPairedString[] = $newHeight;
break;
case 'circle':
$oldCenter = explode(';', $oldPairedString[0]);
$oldCenterX = intval($oldCenter[0]);
$oldCenterY = intval($oldCenter[1]);
$oldRadiusX = intval($oldPairedString[1]) / 2;
@ -83,14 +84,12 @@ class Version20151214170800 extends AbstractMigrationChamilo
$newPairedString[] = $newRadiusX;
$newPairedString[] = $newRadiusY;
break;
case 'poly':
//no break;
case 'delineation':
//no break
case 'oar':
$paired = [];
foreach ($oldPairedString as $pairString) {
$pair = explode(';', $pairString);
$x = isset($pair[0]) ? intval($pair[0]) : 0;

@ -314,7 +314,6 @@ class Version111 extends AbstractMigrationChamilo
$this->addSql('DELETE FROM settings_options WHERE variable = "visio_use_rtmpt"');
$this->addSql('DELETE FROM course_module WHERE name = "conference"');
$this->addSql('ALTER TABLE c_student_publication_assignment CHANGE add_to_calendar add_to_calendar INT NOT NULL;');
$this->addSql('ALTER TABLE extra_field ADD visible_to_others TINYINT(1) DEFAULT 0, CHANGE visible visible_to_self TINYINT(1) DEFAULT 0');
}
/**

@ -24,7 +24,7 @@ class Version20160706182000 extends AbstractMigrationChamilo
{
$this->addSql(
'CREATE TABLE course_rel_user_catalogue (id int NOT NULL AUTO_INCREMENT, user_id int DEFAULT NULL, c_id int DEFAULT NULL, visible int NOT NULL, PRIMARY KEY (id), KEY (user_id), KEY (c_id), CONSTRAINT FOREIGN KEY (c_id) REFERENCES course (id) ON DELETE CASCADE, CONSTRAINT FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci'
);
);
}
/**

@ -28,6 +28,8 @@ class Version20160930144400 extends AbstractMigrationChamilo
h.hotspot_answer_id = qa.id
)
');
$this->addSql('ALTER TABLE extra_field ADD visible_to_others TINYINT(1) DEFAULT 0, CHANGE visible visible_to_self TINYINT(1) DEFAULT 0');
}
/**

@ -1,5 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* HotPotatoes administration.
* @package chamilo.exercise

@ -1,5 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* Exercise administration
* This script allows to manage an exercise. It is included from
@ -8,8 +11,6 @@
* @author Olivier Brouckaert, Julio Montoya
*/
use \ChamiloSession as Session;
require_once '../inc/global.inc.php';
$this_section = SECTION_COURSES;

@ -1,6 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* Exercise submission
* This script allows to run an exercise. According to the exercise type, questions
@ -26,8 +28,6 @@
* Modified by hubert.borderiou (2011-10-21 question category)
*/
use ChamiloSession as Session;
require_once '../inc/global.inc.php';
$current_course_tool = TOOL_QUIZ;
$this_section = SECTION_COURSES;
@ -489,6 +489,10 @@ if (!empty($questionList)) {
$question_count = count($questionList);
}
if ($current_question > $question_count) {
$current_question = 0;
}
if ($formSent && isset($_POST)) {
if ($debug) { error_log('9. $formSent was set'); }
@ -528,7 +532,7 @@ if ($formSent && isset($_POST)) {
//saving each question
if ($objExercise->feedback_type != EXERCISE_FEEDBACK_TYPE_DIRECT) {
$nro_question = $current_question; // - 1;
$questionId = $key;
$questionId = $key;
// gets the student choice for this question
$choice = $exerciseResult[$questionId];
if (isset($exe_id)) {

@ -57,8 +57,6 @@ $data['image_height'] = $pictureHeight;
$data['courseCode'] = $_course['path'];
$data['hotspots'] = [];
error_log("\$objExercise->results_disabled: {$objExercise->results_disabled}");
$showScoreOptions = [
RESULT_DISABLE_SHOW_SCORE_ONLY,
RESULT_DISABLE_SHOW_FINAL_SCORE_ONLY_WITH_CATEGORIES,
@ -89,13 +87,13 @@ if ($showExpectedChoice) {
->getQuery()
->getResult();
/** @var CQuizAnswer $hotspotAnswer */
foreach ($result as $hotspotAnswer) {
/** @var CQuizAnswer $hotSpotAnswer */
foreach ($result as $hotSpotAnswer) {
$hotSpot = [];
$hotSpot['id'] = $hotspotAnswer->getIid();
$hotSpot['answer'] = $hotspotAnswer->getAnswer();
$hotSpot['id'] = $hotSpotAnswer->getIid();
$hotSpot['answer'] = $hotSpotAnswer->getAnswer();
switch ($hotspotAnswer->getHotspotType()) {
switch ($hotSpotAnswer->getHotspotType()) {
case 'square':
$hotSpot['type'] = 'square';
break;
@ -113,8 +111,7 @@ if ($showExpectedChoice) {
break;
}
$hotSpot['coord'] = $hotspotAnswer->getHotspotCoordinates();
$hotSpot['coord'] = $hotSpotAnswer->getHotspotCoordinates();
$data['hotspots'][] = $hotSpot;
}
}

@ -1,9 +1,10 @@
<?php //$id:$
<?php
/* For licensing terms, see /license.txt */
/**
* Hotspot language conversion
* @package chamilo.exercise
* @author
* @deprecated ?
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
*/
/**

@ -1,7 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
use \ChamiloSession as Session;
use ChamiloSession as Session;
/**
* Exercise preview
@ -47,8 +47,7 @@ if ($objExercise->expired_time != 0 && !empty($clock_expired_time)) {
if ($time_control) {
// Get time left for expiring time
$time_left = api_strtotime($clock_expired_time,'UTC') - time();
$time_left = api_strtotime($clock_expired_time, 'UTC') - time();
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/epiclock/stylesheet/jquery.epiclock.css');
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/epiclock/renderers/minute/epiclock.minute.css');
$htmlHeadXtra[] = api_get_js('epiclock/javascript/jquery.dateformat.min.js');
@ -99,18 +98,18 @@ $exercise_stat_info = $objExercise->get_stat_track_exercise_info(
0
);
$attempt_list = null;
/*$attempt_list = null;
if (isset($exercise_stat_info['exe_id'])) {
$attempt_list = Event::getAllExerciseEventByExeId($exercise_stat_info['exe_id']);
}
}*/
//1. Check if this is a new attempt or a previous
$label = get_lang('StartTest');
if ($time_control && !empty($clock_expired_time) || !empty($attempt_list)) {
if ($time_control && !empty($clock_expired_time) || isset($exercise_stat_info['exe_id'])) {
$label = get_lang('ContinueTest');
}
if (!empty($attempt_list)) {
if (isset($exercise_stat_info['exe_id'])) {
$message = Display::return_message(get_lang('YouTriedToResolveThisExerciseEarlier'));
}
@ -177,7 +176,6 @@ if ($objExercise->results_disabled == RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANS
if (!empty($attempts)) {
$i = $counter;
foreach ($attempts as $attempt_result) {
$score = ExerciseLib::show_score(
$attempt_result['exe_result'],
$attempt_result['exe_weighting']

@ -44,14 +44,20 @@ class DatePicker extends HTML_QuickForm_text
$value = api_format_date($value, DATE_TIME_FORMAT_LONG_24H);
}
return $this->getElementJS() . '
return '
<div class="input-group">
<span class="input-group-addon">
<input ' . $this->_getAttrString($this->_attributes) . '>
</span>
<input class="form-control" type="text" readonly id="' . $id . '_alt" value="' . $value . '">
<span class="input-group-btn">
<button class="btn btn-default" type="button">
<span class="fa fa-times text-danger" aria-hidden="true"></span>
<span class="sr-only">' . get_lang('Reset') . '</span>
</button>
</span>
</div>
';
' . $this->getElementJS();
}
/**
@ -78,19 +84,32 @@ class DatePicker extends HTML_QuickForm_text
$js .= "<script>
$(function() {
$('#$id').hide().datepicker({
defaultDate: '" . $this->getValue() . "',
dateFormat: 'yy-mm-dd',
altField: '#{$id}_alt',
altFormat: \"" . get_lang('DateFormatLongNoDayJS') . "\",
showOn: 'both',
buttonImage: '" . Display::return_icon('attendance.png', null, [], ICON_SIZE_TINY, true, true) . "',
buttonImageOnly: true,
buttonText: '" . get_lang('SelectDate') . "',
changeMonth: true,
changeYear: true,
yearRange: 'c-60y:c+5y'
});
var txtDate = $('#$id'),
inputGroup = txtDate.parents('.input-group');
txtDate
.hide()
.datepicker({
defaultDate: '" . $this->getValue() . "',
dateFormat: 'yy-mm-dd',
altField: '#{$id}_alt',
altFormat: \"" . get_lang('DateFormatLongNoDayJS') . "\",
showOn: 'both',
buttonImage: '" . Display::return_icon('attendance.png', null, [], ICON_SIZE_TINY, true, true) . "',
buttonImageOnly: true,
buttonText: '" . get_lang('SelectDate') . "',
changeMonth: true,
changeYear: true,
yearRange: 'c-60y:c+5y'
});
inputGroup
.find('button')
.on('click', function (e) {
e.preventDefault();
$('#$id, #{$id}_alt').val('');
});
});
</script>";

@ -37,14 +37,20 @@ class DateTimePicker extends HTML_QuickForm_text
$value = api_format_date($value, DATE_TIME_FORMAT_LONG_24H);
}
return $this->getElementJS() . '
return '
<div class="input-group">
<span class="input-group-addon">
<input ' . $this->_getAttrString($this->_attributes) . '>
</span>
<input class="form-control" type="text" readonly id="' . $id . '_alt" value="' . $value . '">
<span class="input-group-btn">
<button class="btn btn-default" type="button">
<span class="fa fa-times text-danger" aria-hidden="true"></span>
<span class="sr-only">' . get_lang('Reset') . '</span>
</button>
</span>
</div>
';
' . $this->getElementJS();
}
/**
@ -71,22 +77,35 @@ class DateTimePicker extends HTML_QuickForm_text
//timeFormat: 'hh:mm'
$js .= "<script>
$(function() {
$('#$id').hide().datetimepicker({
defaultDate: '" . $this->getValue() . "',
dateFormat: 'yy-mm-dd',
timeFormat: 'HH:mm',
altField: '#{$id}_alt',
altFormat: \"" . get_lang('DateFormatLongNoDayJS') . "\",
altTimeFormat: \"" . get_lang('TimeFormatNoSecJS') . "\",
altSeparator: \" " . get_lang('AtTime') . " \",
altFieldTimeOnly: false,
showOn: 'both',
buttonImage: '" . Display::return_icon('attendance.png', null, [], ICON_SIZE_TINY, true, true) . "',
buttonImageOnly: true,
buttonText: '" . get_lang('SelectDate') . "',
changeMonth: true,
changeYear: true
});
var txtDateTime = $('#$id'),
inputGroup = txtDateTime.parents('.input-group');
txtDateTime
.hide()
.datetimepicker({
defaultDate: '" . $this->getValue() . "',
dateFormat: 'yy-mm-dd',
timeFormat: 'HH:mm',
altField: '#{$id}_alt',
altFormat: \"" . get_lang('DateFormatLongNoDayJS') . "\",
altTimeFormat: \"" . get_lang('TimeFormatNoSecJS') . "\",
altSeparator: \" " . get_lang('AtTime') . " \",
altFieldTimeOnly: false,
showOn: 'both',
buttonImage: '" . Display::return_icon('attendance.png', null, [], ICON_SIZE_TINY, true, true) . "',
buttonImageOnly: true,
buttonText: '" . get_lang('SelectDate') . "',
changeMonth: true,
changeYear: true
});
inputGroup
.find('button')
.on('click', function (e) {
e.preventDefault();
$('#$id, #{$id}_alt').val('');
});
});
</script>";

@ -1461,7 +1461,13 @@ class SessionManager
'description'=> $description,
'show_description' => intval($showDescription),
'visibility' => $visibility,
'send_subscription_notification' => $sendSubscriptionNotification
'send_subscription_notification' => $sendSubscriptionNotification,
'access_start_date' => null,
'access_end_date' => null,
'display_start_date' => null,
'display_end_date' => null,
'coach_access_start_date' => null,
'coach_access_end_date' => null
];
if (!empty($sessionAdminId)) {
@ -1530,6 +1536,8 @@ class SessionManager
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$tbl_url_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$tbl_item_properties = Database::get_course_table(TABLE_ITEM_PROPERTY);
$tbl_student_publication = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$tbl_student_publication_assignment = Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
$em = Database::getManager();
$userId = api_get_user_id();
@ -1562,8 +1570,26 @@ class SessionManager
foreach ($courses as $courseId) {
$courseInfo = api_get_course_info_by_id($courseId);
DocumentManager::deleteDocumentsFromSession($courseInfo, $id_checked);
$works = Database::select(
'*',
$tbl_student_publication,
[
'where' => ['session_id = ? AND c_id = ?' => [$id_checked, $courseId]]
]
);
$currentCourseRepositorySys = api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/';
foreach ($works as $index => $work) {
if ($work['filetype'] = 'folder') {
Database::query("DELETE FROM $tbl_student_publication_assignment WHERE publication_id = $index");
}
my_delete($currentCourseRepositorySys.'/'.$work['url']);
}
}
Database::query("DELETE FROM $tbl_student_publication WHERE session_id IN($id_checked)");
Database::query("DELETE FROM $tbl_session_rel_course WHERE session_id IN($id_checked)");
Database::query("DELETE FROM $tbl_session_rel_course_rel_user WHERE session_id IN($id_checked)");
Database::query("DELETE FROM $tbl_session_rel_user WHERE session_id IN($id_checked)");

@ -1531,6 +1531,73 @@ class UserManager
);
}
/**
* *** READ BEFORE REVIEW THIS FUNCTION ***
* This function is a exact copy from get_user_picture_path_by_id() and it was create it to avoid
* a recursive calls for get_user_picture_path_by_id() in another functions when you update a user picture
* in same script, so you can find this function usage in update_user_picture() function.
*
* @param integer $id User ID
* @param string $type Type of path to return (can be 'system', 'web')
* @param array $userInfo user information to avoid query the DB
* returns the /main/img/unknown.jpg image set it at true
*
* @return array Array of 2 elements: 'dir' and 'file' which contain
* the dir and file as the name implies if image does not exist it will
* return the unknow image if anonymous parameter is true if not it returns an empty array
*/
public static function getUserPicturePathById($id, $type = 'web', $userInfo = [])
{
switch ($type) {
case 'system': // Base: absolute system path.
$base = api_get_path(SYS_CODE_PATH);
break;
case 'web': // Base: absolute web path.
default:
$base = api_get_path(WEB_CODE_PATH);
break;
}
$anonymousPath = array(
'dir' => $base.'img/',
'file' => 'unknown.jpg',
'email' => ''
);
if (empty($id) || empty($type)) {
return $anonymousPath;
}
$id = intval($id);
if (empty($userInfo)) {
$user_table = Database:: get_main_table(TABLE_MAIN_USER);
$sql = "SELECT email, picture_uri FROM $user_table WHERE id=$id";
$res = Database::query($sql);
if (!Database::num_rows($res)) {
return $anonymousPath;
}
$user = Database::fetch_array($res);
if (empty($user['picture_uri'])) {
return $anonymousPath;
}
} else {
$user = $userInfo;
}
$pictureFilename = trim($user['picture_uri']);
$dir = self::getUserPathById($id, $type);
return array(
'dir' => $dir,
'file' => $pictureFilename,
'email' => $user['email']
);
}
/**
* Get user path from user ID (returns an array).
* The return format is a complete path to a folder ending with "/"
@ -1704,7 +1771,7 @@ class UserManager
}
// User-reserved directory where photos have to be placed.
$path_info = self::get_user_picture_path_by_id($user_id, 'system');
$path_info = self::getUserPicturePathById($user_id, 'system');
$path = $path_info['dir'];
// If this directory does not exist - we create it.
@ -1767,6 +1834,11 @@ class UserManager
// Storing the new photos in 4 versions with various sizes.
$userPath = self::getUserPathById($user_id, 'system');
// If this path does not exist - we create it.
if (!file_exists($userPath)) {
mkdir($userPath, api_get_permissions_for_new_directories(), true);
}
$small = new Image($source_file);
$small->resize(32);
$small->send_image($userPath.'small_'.$filename);

@ -2550,20 +2550,21 @@ function fixIds(EntityManager $em)
error_log("Loading field: ".$field['field_variable']);
}
$originalId = $field['id'];
$extraField = new ExtraField();
$extraField
->setExtraFieldType($type)
->setVariable($field['field_variable'])
->setFieldType($field['field_type'])
->setDisplayText($field['field_display_text'])
->setDefaultValue($field['field_default_value'])
->setFieldOrder($field['field_order'])
->setVisible($field['field_visible'])
->setChangeable($field['field_changeable'])
->setFilter($field['field_filter']);
$em->persist($extraField);
$em->flush();
$params = [
'extra_field_type' => $type,
'variable' => $field['field_variable'],
'field_type' => $field['field_type'],
'display_text' => $field['field_display_text'],
'default_value' => $field['field_default_value'],
'field_order' => $field['field_order'],
'visible' => $field['field_visible'],
'changeable' => $field['field_changeable'],
'filter' => $field['field_filter']
];
$connection->insert('extra_field', $params);
$newExtraFieldId = $connection->lastInsertId();
$values = array();
$handlerId = null;
@ -2603,14 +2604,13 @@ function fixIds(EntityManager $em)
$options = $result->fetchAll();
foreach ($options as $option) {
$extraFieldOption = new ExtraFieldOptions();
$extraFieldOption
->setDisplayText($option['option_display_text'])
->setField($extraField)
->setOptionOrder($option['option_order'])
->setValue($option['option_value']);
$em->persist($extraFieldOption);
$em->flush();
$params = [
'display_text' => $option['option_display_text'],
'field_id' => $newExtraFieldId,
'option_order' => $option['option_order'],
'option_value' => $option['option_value']
];
$connection->insert('extra_field_options', $params);
}
$sql = "SELECT * FROM $valueTable WHERE field_id = $originalId ";
@ -2628,19 +2628,10 @@ function fixIds(EntityManager $em)
$k = 0;
foreach ($values as $value) {
if (isset($value[$handlerId])) {
/*
$extraFieldValue = new ExtraFieldValues();
$extraFieldValue
->setValue($value['field_value'])
->setField($extraField)
->setItemId($value[$handlerId]);
$em->persist($extraFieldValue);
$em->flush();
*/
// Insert without the use of the entity as it reduces
// speed to 2 records per second (much too slow)
$params = [
'field_id' => $extraField->getId(),
'field_id' => $newExtraFieldId,
'value' => $value['field_value'],
'item_id' => $value[$handlerId]
];
@ -3074,7 +3065,7 @@ function migrateSwitch($fromVersion, $manager, $processFiles = true)
$sessionId
);
$courseInfo = api_get_course_info_by_id($courseId);
if (empty($item_info)) {
if (empty($itemInfo)) {
api_item_property_update(
$courseInfo,
'work',

@ -41,7 +41,6 @@ if (defined('SYSTEM_INSTALLATION')) {
if ($debug) {
error_log('Folders cleaned up');
}
} else {
echo 'You are not allowed here !'. __FILE__;
}

@ -39,10 +39,10 @@
</p>
<div class='col-md-12 text-center'>
<h5><b> {{ 'ShareWithYourFriends' | get_lang }} </b></h5>
<a href='http://www.facebook.com/sharer.php?u={{ _p.web }}badge/{{ issue_info.id }}' target='_new'>
<a href="http://www.facebook.com/sharer.php?u={{ _p.web }}badge/{{ issue_info.id }}" target="_new">
<em class='fa fa-facebook-square fa-3x text-info' aria-hidden='true'></em>
</a>
<a href='https://twitter.com/home?status={{ 'IHaveObtainedSkillXOnY' | get_lang |format(skill_info.name, _s.site_name)}} - {{ _p.web }}badge/{{ issue_info.id }}' target='_new'>
<a href="https://twitter.com/home?status={{ 'IHaveObtainedSkillXOnY' | get_lang |format(skill_info.name, _s.site_name)}} - {{ _p.web }}badge/{{ issue_info.id }}" target="_new">
<em class='fa fa-twitter-square fa-3x text-light' aria-hidden='true'></em>
</a>
</div>

@ -40,10 +40,10 @@
</p>
<div class='col-md-12 text-center'>
<h5><b> {{ 'ShareWithYourFriends' | get_lang }} </b></h5>
<a href='http://www.facebook.com/sharer.php?u={{ _p.web }}badge/{{ badge.issue_info.id }}' target='_new'>
<a href="http://www.facebook.com/sharer.php?u={{ _p.web }}badge/{{ badge.issue_info.id }}" target="_new">
<em class='fa fa-facebook-square fa-3x text-info' aria-hidden='true'></em>
</a>
<a href='https://twitter.com/home?status={{ 'IHaveObtainedSkillXOnY' | get_lang |format(skill_info.name, _s.site_name)}} - {{ _p.web }}badge/{{ badge.issue_info.id }}' target='_new'>
<a href="https://twitter.com/home?status={{ 'IHaveObtainedSkillXOnY' | get_lang |format(skill_info.name, _s.site_name)}} - {{ _p.web }}badge/{{ badge.issue_info.id }}" target="_new">
<em class='fa fa-twitter-square fa-3x text-light' aria-hidden='true'></em>
</a>
</div>

@ -3587,7 +3587,7 @@ function checkExistingWorkFileName($filename, $workId)
$work_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
$filename = Database::escape_string($filename);
$sql = "SELECT title FROM $work_table
WHERE parent_id = $workId AND title = '$filename'";
WHERE parent_id = $workId AND title = '$filename' AND active = 1";
$result = Database::query($sql);
return Database::fetch_assoc($result);
}

Loading…
Cancel
Save