fixed whoisonline user picture

skala
ywarnier 17 years ago
commit 04399b15cb
  1. 12
      main/exercice/hotpotatoes.lib.php
  2. 22
      main/tracking/courseLog.php
  3. 13
      tests/all.test2.php
  4. 76
      tests/main/exercice/hotpotatoes.lib.test.php

@ -79,12 +79,19 @@ function GetQuizName($fname,$fpath) {
* Gets the comment about a file from the corresponding database record
* @param string File path
* @return string Comment from the database record
* Added conditional to the table if is empty.
*/
function GetComment($path) {
function GetComment($path,$course_code='') {
global $dbTable;
if (!empty($course_code)) {
$course_info = api_get_course_info($course_code);
$dbTable = Database::get_course_table(TABLE_DOCUMENT,$course_info['dbName']);
}
$path = Database::escape_string($path);
$query = "select comment from $dbTable where path='$path'";
$query = "select comment from $dbTable where path='$path'";
$result = api_sql_query($query,__FILE__,__LINE__);
while ($row = mysql_fetch_array($result)) {
return $row[0];
}
@ -101,7 +108,6 @@ function SetComment($path,$comment) {
global $dbTable;
$path = Database::escape_string($path);
$comment = Database::escape_string($comment);
$query = "UPDATE $dbTable set comment='$comment' where path='$path'";
$result = api_sql_query($query,__FILE__,__LINE__);
return "$result";

@ -375,20 +375,30 @@ if($_GET['studentlist'] == 'false') {
* DOCUMENTS
***************************/
echo '<div class="admin_section">
if ($_GET['num']==0 or empty($_GET['num'])){
$num=3;
$link='&nbsp;-&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&studentlist=false&num=1#ancle">'.get_lang('SeeDetail').'</a>';
} else {
$num=1000;
$link='&nbsp;-&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&studentlist=false&num=0#ancle">'.get_lang('ViewMinus').'</a>';
}
echo '<a name="ancle" id="a"></a><div class="admin_section">
<h4>
<img src="../img/documents.gif" align="absbottom">&nbsp;'.get_lang('DocumentsMostDownloaded').'
<img src="../img/documents.gif" align="absbottom">&nbsp;'.get_lang('DocumentsMostDownloaded').$link.'
</h4>
<table class="data_table">';
<table class="data_table">';
$sql = "SELECT down_doc_path, COUNT(DISTINCT down_user_id), COUNT(down_doc_path) as count_down
FROM $TABLETRACK_DOWNLOADS
FROM $TABLETRACK_DOWNLOADS
WHERE down_cours_id = '$_cid'
GROUP BY down_doc_path
ORDER BY count_down DESC
LIMIT 0, 3";
LIMIT 0, $num";
$rs = api_sql_query($sql, __FILE__, __LINE__);
if ($export_csv) {
$temp=array(get_lang('DocumentsMostDownloaded'),'');
$csv_content[] = array('','');

@ -15,8 +15,17 @@ $_user= 1;
class AllTests2 extends TestSuite {
function AllTests2() {
$this->TestSuite('All tests2');
//$this->addTestFile(dirname(__FILE__).'/main/admin/calendar.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/admin/statistics/statistics.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/admin/calendar.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/admin/statistics/statistics.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/auth/lost_password.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/auth/openid/xrds.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/auth/openid/openid.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/chat/chat_functions.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/conference/get_translation.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/exercice/hotpotatoes.lib.test.php');
}
}
$test = &new AllTests2();

@ -40,19 +40,16 @@ class TestHotpotatoes extends UnitTestCase {
$res=GenerateHpFolder($folder);
$this->assertTrue(is_string($res));
//var_dump($res);
}
}
function testGetComment() {
global $dbTable;
$path = 'test';
$query = "select 1";
$result = api_sql_query($query,__FILE__,__LINE__);
$row = mysql_fetch_array($result);
$res=GetComment($path);
$course_code='test';
$query ="select comment from $dbTable where path='$path'";
$res=GetComment($path,$course_code);
$this->assertTrue(is_string($res));
$this->assertTrue(is_array($row));
//var_dump($res);
//var_dump($row);
}
/* Deprecated
@ -85,10 +82,10 @@ class TestHotpotatoes extends UnitTestCase {
}
function testGetImgParams() {
$fname='test.jpg';
$fpath='main/exercice/test.jpg';
$imgparams=array();
$imgcount=$imgcount + 1;;
$fname='/main/css/academica/images/bg.jpg';
$fpath='main/css/academica/images/';
$imgparams= array();
$imgcount='';
$res=GetImgParams($fname,$fpath,&$imgparams,&$imgcount);
$this->assertTrue(is_null($res));
//var_dump($res);
@ -97,15 +94,6 @@ class TestHotpotatoes extends UnitTestCase {
function testGetQuizName() {
$fname='exercice_submit.php';
$fpath='main/exercice/exercice_submit.php';
$title = GetComment($fname);
$fp = fopen($fpath.$fname, "r");
$pattern = array ( 1 => "title>", 2 => "/title>");
$contents = fread($fp, filesize($fpath.$fname));
fclose($fp);
$contents = api_strtolower($contents);
$s_contents = api_substr($contents,0,api_strpos($contents,$pattern["2"])-1);
$e_contents = api_substr($s_contents,api_strpos($contents,$pattern["1"])+api_strlen($pattern["1"]),api_strlen($s_contents));
$title = $e_contents;
$res=GetQuizName($fname,$fpath);
$this->assertTrue(is_string($res));
//var_dump($e_contents);
@ -119,12 +107,22 @@ class TestHotpotatoes extends UnitTestCase {
}
function testhotpotatoes_init() {
$baseWorkDir='/main/exercice';
$base = api_get_path(SYS_CODE_PATH);
$baseWorkDir=$base.'exercice/';
$res=hotpotatoes_init($baseWorkDir);
$this->assertTrue(is_bool($res));
$this->assertFalse($res);
//var_dump($res);
}
function testhotpotatoes_initWithRemoveFolder() {
$base = '/tmp/';
$baseWorkDir=$base.'test123/';
$res=hotpotatoes_init($baseWorkDir);
$this->assertTrue($res);
rmdir($baseWorkDir);
//var_dump($res);
}
function testHotPotGCt() {
$folder='/main/exercice';
$flag=4;
@ -149,15 +147,31 @@ class TestHotpotatoes extends UnitTestCase {
//var_dump($res);
}
function testReplaceImgTag() {
$content='src="test2.jpg"';
$res=ReplaceImgTag($content);
$this->assertTrue(is_string($res));
//var_dump($res);
}
function testSetComment() {
global $dbTable;
$path='/main/exercice';
$comment='testing this function';
$comment = Database::escape_string($comment);
$query = "UPDATE $dbTable set comment='$comment' where path='$path'";
$result = api_sql_query($query,__FILE__,__LINE__);
$res=SetComment($path,$comment);
$this->assertTrue(is_string($res));
//var_dump($resu);
}
function testWriteFileCont() {
$full_file_path='/main/exercice/';
$content='test test test';
$res=WriteFileCont($full_file_path,$content);
$this->assertTrue(is_bool($res));
//var_dump($res);
}
}
?>

Loading…
Cancel
Save