Minor - code formatting

skala
Julio Montoya 12 years ago
parent 93e4215530
commit 0d48b77b34
  1. 2147
      main/exercice/exercise.lib.php
  2. 144
      main/exercice/exercise_result.php
  3. 6
      main/exercice/exercise_submit.php
  4. 759
      main/inc/lib/events.lib.inc.php
  5. 1
      main/inc/lib/main_api.lib.php

File diff suppressed because it is too large Load Diff

@ -1,22 +1,22 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Exercise result
* This script gets informations from the script "exercise_submit.php",
* through the session, and calculates the score of the student for
* that exercise.
* Then it shows the results on the screen.
* @package chamilo.exercise
* @author Olivier Brouckaert, main author
* @author Roan Embrechts, some refactoring
* @author Julio Montoya Armas switchable fill in blank option added
*
* @todo split more code up in functions, move functions to library?
*/
* Exercise result
* This script gets informations from the script "exercise_submit.php",
* through the session, and calculates the score of the student for
* that exercise.
* Then it shows the results on the screen.
* @package chamilo.exercise
* @author Olivier Brouckaert, main author
* @author Roan Embrechts, some refactoring
* @author Julio Montoya Armas switchable fill in blank option added
*
* @todo split more code up in functions, move functions to library?
*/
/**
* Code
*/
use \ChamiloSession as Session;
require_once 'exercise.class.php';
@ -29,13 +29,13 @@ $language_file = 'exercice';
require_once '../inc/global.inc.php';
require_once 'exercise.lib.php';
if ($_GET['origin']=='learnpath') {
require_once '../newscorm/learnpath.class.php';
require_once '../newscorm/learnpathItem.class.php';
require_once '../newscorm/scorm.class.php';
require_once '../newscorm/scormItem.class.php';
require_once '../newscorm/aicc.class.php';
require_once '../newscorm/aiccItem.class.php';
if ($_GET['origin'] == 'learnpath') {
require_once '../newscorm/learnpath.class.php';
require_once '../newscorm/learnpathItem.class.php';
require_once '../newscorm/scorm.class.php';
require_once '../newscorm/scormItem.class.php';
require_once '../newscorm/aicc.class.php';
require_once '../newscorm/aiccItem.class.php';
}
require_once api_get_path(LIBRARY_PATH).'exercise_show_functions.lib.php';
@ -44,42 +44,50 @@ $this_section = SECTION_COURSES;
/* ACCESS RIGHTS */
api_protect_course_script(true);
if ($debug){ error_log('Entering exercise_result.php: '.print_r($_POST,1));}
if ($debug) {
error_log('Entering exercise_result.php: '.print_r($_POST, 1));
}
// general parameters passed via POST/GET
if ( empty ( $origin ) ) { $origin = Security::remove_XSS($_REQUEST['origin']);}
if ( empty ( $objExercise ) ) { $objExercise = $_SESSION['objExercise'];}
if ( empty ( $remind_list ) ) { $remind_list = $_REQUEST['remind_list'];}
if (empty($origin)) {
$origin = Security::remove_XSS($_REQUEST['origin']);
}
if (empty($objExercise)) {
$objExercise = $_SESSION['objExercise'];
}
if (empty($remind_list)) {
$remind_list = $_REQUEST['remind_list'];
}
$exe_id = isset($_REQUEST['exe_id']) ? intval($_REQUEST['exe_id']) : 0;
if (empty($objExercise)) {
//Redirect to the exercise overview
//Check if the exe_id exists
$objExercise = new Exercise();
$exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exe_id);
if (!empty($exercise_stat_info) && isset($exercise_stat_info['exe_exo_id'])) {
header("Location: overview.php?exerciseId=".$exercise_stat_info['exe_exo_id']);
exit;
}
api_not_allowed();
//Redirect to the exercise overview
//Check if the exe_id exists
$objExercise = new Exercise();
$exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exe_id);
if (!empty($exercise_stat_info) && isset($exercise_stat_info['exe_exo_id'])) {
header("Location: overview.php?exerciseId=".$exercise_stat_info['exe_exo_id']);
exit;
}
api_not_allowed(true);
}
$gradebook = '';
if (isset($_SESSION['gradebook'])) {
$gradebook= $_SESSION['gradebook'];
$gradebook = $_SESSION['gradebook'];
}
if (!empty($gradebook) && $gradebook=='view') {
$interbreadcrumb[]= array ('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('ToolGradebook'));
if (!empty($gradebook) && $gradebook == 'view') {
$interbreadcrumb[] = array('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('ToolGradebook'));
}
$nameTools = get_lang('Exercice');
$interbreadcrumb[]= array("url" => "exercice.php?gradebook=$gradebook","name" => get_lang('Exercices'));
$interbreadcrumb[] = array("url" => "exercice.php?gradebook=$gradebook", "name" => get_lang('Exercices'));
if ($origin != 'learnpath') {
//so we are not in learnpath tool
Display::display_header($nameTools,get_lang('Exercise'));
//so we are not in learnpath tool
Display::display_header($nameTools, get_lang('Exercise'));
} else {
Display::display_reduced_header();
}
@ -88,32 +96,32 @@ if ($origin != 'learnpath') {
// I'm in a preview mode as course admin. Display the action menu.
if (api_is_course_admin() && $origin != 'learnpath') {
echo '<div class="actions">';
echo '<a href="admin.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'">'.Display::return_icon('back.png', get_lang('GoBackToQuestionList'), array(), 32).'</a>';
echo '<a href="exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$objExercise->id.'">'.Display::return_icon('edit.png', get_lang('ModifyExercise'), array(), 32).'</a>';
echo '</div>';
echo '<div class="actions">';
echo '<a href="admin.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'">'.Display::return_icon('back.png', get_lang('GoBackToQuestionList'), array(), 32).'</a>';
echo '<a href="exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$objExercise->id.'">'.Display::return_icon('edit.png', get_lang('ModifyExercise'), array(), 32).'</a>';
echo '</div>';
}
$feedback_type = $objExercise->feedback_type;
$exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exe_id);
$feedback_type = $objExercise->feedback_type;
$exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exe_id);
if (!empty($exercise_stat_info['data_tracking'])) {
$question_list = explode(',', $exercise_stat_info['data_tracking']);
$question_list = explode(',', $exercise_stat_info['data_tracking']);
}
$learnpath_id = $exercise_stat_info['orig_lp_id'];
$learnpath_item_id = $exercise_stat_info['orig_lp_item_id'];
$learnpath_id = $exercise_stat_info['orig_lp_id'];
$learnpath_item_id = $exercise_stat_info['orig_lp_item_id'];
$learnpath_item_view_id = $exercise_stat_info['orig_lp_item_view_id'];
if ($origin == 'learnpath') {
?>
<form method="GET" action="exercice.php?<?php echo api_get_cidreq() ?>">
<input type="hidden" name="origin" value="<?php echo $origin; ?>" />
<input type="hidden" name="learnpath_id" value="<?php echo $learnpath_id; ?>" />
<input type="hidden" name="learnpath_item_id" value="<?php echo $learnpath_item_id; ?>" />
<input type="hidden" name="learnpath_item_view_id" value="<?php echo $learnpath_item_view_id; ?>" />
<?php
}
?>
<form method="GET" action="exercice.php?<?php echo api_get_cidreq() ?>">
<input type="hidden" name="origin" value="<?php echo $origin; ?>" />
<input type="hidden" name="learnpath_id" value="<?php echo $learnpath_id; ?>" />
<input type="hidden" name="learnpath_item_id" value="<?php echo $learnpath_item_id; ?>" />
<input type="hidden" name="learnpath_item_view_id" value="<?php echo $learnpath_item_view_id; ?>" />
<?php
}
$i = $total_score = $total_weight = 0;
@ -130,7 +138,7 @@ if ($objExercise->selectAttempts() > 0) {
}
}
Display :: display_normal_message(get_lang('Saved').'<br />',false);
Display :: display_normal_message(get_lang('Saved').'<br />', false);
//Display questions
display_question_list_by_attempt($objExercise, $exe_id, true);
@ -138,9 +146,9 @@ display_question_list_by_attempt($objExercise, $exe_id, true);
//If is not valid
$session_control_key = get_session_time_control_key($objExercise->id, $learnpath_id, $learnpath_item_id);
if (isset($session_control_key) && !exercise_time_control_is_valid($objExercise->id, $learnpath_id, $learnpath_item_id)) {
$TBL_TRACK_ATTEMPT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$sql_fraud = "UPDATE $TBL_TRACK_ATTEMPT SET answer = 0, marks = 0, position = 0 WHERE exe_id = $exe_id ";
Database::query($sql_fraud);
$TBL_TRACK_ATTEMPT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$sql_fraud = "UPDATE $TBL_TRACK_ATTEMPT SET answer = 0, marks = 0, position = 0 WHERE exe_id = $exe_id ";
Database::query($sql_fraud);
}
//Unset session for clock time
@ -157,18 +165,18 @@ if ($origin != 'learnpath') {
Session::erase('exe_id');
}
Display::display_footer();
Display::display_footer();
} else {
$lp_mode = $_SESSION['lp_mode'];
$url = '../newscorm/lp_controller.php?cidReq='.api_get_course_id().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exercise_stat_info['exe_id'].'&fb_type='.$objExercise->feedback_type;
$href = ($lp_mode == 'fullscreen')?' window.opener.location.href="'.$url.'" ':' top.location.href="'.$url.'"';
$lp_mode = $_SESSION['lp_mode'];
$url = '../newscorm/lp_controller.php?cidReq='.api_get_course_id().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exercise_stat_info['exe_id'].'&fb_type='.$objExercise->feedback_type;
$href = ($lp_mode == 'fullscreen') ? ' window.opener.location.href="'.$url.'" ' : ' top.location.href="'.$url.'"';
if (api_is_allowed_to_session_edit()) {
Session::erase('objExercise');
Session::erase('exe_id');
}
//record the results in the learning path, using the SCORM interface (API)
echo "<script>window.parent.API.void_save_asset('$total_score', '$total_weight', 0, 'completed');</script>";
//record the results in the learning path, using the SCORM interface (API)
echo "<script>window.parent.API.void_save_asset('$total_score', '$total_weight', 0, 'completed');</script>";
echo '<script type="text/javascript">'.$href.'</script>';
echo '</body></html>';
echo '</body></html>';
}

