verifying user doesn't take a test more of allowed times -refs #6784

1.9.x
unknown 12 years ago
parent edca938fe0
commit 6618eccefa
  1. 9
      main/exercice/overview.php
  2. 25
      main/inc/lib/events.lib.inc.php

@ -98,11 +98,18 @@ if (isset($exercise_stat_info['exe_id'])) {
}
//1. Check if this is a new attempt or a previous
$countNotFinished = get_attempt_count_incomplete(api_get_user_id(), $objExercise->selectId(), $learnpath_id, $learnpath_item_id);
$label = get_lang('StartTest');
if ($time_control && !empty($clock_expired_time) || !empty($attempt_list)) {
$label = get_lang('ContinueTest');
}
if ($countNotFinished >= $objExercise->selectAttempts() && !api_is_allowed_to_edit()) {
$message = Display::display_warning_message(sprintf(get_lang('ReachedMaxAttempts'),$objExercise->selectTitle(),$objExercise->selectAttempts()).' '.get_lang('YouTriedToResolveThisExerciseEarlier'));
} elseif ($countNotFinished >= $objExercise->selectAttempts() && api_is_allowed_to_edit()) {
$message = Display::display_warning_message(get_lang('ReachedMaxAttemptsAdmin'));
}
if (!empty($attempt_list)) {
$message = Display::return_message(get_lang('YouTriedToResolveThisExerciseEarlier'));
}
@ -239,7 +246,7 @@ if ($time_control) {
$html .= $message;
if (!empty($exercise_url_button)) {
if (!empty($exercise_url_button) && ($countNotFinished == 0 || api_is_allowed_to_edit())) {
$html .= Display::div(Display::div($exercise_url_button, array('class'=>'exercise_overview_options span12')), array('class'=>' row'));
}

@ -835,6 +835,31 @@ function get_attempt_count_not_finished($user_id, $exerciseId, $lp_id, $lp_item_
}
}
function get_attempt_count_incomplete($user_id, $exerciseId, $lp_id, $lp_item_id) {
$stat_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$user_id = intval($user_id);
$exerciseId = intval($exerciseId);
$lp_id = intval($lp_id);
$lp_item_id = intval($lp_item_id);
$lp_item_view_id= intval($lp_item_view_id);
$sql = "SELECT count(*) as count FROM $stat_table WHERE
exe_exo_id = $exerciseId AND
exe_user_id = $user_id AND
status = 'incomplete' AND
orig_lp_id = $lp_id AND
orig_lp_item_id = $lp_item_id AND
exe_cours_id = '".api_get_course_id()."' AND
session_id = '" . api_get_session_id() . "'";
$query = Database::query($sql);
if (Database::num_rows($query) > 0 ) {
$attempt = Database :: fetch_array($query,'ASSOC');
return $attempt['count'];
} else {
return 0;
}
}
function delete_student_lp_events($user_id, $lp_id, $course, $session_id) {

Loading…
Cancel
Save