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

pull/2858/head
Angel Fernando Quiroz Campos 7 years ago
commit a7d6271897
  1. 27
      app/Resources/public/css/base.css
  2. 69
      main/exercise/exercise.class.php
  3. 7
      main/exercise/exercise_show.php
  4. 6
      main/exercise/fill_blanks.class.php
  5. 30
      main/exercise/hotspot_answers.as.php
  6. 1
      main/exercise/matching.class.php
  7. 9
      main/exercise/overview.php
  8. 14
      main/exercise/question.class.php
  9. 60
      main/group/group_creation.php
  10. 2
      main/inc/lib/chat.lib.php
  11. 2
      main/inc/lib/display.lib.php
  12. 15
      main/inc/lib/exercise.lib.php
  13. 176
      main/inc/lib/exercise_show_functions.lib.php
  14. 3
      main/inc/lib/extra_field.lib.php
  15. 59
      main/inc/lib/groupmanager.lib.php
  16. 8
      main/inc/lib/javascript/hotspot/js/hotspot.js
  17. 14
      main/inc/lib/social.lib.php
  18. 11
      src/Chamilo/CoreBundle/Component/Editor/Driver/CourseDriver.php

@ -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 {

@ -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 '</tr>';
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,

@ -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;

@ -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] : '';
}

@ -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()) {

@ -291,6 +291,7 @@ class Matching extends Question
$header .= '<th>'.get_lang('ExpectedChoice').'</th>';
$header .= '<th>'.get_lang('Status').'</th>';
} else {
$header .= '<th>'.get_lang('YourChoice').'</th>';
$header .= '<th>'.get_lang('CorrespondsTo').'</th>';
}
$header .= '</tr>';

