Fixing PHP warning + reformat code.

1.9.x
Julio Montoya 11 years ago
parent 0817e05f33
commit a23c2f6f6e
  1. 16
      main/exercice/savescores.php
  2. 74
      main/exercice/showinframes.php

@ -1,5 +1,4 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Saving the scores.
@ -24,20 +23,19 @@ if (isset($_GET['origin']) && $_GET['origin'] == 'learnpath') {
require_once '../inc/global.inc.php';
$this_section = SECTION_COURSES;
require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
$documentPath = api_get_path(SYS_COURSE_PATH).$_course['path']."/document";
$test = $_REQUEST['test'];
$full_file_path = $documentPath.$test;
my_delete($full_file_path.$_user['user_id'].".t.html");
$TABLETRACK_HOTPOTATOES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
$tbl_learnpath_user = Database::get_course_table(TABLE_LEARNPATH_USER);
$TABLE_LP_ITEM_VIEW = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$_cid = api_get_course_id();
$test = $_REQUEST['test'];
$score = $_REQUEST['score'];
$origin = $_REQUEST['origin'];
$learnpath_item_id = intval($_REQUEST['learnpath_item_id']);
@ -54,9 +52,9 @@ $jscript2run = '';
* @param integer Score to save inside the tracking tables (HP and learnpath)
* @return void
*/
function save_scores($file, $score) {
global $origin, $_user, $_cid,
$TABLETRACK_HOTPOTATOES;
function save_scores($file, $score)
{
global $origin, $_user, $_cid, $TABLETRACK_HOTPOTATOES;
// if tracking is disabled record nothing
$weighting = 100; // 100%
$date = api_get_utc_datetime();
@ -107,7 +105,7 @@ if ($origin != 'learnpath') {
Display::display_reduced_header();
$update_sql = "UPDATE $TABLE_LP_ITEM_VIEW SET status = 'completed'
WHERE c_id = $course_id AND lp_item_id= $learnpath_item_id";
Database::query($update_sql);
Database::query($update_sql);
Display::display_confirmation_message(get_lang('HotPotatoesFinished'));
Display::display_footer();
}

@ -5,16 +5,13 @@
* @package chamilo.exercise
* @author Istvan Mandak
*/
/**
* Included libraries
*/
require '../inc/global.inc.php';
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
require_once api_get_path(SYS_CODE_PATH).'exercice/hotpotatoes.lib.php';
$time = time();
$doc_url = str_replace(array('../', '\\', '\\0', '..'), array('', '', '', ''), urldecode($_GET['file']));
$cid = api_get_course_id();
$cid = api_get_course_id();
$document_path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
$document_web_path = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document';
$origin = isset($_REQUEST['origin']) ? $_REQUEST['origin'] : null;
@ -29,62 +26,53 @@ $content = ReadFileCont($full_file_path.$user_id.'.t.html');
if ($content == '') {
$content = ReadFileCont($full_file_path);
// Do not move this like:
$mit = "function Finish(){";
$js_content = "
//Code added - start
var SaveScoreVariable = 0;
function mySaveScore() {
if (SaveScoreVariable==0) {
SaveScoreVariable = 1;
if (C.ie) {
document.location.href = '".api_get_path(WEB_PATH)."main/exercice/savescores.php?origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&time=".Security::remove_XSS($time)."&test=".$doc_url."&uid=".$user_id."&cid=".$cid."&score='+Score;
//window.alert(Score);
} else {
window.location.href = '".api_get_path(WEB_PATH)."main/exercice/savescores.php?origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&time=".Security::remove_XSS($time)."&test=".$doc_url."&uid=".$user_id."&cid=".$cid."&score='+Score;
}
}
}
function Finish(){
mySaveScore();
//Code added - end
// Code added - start
var SaveScoreVariable = 0;
function mySaveScore() {
if (SaveScoreVariable==0) {
SaveScoreVariable = 1;
if (C.ie) {
document.location.href = '".api_get_path(WEB_PATH)."main/exercice/savescores.php?origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&time=".Security::remove_XSS($time)."&test=".$doc_url."&uid=".$user_id."&cid=".$cid."&score='+Score;
//window.alert(Score);
} else {
window.location.href = '".api_get_path(WEB_PATH)."main/exercice/savescores.php?origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&time=".Security::remove_XSS($time)."&test=".$doc_url."&uid=".$user_id."&cid=".$cid."&score='+Score;
}
}
}
function Finish() {
mySaveScore();
// Code added - end
";
$newcontent = str_replace($mit, $js_content, $content);
$prehref = "<!-- BeginTopNavButtons -->";
$posthref = "<!-- BeginTopNavButtons -->";
$newcontent = str_replace($prehref, $posthref, $newcontent);
$newcontent = str_replace($mit, $js_content, $content);
$prehref = "<!-- BeginTopNavButtons -->";
$posthref = "<!-- BeginTopNavButtons -->";
$newcontent = str_replace($prehref, $posthref, $newcontent);
if (CheckSubFolder($full_file_path.$user_id.'.t.html') == 0) {
$newcontent = ReplaceImgTag($newcontent);
}
if (CheckSubFolder($full_file_path.$user_id.'.t.html') == 0) {
$newcontent = ReplaceImgTag($newcontent);
}
} else {
$newcontent = $content;
$newcontent = $content;
}
WriteFileCont($full_file_path.$user_id.'.t.html', $newcontent);
$doc_url = GetFolderPath($doc_url).urlencode(basename($doc_url));
$documentPath= api_get_path(SYS_COURSE_PATH).$_course['path']."/document";
$my_file = Security::remove_XSS($_GET['file']);
$my_file = str_replace(array('../','\\..','\\0','..\\'),array('','','',''),urldecode($my_file));
$my_file = str_replace(array('../', '\\..', '\\0', '..\\'), array('', '', '', ''),urldecode($my_file));
$title = GetQuizName($my_file,$documentPath);
$title = GetQuizName($my_file, $documentPath);
if ($title =='') {
$title = basename($my_file);
$title = basename($my_file);
}
$nameTools = $title;
$noPHP_SELF=true;
if (isset($_SESSION['gradebook'])){
$gradebook= $_SESSION['gradebook'];
}
$noPHP_SELF = true;
if (!empty($gradebook) && $gradebook=='view') {
$interbreadcrumb[]= array (
'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
'name' => get_lang('ToolGradebook')
);
}
$htmlHeadXtra[] = '
<script>
$(document).ready( function(){

Loading…
Cancel
Save