From 1795abfbadd6bfb02745f580bafd968ef82bb3b5 Mon Sep 17 00:00:00 2001 From: Arthur Portugal Date: Tue, 4 Aug 2009 12:12:21 -0500 Subject: [PATCH 1/8] Added last functions to hotpotatoes --- tests/main/exercice/hotpotatoes.lib.test.php | 32 +++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/tests/main/exercice/hotpotatoes.lib.test.php b/tests/main/exercice/hotpotatoes.lib.test.php index 3abe668bf4..f74275d151 100644 --- a/tests/main/exercice/hotpotatoes.lib.test.php +++ b/tests/main/exercice/hotpotatoes.lib.test.php @@ -149,15 +149,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); + } } ?> From 0aa8a8f71bf45a4ed3c9cf549f37fb7e600a8276 Mon Sep 17 00:00:00 2001 From: Arthur Portugal Date: Tue, 4 Aug 2009 12:34:03 -0500 Subject: [PATCH 2/8] Added new functions to all test2 --- tests/all.test2.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 tests/all.test2.php diff --git a/tests/all.test2.php b/tests/all.test2.php new file mode 100755 index 0000000000..1e86a3f694 --- /dev/null +++ b/tests/all.test2.php @@ -0,0 +1,34 @@ +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/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(); +//$test-> run( new HtmlReporter()); + +?> From 538291644a49736ce3851a4598fa77e04a72cc53 Mon Sep 17 00:00:00 2001 From: Arthur Portugal Date: Tue, 4 Aug 2009 14:45:52 -0500 Subject: [PATCH 3/8] Added a second parameter in case the table is in blank --- main/exercice/hotpotatoes.lib.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/main/exercice/hotpotatoes.lib.php b/main/exercice/hotpotatoes.lib.php index 5da6d8240c..6ef8ab9f43 100644 --- a/main/exercice/hotpotatoes.lib.php +++ b/main/exercice/hotpotatoes.lib.php @@ -80,11 +80,17 @@ function GetQuizName($fname,$fpath) { * @param string File path * @return string Comment from the database record */ -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]; } From 6db28d7aa084a382c4032597e9f6650344c3c1ca Mon Sep 17 00:00:00 2001 From: Arthur Portugal Date: Tue, 4 Aug 2009 18:03:51 -0500 Subject: [PATCH 4/8] Added a second parameter in case the table is in blank --- main/exercice/hotpotatoes.lib.php | 1 + 1 file changed, 1 insertion(+) diff --git a/main/exercice/hotpotatoes.lib.php b/main/exercice/hotpotatoes.lib.php index 6ef8ab9f43..9f8636a4fe 100644 --- a/main/exercice/hotpotatoes.lib.php +++ b/main/exercice/hotpotatoes.lib.php @@ -105,6 +105,7 @@ function GetComment($path,$course_code='') { */ function SetComment($path,$comment) { global $dbTable; + $path = Database::escape_string($path); $comment = Database::escape_string($comment); From fe600843361e65bd5496a392151732538110e4a5 Mon Sep 17 00:00:00 2001 From: Arthur Portugal Date: Tue, 4 Aug 2009 18:06:44 -0500 Subject: [PATCH 5/8] Updated the function get comment --- tests/main/exercice/hotpotatoes.lib.test.php | 30 ++++++-------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/tests/main/exercice/hotpotatoes.lib.test.php b/tests/main/exercice/hotpotatoes.lib.test.php index f74275d151..98c8aa051c 100644 --- a/tests/main/exercice/hotpotatoes.lib.test.php +++ b/tests/main/exercice/hotpotatoes.lib.test.php @@ -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); From 6be4455dfe9b47c9273b214a77f9f983159a20ba Mon Sep 17 00:00:00 2001 From: Arthur Portugal Date: Wed, 5 Aug 2009 11:23:58 -0500 Subject: [PATCH 6/8] Updated the function hotpotatoes init --- tests/main/exercice/hotpotatoes.lib.test.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/main/exercice/hotpotatoes.lib.test.php b/tests/main/exercice/hotpotatoes.lib.test.php index 98c8aa051c..2d5beca988 100644 --- a/tests/main/exercice/hotpotatoes.lib.test.php +++ b/tests/main/exercice/hotpotatoes.lib.test.php @@ -107,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; From ec16b280fd87370e9a26e4a3a559ba5c53b21311 Mon Sep 17 00:00:00 2001 From: Arthur Portugal Date: Wed, 5 Aug 2009 11:27:08 -0500 Subject: [PATCH 7/8] Cleaned spaces in blank and added comment --- main/exercice/hotpotatoes.lib.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/main/exercice/hotpotatoes.lib.php b/main/exercice/hotpotatoes.lib.php index 9f8636a4fe..12e14b033b 100644 --- a/main/exercice/hotpotatoes.lib.php +++ b/main/exercice/hotpotatoes.lib.php @@ -79,6 +79,7 @@ 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,$course_code='') { global $dbTable; @@ -105,10 +106,8 @@ function GetComment($path,$course_code='') { */ 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"; From e022b969ea8a409469cf58f8747c2c91d1660a9c Mon Sep 17 00:00:00 2001 From: Carlos Vargas Date: Wed, 5 Aug 2009 18:15:33 -0500 Subject: [PATCH 8/8] show all files downloads in reports --- main/tracking/courseLog.php | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/main/tracking/courseLog.php b/main/tracking/courseLog.php index 1601ab6328..524d92693c 100644 --- a/main/tracking/courseLog.php +++ b/main/tracking/courseLog.php @@ -375,20 +375,30 @@ if($_GET['studentlist'] == 'false') { * DOCUMENTS ***************************/ - echo '
+ if ($_GET['num']==0 or empty($_GET['num'])){ + $num=3; + $link=' - '.get_lang('SeeDetail').''; + } else { + $num=1000; + $link=' - '.get_lang('ViewMinus').''; + } + + + echo '

-  '.get_lang('DocumentsMostDownloaded').' +  '.get_lang('DocumentsMostDownloaded').$link.'

- '; +
'; + $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('','');