diff --git a/app/Resources/public/css/base.css b/app/Resources/public/css/base.css index c102d0e499..16bb746109 100644 --- a/app/Resources/public/css/base.css +++ b/app/Resources/public/css/base.css @@ -8450,10 +8450,13 @@ ul#toolnavbox-two li a.btn { border-color: #dd853d; color: #ffffff; } -.checkbox input[type=checkbox], -.checkbox-inline input[type=checkbox], -.radio input[type=radio], -.radio-inline input[type=radio]{ +.btn-post{ + margin-top: 10px; +} +main[dir="rtl"] .checkbox input[type=checkbox], +main[dir="rtl"] .checkbox-inline input[type=checkbox], +main[dir="rtl"] .radio input[type=radio], +main[dir="rtl"] .radio-inline input[type=radio]{ position: relative; margin-left: 10px; } @@ -9716,18 +9719,24 @@ ul.dropdown-menu.inner > li > a { .btn-maps { border-radius: 5px; - border-color: #6d9b00; - background-color: #f8ffdd; + border-color: #cccccc; + background-color: #ffffff; + color: #7a7a7a; } .btn-maps:hover { - background-color: #d4e9ff !important; - color: #0b3e6f; - border-color: #75a9e0; + background-color: #f5f6f7 !important; + color: #7a7a7a; + border-color: #bababa; } .post-attachment { text-align: center; + margin-bottom: 10px; +} +.post-date{ + display: inline-block; + width: 100%; } .pager .current { diff --git a/main/exercise/exercise.class.php b/main/exercise/exercise.class.php index 5222010650..d496bde466 100755 --- a/main/exercise/exercise.class.php +++ b/main/exercise/exercise.class.php @@ -3537,8 +3537,10 @@ class Exercise if (!empty($studentChoice)) { if ($studentChoice == $answerCorrect) { // correct answer and student is Unsure or PrettySur - if ($quiz_question_options[$studentChoiceDegree]['position'] >= 3 - && $quiz_question_options[$studentChoiceDegree]['position'] < 9) { + if (isset($quiz_question_options[$studentChoiceDegree]) && + $quiz_question_options[$studentChoiceDegree]['position'] >= 3 && + $quiz_question_options[$studentChoiceDegree]['position'] < 9 + ) { $questionScore += $true_score; } else { // student ignore correct answer @@ -3629,21 +3631,15 @@ class Exercise } $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : ''; + $real_answers[$answerId] = false; if ($answerCorrect == $studentChoice) { - //$answerCorrect = 1; $real_answers[$answerId] = true; - } else { - //$answerCorrect = 0; - $real_answers[$answerId] = false; } } else { $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : ''; + $real_answers[$answerId] = false; if ($answerCorrect == $studentChoice) { - //$answerCorrect = 1; $real_answers[$answerId] = true; - } else { - //$answerCorrect = 0; - $real_answers[$answerId] = false; } } break; @@ -3659,31 +3655,27 @@ class Exercise $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null; if ($answerCorrect == 1) { + $real_answers[$answerId] = false; if ($studentChoice) { $real_answers[$answerId] = true; - } else { - $real_answers[$answerId] = false; } } else { + $real_answers[$answerId] = true; if ($studentChoice) { $real_answers[$answerId] = false; - } else { - $real_answers[$answerId] = true; } } } else { $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null; if ($answerCorrect == 1) { + $real_answers[$answerId] = false; if ($studentChoice) { $real_answers[$answerId] = true; - } else { - $real_answers[$answerId] = false; } } else { + $real_answers[$answerId] = true; if ($studentChoice) { $real_answers[$answerId] = false; - } else { - $real_answers[$answerId] = true; } } } @@ -4283,6 +4275,12 @@ class Exercise } } + if ($results_disabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) { + if ($s_user_answer != $i_answer_correct_answer) { + continue; + } + } + if ($show_result) { if ($this->showExpectedChoice() == false && $showTotalScoreAndUserChoicesInLastAttempt === false @@ -4901,6 +4899,7 @@ class Exercise if ($debug) { error_log('Showing questions $from '.$from); } + switch ($answerType) { case UNIQUE_ANSWER: case UNIQUE_ANSWER_IMAGE: @@ -5097,26 +5096,6 @@ class Exercise case HOT_SPOT_DELINEATION: $user_answer = $user_array; if ($next) { - //$tbl_track_e_hotspot = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTSPOT); - // Save into db - /* $sql = "INSERT INTO $tbl_track_e_hotspot ( - * hotspot_user_id, - * hotspot_course_code, - * hotspot_exe_id, - * hotspot_question_id, - * hotspot_answer_id, - * hotspot_correct, - * hotspot_coordinate - * ) - VALUES ( - * '".Database::escape_string($_user['user_id'])."', - * '".Database::escape_string($_course['id'])."', - * '".Database::escape_string($exeId)."', '".Database::escape_string($questionId)."', - * '".Database::escape_string($answerId)."', - * '".Database::escape_string($studentChoice)."', - * '".Database::escape_string($user_array)."')"; - $result = Database::query($sql,__FILE__,__LINE__); - */ $user_answer = $user_array; // we compare only the delineation not the other points $answer_question = $_SESSION['hotspot_coord'][1]; @@ -5266,7 +5245,6 @@ class Exercise ) ); echo ''; - break; case ANNOTATION: ExerciseShowFunctions::displayAnnotationAnswer( @@ -5578,16 +5556,17 @@ class Exercise ) { if ($choice != 0) { $reply = array_keys($choice); - for ($i = 0; $i < sizeof($reply); $i++) { + $countReply = count($reply); + for ($i = 0; $i < $countReply; $i++) { $chosenAnswer = $reply[$i]; if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) { if ($choiceDegreeCertainty != 0) { $replyDegreeCertainty = array_keys($choiceDegreeCertainty); - $answerDegreeCertainty = $replyDegreeCertainty[$i]; + $answerDegreeCertainty = isset($replyDegreeCertainty[$i]) ? $replyDegreeCertainty[$i] : ''; + $answerValue = isset($choiceDegreeCertainty[$answerDegreeCertainty]) ? $choiceDegreeCertainty[$answerDegreeCertainty] : ''; Event::saveQuestionAttempt( $questionScore, - $chosenAnswer.':'.$choice[$chosenAnswer].':'. - $choiceDegreeCertainty[$answerDegreeCertainty], + $chosenAnswer.':'.$choice[$chosenAnswer].':'.$answerValue, $quesId, $exeId, $i, @@ -8403,14 +8382,14 @@ class Exercise ['id' => 'result_disabled_6'] ); - /*$resultDisabledGroup[] = $form->createElement( + $resultDisabledGroup[] = $form->createElement( 'radio', 'results_disabled', null, get_lang('ExerciseShowOnlyCorrectAnswer'), '7', ['id' => 'result_disabled_7'] - );*/ + ); $group = $form->addGroup( $resultDisabledGroup, diff --git a/main/exercise/exercise_show.php b/main/exercise/exercise_show.php index da02bc94d6..b2bb7b7179 100755 --- a/main/exercise/exercise_show.php +++ b/main/exercise/exercise_show.php @@ -910,13 +910,18 @@ foreach ($questionList as $questionId) { $score = []; if ($show_results) { + $scorePassed = $my_total_score >= $my_total_weight; + if (function_exists('bccomp')) { + $compareResult = bccomp($my_total_score, $my_total_weight, 3); + $scorePassed = $compareResult === 1 || $compareResult === 0; + } $score['result'] = ExerciseLib::show_score( $my_total_score, $my_total_weight, false, false ); - $score['pass'] = $my_total_score >= $my_total_weight ? true : false; + $score['pass'] = $scorePassed; $score['type'] = $answerType; $score['score'] = $my_total_score; $score['weight'] = $my_total_weight; diff --git a/main/exercise/fill_blanks.class.php b/main/exercise/fill_blanks.class.php index a81fef5e38..4bbfa557db 100755 --- a/main/exercise/fill_blanks.class.php +++ b/main/exercise/fill_blanks.class.php @@ -1231,6 +1231,12 @@ class FillBlanks extends Question // rebuild the sentence with student answer inserted for ($i = 0; $i < count($listStudentAnswerInfo['common_words']); $i++) { + if ($resultsDisabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) { + if (isset($listStudentAnswerInfo['student_score'][$i]) && + $listStudentAnswerInfo['student_score'][$i] != 1) { + continue; + } + } $result .= isset($listStudentAnswerInfo['common_words'][$i]) ? $listStudentAnswerInfo['common_words'][$i] : ''; $result .= isset($listStudentAnswerInfo['student_answer'][$i]) ? $listStudentAnswerInfo['student_answer'][$i] : ''; } diff --git a/main/exercise/hotspot_answers.as.php b/main/exercise/hotspot_answers.as.php index 49fa3d761c..c9efc95b72 100755 --- a/main/exercise/hotspot_answers.as.php +++ b/main/exercise/hotspot_answers.as.php @@ -163,8 +163,36 @@ if (!$hideExpectedAnswer) { /** @var CQuizAnswer $hotSpotAnswer */ foreach ($result as $hotSpotAnswer) { + $hotSpotAnswerId = $hotSpotAnswer->getIid(); + + // Show only correct hotspots + if ($objExercise->selectResultsDisabled() == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) { + $TBL_TRACK_HOTSPOT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTSPOT); + // Check auto id + $sql = "SELECT hotspot_correct + FROM $TBL_TRACK_HOTSPOT + WHERE + hotspot_exe_id = $exeId AND + hotspot_question_id= $questionId AND + hotspot_answer_id = ".$hotSpotAnswerId." + ORDER BY hotspot_id ASC"; + $result = Database::query($sql); + $studentChoice = false; + if (Database::num_rows($result)) { + $studentChoice = Database::result( + $result, + 0, + 'hotspot_correct' + ); + } + + if (!$studentChoice) { + continue; + } + } + $hotSpot = []; - $hotSpot['id'] = $hotSpotAnswer->getIid(); + $hotSpot['id'] = $hotSpotAnswerId; $hotSpot['answer'] = $hotSpotAnswer->getAnswer(); switch ($hotSpotAnswer->getHotspotType()) { diff --git a/main/exercise/matching.class.php b/main/exercise/matching.class.php index 232485fc74..5284704352 100755 --- a/main/exercise/matching.class.php +++ b/main/exercise/matching.class.php @@ -291,6 +291,7 @@ class Matching extends Question $header .= '
| '; - echo ' | '; @@ -399,7 +392,7 @@ class ExerciseShowFunctions echo ' | '; } - if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { + if ($feedbackType != EXERCISE_FEEDBACK_TYPE_EXAM) { echo ''; if ($studentChoice) { $color = 'black'; @@ -444,7 +437,7 @@ class ExerciseShowFunctions */ public static function display_multiple_answer_true_false( $exercise, - $feedback_type, + $feedbackType, $answerType, $studentChoice, $answer, @@ -459,7 +452,7 @@ class ExerciseShowFunctions $hide_expected_answer = false; switch ($resultsDisabled) { case RESULT_DISABLE_SHOW_SCORE_ONLY: - if ($feedback_type == 0) { + if ($feedbackType == 0) { $hide_expected_answer = true; } break; @@ -471,29 +464,30 @@ class ExerciseShowFunctions } break; } - echo ' | |||||||
| '; + + $content = ' | |||||||||
| '; $course_id = api_get_course_int_id(); $new_options = Question::readQuestionOption($questionId, $course_id); // Your choice if (isset($new_options[$studentChoice])) { - echo get_lang($new_options[$studentChoice]['name']); + $content .= get_lang($new_options[$studentChoice]['name']); } else { - echo '-'; + $content .= '-'; } echo ' | '; // Expected choice if (!$hide_expected_answer) { if (isset($new_options[$answerCorrect])) { - echo get_lang($new_options[$answerCorrect]['name']); + $content .= get_lang($new_options[$answerCorrect]['name']); } else { - echo '-'; + $content .= '-'; } } else { - echo '-'; + $content .= '-'; } - echo ' | '; - echo $answer; - echo ' | '; + $content .= ''; + $content .= $answer; + $content .= ' | '; if ($exercise->showExpectedChoice()) { $status = Display::label(get_lang('Incorrect'), 'danger'); if (isset($new_options[$studentChoice])) { @@ -501,31 +495,35 @@ class ExerciseShowFunctions $status = Display::label(get_lang('Correct'), 'success'); } } - echo ''; - echo $status; - echo ' | '; + $content .= ''; + $content .= $status; + $content .= ' | '; } - if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { - echo ''; - $color = "black"; + if ($feedbackType != EXERCISE_FEEDBACK_TYPE_EXAM) { + if ($resultsDisabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) { + if ($studentChoice != $answerCorrect) { + return ''; + } + } + $content .= ' | '; + $color = 'black'; if (isset($new_options[$studentChoice])) { if ($studentChoice == $answerCorrect) { - $color = "green"; + $color = 'green'; } if ($hide_expected_answer) { $color = ''; } - echo ''.nl2br($answerComment).''; - } - echo ' | '; - if ($ans == 1) { - $comm = Event::get_comments($id, $questionId); + $content .= ''.nl2br($answerComment).''; } + $content .= ''; } else { - echo ''; + $content .= ' | '; } - echo ' | '; echo $answer; echo ' | '; - echo $newOptions[$studentChoiceDegree]['name']; + if (isset($newOptions[$studentChoiceDegree])) { + echo $newOptions[$studentChoiceDegree]['name']; + } echo ' | '; $degreeInfo = $question->getResponseDegreeInfo( @@ -628,7 +628,7 @@ class ExerciseShowFunctions */ public static function display_multiple_answer_combination_true_false( $exercise, - $feedback_type, + $feedbackType, $answerType, $studentChoice, $answer, @@ -643,7 +643,7 @@ class ExerciseShowFunctions $hide_expected_answer = false; switch ($resultsDisabled) { case RESULT_DISABLE_SHOW_SCORE_ONLY: - if ($feedback_type == 0) { + if ($feedbackType == 0) { $hide_expected_answer = true; } break; @@ -694,7 +694,7 @@ class ExerciseShowFunctions echo ''; } - if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { + if ($feedbackType != EXERCISE_FEEDBACK_TYPE_EXAM) { echo '';
//@todo replace this harcoded value
if ($studentChoice) {
@@ -718,21 +718,21 @@ class ExerciseShowFunctions
}
/**
- * @param $feedback_type
+ * @param $feedbackType
* @param $exe_id
* @param $questionId
* @param null $questionScore
* @param int $resultsDisabled
*/
public static function displayAnnotationAnswer(
- $feedback_type,
+ $feedbackType,
$exe_id,
$questionId,
$questionScore = null,
$resultsDisabled = 0
) {
$comments = Event::get_comments($exe_id, $questionId);
- if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
+ if ($feedbackType != EXERCISE_FEEDBACK_TYPE_EXAM) {
if ($questionScore <= 0 && empty($comments)) {
echo ' '.ExerciseLib::getNotCorrectedYetText(); } diff --git a/main/inc/lib/extra_field.lib.php b/main/inc/lib/extra_field.lib.php index d83ee253fe..b4303ececc 100755 --- a/main/inc/lib/extra_field.lib.php +++ b/main/inc/lib/extra_field.lib.php @@ -1771,7 +1771,8 @@ class ExtraField extends Model $form->addGeoLocationMapField( 'extra_'.$field_details['variable'], $field_details['display_text'], - $dataValue + $dataValue, + $hideGeoLocalizationDetails ); /*$form->addElement( diff --git a/main/inc/lib/groupmanager.lib.php b/main/inc/lib/groupmanager.lib.php index 7cb9280e13..4bb1b02fec 100755 --- a/main/inc/lib/groupmanager.lib.php +++ b/main/inc/lib/groupmanager.lib.php @@ -66,9 +66,11 @@ class GroupManager } /** + * @param int $courseId + * * @return array */ - public static function get_groups($courseId = null) + public static function get_groups($courseId = 0) { $table_group = Database::get_course_table(TABLE_GROUP); $courseId = !empty($courseId) ? (int) $courseId : api_get_course_int_id(); @@ -189,7 +191,7 @@ class GroupManager $course_id = $_course['real_id']; $currentCourseRepository = $_course['path']; $category = self::get_category($category_id); - $places = intval($places); + $places = (int) $places; // Default values $docState = self::TOOL_PRIVATE; @@ -247,7 +249,7 @@ class GroupManager self_registration_allowed = '".$selfRegAllowed."', self_unregistration_allowed = '".$selfUnregAllwoed."', $documentCondition - session_id='".intval($session_id)."'"; + session_id='".$session_id."'"; Database::query($sql); $lastId = Database::insert_id(); @@ -387,27 +389,31 @@ class GroupManager /** * Create a group for every class subscribed to the current course. * - * @param int $category_id The category in which the groups should be created + * @param int $categoryId The category in which the groups should be created * * @return array */ - public static function create_class_groups($category_id) + public static function create_class_groups($categoryId) { - $options['where'] = [" usergroup.course_id = ? " => api_get_course_int_id()]; + $options['where'] = [' usergroup.course_id = ? ' => api_get_course_int_id()]; $obj = new UserGroup(); $classes = $obj->getUserGroupInCourse($options); $group_ids = []; + foreach ($classes as $class) { - $users_ids = $obj->get_users_by_usergroup($class['id']); - $group_id = self::create_group( + $userList = $obj->get_users_by_usergroup($class['id']); + $groupId = self::create_group( $class['name'], - $category_id, + $categoryId, 0, - count($users_ids) + null ); - $groupInfo = self::get_group_properties($group_id); - self::subscribe_users($users_ids, $groupInfo); - $group_ids[] = $group_id; + + if ($groupId) { + $groupInfo = self::get_group_properties($groupId); + self::subscribe_users($userList, $groupInfo); + $group_ids[] = $groupId; + } } return $group_ids; @@ -544,17 +550,19 @@ class GroupManager public static function get_group_properties($group_id, $useIid = false) { $course_id = api_get_course_int_id(); - if (empty($group_id) || !is_int(intval($group_id))) { + $group_id = (int) $group_id; + + if (empty($group_id)) { return null; } $table_group = Database::get_course_table(TABLE_GROUP); $sql = "SELECT * FROM $table_group - WHERE c_id = $course_id AND id = ".intval($group_id); + WHERE c_id = $course_id AND id = ".$group_id; if ($useIid) { $sql = "SELECT * FROM $table_group - WHERE c_id = $course_id AND iid = ".intval($group_id); + WHERE c_id = $course_id AND iid = ".$group_id; } $db_result = Database::query($sql); $db_object = Database::fetch_object($db_result); @@ -642,7 +650,7 @@ class GroupManager return []; } $name = Database::escape_string($name); - $courseId = intval($courseId); + $courseId = (int) $courseId; $table_group = Database::get_course_table(TABLE_GROUP); $sql = "SELECT * FROM $table_group WHERE c_id = $courseId AND name LIKE '%$name%'"; @@ -698,8 +706,8 @@ class GroupManager ) { $table_group = Database::get_course_table(TABLE_GROUP); $table_forum = Database::get_course_table(TABLE_FORUM); - $categoryId = intval($categoryId); - $group_id = intval($group_id); + $categoryId = (int) $categoryId; + $group_id = (int) $group_id; $courseId = api_get_course_int_id(); $allowDocumentAccess = api_get_configuration_value('group_document_access'); @@ -723,7 +731,7 @@ class GroupManager self_registration_allowed = '".Database::escape_string($selfRegistrationAllowed)."', self_unregistration_allowed = '".Database::escape_string($selfUnRegistrationAllowed)."', $documentCondition - category_id = ".intval($categoryId)." + category_id = ".$categoryId." WHERE c_id = $courseId AND id=".$group_id; $result = Database::query($sql); @@ -1051,7 +1059,7 @@ class GroupManager $documentAccess ) { $table = Database::get_course_table(TABLE_GROUP_CATEGORY); - $id = intval($id); + $id = (int) $id; $courseId = api_get_course_int_id(); @@ -1544,9 +1552,10 @@ class GroupManager public static function is_self_registration_allowed($user_id, $groupInfo) { $course_id = api_get_course_int_id(); - if (!$user_id > 0) { + if (empty($user_id)) { return false; } + $groupIid = $groupInfo['iid']; $table = Database::get_course_table(TABLE_GROUP); if (isset($groupIid)) { @@ -1576,7 +1585,7 @@ class GroupManager */ public static function is_self_unregistration_allowed($user_id, $groupInfo) { - if (!$user_id > 0 || empty($groupInfo)) { + if (empty($user_id) || empty($groupInfo)) { return false; } $groupIid = $groupInfo['iid']; @@ -1917,7 +1926,7 @@ class GroupManager return false; } - if (!empty($groupId) > 0) { + if (!empty($groupId)) { $table_group_tutor = Database::get_course_table(TABLE_GROUP_TUTOR); $sql = "DELETE FROM $table_group_tutor WHERE group_id = $groupId AND c_id = $courseId"; @@ -3129,7 +3138,7 @@ class GroupManager case self::DOCUMENT_MODE_SHARE: // Default chamilo behaviour // Student can upload his own content, cannot modify another content. - $isMember = GroupManager::is_subscribed($userId, $groupInfo); + $isMember = self::is_subscribed($userId, $groupInfo); if ($isMember) { // No document to check, allow access to document feature. if (empty($documentInfoToBeCheck)) { diff --git a/main/inc/lib/javascript/hotspot/js/hotspot.js b/main/inc/lib/javascript/hotspot/js/hotspot.js index e64c80efc2..09d2e55312 100755 --- a/main/inc/lib/javascript/hotspot/js/hotspot.js +++ b/main/inc/lib/javascript/hotspot/js/hotspot.js @@ -764,11 +764,9 @@ window.HotspotQuestion = (function () { default: hotspot = SquareModel.decode(hotspotInfo); break; - case 'circle': hotspot = EllipseModel.decode(hotspotInfo); break; - case 'poly': hotspot = PolygonModel.decode(hotspotInfo); break; @@ -891,9 +889,7 @@ window.HotspotQuestion = (function () { }) .on('mousedown', 'circle, text', function (e) { e.preventDefault(); - isMoving = true; - if (e.target.tagName === 'circle') { //Hack to move correctly the hot spots if there are more than one HS question in same page answerIndex = $(e.target).next().html(); @@ -1141,16 +1137,14 @@ window.HotspotQuestion = (function () { modifyAnswers: parseInt(config.questionId) }); break; - case 'user': xhrQuestion = $.getJSON(config.relPath + 'exercise/hotspot_actionscript.as.php?' + _p.web_cid_query, { modifyAnswers: parseInt(config.questionId), exe_id: parseInt(config.exerciseId) }); break; - case 'solution': - //no break + //no break case 'preview': xhrQuestion = $.getJSON(config.relPath + 'exercise/hotspot_answers.as.php?' + _p.web_cid_query, { modifyAnswers: parseInt(config.questionId), diff --git a/main/inc/lib/social.lib.php b/main/inc/lib/social.lib.php index 92baa58487..ec9fcdfe91 100755 --- a/main/inc/lib/social.lib.php +++ b/main/inc/lib/social.lib.php @@ -1826,13 +1826,17 @@ class SocialManager extends UserManager $formattedList .= ''; $formattedList .= ' ';
- $formattedList .= '';
$formattedList .= ' ';
@@ -3169,10 +3173,10 @@ class SocialManager extends UserManager
$html .= '';
$html .= $iconStatus;
$html .= ' ';
$html .= ''.$nameCompleteAuthor.''.$htmlReceiver.' ';
- $html .= ''.$date.' ';
+ $html .= ''.$date.' ';
$html .= '';
- $html .= ' |