Don't show invited users results - refs BT#9070

1.10.x
Angel Fernando Quiroz Campos 11 years ago
parent 27b24df341
commit 54f87f99ad
  1. 4
      main/exercice/exercise.lib.php
  2. 4
      main/exercice/exercise_show.php
  3. 57
      main/inc/lib/main_api.lib.php

@ -1291,7 +1291,7 @@ function get_exam_results_data(
(
SELECT u.user_id, firstname, lastname, email, username, ' ' as group_name, '' as group_id, official_code
FROM $TBL_USER u
WHERE u.status != " . ROLE_INVITED . "
WHERE u.status NOT IN(" . apiGetExcludedUserTypes('string') . ")
)";
}
@ -1362,7 +1362,7 @@ function get_exam_results_data(
AND tth.exe_cours_id = '" . api_get_course_id()."'
$hotpotatoe_where
$sqlWhereOption
AND user.status != " . ROLE_INVITED . "
AND user.status NOT IN(" . apiGetExcludedUserTypes('string') . ")
ORDER BY
tth.exe_cours_id ASC,
tth.exe_date DESC";

@ -90,6 +90,10 @@ $learnpath_item_id = $track_exercise_info['orig_lp_item_id'];
$lp_item_view_id = $track_exercise_info['orig_lp_item_view_id'];
$current_user_id = api_get_user_id();
if (apiIsExcludedUserType(true, $student_id)) {
api_not_allowed(true);
}
$locked = api_resource_is_locked_by_gradebook($exercise_id, LINK_EXERCISE);
if (empty($objExercise)) {

@ -7497,3 +7497,60 @@ function api_register_campus($listCampus = true) {
}
// Reload the settings.
}
/**
* Check whether the user type should be exclude.
* Such as invited or anonymous users
* @param boolean $checkDB Optional. Whether check the user status
* @param int $userId Options. The user id
* @return boolean
*/
function apiIsExcludedUserType($checkDB = false, $userId = 0)
{
if ($checkDB) {
$userId = empty($userId) ? api_get_user_id() : intval($userId);
if ($userId == 0) {
return true;
}
$userInfo = api_get_user_info($userId);
switch ($userInfo['status']) {
case ROLE_INVITED:
//no break;
case ANONYMOUS:
return true;
default:
return false;
}
}
$isInvited = api_is_invited_user();
$isAnonymous = api_is_anonymous();
if ($isInvited || $isAnonymous) {
return true;
}
return false;
}
/**
* Get the exclude user types
* @param string $format Optional. The result type. Array or string
* @return array
*/
function apiGetExcludedUserTypes($format = 'array')
{
$excludedTypes = array(
ROLE_INVITED,
ANONYMOUS
);
if ($format == 'string') {
return implode(', ', $excludedTypes);
}
return $excludedTypes;
}

Loading…
Cancel
Save