Minor - adding warning message + fixing UI

skala
Julio Montoya 13 years ago
parent 3fd4c82d00
commit 291e5f1f1f
  1. 630
      main/exercice/exercise.class.php
  2. 83
      main/exercice/overview.php

File diff suppressed because it is too large Load Diff

@ -66,6 +66,7 @@ if ($origin != 'learnpath') {
} }
$html = ''; $html = '';
$message = '';
$is_allowed_to_edit = api_is_allowed_to_edit(null,true); $is_allowed_to_edit = api_is_allowed_to_edit(null,true);
$edit_link = ''; $edit_link = '';
@ -74,14 +75,14 @@ if ($is_allowed_to_edit ) {
} }
//Exercise name //Exercise name
$html .= Display::page_header( $objExercise->name .' '.$edit_link); $html .= Display::page_header( $objExercise->name.' '.$edit_link);
//Exercise description //Exercise description
$html .= Display::div($objExercise->description, array('class'=>'exercise_description')); $html .= Display::div($objExercise->description, array('class'=>'exercise_description'));
$extra_params = ''; $extra_params = '';
if (isset($_GET['preview'])) { if (isset($_GET['preview'])) {
$extra_params = '&preview=1'; $extra_params = '&preview=1';
} }
$exercise_stat_info = $objExercise->get_stat_track_exercise_info($learnpath_id, $learnpath_item_id, 0); $exercise_stat_info = $objExercise->get_stat_track_exercise_info($learnpath_id, $learnpath_item_id, 0);
@ -90,76 +91,72 @@ if (isset($exercise_stat_info['exe_id'])) {
$attempt_list = get_all_exercise_event_by_exe_id($exercise_stat_info['exe_id']); $attempt_list = get_all_exercise_event_by_exe_id($exercise_stat_info['exe_id']);
} }
//Exercise button //1. Check if this is a new attempt or a previous
//Notice we not add there the lp_item_view__id because is not already generated
$exercise_url = api_get_path(WEB_CODE_PATH).'exercice/exercise_submit.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'&origin='.$origin.'&learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.$extra_params;
$label = get_lang('StartTest'); $label = get_lang('StartTest');
if ($time_control && !empty($clock_expired_time) || !empty($attempt_list)) { if ($time_control && !empty($clock_expired_time) || !empty($attempt_list)) {
$label = get_lang('ContinueTest'); $label = get_lang('ContinueTest');
} }
if (!empty($attempt_list)) {
$message = Display::return_message(get_lang('YouTriedToResolveThisExerciseEarlier'));
}
//2. Exercise button
//Notice we not add there the lp_item_view_id because is not already generated
$exercise_url = api_get_path(WEB_CODE_PATH).'exercice/exercise_submit.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'&origin='.$origin.'&learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.$extra_params;
$exercise_url_button = Display::url($label, $exercise_url, array('class'=>'btn btn-primary btn-large')); $exercise_url_button = Display::url($label, $exercise_url, array('class'=>'btn btn-primary btn-large'));
//3. Checking visibility of the exercise (overwrites the exercise button)
$visible_return = $objExercise->is_visible($learnpath_id, $learnpath_item_id, null, false); $visible_return = $objExercise->is_visible($learnpath_id, $learnpath_item_id, null, false);
if ($visible_return['value'] == false) {
$exercise_url = api_get_path(WEB_CODE_PATH).'exercice/exercise_report.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id;
$exercise_url_button = $visible_return['message'];
}
//Message "you already try this exercise" //Exercise is not visible remove the button
if ($visible_return['value'] == false) {
$message = ''; if ($is_allowed_to_edit) {
if (!empty($attempt_list)) { $message = Display::return_message(get_lang('ThisItemIsInvisibleForStudentsButYouHaveAccessAsTeacher'), 'warning');
$message = Display::return_message(get_lang('YouTriedToResolveThisExerciseEarlier')); } else {
$label = get_lang('ContinueTest'); $message = $visible_return['message'];
$exercise_url_button = null;
}
} }
$html .= $message;
$attempts = get_exercise_results_by_user(api_get_user_id(), $objExercise->id, api_get_course_id(), api_get_session_id(), $learnpath_id, $learnpath_item_id, 'desc'); $attempts = get_exercise_results_by_user(api_get_user_id(), $objExercise->id, api_get_course_id(), api_get_session_id(), $learnpath_id, $learnpath_item_id, 'desc');
$counter = count($attempts); $counter = count($attempts);
$options = '';
if (!empty($exercise_url_button)) {
$options .= $exercise_url_button;
}
//$options = Display::div($options, array('class'=>'offset4 span4'));
$my_attempt_array = array(); $my_attempt_array = array();
$table_content = ''; $table_content = '';
if (!empty($attempts)) { if (!empty($attempts)) {
$i = $counter; $i = $counter;
foreach ($attempts as $attempt_result) { foreach ($attempts as $attempt_result) {
$score = show_score($attempt_result['exe_result'], $attempt_result['exe_weighting']); $score = show_score($attempt_result['exe_result'], $attempt_result['exe_weighting']);
$attempt_url = api_get_path(WEB_CODE_PATH).'exercice/result.php?'.api_get_cidreq().'&id='.$attempt_result['exe_id'].'&id_session='.api_get_session_id().'&height=500&width=750'; $attempt_url = api_get_path(WEB_CODE_PATH).'exercice/result.php?'.api_get_cidreq().'&id='.$attempt_result['exe_id'].'&id_session='.api_get_session_id().'&height=500&width=750';
$attempt_link = Display::url(get_lang('Show'), $attempt_url, array('class'=>'ajax btn')); $attempt_link = Display::url(get_lang('Show'), $attempt_url, array('class'=>'ajax btn'));
$teacher_revised = Display::label(get_lang('Validated'), 'success'); $teacher_revised = Display::label(get_lang('Validated'), 'success');
//$attempt_link = get_lang('NoResult'); //$attempt_link = get_lang('NoResult');
//$attempt_link = Display::return_icon('quiz_na.png', get_lang('NoResult'), array(), ICON_SIZE_SMALL); //$attempt_link = Display::return_icon('quiz_na.png', get_lang('NoResult'), array(), ICON_SIZE_SMALL);
if ($attempt_result['attempt_revised'] == 0) { if ($attempt_result['attempt_revised'] == 0) {
$teacher_revised = Display::label(get_lang('NotValidated'), 'info'); $teacher_revised = Display::label(get_lang('NotValidated'), 'info');
} }
$row = array('count' => $i, $row = array('count' => $i,
'date' => api_convert_and_format_date($attempt_result['start_date'], DATE_TIME_FORMAT_LONG) 'date' => api_convert_and_format_date($attempt_result['start_date'], DATE_TIME_FORMAT_LONG)
); );
$attempt_link .= "   ".$teacher_revised; $attempt_link .= "   ".$teacher_revised;
if ($objExercise->results_disabled == EXERCISE_FEEDBACK_TYPE_END || $objExercise->results_disabled == EXERCISE_FEEDBACK_TYPE_EXAM) { if ($objExercise->results_disabled == EXERCISE_FEEDBACK_TYPE_END || $objExercise->results_disabled == EXERCISE_FEEDBACK_TYPE_EXAM) {
$row['result'] = $score; $row['result'] = $score;
} }
if ($objExercise->results_disabled == EXERCISE_FEEDBACK_TYPE_END) { if ($objExercise->results_disabled == EXERCISE_FEEDBACK_TYPE_END) {
$row['attempt_link'] = $attempt_link; $row['attempt_link'] = $attempt_link;
} }
$my_attempt_array[] = $row; $my_attempt_array[] = $row;
$i--; $i--;
} }
$table = new HTML_Table(array('class' => 'data_table')); $table = new HTML_Table(array('class' => 'data_table'));
//Hiding score and answer //Hiding score and answer
switch($objExercise->results_disabled) { switch($objExercise->results_disabled) {
case EXERCISE_FEEDBACK_TYPE_END: case EXERCISE_FEEDBACK_TYPE_END:
@ -170,8 +167,8 @@ if (!empty($attempts)) {
break; break;
case EXERCISE_FEEDBACK_TYPE_EXAM: case EXERCISE_FEEDBACK_TYPE_EXAM:
$header_names = array(get_lang('Attempt'), get_lang('Date'), get_lang('Score')); $header_names = array(get_lang('Attempt'), get_lang('Date'), get_lang('Score'));
break; break;
} }
$row = 0; $row = 0;
$column = 0; $column = 0;
foreach ($header_names as $item) { foreach ($header_names as $item) {
@ -193,29 +190,35 @@ if (!empty($attempts)) {
$row++; $row++;
} }
} }
$table_content = $table->toHtml(); $table_content = $table->toHtml();
} }
if ($objExercise->selectAttempts()) { if ($objExercise->selectAttempts()) {
if ($is_allowed_to_edit) { if ($is_allowed_to_edit) {
//$options.= Display::div(get_lang('ExerciseAttempts').' '.$objExercise->selectAttempts(), array('class'=>'right_option')); //$options.= Display::div(get_lang('ExerciseAttempts').' '.$objExercise->selectAttempts(), array('class'=>'right_option'));
} }
$attempt_message = get_lang('Attempts').' '.$counter.' / '.$objExercise->selectAttempts(); $attempt_message = get_lang('Attempts').' '.$counter.' / '.$objExercise->selectAttempts();
if ($counter == $objExercise->selectAttempts()) { if ($counter == $objExercise->selectAttempts()) {
$attempt_message = Display::return_message($attempt_message, 'error'); $attempt_message = Display::return_message($attempt_message, 'error');
} else { } else {
$attempt_message = Display::return_message($attempt_message, 'info'); $attempt_message = Display::return_message($attempt_message, 'info');
} }
$options.= Display::div($attempt_message, array('class'=>"offset2 span2")); if ($visible_return['value'] == true) {
$message .= $attempt_message;
}
//$options.= $attempt_message; //Display::div($attempt_message, array('class'=>"offset2 span2"));
} }
if ($time_control) { if ($time_control) {
$html.= '<div align="left" id="wrapper-clock"><div id="square" class="rounded"><div id="text-content" align="center" class="count_down"></div></div></div>'; $html.= '<div align="left" id="wrapper-clock"><div id="square" class="rounded"><div id="text-content" align="center" class="count_down"></div></div></div>';
} }
$html.= Display::div(Display::div($options, array('class'=>'exercise_overview_options span12')), array('class'=>' row')); $html .= $message;
if (!empty($exercise_url_button)) {
$html .= Display::div(Display::div($exercise_url_button, array('class'=>'exercise_overview_options span12')), array('class'=>' row'));
}
$html .= $table_content; $html .= $table_content;

Loading…
Cancel
Save