@ -216,10 +216,12 @@ if ($debug) { error_log("4. Setting the exe_id: $exe_id");} ;
//5. Getting user exercise info (if the user took the exam before) - generating exe_id
//var_dump($learnpath_id.' - '.$learnpath_item_id.' - '.$learnpath_item_view_id);
$exercise_stat_info = $objExercise->get_stat_track_exercise_info($learnpath_id, $learnpath_item_id, $learnpath_item_view_id);
$clock_expired_time = null;
if (empty($exercise_stat_info)) {
if ($debug) error_log("learnpath_id: $learnpath_id, learnpath_item_id: $learnpath_item_id, learnpath_item_view_id: $learnpath_item_view_id");
if ($debug) error_log('5 $exercise_stat_info is empty ');
$total_weight = 0;
$questionList = $objExercise->get_question_list(true);
@ -244,7 +246,7 @@ if (empty($exercise_stat_info)) {
}
$exe_id = $objExercise->save_stat_track_exercise_info($clock_expired_time, $learnpath_id, $learnpath_item_id, $learnpath_item_view_id, $questionList, $total_weight);
$exercise_stat_info = $objExercise->get_stat_track_exercise_info($learnpath_id, $learnpath_item_id, $learnpath_item_view_id);
if ($debug) error_log("5.5 exercise_stat_info[] exists getting exe_id $exe_id");
if ($debug) error_log("5.5 exercise_stat_info[] created. exe_id: $exe_id");
} else {
$exe_id = $exercise_stat_info['exe_id'];
if ($debug) error_log("5 exercise_stat_info[] exists getting exe_id $exe_id ");
@ -816,7 +818,7 @@ if (!empty($error)) {
//1. Normal choice inputs
var my_choice = $(\'*[name*="choice[\'+question_id+\']"]\').serialize();
//2. Reminder checkbox
var remind_list = $(\'*[name*="remind_list"]\').serialize();

File diff suppressed because it is too large Load Diff

@ -6415,6 +6415,7 @@ function api_detect_user_roles($user_id, $course_code, $session_id = 0) {
}
return $user_roles;
}
function api_get_roles_to_string($roles) {
$role_names = array();
if (!empty($roles)) {

Loading…
Cancel
Save