Skip to content

Commit

Permalink
If chamilo exercise added in LP has pass % then change status to pass…
Browse files Browse the repository at this point in the history
…ed/failed

See #7456
  • Loading branch information
jmontoyaa committed Sep 24, 2015
1 parent b16814c commit 90e2852
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 10 deletions.
17 changes: 13 additions & 4 deletions main/exercice/exercise.class.php
Expand Up @@ -69,10 +69,10 @@ public function __construct($course_id = null)
$this->expired_time = '0000-00-00 00:00:00';
$this->propagate_neg = 0;
$this->review_answers = false;
$this->randomByCat = 0; //
$this->text_when_finished = ""; //
$this->randomByCat = 0;
$this->text_when_finished = '';
$this->display_category_name = 0;
$this->pass_percentage = null;
$this->pass_percentage = '';

if (!empty($course_id)) {
$course_info = api_get_course_info_by_id($course_id);
Expand Down Expand Up @@ -1286,7 +1286,12 @@ public function createForm($form, $type='full')
);
$form->addElement('html','</div>');

$form->addElement('text', 'pass_percentage', array(get_lang('PassPercentage'), null, '%'), array('id' => 'pass_percentage'));
$form->addElement(
'text',
'pass_percentage',
array(get_lang('PassPercentage'), null, '%'),
array('id' => 'pass_percentage')
);
$form->addRule('pass_percentage', get_lang('Numeric'), 'numeric');

// add the text_when_finished textbox
Expand Down Expand Up @@ -4749,6 +4754,10 @@ function transform_question_list_with_medias($question_list, $expand_media_quest
return $new_question_list;
}

/**
* @param int $exe_id
* @return array|mixed
*/
public function get_stat_track_exercise_info_by_exe_id($exe_id)
{
$track_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
Expand Down
5 changes: 4 additions & 1 deletion main/exercice/exercise_result.php
Expand Up @@ -33,7 +33,10 @@
if (empty($origin)) {
$origin = Security::remove_XSS($_REQUEST['origin']);
}

/** @var Exercise $objExercise */
if (empty($objExercise)) {

$objExercise = $_SESSION['objExercise'];
}
if (empty($remind_list)) {
Expand Down Expand Up @@ -74,7 +77,7 @@

if ($origin != 'learnpath') {
// So we are not in learnpath tool
Display::display_header($nameTools,get_lang('Exercise'));
Display::display_header($nameTools, get_lang('Exercise'));
} else {
Display::display_reduced_header();
}
Expand Down
3 changes: 1 addition & 2 deletions main/exercice/exercise_show.php
Expand Up @@ -776,8 +776,7 @@ function getFCK(vals,marksid) {
$url = '../newscorm/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exeId.'&fb_type='.$feedback_type;
$href = ($lp_mode == 'fullscreen')?' window.opener.location.href="'.$url.'" ':' top.location.href="'.$url.'" ';
echo '<script type="text/javascript">'.$href.'</script>';

//Record the results in the learning path, using the SCORM interface (API)
// Record the results in the learning path, using the SCORM interface (API)
echo "<script>window.parent.API.void_save_asset('$totalScore', '$totalWeighting', 0, 'completed'); </script>";
echo '</body></html>';
} else {
Expand Down
23 changes: 20 additions & 3 deletions main/newscorm/lp_view.php
Expand Up @@ -238,7 +238,7 @@
$safe_id == strval(intval($safe_id)) &&
$safe_item_id == strval(intval($safe_item_id))
) {
$sql = 'SELECT start_date, exe_date, exe_result, exe_weighting
$sql = 'SELECT start_date, exe_date, exe_result, exe_weighting, exe_exo_id
FROM ' . $TBL_TRACK_EXERCICES . '
WHERE exe_id = ' . $safe_exe_id;
$res = Database::query($sql);
Expand Down Expand Up @@ -268,8 +268,25 @@
if (Database::num_rows($res_last_attempt) && !api_is_invitee()) {
$row_last_attempt = Database::fetch_row($res_last_attempt);
$lp_item_view_id = $row_last_attempt[0];

$exercise = new Exercise(api_get_course_int_id());
$exercise->read($row_dates['exe_exo_id']);
$status = 'completed';

if (!empty($exercise->pass_percentage)) {
$status = 'failed';
$success = ExerciseLib::is_success_exercise_result(
$score,
$max_score,
$exercise->pass_percentage
);
if ($success) {
$status = 'passed';
}
}

$sql = "UPDATE $TBL_LP_ITEM_VIEW SET
status = 'completed' ,
status = '$status',
score = $score,
total_time = $mytime
WHERE id='" . $lp_item_view_id . "' AND c_id = $course_id ";
Expand All @@ -289,7 +306,7 @@
if (intval($_GET['fb_type']) > 0) {
$src = 'blank.php?msg=exerciseFinished';
} else {
$src = api_get_path(WEB_CODE_PATH) . 'exercice/result.php?origin=learnpath&id=' . $safe_exe_id;
$src = api_get_path(WEB_CODE_PATH) . 'exercice/result.php?origin=learnpath&id=' . $safe_exe_id.'&'.api_get_cidreq();

if ($debug) {
error_log('Calling URL: ' . $src);
Expand Down

0 comments on commit 90e2852

Please sign in to comment.