@ -52,7 +52,7 @@ $interbreadcrumb[] = [
'url' => 'exercise.php?'.api_get_cidreq(),
'name' => get_lang('Exercises'),
];
$interbreadcrumb[] = ["url" => "#", "name" => $objExercise->selectTitle(true)];
$interbreadcrumb[] = ['url' => '#', 'name' => $objExercise->selectTitle(true)];
$time_control = false;
$clock_expired_time = ExerciseLib::get_session_time_control_key($objExercise->id, $learnpath_id, $learnpath_item_id);
@ -210,10 +210,7 @@ if (in_array(
if (!empty($attempts)) {
$i = $counter;
foreach ($attempts as $attempt_result) {
$score = ExerciseLib::show_score(
$attempt_result['exe_result'],
$attempt_result['exe_weighting']
);
$score = ExerciseLib::show_score($attempt_result['exe_result'], $attempt_result['exe_weighting']);
$attempt_url = api_get_path(WEB_CODE_PATH).'exercise/result.php?';
$attempt_url .= api_get_cidreq().'&show_headers=1&';
$attempt_url .= http_build_query([
@ -254,6 +251,7 @@ if (!empty($attempts)) {
RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT,
RESULT_DISABLE_DONT_SHOW_SCORE_ONLY_IF_USER_FINISHES_ATTEMPTS_SHOW_ALWAYS_FEEDBACK,
RESULT_DISABLE_RANKING,
RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER
]
)) {
$row['result'] = $score;
@ -267,6 +265,7 @@ if (!empty($attempts)) {
RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT,
RESULT_DISABLE_DONT_SHOW_SCORE_ONLY_IF_USER_FINISHES_ATTEMPTS_SHOW_ALWAYS_FEEDBACK,
RESULT_DISABLE_RANKING,
RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER
]
) || (
$objExercise->results_disabled == RESULT_DISABLE_SHOW_SCORE_ONLY &&

@ -1980,20 +1980,20 @@ abstract class Question
if (!empty($counter)) {
$counterLabel = (int) $counter;
}
$score_label = get_lang('Wrong');
$scoreLabel = get_lang('Wrong');
$class = 'error';
if (isset($score['pass']) && $score['pass'] == true) {
$score_label = get_lang('Correct');
$scoreLabel = get_lang('Correct');
$class = 'success';
}
if (in_array($this->type, [FREE_ANSWER, ORAL_EXPRESSION, ANNOTATION])) {
$score['revised'] = isset($score['revised']) ? $score['revised'] : false;
if ($score['revised'] == true) {
$score_label = get_lang('Revised');
$scoreLabel = get_lang('Revised');
$class = '';
} else {
$score_label = get_lang('NotRevised');
$scoreLabel = get_lang('NotRevised');
$class = 'warning';
if (isset($score['weight'])) {
$weight = float_format($score['weight'], 1);
@ -2029,7 +2029,10 @@ abstract class Question
// dont display score for certainty degree questions
if ($this->type != MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) {
if (isset($score['result'])) {
$header .= $exercise->getQuestionRibbon($class, $score_label, $score['result'], $scoreCurrent);
if ($exercise->results_disabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
$score['result'] = null;
}
$header .= $exercise->getQuestionRibbon($class, $scoreLabel, $score['result'], $scoreCurrent);
}
}
@ -2070,6 +2073,7 @@ abstract class Question
}
/**
* @deprecated
* Create a question from a set of parameters.
*
* @param int Quiz ID

@ -254,31 +254,43 @@ EOT;
/*
* Show form to generate subgroups
*/
if (api_get_setting('allow_group_categories') === 'true' && count(GroupManager :: get_group_list()) > 0) {
$base_group_options = [];
$groups = GroupManager :: get_group_list();
foreach ($groups as $index => $group) {
$number_of_students = GroupManager :: number_of_students($group['id']);
if ($number_of_students > 0) {
$base_group_options[$group['id']] = $group['name'].' ('.$number_of_students.' '.get_lang('Users').')';
if (api_get_setting('allow_group_categories') === 'true') {
$groups = GroupManager::get_group_list();
if (!empty($groups)) {
$base_group_options = [];
foreach ($groups as $index => $group) {
$number_of_students = GroupManager::number_of_students($group['id']);
if ($number_of_students > 0) {
$base_group_options[$group['id']] =
$group['name'].' ('.$number_of_students.' '.get_lang('Users').')';
}
}
if (count($base_group_options) > 0) {
$create_subgroups_form = new FormValidator(
'create_subgroups',
'post',
api_get_self().'?'.api_get_cidreq()
);
$create_subgroups_form->addElement('header', get_lang('CreateSubgroups'));
$create_subgroups_form->addElement('html', get_lang('CreateSubgroupsInfo'));
$create_subgroups_form->addElement('hidden', 'action');
$group_el = [];
$group_el[] = $create_subgroups_form->createElement(
'static',
null,
null,
get_lang('CreateNumberOfGroups')
);
$group_el[] = $create_subgroups_form->createElement('text', 'number_of_groups', null, ['size' => 3]);
$group_el[] = $create_subgroups_form->createElement('static', null, null, get_lang('WithUsersFrom'));
$group_el[] = $create_subgroups_form->createElement('select', 'base_group', null, $base_group_options);
$group_el[] = $create_subgroups_form->addButtonSave(get_lang('Ok'), 'submit', true);
$create_subgroups_form->addGroup($group_el, 'create_groups', null, null, false);
$defaults = [];
$defaults['action'] = 'create_subgroups';
$create_subgroups_form->setDefaults($defaults);
$create_subgroups_form->display();
}
}
if (count($base_group_options) > 0) {
$create_subgroups_form = new FormValidator('create_subgroups', 'post', api_get_self().'?'.api_get_cidreq());
$create_subgroups_form->addElement('header', get_lang('CreateSubgroups'));
$create_subgroups_form->addElement('html', get_lang('CreateSubgroupsInfo'));
$create_subgroups_form->addElement('hidden', 'action');
$group_el = [];
$group_el[] = $create_subgroups_form->createElement('static', null, null, get_lang('CreateNumberOfGroups'));
$group_el[] = $create_subgroups_form->createElement('text', 'number_of_groups', null, ['size' => 3]);
$group_el[] = $create_subgroups_form->createElement('static', null, null, get_lang('WithUsersFrom'));
$group_el[] = $create_subgroups_form->createElement('select', 'base_group', null, $base_group_options);
$group_el[] = $create_subgroups_form->addButtonSave(get_lang('Ok'), 'submit', true);
$create_subgroups_form->addGroup($group_el, 'create_groups', null, null, false);
$defaults = [];
$defaults['action'] = 'create_subgroups';
$create_subgroups_form->setDefaults($defaults);
$create_subgroups_form->display();
}
}

@ -323,7 +323,7 @@ class Chat extends Model
$_SESSION['openChatBoxes'][$fromUserId] = api_strtotime($chat['sent'], 'UTC');
}
$chatHistory[$fromUserId] = [
$chatHistory[$fromUserId] = [
'window_user_info' => $userInfo,
'total_messages' => $count,
'items' => $chatItems,

@ -2786,7 +2786,7 @@ HTML;
case 'jpeg':
case 'gif':
case 'png':
$content = '<img width="400px" src="'.$fileUrl.'" />';
$content = '<img class="img-responsive" src="'.$fileUrl.'" />';
break;
default:
//$html = self::url($data['basename'], $fileUrl);

@ -4429,6 +4429,10 @@ EOT;
$show_results = true;
}
if ($objExercise->results_disabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
$show_results = true;
}
if (in_array(
$objExercise->results_disabled,
[
@ -4654,14 +4658,18 @@ EOT;
$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' => self::show_score(
$my_total_score,
$my_total_weight,
false,
true
false
),
'pass' => $my_total_score >= $my_total_weight ? true : false,
'pass' => $scorePassed,
'score' => $my_total_score,
'weight' => $my_total_weight,
'comments' => $comnt,
@ -4683,7 +4691,6 @@ EOT;
$question_content = '';
if ($show_results) {
$question_content = '<div class="question_row_answer">';
if ($showQuestionScore == false) {
$score = [];
}

@ -57,11 +57,6 @@ class ExerciseShowFunctions
echo '<tr><td>';
echo Security::remove_XSS($answerHTML, COURSEMANAGERLOWSECURITY);
echo '</td>';
if (!api_is_allowed_to_edit(null, true) && $feedbackType != EXERCISE_FEEDBACK_TYPE_EXAM) {
echo '<td>';
$comm = Event::get_comments($id, $questionId);
echo '</td>';
}
echo '</tr>';
}
}
@ -103,11 +98,6 @@ class ExerciseShowFunctions
echo '</td><td>';
echo Security::remove_XSS($status);
echo '</td>';
if (!api_is_allowed_to_edit(null, true) && $feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
echo '<td>';
$comm = Event::get_comments($id, $questionId);
echo '</td>';
}
echo '</tr>';
}
} else {
@ -116,11 +106,6 @@ class ExerciseShowFunctions
} else {
echo '<tr><td>';
echo Security::remove_XSS($answer);
if (!api_is_allowed_to_edit(null, true) && $feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
echo '<td>';
$comm = Event::get_comments($id, $questionId);
echo '</td>';
}
echo '</tr>';
}
}
@ -254,55 +239,62 @@ class ExerciseShowFunctions
}
$hotspot_colors = [
"", // $i starts from 1 on next loop (ugly fix)
"#4271B5",
"#FE8E16",
"#45C7F0",
"#BCD631",
"#D63173",
"#D7D7D7",
"#90AFDD",
"#AF8640",
"#4F9242",
"#F4EB24",
"#ED2024",
"#3B3B3B",
"#F7BDE2",
'', // $i starts from 1 on next loop (ugly fix)
'#4271B5',
'#FE8E16',
'#45C7F0',
'#BCD631',
'#D63173',
'#D7D7D7',
'#90AFDD',
'#AF8640',
'#4F9242',
'#F4EB24',
'#ED2024',
'#3B3B3B',
'#F7BDE2',
];
echo '<table class="data_table"><tr>';
echo '<td class="text-center" width="5%">';
echo '<span class="fa fa-square fa-fw fa-2x" aria-hidden="true" style="color:'.
$content = '<table class="data_table"><tr>';
$content .= '<td class="text-center" width="5%">';
$content .= '<span class="fa fa-square fa-fw fa-2x" aria-hidden="true" style="color:'.
$hotspot_colors[$orderColor].'"></span>';
echo '</td>';
echo '<td class="text-left" width="25%">';
echo "$answerId - $answer";
echo '</td>';
echo '<td class="text-left" width="10%">';
$content .= '</td>';
$content .= '<td class="text-left" width="25%">';
$content .= "$answerId - $answer";
$content .= '</td>';
$content .= '<td class="text-left" width="10%">';
if (!$hide_expected_answer) {
$status = Display::label(get_lang('Incorrect'), 'danger');
if ($studentChoice) {
$status = Display::label(get_lang('Correct'), 'success');
} else {
if ($resultsDisabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
return '';
}
}
echo $status;
$content .= $status;
}
echo '</td>';
$content .= '</td>';
if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
echo '<td class="text-left" width="60%">';
$content .= '<td class="text-left" width="60%">';
if ($studentChoice) {
echo '<span style="font-weight: bold; color: #008000;">'.nl2br($answerComment).'</span>';
$content .= '<span style="font-weight: bold; color: #008000;">'.nl2br($answerComment).'</span>';
}
echo '</td>';
$content .= '</td>';
} else {
echo '<td class="text-left" width="60%">&nbsp;</td>';
$content .= '<td class="text-left" width="60%">&nbsp;</td>';
}
echo '</tr>';
$content .= '</tr>';
echo $content;
}
/**
* Display the answers to a multiple choice question.
*
* @param Exercise $exercise
* @param int $feedback_type Feedback type
* @param int $feedbackType Feedback type
* @param int $answerType Answer type
* @param int $studentChoice Student choice
* @param string $answer Textual answer
@ -317,7 +309,7 @@ class ExerciseShowFunctions
*/
public static function display_unique_or_multiple_answer(
$exercise,
$feedback_type,
$feedbackType,
$answerType,
$studentChoice,
$answer,
@ -342,15 +334,22 @@ class ExerciseShowFunctions
$answer = str_replace($tags, '', $answer);
}
$studentChoiceInt = (int) $studentChoice;
$answerCorrectChoice = (int) $answerCorrect;
$hide_expected_answer = false;
switch ($resultsDisabled) {
case RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER:
if ($studentChoiceInt !== $answerCorrectChoice) {
return '';
}
if (!$answerCorrect) {
$hide_expected_answer = true;
return '';
}
break;
case RESULT_DISABLE_SHOW_SCORE_ONLY:
if ($feedback_type == 0) {
if ($feedbackType == 0) {
$hide_expected_answer = true;
}
break;
@ -384,14 +383,8 @@ class ExerciseShowFunctions
echo '</td>';
if ($exercise->showExpectedChoice()) {
/*$status = Display::label(get_lang('Incorrect'), 'danger');
if ($studentChoice && $answerCorrect) {
$status = Display::label(get_lang('Correct'), 'success');
}*/
$studentChoiceChoice = (int) $studentChoice;
$answerCorrectChoice = (int) $answerCorrect;
$status = Display::label(get_lang('Incorrect'), 'danger');
if ($studentChoiceChoice === $answerCorrectChoice) {
if ($studentChoiceInt === $answerCorrectChoice) {
$status = Display::label(get_lang('Correct'), 'success');
}
echo '<td width="20%">';
@ -399,7 +392,7 @@ class ExerciseShowFunctions
echo '</td>';
}
if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
if ($feedbackType != EXERCISE_FEEDBACK_TYPE_EXAM) {
echo '<td width="20%">';
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 '<tr><td width="5%">';
$content = '<tr><td width="5%">';
$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 '</td><td width="5%">';
// 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 '</td><td width="40%">';
echo $answer;
echo '</td>';
$content .= '</td><td width="40%">';
$content .= $answer;
$content .= '</td>';
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 '<td width="20%">';
echo $status;
echo '</td>';
$content .= '<td width="20%">';
$content .= $status;
$content .= '</td>';
}
if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
echo '<td width="20%">';
$color = "black";
if ($feedbackType != EXERCISE_FEEDBACK_TYPE_EXAM) {
if ($resultsDisabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
if ($studentChoice != $answerCorrect) {
return '';
}
}
$content .= '<td width="20%">';
$color = 'black';
if (isset($new_options[$studentChoice])) {
if ($studentChoice == $answerCorrect) {
$color = "green";
$color = 'green';
}
if ($hide_expected_answer) {
$color = '';
}
echo '<span style="font-weight: bold; color: '.$color.';">'.nl2br($answerComment).'</span>';
}
echo '</td>';
if ($ans == 1) {
$comm = Event::get_comments($id, $questionId);
$content .= '<span style="font-weight: bold; color: '.$color.';">'.nl2br($answerComment).'</span>';
}
$content .= '</td>';
} else {
echo '<td>&nbsp;</td>';
$content .= '<td>&nbsp;</td>';
}
echo '</tr>';
$content .= '</tr>';
echo $content;
}
/**
@ -582,7 +580,9 @@ class ExerciseShowFunctions
echo '</td><td width="20%">';
echo $answer;
echo '</td><td width="5%" style="text-align:center;">';
echo $newOptions[$studentChoiceDegree]['name'];
if (isset($newOptions[$studentChoiceDegree])) {
echo $newOptions[$studentChoiceDegree]['name'];
}
echo '</td>';
$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 '</td>';
}
if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
if ($feedbackType != EXERCISE_FEEDBACK_TYPE_EXAM) {
echo '<td width="20%">';
//@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 '<br />'.ExerciseLib::getNotCorrectedYetText();
}

@ -1771,7 +1771,8 @@ class ExtraField extends Model
$form->addGeoLocationMapField(
'extra_'.$field_details['variable'],
$field_details['display_text'],
$dataValue
$dataValue,
$hideGeoLocalizationDetails
);
/*$form->addElement(

@ -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)) {

@ -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),

@ -1826,13 +1826,17 @@ class SocialManager extends UserManager
$formattedList .= '</div>';
$formattedList .= '<div class="mediapost-form">';
$formattedList .= '<form id = "form_comment_'.$messageId.'" name="post_comment" method="POST">
$formattedList .= '<form class="form-horizontal" id="form_comment_'.$messageId.'" name="post_comment" method="POST">
<div class="col-sm-9">
<label for="comment" class="hide">'.get_lang('SocialWriteNewComment').'</label>
<input type="hidden" name = "messageId" value="'.$messageId.'" />
<textarea placeholder="'.get_lang('SocialWriteNewComment').'" name="comment" rows="1" style="width:80%;" ></textarea>
<a onclick="submitComment('.$messageId.');" href="javascript:void(0);" name="social_wall_new_msg_submit" class="pull-right btn btn-default">
<textarea rows="3" class="form-control" placeholder="'.get_lang('SocialWriteNewComment').'" name="comment" rows="1" ></textarea>
</div>
<div class="col-sm-3">
<a onclick="submitComment('.$messageId.');" href="javascript:void(0);" name="social_wall_new_msg_submit" class="btn btn-default btn-post">
<em class="fa fa-pencil"></em> '.get_lang('Post').'
</a>
</div>
</form>';
$formattedList .= '</div>';
@ -3169,10 +3173,10 @@ class SocialManager extends UserManager
$html .= '<div class="user-data">';
$html .= $iconStatus;
$html .= '<div class="username"><a href="'.$urlAuthor.'">'.$nameCompleteAuthor.'</a>'.$htmlReceiver.'</div>';
$html .= '<div>'.$date.'</div>';
$html .= '<div class="post-date">'.$date.'</div>';
$html .= '</div>';
$html .= '<div class="msg-content">';
$html .= '<div class="post-attachment" >';
$html .= '<div class="post-attachment thumbnail">';
$html .= $postAttachment;
$html .= '</div>';
$html .= '<div>'.Security::remove_XSS($message['content']).'</div>';

@ -127,6 +127,17 @@ class CourseDriver extends Driver implements DriverInterface
unset($defaultDisabled['mkdir']);
$defaultDisabled = array_flip($defaultDisabled);
$config['disabled'] = $defaultDisabled;
} else {
$protectedFolders = \DocumentManager::getProtectedFolderFromStudent();
foreach ($protectedFolders as $folder) {
$config['attributes'][] = [
'pattern' => $folder.'/',
'read' => false,
'write' => false,
'hidden' => true,
'locked' => false,
];
}
}
$foldersToHide = \DocumentManager::get_all_document_folders(

Loading…
Cancel
Save