Internal: Update from 1.11.x

pull/3451/head
Julio Montoya 4 years ago
parent 5f79f57ca2
commit 39b35e39fe
  1. 153
      public/main/announcements/announcements.php
  2. 6
      public/main/cron/scheduled_announcement.php
  3. 1
      public/main/inc/ajax/work.ajax.php
  4. 101
      public/main/inc/lib/exercise.lib.php
  5. 129
      public/main/inc/lib/extra_field.lib.php
  6. 8
      public/main/inc/lib/extra_field_value.lib.php
  7. 50
      public/main/work/work.lib.php

@ -610,8 +610,12 @@ switch ($action) {
false,
['ToolbarSet' => 'Announcements']
);
$form->addElement('file', 'user_upload', get_lang('Add attachment'));
$form->addElement('textarea', 'file_comment', get_lang('File comment'));
if (!$announcementAttachmentIsDisabled) {
$form->addElement('file', 'user_upload', get_lang('AddAnAttachment'));
$form->addElement('textarea', 'file_comment', get_lang('FileComment'));
}
$form->addHidden('sec_token', $token);
if (empty($sessionId)) {
@ -651,32 +655,93 @@ switch ($action) {
$data['users'] = isset($data['users']) ? $data['users'] : [];
$sendToUsersInSession = isset($data['send_to_users_in_session']) ? true : false;
$sendMeCopy = isset($data['send_me_a_copy_by_email']) ? true : false;
if (isset($id) && $id) {
// there is an Id => the announcement already exists => update mode
if (Security::check_token('post')) {
$file_comment = $_POST['file_comment'];
$file = $_FILES['user_upload'];
$file_comment = $announcementAttachmentIsDisabled ? null : $_POST['file_comment'];
$file = $announcementAttachmentIsDisabled ? [] : $_FILES['user_upload'];
$announcement = AnnouncementManager::edit_announcement(
$id,
$data['title'],
$data['content'],
$data['users'],
$file,
$file_comment,
$sendToUsersInSession
);
// Send mail
$messageSentTo = [];
if (isset($_POST['email_ann']) && empty($_POST['onlyThoseMails'])) {
$messageSentTo = AnnouncementManager::sendEmail(
api_get_course_info(),
api_get_session_id(),
$announcement,
$sendToUsersInSession,
isset($data['send_to_hrm_users'])
);
}
if ($sendMeCopy && !in_array(api_get_user_id(), $messageSentTo)) {
$email = new AnnouncementEmail(api_get_course_info(), api_get_session_id(), $announcement);
$email->sendAnnouncementEmailToMySelf();
}
Display::addFlash(
Display::return_message(
get_lang('Announcement has been modified'),
'success'
)
);
Security::clear_token();
header('Location: '.$homeUrl);
exit;
} else {
// Insert mode
$file = $_FILES['user_upload'];
$file_comment = $data['file_comment'];
$announcement = AnnouncementManager::edit_announcement(
$id,
if (empty($group_id)) {
$announcement = AnnouncementManager::add_announcement(
api_get_course_info(),
api_get_session_id(),
$data['title'],
$data['content'],
$data['users'],
$file,
$file_comment,
null,
$sendToUsersInSession
);
} else {
$announcement = AnnouncementManager::addGroupAnnouncement(
$data['title'],
$data['content'],
$group_id,
$data['users'],
$file,
$file_comment,
$sendToUsersInSession
);
}
if ($announcement) {
Display::addFlash(
Display::return_message(
get_lang('Announcement has been added'),
'success'
)
);
// Send mail
$messageSentTo = [];
if (isset($_POST['email_ann']) && empty($_POST['onlyThoseMails'])) {
if (isset($data['email_ann']) && $data['email_ann']) {
$messageSentTo = AnnouncementManager::sendEmail(
api_get_course_info(),
api_get_session_id(),
$announcement,
$sendToUsersInSession,
isset($data['send_to_hrm_users'])
$sendToUsersInSession
);
}
@ -685,76 +750,12 @@ switch ($action) {
$email->sendAnnouncementEmailToMySelf();
}
Display::addFlash(
Display::return_message(
get_lang('Announcement has been modified'),
'success'
)
);
Security::clear_token();
header('Location: '.$homeUrl);
exit;
}
} else {
// Insert mode
if (Security::check_token('post')) {
$file = $_FILES['user_upload'];
$file_comment = $data['file_comment'];
if (empty($group_id)) {
$announcement = AnnouncementManager::add_announcement(
api_get_course_info(),
api_get_session_id(),
$data['title'],
$data['content'],
$data['users'],
$file,
$file_comment,
null,
$sendToUsersInSession
);
} else {
$announcement = AnnouncementManager::addGroupAnnouncement(
$data['title'],
$data['content'],
$group_id,
$data['users'],
$file,
$file_comment,
$sendToUsersInSession
);
}
if ($announcement) {
Display::addFlash(
Display::return_message(
get_lang('Announcement has been added'),
'success'
)
);
api_not_allowed(true);
// Send mail
$messageSentTo = [];
if (isset($data['email_ann']) && $data['email_ann']) {
$messageSentTo = AnnouncementManager::sendEmail(
api_get_course_info(),
api_get_session_id(),
$announcement,
$sendToUsersInSession
);
}
if ($sendMeCopy && !in_array(api_get_user_id(), $messageSentTo)) {
$email = new AnnouncementEmail(api_get_course_info(), api_get_session_id(), $announcement);
$email->sendAnnouncementEmailToMySelf();
}
Security::clear_token();
header('Location: '.$homeUrl);
exit;
}
api_not_allowed(true);
} // end condition token
}
}
$content = $form->returnForm();

@ -5,10 +5,10 @@ require_once __DIR__.'/../inc/global.inc.php';
$urlList = UrlManager::get_url_data();
foreach ($urlList as $url) {
// Set access_url to set correct paths.
$_configuration['access_url'] = $url['id'];
$urlId = $url['id'];
$_configuration['access_url'] = $urlId;
echo "Portal: # ".$url['id']." - ".$url['url'].'-'.api_get_path(WEB_CODE_PATH).PHP_EOL;
$object = new ScheduledAnnouncement();
$messagesSent = $object->sendPendingMessages($url['id']);
$messagesSent = $object->sendPendingMessages($urlId);
echo "Messages sent $messagesSent".PHP_EOL;
}

@ -1,6 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Responses to AJAX calls.
*/

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
@ -120,7 +121,6 @@ class ExerciseLib
// suggestions here, for the sake of comprehensions, while the ones
// on the right side are called answers
$num_suggestions = 0;
switch ($answerType) {
case MATCHING:
case DRAGGABLE:
@ -151,9 +151,7 @@ class ExerciseLib
// options (A, B, C, ...) that will be put into the list-box
// have the "correct" field set to 0 because they are answer
$cpt1[$x] = $letter;
$answer_matching[$x] = $objAnswerTmp->selectAnswerByAutoId(
$numAnswer
);
$answer_matching[$x] = $objAnswerTmp->selectAnswerByAutoId($numAnswer);
$x++;
$letter++;
}
@ -176,7 +174,6 @@ class ExerciseLib
$user_choice_array_position[$item['position']] = $item['answer'];
}
}
$num_suggestions = ($nbrAnswers - $x) + 1;
break;
case FREE_ANSWER:
@ -523,7 +520,9 @@ class ExerciseLib
}
}
$answer = Security::remove_XSS($answer, STUDENT);
if ($answerType != UNIQUE_ANSWER_IMAGE) {
$answer = Security::remove_XSS($answer, STUDENT);
}
$s .= Display::input(
'hidden',
'choice2['.$questionId.']',
@ -1150,16 +1149,18 @@ class ExerciseLib
$draggableSelectOptions = [];
$selectedValue = 0;
$selectedIndex = 0;
if ($user_choice) {
foreach ($user_choice as $chosen) {
if ($answerCorrect != $chosen['answer']) {
foreach ($user_choice as $userChoiceKey => $chosen) {
$userChoiceKey++;
if ($lines_count != $userChoiceKey) {
continue;
}
/*if ($answerCorrect != $chosen['answer']) {
continue;
}*/
$selectedValue = $chosen['answer'];
}
}
foreach ($select_items as $key => $select_item) {
$draggableSelectOptions[$select_item['id']] = $select_item['letter'];
}
@ -2641,9 +2642,7 @@ HOTSPOT;
$html = ScoreDisplay::instance()->display_score([$score, $weight], $format);
}
$html = Display::span($html, ['class' => 'score_exercise']);
return $html;
return Display::span($html, ['class' => 'score_exercise']);
}
/**
@ -2654,9 +2653,7 @@ HOTSPOT;
*/
public static function getModelStyle($model, $percentage)
{
$modelWithStyle = '<span class="'.$model['css_class'].'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>';
return $modelWithStyle;
return '<span class="'.$model['css_class'].'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>';
}
/**
@ -2723,18 +2720,18 @@ HOTSPOT;
/**
* @param float $score
* @param float $weight
* @param string $pass_percentage
* @param string $passPercentage
*
* @return bool
*/
public static function isSuccessExerciseResult($score, $weight, $pass_percentage)
public static function isSuccessExerciseResult($score, $weight, $passPercentage)
{
$percentage = float_format(
($score / (0 != $weight ? $weight : 1)) * 100,
1
);
if (isset($pass_percentage) && !empty($pass_percentage)) {
if ($percentage >= $pass_percentage) {
if (isset($passPercentage) && !empty($passPercentage)) {
if ($percentage >= $passPercentage) {
return true;
}
}
@ -3506,6 +3503,7 @@ EOT;
* @param int $exercise_id
* @param string $course_code
* @param int $session_id
* @param bool $onlyStudent Filter only enrolled students
*
* @return array
*/
@ -3513,10 +3511,12 @@ EOT;
$question_id,
$exercise_id,
$course_code,
$session_id
$session_id,
$onlyStudent = false
) {
$track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$track_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$courseUser = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$question_id = (int) $question_id;
$exercise_id = (int) $exercise_id;
@ -3526,6 +3526,30 @@ EOT;
$sql = "SELECT MAX(marks) as max, MIN(marks) as min, AVG(marks) as average
FROM $track_exercises e
";
if (true == $onlyStudent) {
$courseCondition = '';
if (empty($session_id)) {
$courseCondition = "
INNER JOIN $courseUser c
ON (
e.exe_user_id = c.user_id AND
e.c_id = c.c_id AND
c.status = ".STUDENT."
AND relation_type <> 2
)";
} else {
$courseCondition = "
INNER JOIN $courseUser c
ON (
e.exe_user_id = c.user_id AND
e.c_id = c.c_id AND
c.status = 0
)";
}
$sql .= $courseCondition;
}
$sql .= "
INNER JOIN $track_attempt a
ON (
a.exe_id = e.exe_id AND
@ -3537,7 +3561,7 @@ EOT;
a.c_id = $courseId AND
e.session_id = $session_id AND
question_id = $question_id AND
status = ''
e.status = ''
LIMIT 1";
$result = Database::query($sql);
$return = [];
@ -4112,6 +4136,7 @@ EOT;
$remainingMessage = ''
) {
$origin = api_get_origin();
$courseId = api_get_course_int_id();
$courseCode = api_get_course_id();
$sessionId = api_get_session_id();
@ -4160,7 +4185,6 @@ EOT;
$total_score = $total_weight = 0;
$exercise_content = null;
// Hide results
$show_results = false;
$show_only_score = false;
if (in_array($objExercise->results_disabled,
@ -4213,8 +4237,8 @@ EOT;
$attempts = Event::getExerciseResultsByUser(
api_get_user_id(),
$objExercise->id,
api_get_course_int_id(),
api_get_session_id(),
$courseId,
$sessionId,
$exercise_stat_info['orig_lp_id'],
$exercise_stat_info['orig_lp_item_id'],
'desc'
@ -4257,16 +4281,19 @@ EOT;
) {
// Shows exercise header
echo $objExercise->showExerciseResultHeader(
$studentInfo,
$exercise_stat_info
);
$studentInfo,
$exercise_stat_info,
$save_user_result
);
}
// Display text when test is finished #4074 and for LP #4227
$endOfMessage = $objExercise->getTextWhenFinished();
if (!empty($endOfMessage)) {
echo Display::return_message($endOfMessage, 'normal', false);
echo "<div class='clear'>&nbsp;</div>";
echo Display::div(
$endOfMessage,
['id' => 'quiz_end_message']
);
}
$question_list_answers = [];
@ -4531,10 +4558,7 @@ EOT;
'score' => $total_score,
'total' => $total_weight,
];
echo TestCategory::get_stats_table_by_attempt(
$objExercise->id,
$category_list
);
echo TestCategory::get_stats_table_by_attempt($objExercise->id, $category_list);
}
if ($show_all_but_expected_answer) {
@ -4559,7 +4583,6 @@ EOT;
}
echo $exercise_content;
if (!$show_only_score) {
echo $totalScoreText;
}
@ -4577,7 +4600,7 @@ EOT;
$objExercise->selectId(),
$total_score,
$total_weight,
api_get_session_id(),
$sessionId,
$learnpath_id,
$learnpath_item_id,
$learnpath_item_view_id,
@ -4590,7 +4613,7 @@ EOT;
$objExercise->generateStats(
$objExercise->selectId(),
api_get_course_info(),
api_get_session_id()
$sessionId
);
}
}
@ -4619,8 +4642,8 @@ EOT;
echo self::displayResultsInRanking(
$objExercise->iId,
api_get_user_id(),
api_get_course_int_id(),
api_get_session_id()
$courseId,
$sessionId
);
}

@ -2488,10 +2488,7 @@ JAVASCRIPT;
}
}
$extraFieldsAll = $this->get_all(
['visible_to_self = ? AND filter = ?' => [1, 1]],
'option_order'
);
$extraFieldsAll = $this->get_all(['visible_to_self = ? AND filter = ?' => [1, 1]], 'option_order');
$extraFieldsType = array_column($extraFieldsAll, 'field_type', 'variable');
$extraFields = array_column($extraFieldsAll, 'variable');
$filter = new stdClass();
@ -2535,7 +2532,6 @@ JAVASCRIPT;
}
$result = $this->getExtraFieldRules($filter, 'extra_', $condition);
$conditionArray = $result['condition_array'];
$whereCondition = '';
@ -2565,8 +2561,8 @@ JAVASCRIPT;
*/
public function getExtraFieldRules($filters, $stringToSearch = 'extra_', $condition = 'OR')
{
$extra_fields = [];
$condition_array = [];
$extraFields = [];
$conditionArray = [];
// Getting double select if exists
$double_select = [];
@ -2594,7 +2590,7 @@ JAVASCRIPT;
// normal fields
$field = $rule->field;
if (isset($rule->data) && is_string($rule->data) && -1 != $rule->data) {
$condition_array[] = $this->get_where_clause($field, $rule->op, $rule->data);
$conditionArray[] = $this->get_where_clause($field, $rule->op, $rule->data);
}
} else {
// Extra fields
@ -2603,7 +2599,8 @@ JAVASCRIPT;
$original_field = str_replace($stringToSearch, '', $rule->field);
$field_option = $this->get_handler_field_info_by_field_variable($original_field);
if (self::FIELD_TYPE_DOUBLE_SELECT == $field_option['field_type']) {
switch ($field_option['field_type']) {
case self::FIELD_TYPE_DOUBLE_SELECT:
if (isset($double_select[$rule->field])) {
$data = explode('#', $rule->data);
$rule->data = $data[1].'::'.$double_select[$rule->field];
@ -2616,34 +2613,47 @@ JAVASCRIPT;
}
if (!isset($rule->data)) {
$condition_array[] = ' ('
$conditionArray[] = ' ('
.$this->get_where_clause($rule->field, $rule->op, $rule->data)
.') ';
$extra_fields[] = ['field' => $rule->field, 'id' => $field_option['id']];
$extraFields[] = ['field' => $rule->field, 'id' => $field_option['id']];
}
} else {
break;
case self::FIELD_TYPE_TAG:
if (isset($rule->data)) {
if (isset($rule->data) && is_int($rule->data) && -1 == $rule->data) {
continue;
if (is_int($rule->data) && -1 == $rule->data) {
break;
}
/*var_dump($rule->data);
foreach ($rule->data as $option) {
}*/
$where = $this->get_where_clause($rule->field, $rule->op, $rule->data, 'OR');
$condition_array[] = " ( $where ) ";
$extra_fields[] = [
//$where = $this->get_where_clause($rule->field, $rule->op, $rule->data, 'OR');
//$conditionArray[] = " ( $where ) ";
$extraFields[] = [
'field' => $rule->field,
'id' => $field_option['id'],
'data' => $rule->data,
];
}
break;
default:
if (isset($rule->data)) {
if (is_int($rule->data) && -1 == $rule->data) {
break;
}
$where = $this->get_where_clause($rule->field, $rule->op, $rule->data, 'OR');
$conditionArray[] = " ( $where ) ";
$extraFields[] = [
'field' => $rule->field,
'id' => $field_option['id'],
'data' => $rule->data,
];
}
break;
}
} else {
$my_field = str_replace('_second', '', $rule->field);
$original_field = str_replace($stringToSearch, '', $my_field);
$field_option = $this->get_handler_field_info_by_field_variable($original_field);
$extra_fields[] = [
$extraFields[] = [
'field' => $rule->field,
'id' => $field_option['id'],
];
@ -2652,17 +2662,7 @@ JAVASCRIPT;
}
}
/*var_dump(
[
'extra_fields' => $extra_fields,
'condition_array' => $condition_array,
]
);*/
return [
'extra_fields' => $extra_fields,
'condition_array' => $condition_array,
];
return ['extra_fields' => $extraFields, 'condition_array' => $conditionArray];
}
/**
@ -2741,7 +2741,6 @@ JAVASCRIPT;
$inject_extra_fields .= " fvo$counter.display_text as {$extra['field']}, ";
break;
case self::FIELD_TYPE_TAG:
// If using OR
//$inject_extra_fields .= " tag$counter.tag as {$extra['field']}, ";
// If using AND
$newCounter = 1;
@ -2751,8 +2750,11 @@ JAVASCRIPT;
$fields[] = "tag$counter$newCounter.tag";
$newCounter++;
}
$tags = implode(' , " ", ', $fields);
$inject_extra_fields .= " CONCAT($tags) as $tagAlias, ";
if (!empty($fields)) {
$tags = implode(' , " ", ', $fields);
$inject_extra_fields .= " CONCAT($tags) as $tagAlias, ";
}
break;
default:
$inject_extra_fields .= " fv$counter.value as {$extra['field']}, ";
@ -2785,9 +2787,12 @@ JAVASCRIPT;
$inject_where = null;
$where = null;
if (!empty($options['where'])) {
if (!empty($options['extra'])) {
// Removing double 1=1
// Removing double 1=1
if (!empty($options['extra']) && !empty($extra_fields)) {
// Removing double 1=1
if (empty($options['where'])) {
$options['where'] = ' 1 = 1 ';
}
$options['where'] = str_replace(' 1 = 1 AND', '', $options['where']);
// Always OR
$counter = 1;
@ -2813,29 +2818,28 @@ JAVASCRIPT;
";
break;
case self::FIELD_TYPE_TAG:
/*$options['where'] = str_replace(
$extra_info['field'],
'tag'.$counter.'.tag ',
$options['where']
);*/
$newCounter = 1;
$whereTag = [];
foreach ($extra['data'] as $data) {
$data = Database::escape_string($data);
$key = $counter.$newCounter;
$whereTag[] = ' tag'.$key.'.tag LIKE "%'.$data.'%" ';
$inject_joins .= "
INNER JOIN $this->table_field_rel_tag tag_rel$key
ON (
tag_rel$key.field_id = ".$extra_info['id']." AND
tag_rel$key.item_id = $alias.".$this->primaryKey."
)
INNER JOIN $this->table_field_tag tag$key
ON (tag$key.id = tag_rel$key.tag_id)
";
$newCounter++;
if (isset($extra_info['data']) && !empty($extra_info['data'])) {
$whereTag = [];
foreach ($extra_info['data'] as $data) {
$data = Database::escape_string($data);
$key = $counter.$newCounter;
$whereTag[] = ' tag'.$key.'.tag LIKE "%'.$data.'%" ';
$inject_joins .= "
INNER JOIN $this->table_field_rel_tag tag_rel$key
ON (
tag_rel$key.field_id = ".$extra_info['id']." AND
tag_rel$key.item_id = $alias.".$this->primaryKey."
)
INNER JOIN $this->table_field_tag tag$key
ON (tag$key.id = tag_rel$key.tag_id)
";
$newCounter++;
}
if (!empty($whereTag)) {
$options['where'] .= ' AND ('.implode(' AND ', $whereTag).') ';
}
}
$options['where'] = ' ('.implode(' AND ', $whereTag).') ';
break;
default:
// text, textarea, etc
@ -2850,14 +2854,17 @@ JAVASCRIPT;
$counter++;
}
}
if (!empty($options['where'])) {
$where .= ' AND '.$options['where'];
}
$order = null;
$order = '';
if (!empty($options['order'])) {
$order = ' ORDER BY '.$options['order'];
}
$limit = null;
$limit = '';
if (!empty($options['limit'])) {
$limit = ' LIMIT '.$options['limit'];
}

@ -619,9 +619,9 @@ class ExtraFieldValue extends Model
}
return $result;
} else {
return false;
}
return false;
}
/**
@ -745,9 +745,9 @@ class ExtraFieldValue extends Model
}
return $result;
} else {
return false;
}
return false;
}
/**

@ -388,10 +388,10 @@ function getUniqueStudentAttemptsTotal($workId, $groupId, $course_id, $sessionId
$groupIid = $groupInfo['iid'];
}
$sql = "SELECT count(DISTINCT u.user_id)
$sql = "SELECT count(DISTINCT u.id)
FROM $work_table w
INNER JOIN $user_table u
ON w.user_id = u.user_id
ON w.user_id = u.id
WHERE
w.c_id = $course_id
$sessionCondition AND
@ -444,7 +444,7 @@ function getUniqueStudentAttempts(
if (!empty($onlyUserList)) {
$onlyUserList = array_map('intval', $onlyUserList);
$studentCondition = "AND u.user_id IN ('".implode("', '", $onlyUserList)."') ";
$studentCondition = "AND u.id IN ('".implode("', '", $onlyUserList)."') ";
} else {
if (empty($userId)) {
return 0;
@ -468,7 +468,7 @@ function getUniqueStudentAttempts(
SELECT count(*), w.parent_id
FROM $work_table w
INNER JOIN $user_table u
ON w.user_id = u.user_id
ON w.user_id = u.id
WHERE
w.filetype = 'file' AND
w.c_id = $course_id
@ -479,9 +479,9 @@ function getUniqueStudentAttempts(
";
if (!empty($userId)) {
$userId = (int) $userId;
$sql .= ' AND u.user_id = '.$userId;
$sql .= ' AND u.id = '.$userId;
}
$sql .= ' GROUP BY u.user_id, w.parent_id) as t';
$sql .= ' GROUP BY u.id, w.parent_id) as t';
$result = Database::query($sql);
$row = Database::fetch_row($result);
@ -1174,11 +1174,11 @@ function get_count_work($work_id, $onlyMeUserId = null, $notMeUserId = null)
$extra_conditions .= ' AND work.parent_id = '.$work_id.' ';
$where_condition = null;
if (!empty($notMeUserId)) {
$where_condition .= ' AND u.user_id <> '.(int) $notMeUserId;
$where_condition .= ' AND u.id <> '.(int) $notMeUserId;
}
if (!empty($onlyMeUserId)) {
$where_condition .= ' AND u.user_id = '.(int) $onlyMeUserId;
$where_condition .= ' AND u.id = '.(int) $onlyMeUserId;
}
$repo = Container::getStudentPublicationRepository();
@ -1192,7 +1192,7 @@ function get_count_work($work_id, $onlyMeUserId = null, $notMeUserId = null)
INNER JOIN $work_table work
ON (node.id = work.resource_node_id)
INNER JOIN $user_table u
ON (work.user_id = u.user_id)
ON (work.user_id = u.id)
WHERE
link.c_id = $course_id AND
resource_type_id = $typeId AND
@ -1327,7 +1327,7 @@ function getWorkListStudent(
$work['title'] = basename($work['url']);
}
$whereCondition = " AND u.user_id = $userId ";
$whereCondition = " AND u.id = $userId ";
$workList = get_work_user_list(
0,
@ -1574,13 +1574,13 @@ function get_work_user_list_from_documents(
$getCount = false
) {
if ($getCount) {
$select1 = ' SELECT count(u.user_id) as count ';
$select2 = ' SELECT count(u.user_id) as count ';
$select1 = ' SELECT count(u.id) as count ';
$select2 = ' SELECT count(u.id) as count ';
} else {
$select1 = ' SELECT DISTINCT
u.firstname,
u.lastname,
u.user_id,
u.id as user_id,
w.title,
w.parent_id,
w.document_id document_id,
@ -1592,7 +1592,7 @@ function get_work_user_list_from_documents(
';
$select2 = ' SELECT DISTINCT
u.firstname, u.lastname,
u.user_id,
u.id as user_id,
d.title,
w.parent_id,
d.id document_id,
@ -1620,7 +1620,7 @@ function get_work_user_list_from_documents(
$studentId = (int) $studentId;
$workId = (int) $workId;
$userCondition = " AND u.user_id = $studentId ";
$userCondition = " AND u.id = $studentId ";
$sessionCondition = api_get_session_condition($sessionId, true, false, 'w.session_id');
$workCondition = " AND w_rel.work_id = $workId";
$workParentCondition = " AND w.parent_id = $workId";
@ -1628,7 +1628,7 @@ function get_work_user_list_from_documents(
$sql = "(
$select1 FROM $userTable u
INNER JOIN $workTable w
ON (u.user_id = w.user_id AND w.active IN (0, 1) AND w.filetype = 'file')
ON (u.id = w.user_id AND w.active IN (0, 1) AND w.filetype = 'file')
WHERE
w.c_id = $courseId
$userCondition
@ -1641,7 +1641,7 @@ function get_work_user_list_from_documents(
ON (w_rel.work_id = w.id AND w.active IN (0, 1) AND w_rel.c_id = w.c_id)
INNER JOIN $documentTable d
ON (w_rel.document_id = d.id AND d.c_id = w.c_id)
INNER JOIN $userTable u ON (u.user_id = $studentId)
INNER JOIN $userTable u ON (u.id = $studentId)
WHERE
w.c_id = $courseId
$workCondition
@ -1881,7 +1881,7 @@ function get_work_user_list(
if (isset($course_info['show_score']) &&
1 == $course_info['show_score']
) {
$extra_conditions .= ' AND (u.user_id = '.api_get_user_id().' AND work.active IN (0, 1)) ';
$extra_conditions .= ' AND (u.id = '.api_get_user_id().' AND work.active IN (0, 1)) ';
} else {
$extra_conditions .= ' AND work.active IN (0, 1) ';
}
@ -1890,7 +1890,7 @@ function get_work_user_list(
$extra_conditions .= " AND parent_id = $work_id ";
$select = 'SELECT DISTINCT
u.user_id,
u.id as user_id,
work.id as id,
title as title,
description,
@ -1912,20 +1912,20 @@ function get_work_user_list(
title_correction
';
if ($getCount) {
$select = 'SELECT DISTINCT count(u.user_id) as count ';
$select = 'SELECT DISTINCT count(u.id) as count ';
}
$work_assignment = get_work_assignment_by_id($work_id, $courseId);
if (!empty($studentId)) {
$studentId = (int) $studentId;
$whereCondition .= " AND u.user_id = $studentId ";
$whereCondition .= " AND u.id = $studentId ";
}
$sql = " $select
FROM $work_table work
INNER JOIN $user_table u
ON (work.user_id = u.user_id)
ON (work.user_id = u.id)
WHERE
work.c_id = $course_id AND
$extra_conditions
@ -2596,19 +2596,19 @@ function get_list_users_without_publication($task_id, $studentId = 0)
if (0 == $session_id) {
$sql_users = "SELECT cu.user_id, u.lastname, u.firstname, u.email
FROM $table_course_user AS cu, $table_user AS u
WHERE u.status != 1 and cu.c_id='".$course_id."' AND u.user_id = cu.user_id";
WHERE u.status != 1 and cu.c_id='".$course_id."' AND u.id = cu.user_id";
} else {
$sql_users = "SELECT cu.user_id, u.lastname, u.firstname, u.email
FROM $session_course_rel_user AS cu, $table_user AS u
WHERE
u.status != 1 AND
cu.c_id='".$course_id."' AND
u.user_id = cu.user_id AND
u.id = cu.user_id AND
cu.session_id = '".$session_id."'";
}
if (!empty($studentId)) {
$sql_users .= ' AND u.user_id = '.(int) $studentId;
$sql_users .= ' AND u.id = '.(int) $studentId;
}
$group_id = api_get_group_id();

Loading…
Cancel
Save