if ($objExercise->selectAttempts() > 0) { $attempt_count = Event::get_attempt_count(api_get_user_id(), $objExercise->id, $learnpath_id, $learnpath_item_id, $learnpath_item_view_id); if ($attempt_count >= $objExercise->selectAttempts()) { Display::display_warning_message(sprintf(get_lang('ReachedMaxAttempts'), $objExercise->selectTitle(), $objExercise->selectAttempts()), false); if ($origin != 'learnpath') { //we are not in learnpath tool Display::display_footer(); } exit; } } $total_score = 0; if (!empty($exercise_stat_info)) { $total_score = $exercise_stat_info['exe_result']; } $max_score = $objExercise->get_max_score(); Display::display_normal_message(get_lang('Saved') . '<br />', false); // Display and save questions ExerciseLib::display_question_list_by_attempt($objExercise, $exe_id, true); //Unset session for clock time ExerciseLib::exercise_time_control_delete($objExercise->id, $learnpath_id, $learnpath_item_id); ExerciseLib::delete_chat_exercise_session($exe_id); if ($origin != 'learnpath') { echo '<hr>'; echo Display::url(get_lang('ReturnToCourseHomepage'), api_get_course_url(), array('class' => 'btn btn-primary')); if (api_is_allowed_to_session_edit()) { Session::erase('objExercise'); Session::erase('exe_id'); } Display::display_footer(); } else {
/** * Return HTML form to allow prerequisites selection * @todo use FormValidator * @param integer Item ID * @return string HTML form */ public function display_item_prerequisites_form($item_id) { $course_id = api_get_course_int_id(); $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM); $item_id = intval($item_id); /* Current prerequisite */ $sql = "SELECT * FROM {$tbl_lp_item}\n WHERE c_id = {$course_id} AND id = " . $item_id; $result = Database::query($sql); $row = Database::fetch_array($result); $prerequisiteId = $row['prerequisite']; $return = '<legend>'; $return .= get_lang('AddEditPrerequisites'); $return .= '</legend>'; $return .= '<form method="POST">'; $return .= '<table class="data_table">'; $return .= '<tr>'; $return .= '<th height="24">' . get_lang('LearnpathPrerequisites') . '</th>'; $return .= '<th width="70" >' . get_lang('Minimum') . '</th>'; $return .= '<th width="70">' . get_lang('Maximum') . '</th>'; $return .= '</tr>'; // Adding the none option to the prerequisites see http://www.chamilo.org/es/node/146 $return .= '<tr >'; $return .= '<td colspan="3" class="radio">'; $return .= '<input checked="checked" id="idNone" name="prerequisites" style="margin-left:0px; margin-right:10px;" type="radio" />'; $return .= '<label for="idNone">' . get_lang('None') . '</label>'; $return .= '</tr>'; $sql = "SELECT * FROM {$tbl_lp_item}\n WHERE c_id = {$course_id} AND lp_id = " . $this->lp_id; $result = Database::query($sql); $arrLP = array(); $selectedMinScore = array(); $selectedMaxScore = array(); while ($row = Database::fetch_array($result)) { if ($row['id'] == $item_id) { $selectedMinScore[$row['prerequisite']] = $row['prerequisite_min_score']; $selectedMaxScore[$row['prerequisite']] = $row['prerequisite_max_score']; } $arrLP[] = array('id' => $row['id'], 'item_type' => $row['item_type'], 'title' => $row['title'], 'ref' => $row['ref'], 'description' => $row['description'], 'parent_item_id' => $row['parent_item_id'], 'previous_item_id' => $row['previous_item_id'], 'next_item_id' => $row['next_item_id'], 'max_score' => $row['max_score'], 'min_score' => $row['min_score'], 'mastery_score' => $row['mastery_score'], 'prerequisite' => $row['prerequisite'], 'next_item_id' => $row['next_item_id'], 'display_order' => $row['display_order'], 'prerequisite_min_score' => $row['prerequisite_min_score'], 'prerequisite_max_score' => $row['prerequisite_max_score']); } $this->tree_array($arrLP); $arrLP = isset($this->arrMenu) ? $this->arrMenu : null; unset($this->arrMenu); for ($i = 0; $i < count($arrLP); $i++) { $item = $arrLP[$i]; if ($item['id'] == $item_id) { break; } $selectedMaxScoreValue = isset($selectedMaxScore[$item['id']]) ? $selectedMaxScore[$item['id']] : $item['max_score']; $selectedMinScoreValue = isset($selectedMinScore[$item['id']]) ? $selectedMinScore[$item['id']] : 0; $return .= '<tr>'; $return .= '<td class="radio"' . ($item['item_type'] != TOOL_QUIZ && $item['item_type'] != TOOL_HOTPOTATOES ? ' colspan="3"' : '') . '>'; $return .= '<label for="id' . $item['id'] . '">'; $return .= '<input' . (in_array($prerequisiteId, array($item['id'], $item['ref'])) ? ' checked="checked" ' : '') . ($item['item_type'] == 'dokeos_module' || $item['item_type'] == 'dokeos_chapter' ? ' disabled="disabled" ' : ' ') . 'id="id' . $item['id'] . '" name="prerequisites" style="margin-left:' . $item['depth'] * 10 . 'px; margin-right:10px;" type="radio" value="' . $item['id'] . '" />'; $icon_name = str_replace(' ', '', $item['item_type']); if (file_exists('../img/lp_' . $icon_name . '.png')) { $return .= '<img alt="" src="../img/lp_' . $icon_name . '.png" style="margin-right:5px;" title="" />'; } else { if (file_exists('../img/lp_' . $icon_name . '.gif')) { $return .= '<img alt="" src="../img/lp_' . $icon_name . '.gif" style="margin-right:5px;" title="" />'; } else { $return .= Display::return_icon('folder_document.gif', '', array('style' => 'margin-right:5px;')); } } $return .= $item['title'] . '</label>'; $return .= '</td>'; if ($item['item_type'] == TOOL_QUIZ) { // lets update max_score Quiz information depending of the Quiz Advanced properties $tmp_obj_lp_item = new LpItem($course_id, $item['id']); $tmp_obj_exercice = new Exercise(); $tmp_obj_exercice->read($tmp_obj_lp_item->path); $tmp_obj_lp_item->max_score = $tmp_obj_exercice->get_max_score(); $tmp_obj_lp_item->update_in_bdd(); $item['max_score'] = $tmp_obj_lp_item->max_score; $return .= '<td class="exercise">'; $return .= '<input size="4" maxlength="3" name="min_' . $item['id'] . '" type="number" min="0" step="any" max="' . $item['max_score'] . '" value="' . $selectedMinScoreValue . '" />'; $return .= '</td>'; $return .= '<td class="exercise">'; $return .= '<input size="4" maxlength="3" name="max_' . $item['id'] . '" type="number" min="0" step="any" max="' . $item['max_score'] . '" value="' . $selectedMaxScoreValue . '" />'; $return .= '</td>'; } if ($item['item_type'] == TOOL_HOTPOTATOES) { $return .= '<td class="exercise">'; $return .= '<center><input size="4" maxlength="3" name="min_' . $item['id'] . '" type="number" min="0" step="any" max="' . $item['max_score'] . '" value="' . $selectedMinScoreValue . '" /></center>'; $return .= '</td>'; $return .= '<td class="exercise"">'; $return .= '<center><input size="4" maxlength="3" name="max_' . $item['id'] . '" type="number" min="0" step="any" max="' . $item['max_score'] . '" value="' . $selectedMaxScoreValue . '" /></center>'; $return .= '</td>'; } $return .= '</tr>'; } $return .= '<tr>'; $return .= '</tr>'; $return .= '</table>'; $return .= '<div style="padding-top:3px;">'; $return .= '<button class="btn btn-primary" name="submit_button" type="submit">' . get_lang('ModifyPrerequisites') . '</button>'; $return .= '</form>'; return $return; }