diff --git a/app/Migrations/Schema/V110/Version110.php b/app/Migrations/Schema/V110/Version110.php index 57de74ed22..15edf18e81 100644 --- a/app/Migrations/Schema/V110/Version110.php +++ b/app/Migrations/Schema/V110/Version110.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"); diff --git a/app/Migrations/Schema/V110/Version20150522112023.php b/app/Migrations/Schema/V110/Version20150522112023.php index 7325186fb1..c6ef04b7b8 100644 --- a/app/Migrations/Schema/V110/Version20150522112023.php +++ b/app/Migrations/Schema/V110/Version20150522112023.php @@ -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')) { diff --git a/app/Migrations/Schema/V110/Version20150603181728.php b/app/Migrations/Schema/V110/Version20150603181728.php index 8c44697e93..85a0d8ed47 100644 --- a/app/Migrations/Schema/V110/Version20150603181728.php +++ b/app/Migrations/Schema/V110/Version20150603181728.php @@ -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)"); diff --git a/app/Migrations/Schema/V110/Version20151214170800.php b/app/Migrations/Schema/V110/Version20151214170800.php index 4ec3e2effc..0d999249a0 100644 --- a/app/Migrations/Schema/V110/Version20151214170800.php +++ b/app/Migrations/Schema/V110/Version20151214170800.php @@ -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; diff --git a/app/Migrations/Schema/V111/Version111.php b/app/Migrations/Schema/V111/Version111.php index 13390b28be..a72e9ba243 100644 --- a/app/Migrations/Schema/V111/Version111.php +++ b/app/Migrations/Schema/V111/Version111.php @@ -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'); } /** diff --git a/app/Migrations/Schema/V111/Version20160304151300.php b/app/Migrations/Schema/V111/Version20160304151300.php index 7cf90edf5f..592afe559c 100644 --- a/app/Migrations/Schema/V111/Version20160304151300.php +++ b/app/Migrations/Schema/V111/Version20160304151300.php @@ -26,6 +26,6 @@ class Version20160304151300 extends AbstractMigrationChamilo */ public function down(Schema $schema) { - + } } diff --git a/app/Migrations/Schema/V111/Version20160706182000.php b/app/Migrations/Schema/V111/Version20160706182000.php index 5c1db18a88..836f1df068 100644 --- a/app/Migrations/Schema/V111/Version20160706182000.php +++ b/app/Migrations/Schema/V111/Version20160706182000.php @@ -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' - ); + ); } /** diff --git a/app/Migrations/Schema/V111/Version20160930144400.php b/app/Migrations/Schema/V111/Version20160930144400.php index 3ff485adb5..ef7886aac6 100644 --- a/app/Migrations/Schema/V111/Version20160930144400.php +++ b/app/Migrations/Schema/V111/Version20160930144400.php @@ -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'); } /** diff --git a/main/exercise/adminhp.php b/main/exercise/adminhp.php index 559817ce86..464f8af3ec 100755 --- a/main/exercise/adminhp.php +++ b/main/exercise/adminhp.php @@ -1,5 +1,6 @@ $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)) { diff --git a/main/exercise/hotspot_answers.as.php b/main/exercise/hotspot_answers.as.php index 947f8a0830..3232154f53 100755 --- a/main/exercise/hotspot_answers.as.php +++ b/main/exercise/hotspot_answers.as.php @@ -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; } } diff --git a/main/exercise/hotspot_lang_conversion.php b/main/exercise/hotspot_lang_conversion.php index 0f74885767..075e631544 100755 --- a/main/exercise/hotspot_lang_conversion.php +++ b/main/exercise/hotspot_lang_conversion.php @@ -1,9 +1,10 @@ -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'] diff --git a/main/inc/lib/formvalidator/Element/DatePicker.php b/main/inc/lib/formvalidator/Element/DatePicker.php index 8aba686b93..a96a730a15 100644 --- a/main/inc/lib/formvalidator/Element/DatePicker.php +++ b/main/inc/lib/formvalidator/Element/DatePicker.php @@ -44,14 +44,20 @@ class DatePicker extends HTML_QuickForm_text $value = api_format_date($value, DATE_TIME_FORMAT_LONG_24H); } - return $this->getElementJS() . ' + return '