From fecfe7f7b39c46745076ab4652af144f5e133c35 Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Mon, 13 Mar 2017 14:22:42 +0000 Subject: [PATCH 01/68] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- main/admin/usergroups.php | 38 +++++----- main/inc/lib/usergroup.lib.php | 124 ++++++++++++++++----------------- 2 files changed, 81 insertions(+), 81 deletions(-) diff --git a/main/admin/usergroups.php b/main/admin/usergroups.php index de152d9afa..9ed8b4fd56 100755 --- a/main/admin/usergroups.php +++ b/main/admin/usergroups.php @@ -15,16 +15,16 @@ api_protect_limit_for_session_admin(); //Add the JS needed to use the jqgrid $htmlHeadXtra[] = api_get_jqgrid_js(); // setting breadcrumbs -$interbreadcrumb[] = array('url' => 'index.php','name' => get_lang('PlatformAdmin')); +$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); $action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : null; if ($action == 'add') { - $interbreadcrumb[] = array('url' => 'usergroups.php','name' => get_lang('Classes')); - $interbreadcrumb[] = array('url' => '#','name' => get_lang('Add')); + $interbreadcrumb[] = array('url' => 'usergroups.php', 'name' => get_lang('Classes')); + $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Add')); } elseif ($action == 'edit') { - $interbreadcrumb[] = array('url' => 'usergroups.php','name' => get_lang('Classes')); - $interbreadcrumb[] = array('url' => '#','name' => get_lang('Edit')); + $interbreadcrumb[] = array('url' => 'usergroups.php', 'name' => get_lang('Classes')); + $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Edit')); } else { - $interbreadcrumb[] = array('url' => '#','name' => get_lang('Classes')); + $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Classes')); } // The header. @@ -55,13 +55,13 @@ $columns = array( ); //Column config -$column_model = array( - array('name'=>'name', 'index'=>'name', 'width'=>'35', 'align'=>'left'), - array('name'=>'users', 'index'=>'users', 'width'=>'15', 'align'=>'left'), - array('name'=>'courses', 'index'=>'courses', 'width'=>'15', 'align'=>'left'), - array('name'=>'sessions', 'index'=>'sessions', 'width'=>'15', 'align'=>'left'), - array('name'=>'group_type', 'index'=>'group_type', 'width'=>'15', 'align'=>'center'), - array('name'=>'actions', 'index'=>'actions', 'width'=>'20', 'align'=>'center', 'sortable'=>'false','formatter'=>'action_formatter'), +$column_model = array( + array('name'=>'name', 'index'=>'name', 'width'=>'35', 'align'=>'left'), + array('name'=>'users', 'index'=>'users', 'width'=>'15', 'align'=>'left'), + array('name'=>'courses', 'index'=>'courses', 'width'=>'15', 'align'=>'left'), + array('name'=>'sessions', 'index'=>'sessions', 'width'=>'15', 'align'=>'left'), + array('name'=>'group_type', 'index'=>'group_type', 'width'=>'15', 'align'=>'center'), + array('name'=>'actions', 'index'=>'actions', 'width'=>'20', 'align'=>'center', 'sortable'=>'false', 'formatter'=>'action_formatter'), ); //Autowidth @@ -73,11 +73,11 @@ $extra_params['sortorder'] = 'desc'; //With this function we can add actions to the jgrid $action_links = 'function action_formatter (cellvalue, options, rowObject) { return \'' - .' ' . Display::return_icon('user_to_class.png', get_lang('SubscribeUsersToClass'), null, ICON_SIZE_MEDIUM) . '' - .' ' . Display::return_icon('course_to_class.png', get_lang('SubscribeClassToCourses'), null, ICON_SIZE_MEDIUM) . '' - .' ' . Display::return_icon('sessions_to_class.png', get_lang('SubscribeClassToSessions'), null, ICON_SIZE_MEDIUM) . '' - .' ' . Display::return_icon('edit.png', get_lang('Edit'), null, ICON_SIZE_SMALL) . '' - .' ' . Display::return_icon('delete.png', get_lang('Delete'), null, ICON_SIZE_SMALL) . '\'; + .' '.Display::return_icon('user_to_class.png', get_lang('SubscribeUsersToClass'), null, ICON_SIZE_MEDIUM).'' + .' '.Display::return_icon('course_to_class.png', get_lang('SubscribeClassToCourses'), null, ICON_SIZE_MEDIUM).'' + .' '.Display::return_icon('sessions_to_class.png', get_lang('SubscribeClassToSessions'), null, ICON_SIZE_MEDIUM).'' + .' '.Display::return_icon('edit.png', get_lang('Edit'), null, ICON_SIZE_SMALL).'' + .' '.Display::return_icon('delete.png', get_lang('Delete'), null, ICON_SIZE_SMALL).'\'; }'; ?> @@ -135,7 +135,7 @@ if ($action == 'add') { } else { echo '
'; echo ''. - Display::return_icon('back.png',get_lang('Back'),'',ICON_SIZE_MEDIUM).''; + Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM).''; echo '
'; $token = Security::get_token(); $form->addElement('hidden', 'sec_token'); diff --git a/main/inc/lib/usergroup.lib.php b/main/inc/lib/usergroup.lib.php index 9990a4fd55..dc8e2b1a3c 100755 --- a/main/inc/lib/usergroup.lib.php +++ b/main/inc/lib/usergroup.lib.php @@ -80,7 +80,7 @@ class UserGroup extends Model "; $result = Database::query($sql); if (Database::num_rows($result)) { - $row = Database::fetch_array($result); + $row = Database::fetch_array($result); return $row['count']; } @@ -99,7 +99,7 @@ class UserGroup extends Model "; $result = Database::query($sql); if (Database::num_rows($result)) { - $row = Database::fetch_array($result); + $row = Database::fetch_array($result); return $row['count']; } } @@ -124,7 +124,7 @@ class UserGroup extends Model "; $result = Database::query($sql); if (Database::num_rows($result)) { - $row = Database::fetch_array($result); + $row = Database::fetch_array($result); return $row['count']; } @@ -145,7 +145,7 @@ class UserGroup extends Model "; $result = Database::query($sql); if (Database::num_rows($result)) { - $row = Database::fetch_array($result); + $row = Database::fetch_array($result); return $row['count']; } @@ -532,13 +532,13 @@ class UserGroup extends Model INNER JOIN {$this->table} g ON (u.usergroup_id = g.id) "; - $where = array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId))); + $where = array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId))); } else { $from = $this->usergroup_rel_user_table." u INNER JOIN {$this->table} g ON (u.usergroup_id = g.id) "; - $where = array('where' => array('user_id = ?' => $userId)); + $where = array('where' => array('user_id = ?' => $userId)); } if ($filterByType !== null) { @@ -571,10 +571,10 @@ class UserGroup extends Model $urlId = api_get_current_access_url_id(); $from = $this->usergroup_rel_user_table." u INNER JOIN {$this->access_url_rel_usergroup} a ON (a.usergroup_id AND u.usergroup_id)"; - $where = array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId))); + $where = array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId))); } else { $from = $this->usergroup_rel_user_table." u "; - $where = array('where' => array('user_id = ?' => $userId)); + $where = array('where' => array('user_id = ?' => $userId)); } $results = Database::select( @@ -894,7 +894,7 @@ class UserGroup extends Model } $result = $new_result; } - $columns = array('name', 'users', 'courses','sessions', 'group_type'); + $columns = array('name', 'users', 'courses', 'sessions', 'group_type'); if (!in_array($sidx, $columns)) { $sidx = 'name'; @@ -1297,7 +1297,7 @@ class UserGroup extends Model } } } - $response->addAssign('ajax_list_courses','innerHTML', api_utf8_encode($return)); + $response->addAssign('ajax_list_courses', 'innerHTML', api_utf8_encode($return)); return $response; } @@ -1401,7 +1401,7 @@ class UserGroup extends Model * @param string style css * @return array with the file and the style of an image i.e $array['file'] $array['style'] */ - public function get_picture_group($id, $picture_file, $height, $size_picture = GROUP_IMAGE_SIZE_MEDIUM , $style = '') + public function get_picture_group($id, $picture_file, $height, $size_picture = GROUP_IMAGE_SIZE_MEDIUM, $style = '') { $picture = array(); //$picture['style'] = $style; @@ -1594,7 +1594,7 @@ class UserGroup extends Model GROUP_USER_PERMISSION_READER, GROUP_USER_PERMISSION_HRM, ); - $user_role = self::get_user_group_role($user_id, $group_id); + $user_role = self::get_user_group_role($user_id, $group_id); if (in_array($user_role, $roles)) { return true; } else { @@ -1611,7 +1611,7 @@ class UserGroup extends Model * */ public function get_user_group_role($user_id, $group_id) { - $table_group_rel_user= $this->usergroup_rel_user_table; + $table_group_rel_user = $this->usergroup_rel_user_table; $return_value = 0; if (!empty($user_id) && !empty($group_id)) { $sql = "SELECT relation_type FROM $table_group_rel_user @@ -1619,8 +1619,8 @@ class UserGroup extends Model usergroup_id = ".intval($group_id)." AND user_id = ".intval($user_id)." "; $result = Database::query($sql); - if (Database::num_rows($result)>0) { - $row = Database::fetch_array($result,'ASSOC'); + if (Database::num_rows($result) > 0) { + $row = Database::fetch_array($result, 'ASSOC'); $return_value = $row['relation_type']; } } @@ -1675,7 +1675,7 @@ class UserGroup extends Model if (is_array($user_list) && is_array($group_list)) { foreach ($group_list as $group_id) { foreach ($user_list as $user_id) { - $role = self::get_user_group_role($user_id,$group_id); + $role = self::get_user_group_role($user_id, $group_id); if ($role == 0) { $sql = "INSERT INTO $table_url_rel_group SET @@ -1706,7 +1706,7 @@ class UserGroup extends Model public function delete_user_rel_group($user_id, $group_id) { $table = $this->usergroup_rel_user_table; - $sql= "DELETE FROM $table + $sql = "DELETE FROM $table WHERE user_id = ".intval($user_id)." AND usergroup_id = ".intval($group_id)." "; @@ -1762,7 +1762,7 @@ class UserGroup extends Model $sql = "UPDATE $table_group_rel_user SET relation_type = ".intval($relation_type)." - WHERE user_id = $user_id AND usergroup_id = $group_id" ; + WHERE user_id = $user_id AND usergroup_id = $group_id"; Database::query($sql); } @@ -1804,7 +1804,7 @@ class UserGroup extends Model if (Database::num_rows($result) > 0) { while ($row = Database::fetch_array($result, 'ASSOC')) { if ($with_image) { - $picture = self::get_picture_group($row['id'], $row['picture'],80); + $picture = self::get_picture_group($row['id'], $row['picture'], 80); $img = ''; $row['picture'] = $img; } @@ -1840,11 +1840,11 @@ class UserGroup extends Model ORDER BY count DESC LIMIT $num"; - $result=Database::query($sql); + $result = Database::query($sql); $array = array(); while ($row = Database::fetch_array($result, 'ASSOC')) { if ($with_image) { - $picture = self::get_picture_group($row['id'], $row['picture'],80); + $picture = self::get_picture_group($row['id'], $row['picture'], 80); $img = ''; $row['picture'] = $img; } @@ -1889,11 +1889,11 @@ class UserGroup extends Model ORDER BY created_at DESC LIMIT $num "; - $result=Database::query($sql); + $result = Database::query($sql); $array = array(); while ($row = Database::fetch_array($result, 'ASSOC')) { if ($with_image) { - $picture = self::get_picture_group($row['id'], $row['picture'],80); + $picture = self::get_picture_group($row['id'], $row['picture'], 80); $img = ''; $row['picture'] = $img; } @@ -1927,7 +1927,7 @@ class UserGroup extends Model $tbl_user = Database::get_main_table(TABLE_MAIN_USER); $group_id = intval($group_id); - if (empty($group_id)){ + if (empty($group_id)) { return array(); } @@ -1942,9 +1942,9 @@ class UserGroup extends Model $where_relation_condition = ''; } else { $new_relation_type = array(); - foreach($relation_type as $rel) { + foreach ($relation_type as $rel) { $rel = intval($rel); - $new_relation_type[] ="'$rel'"; + $new_relation_type[] = "'$rel'"; } $relation_type = implode(',', $new_relation_type); if (!empty($relation_type)) @@ -1988,7 +1988,7 @@ class UserGroup extends Model $tbl_user = Database::get_main_table(TABLE_MAIN_USER); $group_id = intval($group_id); - if (empty($group_id)){ + if (empty($group_id)) { return array(); } @@ -1999,7 +1999,7 @@ class UserGroup extends Model WHERE gu.usergroup_id= $group_id ORDER BY relation_type, firstname"; - $result=Database::query($sql); + $result = Database::query($sql); $array = array(); while ($row = Database::fetch_array($result, 'ASSOC')) { $array[$row['id']] = $row; @@ -2027,33 +2027,33 @@ class UserGroup extends Model case GROUP_USER_PERMISSION_READER: // I'm just a reader $relation_group_title = get_lang('IAmAReader'); - $links .= '
  • '. - Display::return_icon('invitation_friend.png', get_lang('InviteFriends')) . get_lang('InviteFriends') . '
  • '; - $links .= '
  • '. - Display::return_icon('group_leave.png', get_lang('LeaveGroup')) . get_lang('LeaveGroup') . '
  • '; + $links .= '
  • '. + Display::return_icon('invitation_friend.png', get_lang('InviteFriends')).get_lang('InviteFriends').'
  • '; + $links .= '
  • '. + Display::return_icon('group_leave.png', get_lang('LeaveGroup')).get_lang('LeaveGroup').'
  • '; if (UserGroup::canLeave($group_info)) { - $links .= '
  • '. - Display::return_icon('group_leave.png', get_lang('LeaveGroup')) . get_lang('LeaveGroup') . '
  • '; + $links .= '
  • '. + Display::return_icon('group_leave.png', get_lang('LeaveGroup')).get_lang('LeaveGroup').'
  • '; } break; case GROUP_USER_PERMISSION_ADMIN: $relation_group_title = get_lang('IAmAnAdmin'); - $links .= '
  • '. - Display::return_icon('group_edit.png', get_lang('EditGroup')) . get_lang('EditGroup') . '
  • '; - $links .= '
  • '. - Display::return_icon('waiting_list.png', get_lang('WaitingList')) . get_lang('WaitingList') . '
  • '; - $links .= '
  • '. - Display::return_icon('invitation_friend.png', get_lang('InviteFriends')) . get_lang('InviteFriends') . '
  • '; + $links .= '
  • '. + Display::return_icon('group_edit.png', get_lang('EditGroup')).get_lang('EditGroup').'
  • '; + $links .= '
  • '. + Display::return_icon('waiting_list.png', get_lang('WaitingList')).get_lang('WaitingList').'
  • '; + $links .= '
  • '. + Display::return_icon('invitation_friend.png', get_lang('InviteFriends')).get_lang('InviteFriends').'
  • '; if (UserGroup::canLeave($group_info)) { $links .= '
  • '. - Display::return_icon('group_leave.png', get_lang('LeaveGroup')) . get_lang('LeaveGroup') . '
  • '; + Display::return_icon('group_leave.png', get_lang('LeaveGroup')).get_lang('LeaveGroup').''; } break; case GROUP_USER_PERMISSION_PENDING_INVITATION: // $links .= '
  • '.Display::return_icon('addd.gif', get_lang('YouHaveBeenInvitedJoinNow'), array('hspace'=>'6')).'
  • '; break; case GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER: - $relation_group_title = get_lang('WaitingForAdminResponse'); + $relation_group_title = get_lang('WaitingForAdminResponse'); break; case GROUP_USER_PERMISSION_MODERATOR: $relation_group_title = get_lang('IAmAModerator'); @@ -2061,28 +2061,28 @@ class UserGroup extends Model //$links .= '
  • '. Display::return_icon('message_list.png', get_lang('MessageList'), array('hspace'=>'6')).''.get_lang('MessageList').'
  • '; //$links .= '
  • '. Display::return_icon('member_list.png', get_lang('MemberList'), array('hspace'=>'6')).''.get_lang('MemberList').'
  • '; if ($group_info['visibility'] == GROUP_PERMISSION_CLOSED) { - $links .= '
  • '. - Display::return_icon('waiting_list.png', get_lang('WaitingList')) . get_lang('WaitingList') . '
  • '; + $links .= '
  • '. + Display::return_icon('waiting_list.png', get_lang('WaitingList')).get_lang('WaitingList').'
  • '; } - $links .= '
  • '. - Display::return_icon('invitation_friend.png', get_lang('InviteFriends')) . get_lang('InviteFriends') . '
  • '; + $links .= '
  • '. + Display::return_icon('invitation_friend.png', get_lang('InviteFriends')).get_lang('InviteFriends').'
  • '; if (UserGroup::canLeave($group_info)) { - $links .= '
  • '. - Display::return_icon('group_leave.png', get_lang('LeaveGroup')) . get_lang('LeaveGroup') . '
  • '; + $links .= '
  • '. + Display::return_icon('group_leave.png', get_lang('LeaveGroup')).get_lang('LeaveGroup').'
  • '; } break; case GROUP_USER_PERMISSION_HRM: $relation_group_title = get_lang('IAmAHRM'); $links .= '
  • '. - Display::return_icon('new-message.png', get_lang('NewTopic')) . get_lang('NewTopic') . '
  • '; - $links .= '
  • '. - Display::return_icon('message_list.png', get_lang('MessageList')) . get_lang('MessageList') . '
  • '; - $links .= '
  • '. - Display::return_icon('invitation_friend.png', get_lang('InviteFriends')) . get_lang('InviteFriends') . '
  • '; - $links .= '
  • '. - Display::return_icon('member_list.png', get_lang('MemberList')) . get_lang('MemberList') . '
  • '; - $links .= '
  • '. - Display::return_icon('delete_data.gif', get_lang('LeaveGroup')) . get_lang('LeaveGroup') . '
  • '; + Display::return_icon('new-message.png', get_lang('NewTopic')).get_lang('NewTopic').''; + $links .= '
  • '. + Display::return_icon('message_list.png', get_lang('MessageList')).get_lang('MessageList').'
  • '; + $links .= '
  • '. + Display::return_icon('invitation_friend.png', get_lang('InviteFriends')).get_lang('InviteFriends').'
  • '; + $links .= '
  • '. + Display::return_icon('member_list.png', get_lang('MemberList')).get_lang('MemberList').'
  • '; + $links .= '
  • '. + Display::return_icon('delete_data.gif', get_lang('LeaveGroup')).get_lang('LeaveGroup').'
  • '; break; default: //$links .= '
  • '.Display::return_icon('addd.gif', get_lang('JoinGroup'), array('hspace'=>'6')).'
  • '; @@ -2174,7 +2174,7 @@ class UserGroup extends Model } $direction = 'ASC'; - if (!in_array($direction, array('ASC','DESC'))) { + if (!in_array($direction, array('ASC', 'DESC'))) { $direction = 'ASC'; } @@ -2185,8 +2185,8 @@ class UserGroup extends Model $sql .= " LIMIT $from,$number_of_items"; $res = Database::query($sql); - if (Database::num_rows($res)> 0) { - while ($row = Database::fetch_array($res,'ASSOC')) { + if (Database::num_rows($res) > 0) { + while ($row = Database::fetch_array($res, 'ASSOC')) { if (!in_array($row['id'], $return)) { $return[$row['id']] = $row; } @@ -2211,7 +2211,7 @@ class UserGroup extends Model if ($i == $max_level) { $select_part .= "rg$rg_number.group_id as id_$rg_number "; } else { - $select_part .="rg$rg_number.group_id as id_$rg_number, "; + $select_part .= "rg$rg_number.group_id as id_$rg_number, "; } if ($i == 1) { $cond_part .= "FROM $t_rel_group rg0 LEFT JOIN $t_rel_group rg$i on rg$rg_number.group_id = rg$i.subgroup_id "; @@ -2396,7 +2396,7 @@ class UserGroup extends Model $nameList = ''; From 8b8e36895c75f9f7ed8ba95462b1c3bef0d44fc5 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Tue, 14 Mar 2017 11:37:58 -0500 Subject: [PATCH 02/68] Fix #1505 Show results for fill in blanks --- main/exercise/fill_blanks.class.php | 43 ++++++++++++++------ main/inc/lib/exercise_show_functions.lib.php | 2 +- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/main/exercise/fill_blanks.class.php b/main/exercise/fill_blanks.class.php index b7a6b747cf..32f9b97cf4 100755 --- a/main/exercise/fill_blanks.class.php +++ b/main/exercise/fill_blanks.class.php @@ -1099,13 +1099,14 @@ class FillBlanks extends Question /** * return the HTML display of the answer * @param string $answer - * @param bool $resultsDisabled + * @param int $feedbackType + * @param bool $resultsDisabled * @param bool $showTotalScoreAndUserChoices - * * @return string */ public static function getHtmlDisplayForAnswer( $answer, + $feedbackType, $resultsDisabled = false, $showTotalScoreAndUserChoices = false ) { @@ -1127,13 +1128,17 @@ class FillBlanks extends Question $listStudentAnswerInfo['studentanswer'][$i] = self::getHtmlRightAnswer( $listStudentAnswerInfo['studentanswer'][$i], $listStudentAnswerInfo['tabwords'][$i], - $resultsDisabled + $feedbackType, + $resultsDisabled, + $showTotalScoreAndUserChoices ); } else { $listStudentAnswerInfo['studentanswer'][$i] = self::getHtmlWrongAnswer( $listStudentAnswerInfo['studentanswer'][$i], $listStudentAnswerInfo['tabwords'][$i], - $resultsDisabled + $feedbackType, + $resultsDisabled, + $showTotalScoreAndUserChoices ); } } @@ -1155,12 +1160,26 @@ class FillBlanks extends Question * @param string $answer * @param string $correct * @param string $right - * @param bool $resultsDisabled - * + * @param int $feedbackType + * @param bool $resultsDisabled + * @param bool $showTotalScoreAndUserChoices * @return string */ - public static function getHtmlAnswer($answer, $correct, $right, $resultsDisabled = false) + public static function getHtmlAnswer($answer, $correct, $right, $feedbackType, $resultsDisabled = false, $showTotalScoreAndUserChoices = false) { + $hideExpectedAnswer = false; + if ($feedbackType == 0 && ($resultsDisabled == RESULT_DISABLE_SHOW_SCORE_ONLY)) { + $hideExpectedAnswer = true; + } + + if ($resultsDisabled == RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT) { + if ($showTotalScoreAndUserChoices) { + $hideExpectedAnswer = false; + } else { + $hideExpectedAnswer = true; + } + } + $style = "color: green"; if (!$right) { $style = "color: red; text-decoration: line-through;"; @@ -1193,7 +1212,7 @@ class FillBlanks extends Question $correctAnswerHtml = "".$correct.""; } - if ($resultsDisabled) { + if ($hideExpectedAnswer) { $correctAnswerHtml = " - "; } @@ -1214,9 +1233,9 @@ class FillBlanks extends Question * * @return string */ - public static function getHtmlRightAnswer($answer, $correct, $resultsDisabled = false) + public static function getHtmlRightAnswer($answer, $correct, $feedbackType, $resultsDisabled = false, $showTotalScoreAndUserChoices = false) { - return self::getHtmlAnswer($answer, $correct, true, $resultsDisabled); + return self::getHtmlAnswer($answer, $correct, true, $feedbackType, $resultsDisabled, $showTotalScoreAndUserChoices); } /** @@ -1227,9 +1246,9 @@ class FillBlanks extends Question * * @return string */ - public static function getHtmlWrongAnswer($answer, $correct, $resultsDisabled = false) + public static function getHtmlWrongAnswer($answer, $correct, $feedbackType, $resultsDisabled = false, $showTotalScoreAndUserChoices = false) { - return self::getHtmlAnswer($answer, $correct, false, $resultsDisabled); + return self::getHtmlAnswer($answer, $correct, false, $feedbackType, $resultsDisabled, $showTotalScoreAndUserChoices); } /** diff --git a/main/inc/lib/exercise_show_functions.lib.php b/main/inc/lib/exercise_show_functions.lib.php index fe2d46adbc..40657ce19e 100755 --- a/main/inc/lib/exercise_show_functions.lib.php +++ b/main/inc/lib/exercise_show_functions.lib.php @@ -37,7 +37,7 @@ class ExerciseShowFunctions $originalStudentAnswer = '', $showTotalScoreAndUserChoices ) { - $answerHTML = FillBlanks::getHtmlDisplayForAnswer($answer, $resultsDisabled, $showTotalScoreAndUserChoices); + $answerHTML = FillBlanks::getHtmlDisplayForAnswer($answer, $feedbackType, $resultsDisabled, $showTotalScoreAndUserChoices); if (strpos($originalStudentAnswer, 'font color') !== false) { $answerHTML = $originalStudentAnswer; } From 8ccc30396ba0cae34f68a6f09afe48edf19ca157 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Tue, 14 Mar 2017 15:22:31 -0500 Subject: [PATCH 03/68] Avoid duplicated code - refs BT#12454 --- main/announcements/announcements.php | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/main/announcements/announcements.php b/main/announcements/announcements.php index f4da8a3afe..10cb93a007 100755 --- a/main/announcements/announcements.php +++ b/main/announcements/announcements.php @@ -432,21 +432,15 @@ switch ($action) { } $element = CourseManager::addUserGroupMultiSelect($form, array()); - $form->setRequired($element); - - if (!isset($announcement_to_modify)) { - $announcement_to_modify = ''; - } - - $form->addCheckBox('email_ann', '', get_lang('EmailOption')); } else { - if (!isset($announcement_to_modify)) { - $announcement_to_modify = ''; - } - $element = CourseManager::addGroupMultiSelect($form, $group_properties['iid'], array()); - $form->setRequired($element); - $form->addCheckBox('email_ann', '', get_lang('EmailOption')); + } + + $form->setRequired($element); + $form->addCheckBox('email_ann', '', get_lang('EmailOption')); + + if (!isset($announcement_to_modify)) { + $announcement_to_modify = ''; } $announcementInfo = AnnouncementManager::get_by_id($course_id, $id); From 1697235826102bd41e5b5be55fb01b7eff53bc41 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Tue, 14 Mar 2017 16:11:26 -0500 Subject: [PATCH 04/68] Allow add description and help blocks for Advanced Settings Button - refs BT#12454 --- .../pear/HTML/QuickForm/advanced_settings.php | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/main/inc/lib/pear/HTML/QuickForm/advanced_settings.php b/main/inc/lib/pear/HTML/QuickForm/advanced_settings.php index 5b6c86316a..3520952825 100755 --- a/main/inc/lib/pear/HTML/QuickForm/advanced_settings.php +++ b/main/inc/lib/pear/HTML/QuickForm/advanced_settings.php @@ -45,15 +45,27 @@ class HTML_QuickForm_advanced_settings extends HTML_QuickForm_static { $name = $this->getAttribute('name'); $text = $this->getAttribute('label'); + $label = is_array($text) ? $text[0] : $text; - return '
    - -
    - -
    -
    '; + $html = '
    '; + + if (is_array($text) && isset($text[1])) { + $html .= ''.$text[1].''; + } + + $html .= ' + + '; + + if (is_array($text) && isset($text[2])) { + $html .= '
    '.$text[2].'
    '; + } + + $html .= '
    '; + + return $html; } } From 3aa2f72e2cdf85da166d0cc6f808304bffe1a34a Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Tue, 14 Mar 2017 17:24:42 -0500 Subject: [PATCH 05/68] Allow sent announcements to all users in course/group - refs BT#12454 --- main/announcements/announcements.php | 22 +++++++++++++++++++++- main/inc/lib/AnnouncementManager.php | 10 +++++----- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/main/announcements/announcements.php b/main/announcements/announcements.php index 10cb93a007..6e8022d371 100755 --- a/main/announcements/announcements.php +++ b/main/announcements/announcements.php @@ -378,6 +378,9 @@ switch ($action) { $nameTools = $form_name; $form->addElement('header', $form_name); + $form->addButtonAdvancedSettings('choose_recipients', [get_lang('ChooseRecipients'), get_lang('AnnouncementChooseRecipientsDescription')]); + $form->addHtml(''); +// $form->setRequired($element); $form->addCheckBox('email_ann', '', get_lang('EmailOption')); if (!isset($announcement_to_modify)) { @@ -461,6 +465,21 @@ switch ($action) { } } + foreach ($defaults['users'] as $value) { + $parts = explode(':', $value); + + if (isset($parts[1]) && !empty($parts[1])) { + $form->addHtml(" + + "); + break; + } + } + $defaults['email_ann'] = true; $form->addElement('text', 'title', get_lang('EmailTitle')); @@ -500,6 +519,7 @@ switch ($action) { if ($form->validate()) { $data = $form->getSubmitValues(); + $data['users'] = isset($data['users']) ? $data['users'] : ['everyone']; $sendToUsersInSession = isset($data['send_to_users_in_session']) ? true : false; diff --git a/main/inc/lib/AnnouncementManager.php b/main/inc/lib/AnnouncementManager.php index ef4b79f3bc..d91b53a98e 100755 --- a/main/inc/lib/AnnouncementManager.php +++ b/main/inc/lib/AnnouncementManager.php @@ -1475,7 +1475,7 @@ class AnnouncementManager // No group $cond_user_id = " AND ( ip.lastedit_user_id = '".$user_id."' OR ( - ip.to_user_id='".$user_id."' OR + (ip.to_user_id='$user_id' OR ip.to_user_id IS NULL) OR (ip.to_group_id IS NULL OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).")) ) ) "; @@ -1487,11 +1487,11 @@ class AnnouncementManager } else { if ($group_id == 0) { $cond_user_id = " AND ( - ip.to_user_id = $user_id AND (ip.to_group_id IS NULL OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).")) + (ip.to_user_id='$user_id' OR ip.to_user_id IS NULL) AND (ip.to_group_id IS NULL OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).")) ) "; } else { $cond_user_id = " AND ( - ip.to_user_id = $user_id AND (ip.to_group_id IS NULL OR ip.to_group_id IN (0, ".$group_id.")) + (ip.to_user_id='$user_id' OR ip.to_user_id IS NULL) AND (ip.to_group_id IS NULL OR ip.to_group_id IN (0, ".$group_id.")) )"; } } @@ -1514,10 +1514,10 @@ class AnnouncementManager if ($allowUserEditSetting && !api_is_anonymous()) { $cond_user_id = " AND ( ip.lastedit_user_id = '".api_get_user_id()."' OR - (ip.to_user_id='".$user_id."' AND (ip.to_group_id='0' OR ip.to_group_id IS NULL)) + ((ip.to_user_id='$user_id' OR ip.to_user_id IS NULL) AND (ip.to_group_id='0' OR ip.to_group_id IS NULL)) ) "; } else { - $cond_user_id = " AND (ip.to_user_id='".$user_id."' AND (ip.to_group_id='0' OR ip.to_group_id IS NULL) ) "; + $cond_user_id = " AND ((ip.to_user_id='$user_id' OR ip.to_user_id IS NULL) AND (ip.to_group_id='0' OR ip.to_group_id IS NULL) ) "; } $sql = "SELECT $select From 6b416a51fa226af8a3c673e37bced24edcd8c905 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Tue, 14 Mar 2017 17:44:34 -0500 Subject: [PATCH 06/68] Update dates in license file --- license.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/license.txt b/license.txt index ebf52bd32f..be3ab6348e 100755 --- a/license.txt +++ b/license.txt @@ -1,11 +1,11 @@ Chamilo LMS - elearning and course management software -Copyright (c) 2008-2012 BeezNest Latino SAC, Peru & BeezNest Belgium SPRL, Belgium +Copyright (c) 2008-2017 BeezNest Latino SAC, Peru & BeezNest Belgium SPRL, Belgium Copyright (c) 2012 Université de Genève, Switzerland -Copyright (c) 2010-2012 Université de Grenoble, France +Copyright (c) 2010-2017 Université de Grenoble, France Copyright (c) 2011-2012 CBlue SPRL, Belgium -Copyright (c) Juan Carlos Raña (independent), Spain +Copyright (c) 2004-2012 Juan Carlos Raña (independent), Spain Copyright (c) 2004-2009 Dokeos SPRL, Belgium Copyright (c) 2003-2007 Ghent University (UGent) Copyright (c) 2001-2004 Universite catholique de Louvain (UCL) From 709c658a3ed6e575a7ce24c10fa4ef890db2991a Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Wed, 15 Mar 2017 08:32:42 +0100 Subject: [PATCH 07/68] Avoid main folder --- .styleci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.styleci.yml b/.styleci.yml index 1c4558c962..aa6de9bb73 100644 --- a/.styleci.yml +++ b/.styleci.yml @@ -14,6 +14,7 @@ finder: exclude: - 'app/cache/*' - 'app/logs/*' + - 'main/*' - 'documentation/*' - 'app/Migrations/*' - 'app/Resources/*' From 341f542ba3ba7db52099092bb21662bb6c97d772 Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Wed, 15 Mar 2017 09:08:24 +0100 Subject: [PATCH 08/68] Avoid PHP warnings when using portuguese. --- main/inc/lib/internationalization.lib.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/main/inc/lib/internationalization.lib.php b/main/inc/lib/internationalization.lib.php index 3a3322852b..09fd23c200 100755 --- a/main/inc/lib/internationalization.lib.php +++ b/main/inc/lib/internationalization.lib.php @@ -678,7 +678,16 @@ function date_to_str_ago($date, $timeZone = 'UTC') } $getOldTimezone = api_get_timezone(); - $timeAgo = new TimeAgo($timeZone, api_get_language_isocode()); + + $isoCode = api_get_language_isocode(); + if ($isoCode == 'pt') { + $isoCode = 'pt-BR'; + } + $checkFile = api_get_path(SYS_PATH).'vendor/jimmiw/php-time-ago/translations/'.$isoCode.'.php'; + if (!file_exists($checkFile)) { + $isoCode = 'en'; + } + $timeAgo = new TimeAgo($timeZone, $isoCode); $value = $timeAgo->inWords($date); date_default_timezone_set($getOldTimezone); From af1b9d246972e08612711ef5ca8e35a7b5fe3549 Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Wed, 15 Mar 2017 09:39:40 +0100 Subject: [PATCH 09/68] Avoid external libs --- .scrutinizer.yml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 54834d00a6..8f1169bf8a 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -163,3 +163,40 @@ tools: - 'tests/*' enabled: true php_code_coverage: true + +filter: + excluded_paths: + - 'app/cache/*' + - 'app/logs/*' + - 'documentation/*' + - 'app/Migrations/*' + - 'app/Resources/*' + - 'main/admin/db.php' + - 'main/auth/cas/lib/CAS/*' + - 'main/inc/lib/browser/*' + - 'main/inc/lib/freemindflashbrowser/*' + - 'main/inc/lib/internationalization_database/*' + - 'main/inc/lib/javascript/*' + - 'main/inc/lib/kses-0.2.2/*' + - 'main/inc/lib/mimetex/*' + - 'main/inc/lib/nanogong/*' + - 'main/inc/lib/nusoap/*' + - 'main/inc/lib/opengraph/*' + - 'main/inc/lib/ppt2png/*' + - 'main/inc/lib/phpseclib' + - 'main/inc/lib/pear/*' + - 'main/inc/lib/phpmailer/*' + - 'main/inc/lib/phpseclib/*' + - 'main/inc/lib/svg-edit/*' + - 'main/inc/lib/swfobject/*' + - 'main/inc/lib/wami-recorder/*' + - 'main/inc/lib/xajax/*' + - 'main/lp/packaging/*' + - 'main/template/*' + - 'main/img/*' + - 'main/lang/*' + - 'main/default_course_document' + - 'fonts' + - 'tests/*' + - 'vendor/*' + - 'web/*' From d5719ce22647d4a177b1cd7bb4a1c8f37fb1654d Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Wed, 15 Mar 2017 10:07:28 +0100 Subject: [PATCH 10/68] Minor - format code. --- main/inc/lib/tracking.lib.php | 34 +++++++++------- main/mySpace/myStudents.php | 74 ++++++++++++++++++++++------------- 2 files changed, 66 insertions(+), 42 deletions(-) diff --git a/main/inc/lib/tracking.lib.php b/main/inc/lib/tracking.lib.php index b4b75b1a65..576a2571ec 100755 --- a/main/inc/lib/tracking.lib.php +++ b/main/inc/lib/tracking.lib.php @@ -2891,13 +2891,18 @@ class Tracking /** * This function gets last connection time to one learning path - * @param int|array Student id(s) - * @param string Course code - * @param int Learning path id - * @return int Total time + * @param int|array $student_id Student id(s) + * @param string $course_code Course code + * @param int $lp_id Learning path id + * @param int $session_id + * @return int Total time */ - public static function get_last_connection_time_in_lp($student_id, $course_code, $lp_id, $session_id = 0) - { + public static function get_last_connection_time_in_lp( + $student_id, + $course_code, + $lp_id, + $session_id = 0 + ) { $course = CourseManager :: get_course_information($course_code); $student_id = intval($student_id); $lp_id = intval($lp_id); @@ -2905,16 +2910,15 @@ class Tracking $session_id = intval($session_id); if (!empty($course)) { - - $course_id = $course['real_id']; - - $lp_table = Database :: get_course_table(TABLE_LP_MAIN); - $t_lpv = Database :: get_course_table(TABLE_LP_VIEW); - $t_lpiv = Database :: get_course_table(TABLE_LP_ITEM_VIEW); + $course_id = $course['real_id']; + $lp_table = Database:: get_course_table(TABLE_LP_MAIN); + $t_lpv = Database:: get_course_table(TABLE_LP_VIEW); + $t_lpiv = Database:: get_course_table(TABLE_LP_ITEM_VIEW); // Check the real number of LPs corresponding to the filter in the // database (and if no list was given, get them all) - $res_row_lp = Database::query("SELECT id FROM $lp_table WHERE c_id = $course_id AND id = $lp_id "); + $sql = "SELECT id FROM $lp_table WHERE c_id = $course_id AND id = $lp_id "; + $res_row_lp = Database::query($sql); $count_row_lp = Database::num_rows($res_row_lp); // calculates last connection time @@ -2922,7 +2926,7 @@ class Tracking $sql = 'SELECT MAX(start_time) FROM ' . $t_lpiv . ' AS item_view INNER JOIN ' . $t_lpv . ' AS view - ON item_view.lp_view_id = view.id + ON (item_view.lp_view_id = view.id) WHERE item_view.c_id = '.$course_id.' AND view.c_id = '.$course_id.' AND @@ -2941,7 +2945,7 @@ class Tracking /** * gets the list of students followed by coach - * @param int Coach id + * @param int $coach_id Coach id * @return array List of students */ public static function get_student_followed_by_coach($coach_id) diff --git a/main/mySpace/myStudents.php b/main/mySpace/myStudents.php index 675c7f1803..140d4f6b1b 100755 --- a/main/mySpace/myStudents.php +++ b/main/mySpace/myStudents.php @@ -1,6 +1,7 @@ get_values_by_handler_and_field_variable($student_id, 'legal_accept'); + $value = $extraFieldValue->get_values_by_handler_and_field_variable( + $student_id, + 'legal_accept' + ); $result = $extraFieldValue->delete($value['id']); if ($result) { Display::addFlash(Display::return_message(get_lang('Deleted'))); @@ -477,17 +481,19 @@ if (!empty($student_id)) { $coachs_name = ''; $session_name = ''; $table_title = Display::return_icon( - 'user.png', - get_lang('User'), - array(), - ICON_SIZE_SMALL - ).$user_info['complete_name']; + 'user.png', + get_lang('User'), + array(), + ICON_SIZE_SMALL + ).$user_info['complete_name']; echo Display::page_subheader($table_title); - $userPicture = UserManager::getUserPicture($user_info['user_id']); $userGroupManager = new UserGroup(); - $userGroups = $userGroupManager->getNameListByUser($user_info['user_id'], UserGroup::NORMAL_CLASS); + $userGroups = $userGroupManager->getNameListByUser( + $user_info['user_id'], + UserGroup::NORMAL_CLASS + ); ?>
    @@ -503,9 +509,11 @@ if (!empty($student_id)) { - ' . $user_info['email'] . ''; + + '.$user_info['email'].''; } else { echo get_lang('NoEmail'); } ?> @@ -513,7 +521,7 @@ if (!empty($student_id)) { - + get_values_by_handler_and_field_variable($student_id, 'legal_accept'); @@ -689,11 +701,11 @@ if (!empty($student_id)) { $access_end_date = ''; $date_session = ''; $title = Display::return_icon( - 'course.png', - get_lang('Courses'), - array(), - ICON_SIZE_SMALL - ).' '.get_lang('Courses'); + 'course.png', + get_lang('Courses'), + array(), + ICON_SIZE_SMALL + ).' '.get_lang('Courses'); $session_info = api_get_session_info($sId); if ($session_info) { @@ -734,14 +746,22 @@ if (!empty($student_id)) { $courseInfoItem = api_get_course_info_by_id($courseId); $courseId = $courseInfoItem['real_id']; $courseCodeItem = $courseInfoItem['code']; - - if (CourseManager :: is_user_subscribed_in_course($student_id, $courseCodeItem, true)) { + $isSubscribed = CourseManager:: is_user_subscribed_in_course( + $student_id, + $courseCodeItem, + true + ); + if ($isSubscribed) { $time_spent_on_course = api_time_to_hms( Tracking :: get_time_spent_on_the_course($user_info['user_id'], $courseId, $sId) ); // get average of faults in attendances by student - $results_faults_avg = $attendance->get_faults_average_by_course($student_id, $courseCodeItem, $sId); + $results_faults_avg = $attendance->get_faults_average_by_course( + $student_id, + $courseCodeItem, + $sId + ); if (!empty($results_faults_avg['total'])) { if (api_is_drh()) { $attendances_faults_avg = @@ -780,7 +800,7 @@ if (!empty($student_id)) { $scoretotal_display = '0/0 (0%)'; if (!empty($scoretotal) && !empty($scoretotal[1])) { $scoretotal_display = - round($scoretotal[0], 1 ).'/'. + round($scoretotal[0], 1).'/'. round($scoretotal[1], 1). ' ('.round(($scoretotal[0] / $scoretotal[1]) * 100, 2).' %)'; } @@ -949,7 +969,7 @@ if (!empty($student_id)) { getId(); $lp_name = $learnpath->getName(); From 2aee4c0d14b8ea1f27d01645f5c76972071c6657 Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Wed, 15 Mar 2017 10:14:03 +0100 Subject: [PATCH 11/68] Improve queries --- main/inc/lib/tracking.lib.php | 40 +++++++++++++++++------------------ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/main/inc/lib/tracking.lib.php b/main/inc/lib/tracking.lib.php index 576a2571ec..0c9b8a7ef3 100755 --- a/main/inc/lib/tracking.lib.php +++ b/main/inc/lib/tracking.lib.php @@ -2926,13 +2926,13 @@ class Tracking $sql = 'SELECT MAX(start_time) FROM ' . $t_lpiv . ' AS item_view INNER JOIN ' . $t_lpv . ' AS view - ON (item_view.lp_view_id = view.id) + ON (item_view.lp_view_id = view.id AND item_view.c_id = view.c_id) WHERE - item_view.c_id = '.$course_id.' AND - view.c_id = '.$course_id.' AND - view.lp_id = '.$lp_id.' - AND view.user_id = '.$student_id.' - AND view.session_id = '.$session_id; + item_view.c_id = '.$course_id.' AND + view.c_id = '.$course_id.' AND + view.lp_id = '.$lp_id.' AND + view.user_id = '.$student_id.' AND + view.session_id = '.$session_id; $rs = Database::query($sql); if (Database :: num_rows($rs) > 0) { $last_time = Database :: result($rs, 0, 0); @@ -2982,17 +2982,17 @@ class Tracking $result = Database::query($sql); while ($a_courses = Database::fetch_array($result)) { - $courseId = $a_courses["c_id"]; - $id_session = $a_courses["session_id"]; + $courseId = $a_courses['c_id']; + $id_session = $a_courses['session_id']; $sql = "SELECT DISTINCT srcru.user_id - FROM $tbl_session_course_user AS srcru, $tbl_session_user sru + FROM $tbl_session_course_user AS srcru + INNER JOIN $tbl_session_user sru + ON (srcru.user_id = sru.user_id AND srcru.session_id = sru.session_id) WHERE - srcru.user_id = sru.user_id AND - sru.relation_type<>".SESSION_RELATION_TYPE_RRHH." AND - srcru.session_id = sru.session_id AND + sru.relation_type<>".SESSION_RELATION_TYPE_RRHH." AND srcru.c_id = '$courseId' AND - srcru.session_id='$id_session'"; + srcru.session_id = '$id_session'"; $rs = Database::query($sql); @@ -3019,16 +3019,16 @@ class Tracking $sql = 'SELECT session_course_user.user_id FROM ' . $tbl_session_course_user . ' as session_course_user INNER JOIN '.$tbl_session_user.' sru - ON session_course_user.user_id = sru.user_id AND - session_course_user.session_id = sru.session_id + ON session_course_user.user_id = sru.user_id AND + session_course_user.session_id = sru.session_id INNER JOIN ' . $tbl_session_course . ' as session_course - ON session_course.c_id = session_course_user.c_id AND - session_course_user.session_id = session_course.session_id + ON session_course.c_id = session_course_user.c_id AND + session_course_user.session_id = session_course.session_id INNER JOIN ' . $tbl_session . ' as session - ON session.id = session_course.session_id AND - session.id_coach = ' . $coach_id.' + ON session.id = session_course.session_id AND + session.id_coach = ' . $coach_id.' INNER JOIN '.$tbl_session_rel_access_url.' session_rel_url - ON session.id = session_rel_url.session_id WHERE access_url_id = '.$access_url_id; + ON session.id = session_rel_url.session_id WHERE access_url_id = '.$access_url_id; } } From f44009af2f31ac066ad40b9b87c155c788522a68 Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Wed, 15 Mar 2017 10:27:41 +0100 Subject: [PATCH 12/68] Add deprecated --- main/inc/lib/course.lib.php | 1 + 1 file changed, 1 insertion(+) diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php index 4fda68d7ed..141507fa33 100755 --- a/main/inc/lib/course.lib.php +++ b/main/inc/lib/course.lib.php @@ -114,6 +114,7 @@ class CourseManager * Returns all the information of a given course code * @param string $course_code , the course code * @return array with all the fields of the course table + * @deprecated Use api_get_course_info() instead * @author Patrick Cool , Ghent University * @assert ('') === false */ From c82c9525f583888e8c18bc63f801bade63dcda77 Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Wed, 15 Mar 2017 10:49:42 +0100 Subject: [PATCH 13/68] Replace api_is_allowed_to_create_course() with api_is_teacher() If i'm a teacher but I cannot create courses, I'm still a teacher, so I will need to have the Reporting instead of My progress. See BT#12457 --- main/inc/lib/banner.lib.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/main/inc/lib/banner.lib.php b/main/inc/lib/banner.lib.php index 52c4d66ae5..cde143cdf5 100755 --- a/main/inc/lib/banner.lib.php +++ b/main/inc/lib/banner.lib.php @@ -36,9 +36,7 @@ function get_tabs($courseId = null) $navigation[SECTION_CATALOG]['key'] = 'catalog'; $navigation[SECTION_CATALOG]['icon'] = 'catalog.png'; - // My Courses - if (api_is_allowed_to_create_course()) { // Link to my courses for teachers $navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php?nosession=true'; @@ -50,7 +48,6 @@ function get_tabs($courseId = null) $navigation['mycourses']['key'] = 'my-course'; $navigation['mycourses']['icon'] = 'my-course.png'; - // My Profile $navigation['myprofile']['url'] = api_get_path(WEB_CODE_PATH).'auth/profile.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&courseCode='.$_course['official_code'] : '' ); $navigation['myprofile']['title'] = get_lang('ModifyProfile'); @@ -71,7 +68,7 @@ function get_tabs($courseId = null) } // Reporting - if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) { + if (api_is_teacher() || api_is_drh() || api_is_session_admin()) { // Link to my space $navigation['session_my_space']['url'] = api_get_path(WEB_CODE_PATH).'mySpace/'.(api_is_drh()?'session.php':''); $navigation['session_my_space']['title'] = get_lang('MySpace'); @@ -292,13 +289,13 @@ function return_navigation_array() // Reporting if (api_get_setting('show_tabs', 'reporting') == 'true') { - if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin() || api_is_student_boss()) { + if (api_is_teacher() || api_is_drh() || api_is_session_admin() || api_is_student_boss()) { $navigation['session_my_space'] = $possible_tabs['session_my_space']; } else { $navigation['session_my_space'] = $possible_tabs['session_my_progress']; } } else { - if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin() || api_is_student_boss()) { + if (api_is_teacher() || api_is_drh() || api_is_session_admin() || api_is_student_boss()) { $menu_navigation['session_my_space'] = $possible_tabs['session_my_space']; } else { $menu_navigation['session_my_space'] = $possible_tabs['session_my_progress']; From 6835810d7c21d2584686e0f50292fdc80ed1ff14 Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Wed, 15 Mar 2017 11:21:35 +0100 Subject: [PATCH 14/68] Disable analyzers --- .scrutinizer.yml | 63 ++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 34 deletions(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 8f1169bf8a..f916fb7c08 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -125,44 +125,39 @@ tools: extensions: - php command: phpmd - filter: - paths: { } - excluded_paths: - - 'tests/*' - - 'vendor/*' config: rulesets: - codesize - php_analyzer: - enabled: true - filter: - excluded_paths: - - 'tests/*' - extensions: - - php - php_code_sniffer: - enabled: true - config: - standard: PSR2 - extensions: - - php - command: phpcs - filter: - excluded_paths: - - 'tests/*' - sensiolabs_security_checker: - enabled: true - php_pdepend: - command: pdepend - configuration_file: ~ - suffixes: - - php - excluded_dirs: - - 'vendor' - - 'tests/*' - enabled: true - php_code_coverage: true +# php_analyzer: +# enabled: true +# filter: +# excluded_paths: +# - 'tests/*' +# extensions: +# - php +# php_code_sniffer: +# enabled: true +# config: +# standard: PSR2 +# extensions: +# - php +# command: phpcs +# filter: +# excluded_paths: +# - 'tests/*' +# sensiolabs_security_checker: +# enabled: true +# php_pdepend: +# command: pdepend +# configuration_file: ~ +# suffixes: +# - php +# excluded_dirs: +# - 'vendor' +# - 'tests/*' +# enabled: true +# php_code_coverage: true filter: excluded_paths: From 8fd4492cff5e4b5ed6a94a73832999dd6c168878 Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Wed, 15 Mar 2017 11:45:51 +0100 Subject: [PATCH 15/68] Remove unused test code #1750 --- tests/README.md | 17 - tests/api/README.txt | 1 - tests/behat/behat.yml | 2 +- tests/build.xml | 115 -- tests/chamilotest.php | 6 - ...ternationalization.lib.test_standalone.php | 49 - tests/logs/code-browser/README.txt | 1 - tests/logs/index.html | 4 - tests/logs/jdepend.xml | 0 tests/logs/junit.xml | 0 tests/main/admin/calendar.lib.test.php | 101 -- .../admin/statistics/statistics.lib.test.php | 188 -- tests/main/admin/sub_language.class.test.php | 206 --- .../announcements/announcements.inc.test.php | 43 - tests/main/auth/openid/xrds.lib.test.php | 71 - tests/main/chat/chat_functions.lib.test.php | 35 - tests/main/dropbox/dropbox_class.inc.test.php | 299 ---- .../dropbox/dropbox_functions.inc.test.php | 424 ----- tests/main/exercice/answer.class.test.php | 389 ---- tests/main/exercice/exercise.class.test.php | 539 ------ tests/main/exercice/exercise.lib.test.php | 42 - .../exercice/exercise_result.class.test.php | 83 - .../export/exercise_import.inc.test.php | 90 - .../export/qti2/qti2_classes.test.php | 189 -- .../exercice/export/qti2/qti2_export.test.php | 86 - .../export/scorm/scorm_classes.test.php | 219 --- .../main/exercice/fill_blanks.class.test.php | 45 - tests/main/exercice/freeanswer.class.test.php | 29 - tests/main/exercice/hotpotatoes.lib.test.php | 178 -- tests/main/forum/forumfunction.inc.test.php | 1248 ------------- .../lib/be/attendancelink.class.test.php | 135 -- .../gradebook/lib/be/category.class.test.php | 423 ----- .../lib/be/dropboxlink.class.test.php | 42 - .../lib/be/evaluation.class.test.php | 347 ---- .../lib/be/exerciselink.class.test.php | 153 -- .../lib/be/forumthreadlink.class.test.php | 42 - tests/main/inc/banner.inc.test.php | 21 - tests/main/inc/course_document.lib.test.php | 35 - ...edit_courses_to_url_functions.lib.test.php | 35 - ...dit_sessions_to_url_functions.lib.test.php | 32 - ...l_edit_users_to_url_functions.lib.test.php | 33 - .../main/inc/lib/add_course.lib.inc.test.php | 132 -- ...courses_to_sessions_functions.lib.test.php | 34 - ...session_to_category_functions.lib.test.php | 29 - tests/main/inc/lib/blog.lib.test.php | 598 ------- tests/main/inc/lib/database.lib.test.php | 173 -- tests/main/inc/lib/debug.lib.inc.test.php | 65 - tests/main/inc/lib/display.lib.test.php | 256 --- tests/main/inc/lib/document.lib.test.php | 300 ---- tests/main/inc/lib/events.lib.inc.test.php | 150 -- .../lib/exercise_show_functions.lib.test.php | 121 -- tests/main/inc/lib/export.lib.inc.test.php | 73 - tests/main/inc/lib/fileDisplay.lib.test.php | 75 - tests/main/inc/lib/fileManage.lib.test.php | 123 -- tests/main/inc/lib/fileManager.lib.test.php | 129 -- tests/main/inc/lib/fileUpload.lib.test.php | 363 ---- tests/main/inc/lib/geometry.lib.test.php | 9 - tests/main/inc/lib/glossary.lib.test.php | 157 -- tests/main/inc/lib/groupmanager.lib.test.php | 435 ----- tests/main/inc/lib/image.lib.test.php | 112 -- tests/main/inc/lib/import.lib.test.php | 16 - .../inc/lib/internationalization.lib.test.php | 1039 ----------- tests/main/inc/lib/legal.lib.test.php | 81 - tests/main/inc/lib/login.lib.test.php | 82 - tests/main/inc/lib/mail.lib.inc.test.php | 32 - tests/main/inc/lib/main_api.lib.test.php | 707 -------- .../inc/lib/main_api.lib.test_standalone.php | 515 ------ tests/main/inc/lib/message.lib.test.php | 28 - tests/main/inc/lib/notebook.lib.test.php | 87 - tests/main/inc/lib/online.inc.test.php | 62 - tests/main/inc/lib/rmdirr.lib.test.php | 72 - tests/main/inc/lib/security.lib.test.php | 96 - .../inc/lib/session_handler.class.test.php | 107 -- .../main/inc/lib/sessionmanager.lib.test.php | 140 -- tests/main/inc/lib/social.lib.test.php | 141 -- .../inc/lib/sortable_table.class.test.php | 165 -- .../lib/specific_fields_manager.lib.test.php | 99 -- .../main/inc/lib/statsUtils.lib.inc.test.php | 55 - tests/main/inc/lib/surveymanager.lib.test.php | 313 ---- .../inc/lib/system_announcements.lib.test.php | 106 -- tests/main/inc/lib/tablesort.lib.test.php | 79 - tests/main/inc/lib/text.lib.test.php | 71 - tests/main/inc/lib/tracking.lib.test.php | 467 ----- tests/main/inc/lib/urlmanager.lib.test.php | 192 -- tests/main/inc/lib/usermanager.lib.test.php | 308 ---- tests/main/inc/lib/xht.lib.test.php | 85 - tests/main/inc/lib/xmd.lib.test.php | 211 --- .../main/install/install_upgrade.lib.test.php | 55 - tests/main/mySpace/myspace.lib.test.php | 213 --- tests/main/newscorm/learnpath.class.test.php | 1400 --------------- .../newscorm/learnpathItem.class.test.php | 593 ------- .../openoffice_document.class.test.php | 8 - .../openoffice_presentation.class.test.php | 38 - .../newscorm/openoffice_text.class.test.php | 50 - .../openoffice_text_document.class.test.php | 47 - tests/main/newscorm/scorm.class.test.php | 184 -- tests/main/newscorm/scormItem.class.test.php | 26 - .../newscorm/scormOrganization.class.test.php | 39 - .../newscorm/scormResource.class.test.php | 30 - .../permissions_functions.inc.test.php | 235 --- tests/main/search/search_suggestions.test.php | 18 - .../user_import/import.lib.test.php | 53 - tests/main/work/work.lib.test.php | 264 --- tests/main_api.lib.test_standalone.php | 46 - tests/phpunit/README.txt | 4 - tests/phpunit/autoload.php | 2 - .../classes/AppendIteratorTest.class.php | 136 -- .../classes/ArrayIteratorTest.class.php | 304 ---- .../phpunit/classes/ArrayObjectTest.class.php | 280 --- .../classes/ConditionalLoginTest.class.php | 52 - .../phpunit/classes/CustomPagesTest.class.php | 76 - tests/phpunit/classes/DateTimeTest.class.php | 232 --- tests/phpunit/classes/DirectoryTest.class.php | 64 - tests/phpunit/classes/DisplayTest.lib.php | 713 -------- .../classes/EmptyIteratorTest.class.php | 88 - .../classes/ErrorExceptionTest.class.php | 40 - .../phpunit/classes/EventsMailTest.class.php | 52 - tests/phpunit/classes/ExceptionTest.class.php | 124 -- tests/phpunit/classes/ImportTest.class.php | 52 - tests/phpunit/classes/LocaleTest.class.php | 244 --- .../classes/LoginRedirectionTest.class.php | 40 - .../classes/MultipleIteratorTest.class.php | 160 -- .../phpunit/classes/NormalizerTest.class.php | 52 - tests/phpunit/classes/RightsTest.class.php | 52 - .../classes/SessionHandlerTest.class.php | 136 -- tests/phpunit/classes/SessionManager.lib.php | 532 ------ tests/phpunit/classes/TableSortTest.class.php | 52 - .../classes/UserApiKeyManagerTest.class.php | 88 - tests/phpunit/classes/XMLReaderTest.class.php | 328 ---- tests/phpunit/classes/XMLWriterTest.class.php | 532 ------ .../phpunit/classes/ZipArchiveTest.class.php | 388 ---- tests/phpunit/classes/finfoTest.class.php | 64 - .../classes/php_user_filterTest.class.php | 64 - tests/phpunit/generate_test_classes.php | 33 - tests/phpunit/phpunit.xml | 24 - tests/rmdirr.lib.test_standalone.php | 50 - tests/run.sh | 3 - tests/scripts/packaging/README.md | 12 - tests/scripts/packaging/gitlog.php | 126 -- .../HELP_MY_TESTS_DONT_WORK_ANYMORE | 348 ---- tests/simpletest/LICENSE | 502 ------ tests/simpletest/README | 108 -- tests/simpletest/VERSION | 1 - tests/simpletest/authentication.php | 238 --- tests/simpletest/autorun.php | 87 - tests/simpletest/browser.php | 1098 ------------ tests/simpletest/collector.php | 122 -- tests/simpletest/compatibility.php | 175 -- tests/simpletest/cookies.php | 380 ---- tests/simpletest/default_reporter.php | 133 -- tests/simpletest/detached.php | 96 - tests/simpletest/dumper.php | 360 ---- tests/simpletest/eclipse.php | 307 ---- tests/simpletest/encoding.php | 552 ------ tests/simpletest/errors.php | 288 --- tests/simpletest/exceptions.php | 198 --- tests/simpletest/expectation.php | 895 ---------- tests/simpletest/extensions/index.html | 8 - .../simpletest/extensions/pear_test_case.php | 198 --- .../extensions/phpunit_test_case.php | 96 - tests/simpletest/extensions/testdox.php | 42 - .../simpletest/extensions/testdox/index.html | 8 - tests/simpletest/extensions/testdox/test.php | 108 -- tests/simpletest/form.php | 355 ---- tests/simpletest/frames.php | 596 ------- tests/simpletest/http.php | 624 ------- tests/simpletest/index.html | 8 - tests/simpletest/invoker.php | 139 -- tests/simpletest/mock_objects.php | 1581 ----------------- tests/simpletest/page.php | 983 ---------- tests/simpletest/parser.php | 765 -------- tests/simpletest/reflection_php4.php | 136 -- tests/simpletest/reflection_php5.php | 380 ---- tests/simpletest/remote.php | 117 -- tests/simpletest/reporter.php | 473 ----- tests/simpletest/scorer.php | 863 --------- tests/simpletest/selector.php | 137 -- tests/simpletest/shell_tester.php | 334 ---- tests/simpletest/simpletest.php | 478 ----- tests/simpletest/socket.php | 218 --- tests/simpletest/tag.php | 1418 --------------- tests/simpletest/test_case.php | 709 -------- tests/simpletest/unit_tester.php | 420 ----- tests/simpletest/url.php | 528 ------ tests/simpletest/user_agent.php | 332 ---- tests/simpletest/web_tester.php | 1541 ---------------- tests/simpletest/xml.php | 647 ------- tests/simpletest_to_junit.xsl | 47 - tests/test_manager.inc.php | 206 --- tests/test_suite.php | 191 -- tests/test_webservices.php | 182 -- 191 files changed, 1 insertion(+), 43940 deletions(-) delete mode 100755 tests/api/README.txt delete mode 100755 tests/build.xml delete mode 100755 tests/chamilotest.php delete mode 100755 tests/internationalization.lib.test_standalone.php delete mode 100755 tests/logs/code-browser/README.txt delete mode 100755 tests/logs/index.html delete mode 100755 tests/logs/jdepend.xml delete mode 100755 tests/logs/junit.xml delete mode 100755 tests/main/admin/calendar.lib.test.php delete mode 100755 tests/main/admin/statistics/statistics.lib.test.php delete mode 100755 tests/main/admin/sub_language.class.test.php delete mode 100755 tests/main/announcements/announcements.inc.test.php delete mode 100755 tests/main/auth/openid/xrds.lib.test.php delete mode 100755 tests/main/chat/chat_functions.lib.test.php delete mode 100755 tests/main/dropbox/dropbox_class.inc.test.php delete mode 100755 tests/main/dropbox/dropbox_functions.inc.test.php delete mode 100755 tests/main/exercice/answer.class.test.php delete mode 100755 tests/main/exercice/exercise.class.test.php delete mode 100755 tests/main/exercice/exercise.lib.test.php delete mode 100755 tests/main/exercice/exercise_result.class.test.php delete mode 100755 tests/main/exercice/export/exercise_import.inc.test.php delete mode 100755 tests/main/exercice/export/qti2/qti2_classes.test.php delete mode 100755 tests/main/exercice/export/qti2/qti2_export.test.php delete mode 100755 tests/main/exercice/export/scorm/scorm_classes.test.php delete mode 100755 tests/main/exercice/fill_blanks.class.test.php delete mode 100755 tests/main/exercice/freeanswer.class.test.php delete mode 100755 tests/main/exercice/hotpotatoes.lib.test.php delete mode 100755 tests/main/forum/forumfunction.inc.test.php delete mode 100755 tests/main/gradebook/lib/be/attendancelink.class.test.php delete mode 100755 tests/main/gradebook/lib/be/category.class.test.php delete mode 100755 tests/main/gradebook/lib/be/dropboxlink.class.test.php delete mode 100755 tests/main/gradebook/lib/be/evaluation.class.test.php delete mode 100755 tests/main/gradebook/lib/be/exerciselink.class.test.php delete mode 100755 tests/main/gradebook/lib/be/forumthreadlink.class.test.php delete mode 100755 tests/main/inc/banner.inc.test.php delete mode 100755 tests/main/inc/course_document.lib.test.php delete mode 100755 tests/main/inc/lib/access_url_edit_courses_to_url_functions.lib.test.php delete mode 100755 tests/main/inc/lib/access_url_edit_sessions_to_url_functions.lib.test.php delete mode 100755 tests/main/inc/lib/access_url_edit_users_to_url_functions.lib.test.php delete mode 100755 tests/main/inc/lib/add_course.lib.inc.test.php delete mode 100755 tests/main/inc/lib/add_courses_to_sessions_functions.lib.test.php delete mode 100755 tests/main/inc/lib/add_many_session_to_category_functions.lib.test.php delete mode 100755 tests/main/inc/lib/blog.lib.test.php delete mode 100755 tests/main/inc/lib/database.lib.test.php delete mode 100755 tests/main/inc/lib/debug.lib.inc.test.php delete mode 100755 tests/main/inc/lib/display.lib.test.php delete mode 100755 tests/main/inc/lib/document.lib.test.php delete mode 100755 tests/main/inc/lib/events.lib.inc.test.php delete mode 100755 tests/main/inc/lib/exercise_show_functions.lib.test.php delete mode 100755 tests/main/inc/lib/export.lib.inc.test.php delete mode 100755 tests/main/inc/lib/fileDisplay.lib.test.php delete mode 100755 tests/main/inc/lib/fileManage.lib.test.php delete mode 100755 tests/main/inc/lib/fileManager.lib.test.php delete mode 100755 tests/main/inc/lib/fileUpload.lib.test.php delete mode 100755 tests/main/inc/lib/geometry.lib.test.php delete mode 100755 tests/main/inc/lib/glossary.lib.test.php delete mode 100755 tests/main/inc/lib/groupmanager.lib.test.php delete mode 100755 tests/main/inc/lib/image.lib.test.php delete mode 100755 tests/main/inc/lib/import.lib.test.php delete mode 100755 tests/main/inc/lib/internationalization.lib.test.php delete mode 100755 tests/main/inc/lib/legal.lib.test.php delete mode 100755 tests/main/inc/lib/login.lib.test.php delete mode 100755 tests/main/inc/lib/mail.lib.inc.test.php delete mode 100755 tests/main/inc/lib/main_api.lib.test.php delete mode 100755 tests/main/inc/lib/main_api.lib.test_standalone.php delete mode 100755 tests/main/inc/lib/message.lib.test.php delete mode 100755 tests/main/inc/lib/notebook.lib.test.php delete mode 100755 tests/main/inc/lib/online.inc.test.php delete mode 100755 tests/main/inc/lib/rmdirr.lib.test.php delete mode 100755 tests/main/inc/lib/security.lib.test.php delete mode 100755 tests/main/inc/lib/session_handler.class.test.php delete mode 100755 tests/main/inc/lib/sessionmanager.lib.test.php delete mode 100755 tests/main/inc/lib/social.lib.test.php delete mode 100755 tests/main/inc/lib/sortable_table.class.test.php delete mode 100755 tests/main/inc/lib/specific_fields_manager.lib.test.php delete mode 100755 tests/main/inc/lib/statsUtils.lib.inc.test.php delete mode 100755 tests/main/inc/lib/surveymanager.lib.test.php delete mode 100755 tests/main/inc/lib/system_announcements.lib.test.php delete mode 100755 tests/main/inc/lib/tablesort.lib.test.php delete mode 100755 tests/main/inc/lib/text.lib.test.php delete mode 100755 tests/main/inc/lib/tracking.lib.test.php delete mode 100755 tests/main/inc/lib/urlmanager.lib.test.php delete mode 100755 tests/main/inc/lib/usermanager.lib.test.php delete mode 100755 tests/main/inc/lib/xht.lib.test.php delete mode 100755 tests/main/inc/lib/xmd.lib.test.php delete mode 100755 tests/main/install/install_upgrade.lib.test.php delete mode 100755 tests/main/mySpace/myspace.lib.test.php delete mode 100755 tests/main/newscorm/learnpath.class.test.php delete mode 100755 tests/main/newscorm/learnpathItem.class.test.php delete mode 100755 tests/main/newscorm/openoffice_document.class.test.php delete mode 100755 tests/main/newscorm/openoffice_presentation.class.test.php delete mode 100755 tests/main/newscorm/openoffice_text.class.test.php delete mode 100755 tests/main/newscorm/openoffice_text_document.class.test.php delete mode 100755 tests/main/newscorm/scorm.class.test.php delete mode 100755 tests/main/newscorm/scormItem.class.test.php delete mode 100755 tests/main/newscorm/scormOrganization.class.test.php delete mode 100755 tests/main/newscorm/scormResource.class.test.php delete mode 100755 tests/main/permissions/permissions_functions.inc.test.php delete mode 100755 tests/main/search/search_suggestions.test.php delete mode 100755 tests/main/webservices/user_import/import.lib.test.php delete mode 100755 tests/main/work/work.lib.test.php delete mode 100755 tests/main_api.lib.test_standalone.php delete mode 100755 tests/phpunit/README.txt delete mode 100755 tests/phpunit/autoload.php delete mode 100755 tests/phpunit/classes/AppendIteratorTest.class.php delete mode 100755 tests/phpunit/classes/ArrayIteratorTest.class.php delete mode 100755 tests/phpunit/classes/ArrayObjectTest.class.php delete mode 100755 tests/phpunit/classes/ConditionalLoginTest.class.php delete mode 100755 tests/phpunit/classes/CustomPagesTest.class.php delete mode 100755 tests/phpunit/classes/DateTimeTest.class.php delete mode 100755 tests/phpunit/classes/DirectoryTest.class.php delete mode 100755 tests/phpunit/classes/DisplayTest.lib.php delete mode 100755 tests/phpunit/classes/EmptyIteratorTest.class.php delete mode 100755 tests/phpunit/classes/ErrorExceptionTest.class.php delete mode 100755 tests/phpunit/classes/EventsMailTest.class.php delete mode 100755 tests/phpunit/classes/ExceptionTest.class.php delete mode 100755 tests/phpunit/classes/ImportTest.class.php delete mode 100755 tests/phpunit/classes/LocaleTest.class.php delete mode 100755 tests/phpunit/classes/LoginRedirectionTest.class.php delete mode 100755 tests/phpunit/classes/MultipleIteratorTest.class.php delete mode 100755 tests/phpunit/classes/NormalizerTest.class.php delete mode 100755 tests/phpunit/classes/RightsTest.class.php delete mode 100755 tests/phpunit/classes/SessionHandlerTest.class.php delete mode 100755 tests/phpunit/classes/SessionManager.lib.php delete mode 100755 tests/phpunit/classes/TableSortTest.class.php delete mode 100755 tests/phpunit/classes/UserApiKeyManagerTest.class.php delete mode 100755 tests/phpunit/classes/XMLReaderTest.class.php delete mode 100755 tests/phpunit/classes/XMLWriterTest.class.php delete mode 100755 tests/phpunit/classes/ZipArchiveTest.class.php delete mode 100755 tests/phpunit/classes/finfoTest.class.php delete mode 100755 tests/phpunit/classes/php_user_filterTest.class.php delete mode 100755 tests/phpunit/generate_test_classes.php delete mode 100755 tests/phpunit/phpunit.xml delete mode 100755 tests/rmdirr.lib.test_standalone.php delete mode 100755 tests/run.sh delete mode 100644 tests/scripts/packaging/README.md delete mode 100644 tests/scripts/packaging/gitlog.php delete mode 100755 tests/simpletest/HELP_MY_TESTS_DONT_WORK_ANYMORE delete mode 100755 tests/simpletest/LICENSE delete mode 100755 tests/simpletest/README delete mode 100755 tests/simpletest/VERSION delete mode 100755 tests/simpletest/authentication.php delete mode 100755 tests/simpletest/autorun.php delete mode 100755 tests/simpletest/browser.php delete mode 100755 tests/simpletest/collector.php delete mode 100755 tests/simpletest/compatibility.php delete mode 100755 tests/simpletest/cookies.php delete mode 100755 tests/simpletest/default_reporter.php delete mode 100755 tests/simpletest/detached.php delete mode 100755 tests/simpletest/dumper.php delete mode 100755 tests/simpletest/eclipse.php delete mode 100755 tests/simpletest/encoding.php delete mode 100755 tests/simpletest/errors.php delete mode 100755 tests/simpletest/exceptions.php delete mode 100755 tests/simpletest/expectation.php delete mode 100755 tests/simpletest/extensions/index.html delete mode 100755 tests/simpletest/extensions/pear_test_case.php delete mode 100755 tests/simpletest/extensions/phpunit_test_case.php delete mode 100755 tests/simpletest/extensions/testdox.php delete mode 100755 tests/simpletest/extensions/testdox/index.html delete mode 100755 tests/simpletest/extensions/testdox/test.php delete mode 100755 tests/simpletest/form.php delete mode 100755 tests/simpletest/frames.php delete mode 100755 tests/simpletest/http.php delete mode 100755 tests/simpletest/index.html delete mode 100755 tests/simpletest/invoker.php delete mode 100755 tests/simpletest/mock_objects.php delete mode 100755 tests/simpletest/page.php delete mode 100755 tests/simpletest/parser.php delete mode 100755 tests/simpletest/reflection_php4.php delete mode 100755 tests/simpletest/reflection_php5.php delete mode 100755 tests/simpletest/remote.php delete mode 100755 tests/simpletest/reporter.php delete mode 100755 tests/simpletest/scorer.php delete mode 100755 tests/simpletest/selector.php delete mode 100755 tests/simpletest/shell_tester.php delete mode 100755 tests/simpletest/simpletest.php delete mode 100755 tests/simpletest/socket.php delete mode 100755 tests/simpletest/tag.php delete mode 100755 tests/simpletest/test_case.php delete mode 100755 tests/simpletest/unit_tester.php delete mode 100755 tests/simpletest/url.php delete mode 100755 tests/simpletest/user_agent.php delete mode 100755 tests/simpletest/web_tester.php delete mode 100755 tests/simpletest/xml.php delete mode 100755 tests/simpletest_to_junit.xsl delete mode 100755 tests/test_manager.inc.php delete mode 100755 tests/test_suite.php delete mode 100755 tests/test_webservices.php diff --git a/tests/README.md b/tests/README.md index 8271cb6547..2a803dd229 100755 --- a/tests/README.md +++ b/tests/README.md @@ -49,24 +49,10 @@ Behat-specific folder Attempt at keeping a track of what Chamilo looked like over time. -### logs - -Meant as a destination for all logs generated by automated testing and building -scripts. Should be writeable whenever tests (other than behat) are run (clover -and stuff like that). Initially used when Chamilo was using its own Jenkins -setup (now it tries to use Travis-CI). - -### main - -Deprecated PHPUnit code reflecting the internal code structure of Chamilo - ### migrations Combination of unofficial scripts to execute migrations from other systems -### phpunit - -Deprecated PHPUnit code ### procedures @@ -78,9 +64,6 @@ Chamilo. A collection of scripts used to fix or improve some things globally in Chamilo portals. Mostly for old versions. -### simpletest - -Deprecated SimpleTest code (unused since 2009) ### translations diff --git a/tests/api/README.txt b/tests/api/README.txt deleted file mode 100755 index 694178c7fa..0000000000 --- a/tests/api/README.txt +++ /dev/null @@ -1 +0,0 @@ -This directory will contain the auto-generated PHPDoc files diff --git a/tests/behat/behat.yml b/tests/behat/behat.yml index 8b88e16c7d..d77c9d512b 100644 --- a/tests/behat/behat.yml +++ b/tests/behat/behat.yml @@ -1,7 +1,7 @@ default: extensions: Behat\MinkExtension: - base_url: http://localhost/ + base_url: http://localhost/chamilo_111/ goutte: ~ show_cmd: 'open %s' selenium2: diff --git a/tests/build.xml b/tests/build.xml deleted file mode 100755 index d71096cef4..0000000000 --- a/tests/build.xml +++ /dev/null @@ -1,115 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/chamilotest.php b/tests/chamilotest.php deleted file mode 100755 index 7334954dec..0000000000 --- a/tests/chamilotest.php +++ /dev/null @@ -1,6 +0,0 @@ - \ No newline at end of file diff --git a/tests/internationalization.lib.test_standalone.php b/tests/internationalization.lib.test_standalone.php deleted file mode 100755 index 6d09a54fb0..0000000000 --- a/tests/internationalization.lib.test_standalone.php +++ /dev/null @@ -1,49 +0,0 @@ -TestSuite('Internationalization Tests'); - - global $_test_sys_library_path; - $this->addTestFile($_test_sys_library_path.'internationalization.lib.test.php'); - } - -} - -$test = & new InternationalizationTests(); -//$test-> run( new HtmlReporter()); - -?> diff --git a/tests/logs/code-browser/README.txt b/tests/logs/code-browser/README.txt deleted file mode 100755 index d6699499b7..0000000000 --- a/tests/logs/code-browser/README.txt +++ /dev/null @@ -1 +0,0 @@ -Code browser report will be generated in this directory diff --git a/tests/logs/index.html b/tests/logs/index.html deleted file mode 100755 index 7879e1ce9f..0000000000 --- a/tests/logs/index.html +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/tests/logs/jdepend.xml b/tests/logs/jdepend.xml deleted file mode 100755 index e69de29bb2..0000000000 diff --git a/tests/logs/junit.xml b/tests/logs/junit.xml deleted file mode 100755 index e69de29bb2..0000000000 diff --git a/tests/main/admin/calendar.lib.test.php b/tests/main/admin/calendar.lib.test.php deleted file mode 100755 index 9aa473c871..0000000000 --- a/tests/main/admin/calendar.lib.test.php +++ /dev/null @@ -1,101 +0,0 @@ -UnitTestCase('Admin calendar library - main/admin/calendar.inc.test.php'); - } - public function testToJavascript(){ - $res = to_javascript(); - $this->assertTrue($res); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - public function testAddWeek(){ - $timestamp=12; - $num=1; - $res = add_week($timestamp,$num); - $this->assertTrue(is_numeric($res)); - //var_dump($res); - } - - public function testAddMonth(){ - $timestamp=5; - $num=1; - $res = add_month($timestamp,$num); - $this->assertTrue(is_numeric($res)); - //var_dump($res); - } - - public function testAddYear(){ - $timestamp=9999; - $num=1; - $res = add_year($timestamp,$num); - $this->assertTrue(is_numeric($res)); - //var_dump($res); - } - - -/** - * Adds a repetitive item to the database - * @param array Course info - * @param int The original event's id - * @param string Type of repetition - * @param int Timestamp of end of repetition (repeating until that date) - * @param array Original event's destination - * @return boolean False if error, True otherwise - */ - - public function testAgendaAddRepeatItem(){ - //this function is not used or deprecated - } - - public function testCalculateStartEndOfWeek(){ - $week_number=4; - $year=2011; - $res = calculate_start_end_of_week($week_number, $year); - $this->assertTrue(is_array($res)); - $this->assertTrue($res); - //var_dump($res); - } - - - public function testGetDayAgendaitems() { - $courses_dbs=array(); - $month=01; - $year=2010; - $day='1'; - $res = get_day_agendaitems($courses_dbs, $month, $year, $day); - $this->assertTrue(is_array($res)); - } - - public function testDeleteAgendaItem(){ - $id=1; - $res = delete_agenda_item($id); - $this->assertTrue(is_bool($res)); - } - public function testDisplayMinimonthcalendar(){ - ob_start(); - global $DaysShort; - $agendaitems=array('test','test2'); - $month=01; - $year=2010; - $monthName=''; - $res = display_minimonthcalendar($agendaitems, $month, $year, $monthName); - ob_end_clean(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - public function testShowUserFilterForm(){ - ob_start(); - $res = show_user_filter_form(); - ob_end_clean(); - $this->assertTrue(is_null($res)); - } - - public function testIsRepeatedEvent() { - //This is deprecated or not used - } -} diff --git a/tests/main/admin/statistics/statistics.lib.test.php b/tests/main/admin/statistics/statistics.lib.test.php deleted file mode 100755 index df6e22febd..0000000000 --- a/tests/main/admin/statistics/statistics.lib.test.php +++ /dev/null @@ -1,188 +0,0 @@ -UnitTestCase('this File test the provides some function for statistics '); - } - - public function setUp() - { - $this->statisc = new Statistics(); - } - - public function tearDown() - { - $this->statisc = null; - } - - public function testMakeSizeString() - { - $size = 20960000; - $res = Statistics::makeSizeString($size); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - /** - * Count courses - * @param string $category_code Code of a course category. Default: count - * all courses. - * @return int Number of courses counted - */ - public function testCountCourses() - { - $res = Statistics::countCourses(); - $this->assertTrue(is_numeric($res)); - //var_dump($res); - } - - public function testCountUsers() - { - $user_id = '1'; - $category_code = null; - $course_code = 'ABC'; - $firstName = 'Jhon'; - $lastName = 'Doe'; - $status = '1'; - $email = 'localhost@localhost.com'; - $loginName = 'admin'; - $password = 'admin'; - $count_invisible_courses = true; - $res = Statistics::countUsers($status, $category_code, - $count_invisible_courses); - $this->assertTrue(is_numeric($res)); - $this->assertTrue(count($res) === 0 || count($res) !== 0); - } - - public function testGetNumberOfActivities() - { - $resu = Statistics::getNumberOfActivities(); - if (!is_null($resu)) { - $this->assertTrue(is_numeric($resu)); - $this->assertTrue(count($resu) == 0 || count($resu) !== 0); - } - } - - /** - * Get activities data to display - */ - public function testGetActivitiesData() - { - global $dateTimeFormatLong; - $from = 0; - $number_of_items = 30; - $column = ''; - $direction = 'ASC'; - $resu = Statistics::getActivitiesData($from, $number_of_items, $column, - $direction); - $this->assertTrue(is_array($resu)); - } - - /** - * Get all course categories - * @return array All course categories (code => name) - */ - public function testGetCourseCategories() - { - $res = Statistics::getCourseCategories(); - $this->assertTrue($res); - //var_dump($res); - } - - public function testRescale() - { - $data = array('test', 'test2', 'test3'); - $max = 500; - $res = Statistics::rescale($data, $max); - $this->assertTrue($res); - $this->assertTrue(is_array($res)); - //var_dump($res); - } - - public function testPrintStats() - { - ob_start(); - $title = 'testing'; - $stats = array('test', 'test2', 'test3'); - $show_total = true; - $is_file_size = false; - $res = Statistics::printStats( - $title, - $stats, - $show_total = true, - $is_file_size = false - ); - ob_end_clean(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - public function testPrintLoginStats() - { - ob_start(); - $type = 'month'; - $resu = Statistics::printLoginStats($type); - ob_end_clean(); - $this->assertTrue(is_null($resu)); - //var_dump($resu); - } - - public function testPrintRecentLoginStats() - { - ob_start(); - $res = Statistics::printRecentLoginStats(); - ob_end_clean(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - public function testPrintToolStats() - { - ob_start(); - $resu = Statistics::printToolStats(); - ob_end_clean(); - $this->assertTrue(is_null($resu)); - } - - public function testPrintCourseByLanguageStats() - { - ob_start(); - $resu = Statistics::printCourseByLanguageStats(); - ob_end_clean(); - $this->assertTrue(is_null($resu)); - //var_dump($resu); - } - - public function testPrintUserPicturesStats() - { - ob_start(); - $resu = Statistics::printUserPicturesStats(); - ob_end_clean(); - $this->assertTrue(is_null($resu)); - } - - public function testPrintActivitiesStats() - { - ob_start(); - $res = Statistics::printActivitiesStats(); - ob_end_clean(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - public function testPrintCourseLastVisit() - { - ob_start(); - $column = ''; - $direction = ''; - $parameters['action'] = 'courselastvisit'; - $res = Statistics::printCourseLastVisit(); - ob_end_clean(); - $this->assertTrue(is_null($res)); - } -} - -?> diff --git a/tests/main/admin/sub_language.class.test.php b/tests/main/admin/sub_language.class.test.php deleted file mode 100755 index 2f267c6331..0000000000 --- a/tests/main/admin/sub_language.class.test.php +++ /dev/null @@ -1,206 +0,0 @@ -UnitTestCase('Sublanguage Manager library - main/admin/sub_language.class.test.php'); - } - /** - * Testing who get all data of lang folder - * @param String to url path folder - * @param bool true if we only want the subname - * @return Array All file of lang folder - */ - public function testget_lang_folder_files_list(){ - $path = api_get_path(SYS_LANG_PATH).'english'; - $res = SubLanguageManager::get_lang_folder_files_list($path, $only_main_name = false); - $this->assertTrue(is_array($res)); - $this->assertTrue(count($res)>0); - } - - /** - * - * - */ - public function testget_all_information_of_sub_language(){ - $parent_id = 13; - $language_id = 10; - $res = SubLanguageManager::get_all_information_of_sub_language($parent_id, $language_id); - // under normal circumstances, there is no language 10 child of language 13 - $this->assertFalse($res); - } - - /** - * - */ - public function testget_all_information_of_language(){ - $parent_id = 11; - $res = SubLanguageManager::get_all_information_of_language($parent_id); - $this->assertTrue(is_array($res)); - } - - /** - * Get variables within a language file - */ - public function testget_all_language_variable_in_file(){ - $system_path_folder = api_get_path(SYS_LANG_PATH); - $system_path_file = $system_path_folder.'spanish/link.inc.php'; - $res = SubLanguageManager::get_all_language_variable_in_file($system_path_file); - $this->assertTrue(is_array($res)); - } - - /** - * Add directory for sub-language - * @param String The sub-language path directory ( /var/www/my_lms/main/lang/spanish_corporate ) - * @return boolean - */ - public function testadd_language_directory() { - $res = SubLanguageManager :: add_language_directory('test'); - $this->assertTrue($res); - $res = SubLanguageManager :: remove_language_directory('test'); - } - - /** - * - */ - public function testadd_file_in_language_directory(){ - $res = SubLanguageManager :: add_language_directory('test'); - $this->assertTrue($res); - $system_path_file = api_get_path(SYS_LANG_PATH).'test/spanish.inc.php'; - $res = SubLanguageManager::add_file_in_language_directory($system_path_file); - $this->assertTrue($res); - $res = SubLanguageManager :: remove_language_directory('test'); - } - - public function testwrite_data_in_file(){ - $dirname = api_get_path(SYS_LANG_PATH); - $file = $dirname.'spanish.inc.php'; - $path_file = $file; - $new_sub_language='spanishtest'; - $variable_sub_language='test'; - $res = SubLanguageManager::write_data_in_file($path_file,$new_sub_language,$variable_sub_language); - $this->assertTrue($res); - } - - /** - * Delete sub language of database - * @param Integer id's. - * @return null - */ - public function Testremove_sub_language() { - $parent_id = ''; - $sub_language_id = 1; - $res = SubLanguageManager :: remove_sub_language($parent_id, $sub_language_id); - $this->assertFalse($res); - // var_dump($res); - } - - /** - * Test of Check if language exist by id - * @param Integer - * @return Boolean - */ - public function Testcheck_if_exist_language_by_id() { - $language_id = 14; - $res = SubLanguageManager :: check_if_exist_language_by_id($language_id); - $this->assertTrue($res); - // var_dump($res); - } - - /** - * Show the name of language by id - * @param Integer id - * @return String the name of language - */ - public function Testget_name_of_language_by_id() { - $language_id = 13; - $tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE); - $sql='SELECT original_name FROM '.$tbl_admin_languages.' WHERE id=13'; - $rs=Database::query($sql); - $name =''; - if (Database::num_rows($rs)>0) { - $name = Database::result($rs,0,'original_name'); - } - $res = SubLanguageManager :: get_name_of_language_by_id($language_id); - $this->assertEqual($res,$name,'The language name from function does not match the database value'); - } - - /** - * Verified if language is an sub-language - * @param Integer - * @return Boolean - */ - public function Testcheck_if_language_is_sub_language_for_non_existing_sublanguage() { - $language_id = 112; - $res = SubLanguageManager :: check_if_language_is_sub_language($language_id); - $this->assertFalse($res); - // var_dump($res); - } - - /** - * - */ - public function Testcheck_if_language_is_father() { - $language_id = 12; - $res = SubLanguageManager :: check_if_language_is_father($language_id); - $this->assertFalse($res); - // var_dump($res); - } - - /** - * - */ - public function Testmake_language_unavailable_and_back() { - $language_id = 11; - $res = SubLanguageManager :: make_unavailable_language($language_id); - $this->assertTrue($res,'Language could not be made unavailable'); - $res = SubLanguageManager :: make_available_language($language_id); - // var_dump($res); - } - - /** - * - */ - public function Testmake_available_language() { - $language_id= 11; - $res = SubLanguageManager :: make_unavailable_language($language_id); - $res = SubLanguageManager :: make_available_language ($language_id); - $this->assertTrue($res,'Language could not be made available'); - // var_dump($res); - } - /** - * - * - */ - public function Testset_platform_language_empty(){ - $backup = SubLanguageManager :: get_platform_language_id(); - $language_id = ''; - $res = SubLanguageManager :: set_platform_language($language_id); - $this->assertFalse($res); - $res = SubLanguageManager :: set_platform_language($backup); - // var_dump($res); - } - public function Testset_platform_language_2(){ - $backup = SubLanguageManager :: get_platform_language_id(); - $language_id = 2; - $res = SubLanguageManager :: set_platform_language($language_id); - $this->assertTrue($res); - $res = SubLanguageManager :: set_platform_language($backup); - // var_dump($res); - } - /** - * - * - */ - public function Testremove_directory_of_sub_language(){ - $res = SubLanguageManager :: remove_language_directory('test'); - // create a directory of sub language - $res = SubLanguageManager :: add_language_directory('test'); - $this->assertTrue($res); - $res = SubLanguageManager :: remove_language_directory('test'); - // var_dump($res); - } -} -?> diff --git a/tests/main/announcements/announcements.inc.test.php b/tests/main/announcements/announcements.inc.test.php deleted file mode 100755 index 6893c5e323..0000000000 --- a/tests/main/announcements/announcements.inc.test.php +++ /dev/null @@ -1,43 +0,0 @@ -UnitTestCase('Displays one specific announcement test'); - } - - - public function Testget_course_users(){ - $_SESSION['id_session'] = 'CURSO1'; - $user_list = CourseManager::get_real_and_linked_user_list(api_get_course_id(), true, $_SESSION['id_session']); - $res = get_course_users(); - if($res = array($res)){ - $this->assertTrue(is_array($res)); - } else { - $this->assertTrue(is_null($res)); - } - //var_dump($res); - } - - public function Testget_course_groups(){ - $_SESSION['id_session']='CURSO1'; - $new_group_list = CourseManager::get_group_list_of_course(api_get_course_id(), intval($_SESSION['id_session'])); - $res = get_course_groups(); - $this->assertFalse($res); - $this->assertTrue(is_array($res)); - var_dump($res); - } - - public function Testload_edit_users(){ - $_SESSION['id_session']='CURSO1'; - global $_course; - global $tbl_item_property; - $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY); - $tool = ''; - $id = ''; - $res = load_edit_users($tool, $id); - $this->assertTrue(is_null($res)); - var_dump($res); - } -} diff --git a/tests/main/auth/openid/xrds.lib.test.php b/tests/main/auth/openid/xrds.lib.test.php deleted file mode 100755 index ad5ae85726..0000000000 --- a/tests/main/auth/openid/xrds.lib.test.php +++ /dev/null @@ -1,71 +0,0 @@ -UnitTestCase('XRDS library for OpenID - main/auth/openid/xrds.lib.test.php'); - } - /* - function testxrds_cdata() { - global $xrds_open_elements, $xrds_services, $xrds_current_service; - $parser=''; - $data=''; - $res=_xrds_cdata(&$parser, $data); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - */ - - function testxrdsparse() { - - $xml = << - - Christian - Fasa Fasa - -XML; - - $parser = xrds_parse($xml); - if (is_resource($parser)) { - $this->assertTrue(is_resource($parser)); - } else { - $this->assertTrue(is_null($parser)); - } - } -/* - function test_xrds_element_end() { - global $xrds_open_elements, $xrds_services, $xrds_current_service; - $parser=''; - $name=''; - $xrds_current_service['version'] = 2; - $xrds_current_service['version'] = 1; - $xrds_services[] = $xrds_current_service; - $xrds_current_service= array(); - $res=_xrds_element_end(&$parser, $name); - $this->assertTrue(is_null($res)); - //var_dump($xrds_current_service); - } - - function test_xrds_element_start() { - - global $xrds_open_elements; - - $name=''; - $attribs=''; - - $res=_xrds_element_start(&$parser, $name, $attribs); - - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - function test_xrds_strip_namespace() { - $name=''; - $res=_xrds_strip_namespace($name); - $this->assertTrue(is_string($res)); - //var_dump($res); - }*/ -} -?> diff --git a/tests/main/chat/chat_functions.lib.test.php b/tests/main/chat/chat_functions.lib.test.php deleted file mode 100755 index c10a8dfb5c..0000000000 --- a/tests/main/chat/chat_functions.lib.test.php +++ /dev/null @@ -1,35 +0,0 @@ -UnitTestCase('Chat library - main/chat/chat_functions.lib.test.php'); - } - - public function setUp() { - $this->tcourse = new CourseManager(); - } - - public function tearDown() { - $this->tcourse = null; - } - - function CreateChatConnection($database_name) { - $session_id = 1; - $tbl_chat_connected = Database::get_main_table(TABLE_MAIN_CHAT); - $sql = "SELECT user_id FROM $tbl_chat_connected WHERE user_id = 1"; - $result = Database::query($sql); - //The user_id exists so we must do an UPDATE and not a INSERT - $current_time = date('Y-m-d H:i:s'); - if (Database::num_rows($result)==0) { - $query="INSERT INTO $tbl_chat_connected(user_id,last_connection,session_id) - VALUES(1,'$current_time','$session_id')"; - } else { - $query="UPDATE $tbl_chat_connected set last_connection='".$current_time."' - WHERE user_id=1 AND session_id='$session_id'"; - } - Database::query($query); - } -} -?> diff --git a/tests/main/dropbox/dropbox_class.inc.test.php b/tests/main/dropbox/dropbox_class.inc.test.php deleted file mode 100755 index c96dffe41d..0000000000 --- a/tests/main/dropbox/dropbox_class.inc.test.php +++ /dev/null @@ -1,299 +0,0 @@ -UnitTestCase(''); - } - - public function setUp() { - global $dropbox_cnf; - $dropbox_cnf['tbl_post'] = Database::get_course_table(TABLE_DROPBOX_POST); - $dropbox_cnf['tbl_file'] = Database::get_course_table(TABLE_DROPBOX_FILE); - $dropbox_cnf['tbl_person'] = Database::get_course_table(TABLE_DROPBOX_PERSON); - $dropbox_cnf['tbl_intro'] = Database::get_course_table(TABLE_TOOL_INTRO); - $dropbox_cnf['tbl_user'] = Database::get_main_table(TABLE_MAIN_USER); - $dropbox_cnf['tbl_course_user'] = Database::get_main_table(TABLE_MAIN_COURSE_USER); - $dropbox_cnf['tbl_category'] = Database::get_course_table(TABLE_DROPBOX_CATEGORY); - $dropbox_cnf['tbl_feedback'] = Database::get_course_table(TABLE_DROPBOX_FEEDBACK); - $this->ddropboxwork = new Dropbox_Work(1); - $this->ddropboxsentwork = new Dropbox_SentWork(1); - $this->dperson = new Dropbox_Person(1, 1, 1); - } - - public function tearDown() { - $this-> ddropboxwork = null; - $this-> ddropboxsentwork = null; - $this-> dperson = null; - } - -//Class Dropbox_Work - - /** - * Constructor calls private functions to create a new work or retreive an existing work from DB - * depending on the number of parameters - * - * @param unknown_type $arg1 - * @param unknown_type $arg2 - * @param unknown_type $arg3 - * @param unknown_type $arg4 - * @param unknown_type $arg5 - * @param unknown_type $arg6 - * @return Dropbox_Work - */ - - function testDropbox_Work() { - $arg1=1; - $resu= $this->ddropboxwork->Dropbox_Work($arg1, $arg2=null, $arg3=null, $arg4=null, $arg5=null, $arg6=null); - $this->assertTrue(is_null($resu)); - //var_dump($resu); - } - - /** - * private function creating a new work object - * - * @param unknown_type $uploader_id - * @param unknown_type $title - * @param unknown_type $description - * @param unknown_type $author - * @param unknown_type $filename - * @param unknown_type $filesize - * - * @todo $author was originally a field but this has now been replaced by the first and lastname of the uploader (to prevent anonymous uploads) - * As a consequence this parameter can be removed - */ - - function testCreateNewWork() { - global $dropbox_cnf; - $uploader_id=1; - $title='test'; - $description = 'testing'; - $author= 'test'; - $filename='test.txt'; - $filesize=125; - $resu= $this->ddropboxwork->_createNewWork($uploader_id, $title, $description, $author, $filename, $filesize); - $this->assertTrue(is_null($resu)); - //var_dump($resu); - } - - /** - * private function creating existing object by retreiving info from db - * - * @param unknown_type $id - */ - - function testCreateExistingWork() { - global $dropbox_cnf; - $dropbox_cnf['tbl_file'] = Database::get_course_table(TABLE_DROPBOX_FILE); - $dropbox_cnf['tbl_feedback'] = Database::get_course_table(TABLE_DROPBOX_FEEDBACK); - $id = 1; - $resu= $this->ddropboxwork->_createExistingWork($id); - $this->assertTrue(is_null($resu)); - //var_dump($resu); - } - -//Class Dropbox_SentWork - - /** - * Constructor calls private functions to create a new work or retreive an existing work from DB - * depending on the number of parameters - * - * @param unknown_type $arg1 - * @param unknown_type $arg2 - * @param unknown_type $arg3 - * @param unknown_type $arg4 - * @param unknown_type $arg5 - * @param unknown_type $arg6 - * @param unknown_type $arg7 - * @return Dropbox_SentWork - */ - - function testDropbox_SentWork() { - $arg1 = 1; - $resu= $this->ddropboxsentwork->Dropbox_SentWork($arg1, $arg2=null, $arg3=null, $arg4=null, $arg5=null, $arg6=null, $arg7=null); - $this->assertTrue(is_null($resu)); - } - - /** - * private function creating a new SentWork object - * - * @param unknown_type $uploader_id - * @param unknown_type $title - * @param unknown_type $description - * @param unknown_type $author - * @param unknown_type $filename - * @param unknown_type $filesize - * @param unknown_type $recipient_ids - */ - - function testCreateNewSentWork() { - $recipient_ids = array(1,2); - $uploader_id=1; - $title='test'; - $description = 'testing'; - $author= 'test'; - $filename='test.txt'; - $filesize=125; - $resu= $this->ddropboxsentwork->_createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids); - $this->assertTrue(is_null($resu)); - } - - /** - * private function creating existing object by retreiving info from db - * - * @param unknown_type $id - */ - - function testCreateExistingSentWork() { - $id = 1; - $resu= $this->ddropboxsentwork->_createExistingSentWork($id); - $this->assertTrue(is_null($resu)); - } - -//Class Dropbox_SentWork - - /** - * Constructor for recreating the Dropbox_Person object - * - * @param unknown_type $userId - * @param unknown_type $isCourseAdmin - * @param unknown_type $isCourseTutor - * @return Dropbox_Person - */ - - function testDropbox_Person() { - $userId = 1; - $isCourseAdmin = 1; - $isCourseTutor = 1; - $resu= $this->dperson->Dropbox_Person($userId, $isCourseAdmin, $isCourseTutor); - $this->assertTrue(is_null($resu)); - } - - /** - * method that sorts the objects in the sentWork array, dependent on the $sort parameter. - * $sort can be lastDate, firstDate, title, size, ... - * - * @param unknown_type $sort - */ - - function testorderSentWork() { - $sort = 1; - $resu= $this->dperson->orderSentWork($sort); - if(!is_numeric($resu)) { - $this->assertTrue(is_null($resu)); - } - } - - /** - * method that sorts the objects in the receivedWork array, dependent on the $sort parameter. - * $sort can be lastDate, firstDate, title, size, ... - * @param unknown_type $sort - */ - - function testorderReceivedWork() { - $sort = 1; - $resu= $this->dperson->orderReceivedWork($sort); - if(!is_numeric($resu)) { - $this->assertTrue(is_null($resu)); - } - } - - /** - * Updates feedback for received work of this person with id=$id - * - * @param unknown_type $id - * @param unknown_type $text - */ - - function testupdateFeedback() { - $id = 1; - $text = 'test'; - $resu= $this->dperson->updateFeedback($id, $text); - if(!is_bool($resu)) { - $this->assertTrue(is_null($resu)); - } - } - - /** - * Filter the received work - * @param string $type - * @param string $value - */ - - function testfilter_received_work() { - $type = 1; - $value = 1; - $resu= $this->dperson->filter_received_work($type,$value); - if(!is_bool($resu)) { - $this->assertTrue(is_null($resu)); - } - } - - /** - * Deletes all the received work of this person - * - */ - - function testdeleteAllReceivedWork() { - $resu= $this->dperson->deleteAllReceivedWork(); - if(!is_numeric($resu)) { - $this->assertTrue(is_null($resu)); - } - } - - /** - * Deletes all the received categories and work of this person - */ - - function testdeleteReceivedWorkFolder() { - $id = 1; - $resu= $this->dperson->deleteReceivedWorkFolder($id); - if(!is_bool($resu)) { - $this->assertTrue(is_null($resu)); - } - } - - /** - * Deletes a received dropbox file of this person with id=$id - * - * @param integer $id - */ - - function testdeleteReceivedWork() { - $id = 1; - $resu= $this->dperson->deleteReceivedWork($id); - if(!is_bool($resu)) { - $this->assertTrue(is_null($resu)); - } - } - - /** - * Deletes all the sent dropbox files of this person - */ - - function testdeleteAllSentWork() { - $resu= $this->dperson->deleteAllSentWork(); - if(!is_bool($resu)) { - $this->assertTrue(is_null($resu)); - } - } - - /** - * Deletes a sent dropbox file of this person with id=$id - * - * @param unknown_type $id - */ - - function testdeleteSentWork() { - $id = 1; - $resu= $this->dperson->deleteSentWork($id); - if(!is_bool($resu)) { - $this->assertTrue(is_null($resu)); - } - } -} -?> diff --git a/tests/main/dropbox/dropbox_functions.inc.test.php b/tests/main/dropbox/dropbox_functions.inc.test.php deleted file mode 100755 index fc3c4de1e9..0000000000 --- a/tests/main/dropbox/dropbox_functions.inc.test.php +++ /dev/null @@ -1,424 +0,0 @@ -assertTrue(is_string($res)); - } - //var_dump($res); - } - - - /** - * Displays the form to move one individual file to a category - * @return html code of the form that appears in a dokeos message box. - */ - - function testdisplay_move_form() { - ob_start(); - $id = 1; - $part = 'test'; - $res = display_move_form($part, $id, $target = array()); - ob_end_clean(); - if (!is_null($res)) { - $this->assertTrue(is_string($res)); - } - } - /** - * This function displays the form to add a new category. - * - * @param $category_name this parameter is the name of the category (used when no section is selected) - * @param $id this is the id of the category we are editing. - * - * @author Patrick Cool , Ghent University - * @version march 2006 - */ - - function testdisplay_addcategory_form() { - global $dropbox_cnf; - ob_start(); - $action= 'test'; - $res= display_addcategory_form($category_name='', $id='',$action); - ob_end_clean(); - if(!is_null($res)){ - $this->assertTrue(is_string($res)); - } - //var_dump($res); - } - - /** - * this function displays the form to upload a new item to the dropbox. - * - * @author Patrick Cool , Ghent University - * @version march 2006 - */ - - function testDisplay_add_form() { - global $_user, $is_courseAdmin, $is_courseTutor, $course_info, $origin, $dropbox_unid; - ob_start(); - $res= display_add_form(); - ob_end_clean(); - if(!is_null($res)){ - $this->assertTrue(is_string($res)); - } - //var_dump($res); - } - - /** - * This function displays the firstname and lastname of the user as a link to the user tool. - * @see this is the same function as in the new forum, so this probably has to move to a user library. - * @todo move this function to the user library - */ - - function testdisplayuserlink() { - global $_otherusers; - $user_id = 1; - $res= display_user_link($user_id, $name=''); - if(!is_null($res)){ - $this->assertTrue(is_string($res)); - } - //var_dump($res); - } - - /** - * @desc This function retrieves the number of feedback messages on every document. This function might become obsolete when - * the feedback becomes user individual. - */ - - function testget_total_number_feedback() { - global $dropbox_cnf; - $res= get_total_number_feedback($file_id=''); - if(!is_null($res)){ - $this->assertTrue(is_string($res)); - } - //var_dump($res); - } - - /** - * This function retrieves all the dropbox categories and returns them as an array - * @param $filter default '', when we need only the categories of the sent or the received part. - * @return array - */ - - function testGetdropbox_categories() { - $res= get_dropbox_categories($filter=''); - if(!is_null($res)){ - $this->assertTrue(is_array($res)); - } - //var_dump($res); - } - - /** - * Mailing zip-file is posted to (dest_user_id = ) mailing pseudo_id - * and is only visible to its uploader (user_id). - * Mailing content files have uploader_id == mailing pseudo_id, a normal recipient, - * and are visible initially to recipient and pseudo_id. - * @todo check if this function is still necessary. - */ - - function testgetUserOwningThisMailing() { - global $dropbox_cnf; - $mailingPseudoId = '1'; - $res= getUserOwningThisMailing($mailingPseudoId, $owner = 0, $or_die = ''); - if(!is_null($res)){ - $this->assertTrue(is_string($res)); - } - //var_dump($res); - } - - /** - * Get the last access to a given tool of a given user - * @param $tool string the tool constant - * @param $course_code the course_id - * @param $user_id the id of the user - * @return string last tool access date - * @todo consider moving this function to a more appropriate place. - */ - - function testget_last_tool_access() { - global $_course, $_user; - $tool = '1'; - $res= get_last_tool_access($tool, $course_code='', $user_id=''); - if(!is_null($res)){ - $this->assertTrue(is_string($res)); - } - //var_dump($res); - } - - /** - * This functions stores a new dropboxcategory - * @var it might not seem very elegant if you create a category in sent and in received with the same name that you get two entries in the - * dropbox_category table but it is the easiest solution. You get - * cat_name | received | sent | user_id - * test | 1 | 0 | 237 - * test | 0 | 1 | 237 - * more elegant would be - * test | 1 | 1 | 237 - */ - - function teststoreaddcategory() { - global $_user,$dropbox_cnf; - $res= store_addcategory(); - if(!is_null($res)){ - $this->assertTrue(is_string($res)); - } - //var_dump($res); - } - - /** - * This function moves a file to a different category - * @param $id the id of the file we are moving - * @param $target the id of the folder we are moving to - * @param $part are we moving a received file or a sent file? - * @return language string - */ - - function testStoremove() { - $id= 1; - $part = 'test'; - $target = array(); - $res= store_move($id, $target, $part); - if(!is_null($res)){ - $this->assertTrue(is_string($res)); - } - //var_dump($res); - } - - /** - *@return selected string - */ - - function teststoreadddropbox() { - global $dropbox_cnf; - global $_user; - global $_course; - $res= store_add_dropbox(); - if(!is_null($res)){ - $this->assertTrue(is_string($res)); - } - //var_dump($res); - } - - /** - * @return boolean indicating if user with user_id=$user_id is a course member - * @todo eliminate global - * @todo check if this function is still necessary. There might be a library function for this. - */ - - function testIsCourseMember() { - $user_id = 1; - $res= isCourseMember($user_id); - if(!is_null($res)){ - $this->assertTrue(is_bool($res)); - } - //var_dump($res); - } - - /** - * this function transforms the array containing all the feedback into something visually attractive. - * @param an array containing all the feedback about the given message. - */ - - function testfeedback() { - $array = array(); - $res= feedback($array); - if(!is_null($res)){ - $this->assertTrue(is_string($res)); - } - //var_dump($res); - } - - /** - * This function returns the html code to display the feedback messages on a given dropbox file - * @param $feedback_array an array that contains all the feedback messages about the given document. - * @return html code - * @todo add the form for adding new comment (if the other party has not deleted it yet). - * @author Patrick Cool , Ghent University - * @version march 2006 - */ - - function testformat_feedback() { - $feedback = array(); - $res= format_feedback($feedback); - if(!is_null($res)){ - $this->assertTrue(is_string($res)); - } - //var_dump($res); - } - - /** - * this function returns the code for the form for adding a new feedback message to a dropbox file. - * @return html code - */ - - function testfeedback_form() { - global $dropbox_cnf; - $res= feedback_form(); - if(!is_null($res)){ - $this->assertTrue(is_string($res)); - } - //var_dump($res); - } - - /** - * @return a language string (depending on the success or failure. - */ - - function teststore_feedback() { - global $dropbox_cnf; - global $_user; - $res= store_feedback(); - if(!is_null($res)){ - $this->assertTrue(is_string($res)); - } - //var_dump($res); - } - - /** - * @desc This function checks if the real filename of the dropbox files doesn't already exist in the temp folder. If this is the case then - * it will generate a different filename; - */ - - function testcheck_file_name() { - global $_course; - $file_name_2_check = 'test'; - $res= check_file_name($file_name_2_check, $counter=0); - if(!is_null($res)){ - $this->assertTrue(is_string($res)); - } - //var_dump($res); - } - - /** - * @desc this function checks if the key exists. If this is the case it returns the value, if not it returns 0 - */ - - function testcheck_number_feedback() { - $key = 'test'; - $array = array(); - $res= check_number_feedback($key, $array); - if(!is_null($res)){ - $this->assertTrue(is_numeric($res)); - } - //var_dump($res); - } - - /** - * @desc generates the contents of a html file that gives an overview of all the files in the zip file. - * This is to know the information of the files that are inside the zip file (who send it, the comment, ...) - */ - - function testgenerate_html_overview() { - $files = array(); - $res= generate_html_overview($files, $dont_show_columns=array(), $make_link=array()); - if(!is_null($res)){ - $this->assertTrue(is_string($res)); - } - //var_dump($res); - } - - /** - * This function downloads all the files of the inputarray into one zip - * @param $array an array containing all the ids of the files that have to be downloaded. - * @todo consider removing the check if the user has received or sent this file (zip download of a folder already sufficiently checks for this). - * @todo integrate some cleanup function that removes zip files that are older than 2 days - */ - /* - function testzip_download() { - global $_course; - global $dropbox_cnf; - global $_user; - global $files; - $array = array(); - $res= zip_download($array); - if(!is_string($res)){ - $this->assertTrue(is_null($res)); - } - //var_dump($res); - } - */ - - /** - * This is a callback function to decrypt the files in the zip file to their normal filename (as stored in the database) - * @param $p_event a variable of PCLZip - * @param $p_header a variable of PCLZip - */ - - function testmy_pre_add_callback() { - global $files; - $p_event = 'test'; - $res= my_pre_add_callback($p_event, &$p_header); - if(!is_null($res)){ - $this->assertTrue(is_numeric($res)); - } - //var_dump($res); - } - - /** - * @desc Cleans the temp zip files that were created when users download several files or a whole folder at once. - * T - * @return true - */ - - function testcleanup_temp_dropbox() { - global $_course; - $res= cleanup_temp_dropbox(); - if(!is_null($res)){ - $this->assertTrue(is_bool($res)); - } - //var_dump($res); - } - - /** - * This function deletes a dropbox category - * @todo give the user the possibility what needs to be done with the files in this category: move them to the root, download them as a zip, delete them - */ - - function testdelete_category() { - global $_user, $is_courseAdmin, $is_courseTutor,$dropbox_cnf; - $id= 1; - $action = 'test'; - $res= delete_category($action, $id); - if(!is_null($res)){ - $this->assertTrue(is_string($res)); - } - //var_dump($res); - } - - - /** - * Checks if there are files in the dropbox_file table that aren't used anymore in dropbox_person table. - * If there are, all entries concerning the file are deleted from the db + the file is deleted from the server - */ - - function testremoveUnusedFiles() { - $res= removeUnusedFiles(); - if(!is_null($res)){ - $this->assertTrue(is_array($res)); - } - //var_dump($res); - } - - /** - * @todo check if this function is still necessary. - */ - - function testremoveMoreIfMailing() { - $file_id = 1; - $res= removeMoreIfMailing($file_id); - if(!is_null($res)){ - $this->assertTrue(is_array($res)); - } - //var_dump($res); - } -} -?> \ No newline at end of file diff --git a/tests/main/exercice/answer.class.test.php b/tests/main/exercice/answer.class.test.php deleted file mode 100755 index e9939b0b2b..0000000000 --- a/tests/main/exercice/answer.class.test.php +++ /dev/null @@ -1,389 +0,0 @@ -UnitTestCase(''); - } - - public function setUp() { - /* - //Create a new exercise - require_once api_get_path(SYS_CODE_PATH).'exercise/exercise.class.php'; - require_once api_get_path(SYS_CODE_PATH).'inc/lib/pear/HTML/QuickForm.php'; - $this->aAnswer = new Answer(2); - $this->aAnswer->read(); - $this->aAnswer = new Exercise(); - - $form = array( - 'exerciseTitle'=>'testtitle', - 'exerciseDescription'=>'testdescription', - 'exerciseAttempts'=>'0', - 'exerciseFeedbackType'=>'0', - 'exerciseType'=>'1', - 'randomQuestions'=>'0', - 'randomAnswers'=>'0', - 'results_disabled'=>'0', - 'enabletimercontroltotalminutes'=>'0'); - $res = Exercise::processCreation($form,$type='1'); - */ - $this->aAnswer = new Answer(2); - - - } - - public function tearDown() { - $this->aAnswer = null; - } - - /** - * constructor of the class - * - * @author Olivier Brouckaert - * @param integer Question ID that answers belong to - */ - - /* - function testAnswerConstructor() { - $questionId = 1; - $res = $this->aAnswer->Answer($questionId); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - */ - - - - /** - * creates a new answer - * - * @author Olivier Brouckaert - * @param string answer title - * @param integer 0 if bad answer, not 0 if good answer - * @param string answer comment - * @param integer answer weighting - * @param integer answer position - * @param coordinates Coordinates for hotspot exercises (optional) - * @param integer Type for hotspot exercises (optional) - */ - - function testcreateAnswer() { - $answer = 'test'; - $correct = 1; - $comment ='test'; - $weighting = 2; - $position = 1; - $res = $this->aAnswer->createAnswer($answer,$correct,$comment,$weighting,$position,$new_hotspot_coordinates = 1, $new_hotspot_type = 1,$destination=''); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * duplicates answers by copying them into another question - * @param - integer $newQuestionId - ID of the new question - */ - - function testduplicate() { - $newQuestionId = 1; - $res = $this->aAnswer->duplicate($newQuestionId); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * Returns a list of answers - * @return array List of answers where each answer is an array of (id, answer, comment, grade) and grade=weighting - */ - - function testgetAnswersList() { - $res = $this->aAnswer->getAnswersList(); - $this->assertTrue(is_array($res)); - //var_dump($res); - } - - /** - * Returns a list of grades - * @return array List of grades where grade=weighting (?) - */ - - function testgetGradesList() { - $res = $this->aAnswer->getGradesList(); - $this->assertTrue(is_array($res)); - //var_dump($res); - } - - /** - * Returns the question type - * @return integer The type of the question this answer is bound to - */ - - function testgetQuestionType() { - $res = $this->aAnswer->getQuestionType(); - if(!is_null($res)){ - $this->assertTrue(is_numeric($res)); - } - //var_dump($res); - } - - /** - * tells if answer is correct or not - * @param - integer $id - answer ID - * @return - integer - 0 if bad answer, not 0 if good answer - */ - - function testisCorrect() { - $id = 1; - $res = $this->aAnswer->isCorrect($id); - if(!is_null($res)){ - $this->assertTrue(is_numeric($res)); - } - //var_dump($res); - } - - /** - * reads answer informations from the data base - */ - - function testread() { - $res = $this->aAnswer->read(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * reads answer informations from the data base ordered by parameter - * @param string Field we want to order by - * @param string DESC or ASC - */ - - function testreadOrderedBy() { - global $_course; - $field = 'position'; - $res = $this->aAnswer->readOrderedBy($field,$order=ASC); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * records answers into the data base - */ - - function testsave() { - $res = $this->aAnswer->save(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * returns the answer title - * @param - integer $id - answer ID - * @return - string - answer title - */ - - function testselectAnswer() { - $id = 1; - $res = $this->aAnswer->selectAnswer($id); - if(!is_null($res)){ - $this->assertTrue(is_string($res)); - } - //var_dump($res); - } - - /** - * @param - integer $id - answer ID - * @return - bool - answer by id - */ - function testselectAnswerByAutoId() { - $auto_id = 1; - $res = $this->aAnswer->selectAnswerByAutoId($auto_id); - if(!is_null($res)){ - $this->assertTrue(is_array($res)); - } else { - $this->assertTrue(is_bool($res)); - } - //var_dump($res); - } - - /** - * returns the answer title from an answer's position - * @param - integer $id - answer ID - * @return - bool - answer title - */ - - function testselectAnswerIdByPosition() { - $pos = 1; - $res = $this->aAnswer->selectAnswerIdByPosition($pos); - if(!is_null($res)){ - $this->assertTrue(is_bool($res)); - } - //var_dump($res); - } - - /** - * returns the autoincrement id identificator - * @return - integer - answer num - */ - - function testselectAutoId() { - $id = 1; - $res = $this->aAnswer->selectAutoId($id); - if(!is_null($res)){ - $this->assertTrue(is_numeric($res)); - } - //var_dump($res); - } - - /** - * returns answer comment - * @param - integer $id - answer ID - * @return - string - answer comment - */ - - function testselectComment() { - $id = 1; - $res = $this->aAnswer->selectComment($id); - if(!is_null($res)){ - $this->assertTrue(is_string($res)); - } - //var_dump($res); - } - - /** - * returns the question ID of the destination question - * @return - integer - the question ID - */ - - function testselectDestination() { - $id = 1; - $res = $this->aAnswer->selectDestination($id); - if(!is_null($res)){ - $this->assertTrue(is_string($res)); - } - //var_dump($res); - } - - /** - * returns answer hotspot coordinates - * @param integer Answer ID - * @return integer Answer position - */ - - function testselectHotspotCoordinates() { - $id = 1; - $res = $this->aAnswer->selectHotspotCoordinates($id); - if(!is_null($res)){ - $this->assertTrue(is_string($res)); - } - } - - /** - * returns answer hotspot type - * - * @author Toon Keppens - * @param integer Answer ID - * @return integer Answer position - */ - - function testselectHotspotType() { - $id = 1; - $res = $this->aAnswer->selectHotspotType($id); - if(!is_null($res)){ - $this->assertTrue(is_string($res)); - } - } - - /** - * returns the number of answers in this question - * - * @author - Olivier Brouckaert - * @return - integer - number of answers - */ - - function testselectNbrAnswers() { - $res = $this->aAnswer->selectNbrAnswers(); - if(!is_null($res)){ - $this->assertTrue(is_numeric($res)); - } - } - - /** - * returns answer position - * - * @author - Olivier Brouckaert - * @param - integer $id - answer ID - * @return - integer - answer position - */ - - function testselectPosition() { - $id = 1; - $res = $this->aAnswer->selectPosition($id); - if(!is_null($res)){ - $this->assertTrue(is_numeric($res)); - } - } - - /** - * returns the question ID which the answers belong to - * - * @author - Olivier Brouckaert - * @return - integer - the question ID - */ - - function testselectQuestionId() { - $res = $this->aAnswer->selectQuestionId(); - if(!is_null($res)){ - $this->assertTrue(is_numeric($res)); - } - } - - /** - * returns answer weighting - * - * @author - Olivier Brouckaert - * @param - integer $id - answer ID - * @return - integer - answer weighting - */ - - function testselectWeighting() { - $id = 1; - $res = $this->aAnswer->selectWeighting($id); - if(!is_null($res)){ - $this->assertTrue(is_numeric($res)); - } - } - - /** - * updates an answer - * - * @author Toon Keppens - * @param string Answer title - * @param string Answer comment - * @param integer Answer weighting - * @param integer Answer position - */ - - function testupdateAnswers() { - $answer = ''; - $comment = ''; - $weighting=2; - $position=1; - $destination='0@@0@@0@@0'; - $res = $this->aAnswer->updateAnswers($answer,$comment,$weighting,$position,$destination); - if(!is_null($res)){ - $this->assertTrue(is_numeric($res)); - } - } - - /** - * clears $new_* arrays - */ - - function testcancel() { - $res = $this->aAnswer->cancel(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } -} -?> diff --git a/tests/main/exercice/exercise.class.test.php b/tests/main/exercice/exercise.class.test.php deleted file mode 100755 index 83490531b3..0000000000 --- a/tests/main/exercice/exercise.class.test.php +++ /dev/null @@ -1,539 +0,0 @@ -UnitTestCase(''); - } - - public function setUp() { - - $this->eExercise = new Exercise(); - } - - public function tearDown() { - $this->eExercise = null; - } - - /** - * adds a question into the question list - * @param - integer $questionId - question ID - * @return - boolean - true if the question has been added, otherwise false - */ - - function testaddToList() { - $questionId = 1; - $res = $this->eExercise->addToList($questionId); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - /** - * Creates the form to create / edit an exercise - * @param FormValidator $form the formvalidator instance (by reference) - */ - - function testcreateForm() { - global $id; - $form = new FormValidator('introduction_text'); - $res = $this->eExercise->createForm($form, $type='full'); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - - /** - * disables the exercise - */ - - function testdisable() { - $res = $this->eExercise->disable(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - function testdisable_results() { - $res = $this->eExercise->disable_results(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * enables the exercise - */ - - function testenable() { - $res = $this->eExercise->enable(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - function testenable_results() { - $res = $this->eExercise->enable_results(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * Same as isRandom() but has a name applied to values different than 0 or 1 - */ - - function testgetShuffle() { - $res = $this->eExercise->getShuffle(); - $this->assertTrue(is_numeric($res)); - //var_dump($res); - } - - /** - * returns 'true' if the question ID is in the question list - * - * @author - Olivier Brouckaert - * @param - integer $questionId - question ID - * @return - boolean - true if in the list, otherwise false - */ - - function testisInList() { - $questionId = 1; - $res = $this->eExercise->isInList($questionId); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - /** - * tells if questions are selected randomly, and if so returns the draws - * - * @author - Olivier Brouckaert - * @return - integer - 0 if not random, otherwise the draws - */ - - function testisRandom() { - $res = $this->eExercise->isRandom(); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - /** - * moves a question down in the list - * @param - integer $id - question ID to move down - */ - - function testmoveDown() { - $id=1; - $res = $this->eExercise->moveDown($id); - if(!is_null($res)){ - $this->assertTrue(is_numeric($res)); - } - //var_dump($res); - } - - /** - * moves a question up in the list - * @param - integer $id - question ID to move up - */ - - function testmoveUp() { - $id=1; - $res = $this->eExercise->moveUp($id); - if(!is_null($res)){ - $this->assertTrue(is_numeric($res)); - } - //var_dump($res); - } - - /** - * function which process the creation of exercises - * @param FormValidator $form the formvalidator instance - */ - /* - function testprocessCreation() { - $form = new FormValidator('exerciseTitle'); - $res = $this->eExercise->processCreation($form,$type=''); - if(!is_null($res)){ - $this->assertTrue(is_numeric($res)); - } - //var_dump($res); - }*/ - - /** - * reads exercise informations from the data base - * @param - integer $id - exercise ID - * @return - boolean - true if exercise exists, otherwise false - */ - - function testread() { - global $_course; - global $_configuration; - global $questionList; - $id=1; - $res = $this->eExercise->read($id); - if(!is_null($res)){ - $this->assertTrue(is_bool($res)); - } - //var_dump($res); - } - - /** - * removes a question from the question list - * @param - integer $questionId - question ID - * @return - boolean - true if the question has been removed, otherwise false - */ - - function testremoveFromList() { - global $_course; - global $_configuration; - global $questionList; - $questionId=1; - $res = $this->eExercise-> removeFromList($questionId); - if(!is_null($res)){ - $this->assertTrue(is_bool($res)); - } - //var_dump($res); - } - - /** - * updates the exercise in the data base - */ - - function testsave() { - global $_course,$_user; - $res = $this->eExercise-> save($type_e=''); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - function testsearch_engine_delete() { - $res = $this->eExercise-> search_engine_delete(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - function testsearch_engine_save() { - $res = $this->eExercise-> search_engine_save(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * returns the number of attempts setted - * @return - numeric - exercise attempts - */ - - function testselectAttempts() { - $res = $this->eExercise-> selectAttempts(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * returns the exercise description - * @return - string - exercise description - */ - - function testselectDescription() { - $res = $this->eExercise-> selectDescription(); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - /** - * returns the expired time - * @return - string - expired time - */ - - function testselectExpiredTime() { - $res = $this->eExercise-> selectExpiredTime(); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - /** returns the number of FeedbackType * - * 0=>Feedback , 1=>DirectFeedback, 2=>NoFeedback - * @return - numeric - exercise attempts - */ - - function testselectFeedbackType() { - $res = $this->eExercise-> selectFeedbackType(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * returns the exercise ID - * @return - integer - exercise ID - */ - - function testselectId() { - $res = $this->eExercise-> selectId(); - $this->assertTrue(is_numeric($res)); - //var_dump($res); - } - - /** - * returns the number of questions in this exercise - * @return - integer - number of questions - */ - - function testselectNbrQuestions() { - $res = $this->eExercise-> selectNbrQuestions(); - $this->assertTrue(is_numeric($res)); - //var_dump($res); - } - - /** - * returns the array with the question ID list - * @return - array - question ID list - */ - - function testselectQuestionList() { - $res = $this->eExercise-> selectQuestionList(); - $this->assertTrue(is_array($res)); - //var_dump($res); - } - - /** - * returns random answers status. - */ - - function testselectRandomAnswers() { - $res = $this->eExercise-> selectRandomAnswers(); - $this->assertTrue(is_numeric($res)); - //var_dump($res); - } - - /** - * selects questions randomly in the question list - * - * @author - Olivier Brouckaert - * @return - array - if the exercise is not set to take questions randomly, returns the question list - * without randomizing, otherwise, returns the list with questions selected randomly - */ - - function testselectRandomList() { - $res = $this->eExercise-> selectRandomList(); - $this->assertTrue(is_array($res)); - //var_dump($res); - } - - /** - * tells if questions are selected randomly, and if so returns the draws - * @return - integer - results disabled exercise - */ - - function testselectResultsDisabled() { - $res = $this->eExercise-> selectResultsDisabled(); - $this->assertTrue(is_numeric($res)); - //var_dump($res); - } - - /** - * returns the exercise sound file - * @return - string - exercise description - */ - - function testselectSound() { - $res = $this->eExercise-> selectSound(); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - /** - * returns the exercise status (1 = enabled ; 0 = disabled) - * @return - int - true if enabled, otherwise false - */ - - function testselectStatus() { - $res = $this->eExercise-> selectStatus(); - $this->assertTrue(is_numeric($res)); - //var_dump($res); - } - - /** - * returns the time limit - * @return int - */ - - function testselectTimeLimit() { - $res = $this->eExercise-> selectTimeLimit(); - $this->assertTrue(is_numeric($res)); - //var_dump($res); - } - - /** - * returns the exercise title - * @return - string - exercise title - */ - - function testselectTitle() { - $res = $this->eExercise-> selectTitle(); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - /** - * returns the exercise type - * @return - integer - exercise type - */ - - function testselectType() { - $res = $this->eExercise-> selectType(); - $this->assertTrue(is_numeric($res)); - //var_dump($res); - } - - /** - * sets to 0 if questions are not selected randomly - * if questions are selected randomly, sets the draws - * @param - integer $random - 0 if not random, otherwise the draws - * @return void - */ - - function testsetRandom() { - $random = 1; - $res = $this->eExercise-> setRandom($random); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * update the table question - * @return void - */ - function testupdate_question_positions() { - $res = $this->eExercise-> update_question_positions(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * changes the exercise max attempts - * @param - numeric $attempts - exercise max attempts - * @return void - */ - - function testupdateAttempts() { - $attempts = 1; - $res = $this->eExercise-> updateAttempts($attempts); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * changes the exercise description - * @param - string $description - exercise description - * @return void - */ - - function testupdateDescription() { - $description = 'testdescription'; - $res = $this->eExercise-> updateDescription($description); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * changes the exercise expired_time - * @param - int The expired time of the quiz - * @return void - */ - - function testupdateExpiredTime() { - $expired_time = 1; - $res = $this->eExercise-> updateExpiredTime($expired_time); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * changes the exercise feedback type - * @param - numeric $attempts - exercise max attempts - * @return void - */ - - function testupdateFeedbackType() { - $feedback_type = 1; - $res = $this->eExercise-> updateFeedbackType($feedback_type); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * sets to 0 if answers are not selected randomly - * if answers are selected randomly - * @param - integer $random_answers - random answers - * @return void - */ - - function testupdateRandomAnswers() { - $random_answers = 0; - $res = $this->eExercise-> updateRandomAnswers($random_answers); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * update the results - * @return void - */ - function testupdateResultsDisabled() { - $results_disabled = 1; - $res = $this->eExercise->updateResultsDisabled($results_disabled); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * changes the exercise sound file - * @param - string $sound - exercise sound file - * @param - string $delete - ask to delete the file - * @return void - */ - - function testupdateSound() { - global $audioPath, $documentPath,$_course, $_user; - $sound = 'test'; - $delete = 'test'; - $res = $this->eExercise->updateSound($sound,$delete); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * changes the exercise title - * @param - string $title - exercise title - * @return void - */ - - function testupdateTitle() { - $title = 'test'; - $res = $this->eExercise->updateTitle($title); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * changes the exercise type - * @param - integer $type - exercise type - */ - - function testupdateType() { - $type = 1; - $res = $this->eExercise->updateType($type); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * deletes the exercise from the database - * Notice : leaves the question in the data base - */ - - function testdelete() { - global $_course,$_user; - $res = $this->eExercise->delete(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } -} -?> diff --git a/tests/main/exercice/exercise.lib.test.php b/tests/main/exercice/exercise.lib.test.php deleted file mode 100755 index 70658cb426..0000000000 --- a/tests/main/exercice/exercise.lib.test.php +++ /dev/null @@ -1,42 +0,0 @@ -UnitTestCase(''); - } - - public function setUp() { - - $this->eQuestion = new Question(); - } - - public function tearDown() { - $this->eQuestion = null; - }*/ - /** - * @param int question id - * @param boolean only answers - * @param boolean origin i.e = learnpath - * @param int current item from the list of questions - * @param int number of total questions - */ - - function testshowQuestion() { - global $_course; - $questionId = 1; - $current_item = 1 ; - $total_item = 1; - //$objQuestionTmp = $question->read($questionId); - $res = ExerciseLib::showQuestion($questionId, $onlyAnswers=false, $origin=false,$current_item, $total_item); - $this->assertTrue(is_null($res)); - var_dump($res); - } - - - - -} -?> diff --git a/tests/main/exercice/exercise_result.class.test.php b/tests/main/exercice/exercise_result.class.test.php deleted file mode 100755 index 7ec2587c82..0000000000 --- a/tests/main/exercice/exercise_result.class.test.php +++ /dev/null @@ -1,83 +0,0 @@ -UnitTestCase(''); - } - - public function setUp() { - $this->eExerciseResult = new ExerciseResult(); - } - - public function tearDown() { - $this->eExerciseResult = null; - } - - /** - * Gets the results of all students (or just one student if access is limited) - * @param string The document path (for HotPotatoes retrieval) - * @param integer User ID. Optional. If no user ID is provided, we take all the results. Defauts to null - */ - - function test_getExercisesReporting() { - global $user_id; - $document_path = api_get_path(SYS_COURSE_PATH).'document/'; - $res = $this->eExerciseResult->_getExercisesReporting($document_path,$user_id,$filter=0); - if(!is_null($res)) { - $this->assertTrue(is_bool($res)); - } - //var_dump($res); - } - - /** - * Exports the complete report as a CSV file - * @param string Document path inside the document tool - * @param integer Optional user ID - * @param boolean Whether to include user fields or not - * @return boolean False on error - */ - - function testexportCompleteReportCSV() { - global $user_id; - $document_path = api_get_path(SYS_COURSE_PATH).'document/'; - if(!headers_sent()){ - $res = $this->eExerciseResult->exportCompleteReportCSV($document_path,$user_id, $export_user_fields = array(), $export_filter = 0); - } - if(!is_null($res)) { - $this->assertTrue(is_bool($res)); - } - //var_dump($res); - } - - /** - * Exports the complete report as an XLS file - * @return boolean False on error - */ - - function testexportCompleteReportXLS() { - global $user_id; - $document_path = api_get_path(SYS_COURSE_PATH).'document/'; - if(!headers_sent()){ - $res = $this->eExerciseResult->exportCompleteReportXLS($document_path='',$user_id, $export_user_fields=array(), $export_filter = 0); - } - if(!is_null($res)) { - $this->assertTrue(is_bool($res)); - } - //var_dump($res); - } - - - - - - - - - - - -} -?> diff --git a/tests/main/exercice/export/exercise_import.inc.test.php b/tests/main/exercice/export/exercise_import.inc.test.php deleted file mode 100755 index 2f2c1b13a7..0000000000 --- a/tests/main/exercice/export/exercise_import.inc.test.php +++ /dev/null @@ -1,90 +0,0 @@ -assertFalse(is_array($res)); - if(!is_null){ - $this->assertTrue($res); - } - //var_dump($res); - } - - function testendElement() { - global $element_pile; - $element_pile = array(); - $parser= array(); - $data = array(); - $res = endElement($parser,$data); - $this->assertFalse(is_array($res)); - if(!is_null){ - $this->assertTrue($res); - } - //var_dump($res); - } - - /** - * possible deprecated - * @return the path of the temporary directory where the exercise was uploaded and unzipped - */ - - /*function testgetandunzipuploadedexercise() { - include_once (realpath(dirname(__FILE__) . '/../../inc/lib/pclzip/') . '/pclzip.lib.php'); - $res = get_and_unzip_uploaded_exercise(); - $this->assertFalse(is_array($res)); - if(!is_null){ - $this->assertTrue($res); - } - //var_dump($res); - } */ - - /** - * main function to import an exercise, - * Possible deprecated - * @return an array as a backlog of what was really imported, and error or debug messages to display - */ - - /*function testimport_exercise() { - $file = ''; - $res = import_exercise($file); - $this->assertFalse(is_array($res)); - if(!is_null){ - $this->assertTrue($res); - } - var_dump($res); - }*/ - - function testparse_file() { - $file = ''; - $exercisePath = ''; - $questionFile = ''; - $res = qti_parse_file($exercisePath, $file, $questionFile); - $this->assertTrue(is_array($res)); - if(!is_null){ - $this->assertTrue($res); - } - //var_dump($res); - } - - function teststartElement() { - $parser = 'test'; - $name = 'test'; - $attributes = array(); - $res = startElement($parser, $name, $attributes); - $this->assertFalse(is_array($res)); - if(!is_null){ - $this->assertTrue($res); - } - //var_dump($res); - } -} -?> diff --git a/tests/main/exercice/export/qti2/qti2_classes.test.php b/tests/main/exercice/export/qti2/qti2_classes.test.php deleted file mode 100755 index b264395b28..0000000000 --- a/tests/main/exercice/export/qti2/qti2_classes.test.php +++ /dev/null @@ -1,189 +0,0 @@ -UnitTestCase('QTI2 library - main/exercise/export/qti2/qti2_classes.test.php'); - } - - public function setUp() { - $this->qIms2Question = new Ims2Question(); - $this->qImsAnswerFillInBlanks = new ImsAnswerFillInBlanks(1); - $this->qImsAnswerFree = new ImsAnswerFree(1); - $this->qImsAnswerHotspot = new ImsAnswerHotspot(1); - $this->qImsAnswerMatching = new ImsAnswerMatching(1); - $this->qImsAnswerMultipleChoice = new ImsAnswerMultipleChoice(1); - } - - public function tearDown() { - $this-> qIms2Question = null; - $this-> qImsAnswerFillInBlanks = null; - $this-> qImsAnswerFree = null; - $this-> qImsAnswerHotspot = null; - $this-> qImsAnswerMatching = null; - $this-> qImsAnswerMultipleChoice = null; - } - -//Class qIms2Question - /** - * Include the correct answer class and create answer - */ - - function testsetAnswer() { - $res=Ims2Question::setAnswer(); - if(!is_null){ - $this->assertTrue(is_bool($res)); - } - //var_dump($res); - } - - function testcreateAnswersForm() { - $form = array(1); - $res=Ims2Question::createAnswersForm($form); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - function testprocessAnswersCreation() { - $form = array(1); - $res=Ims2Question::processAnswersCreation($form); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - -//Class qImsAnswerFillInBlanks - - /** - * Export the text with missing words. - * - * - */ - function testimsExportResponses() { - $questionIdent = array(1); - $questionStatment = array(1); - $res=$this->qImsAnswerFillInBlanks->imsExportResponses($questionIdent, $questionStatment); - if(!is_null){ - $this->assertTrue(is_bool($res)); - } - //var_dump($res); - } - - function testimsExportResponsesDeclaration() { - $questionIdent = array(1); - $res=$this->qImsAnswerFillInBlanks->imsExportResponsesDeclaration($questionIdent); - if(!is_null){ - $this->assertTrue(is_bool($res)); - } - //var_dump($res); - } - -//Class qImsAnswerFree - - /** - * TODO implement - * Export the question part as a matrix-choice, with only one possible answer per line. - */ - - function testImsExportResponsesqImsAnswerFree() { - $questionIdent = array(''); - $questionStatment = array(''); - $res=$this->qImsAnswerFree->imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia=''); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - function testImsExportResponsesDeclarationqImsAnswerFree() { - $questionIdent = array(1); - $res=$this->qImsAnswerFree->imsExportResponsesDeclaration($questionIdent); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - -//Class qImsAnswerHotspot - - /** - * TODO update this to match hotspots instead of copying matching - * Export the question part as a matrix-choice, with only one possible answer per line. - */ - - function testimsExportResponsesqImsAnswerHotspot() { - $questionIdent = array(1); - $questionStatment = array(1); - $res=$this->qImsAnswerHotspot->imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia=''); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - - function testimsExportResponsesDeclarationqImsAnswerHotspot() { - $questionIdent = array(1); - $res=$this->qImsAnswerHotspot->imsExportResponsesDeclaration($questionIdent); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - -//Class qImsAnswerMatching - - /** - * Export the question part as a matrix-choice, with only one possible answer per line. - */ - - function testimsExportResponsesqImsAnswerMatching() { - $questionIdent = array(1); - $questionStatment = array(1); - $res=$this->qImsAnswerMatching->imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia=''); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - - function testimsExportResponsesDeclarationqImsAnswerMatching() { - $questionIdent = array(1); - $res=$this->qImsAnswerMatching->imsExportResponsesDeclaration($questionIdent); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - -//Class qImsAnswerMultipleChoice - - /** - * Return the XML flow for the possible answers. - * - */ - - function testimsExportResponsesqImsAnswerMultipleChoice() { - $questionIdent = array(1); - $questionStatment = array(1); - $res=$this->qImsAnswerMultipleChoice->imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia=''); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - - function testimsExportResponsesDeclarationqImsAnswerMultipleChoice() { - $questionIdent = array(1); - $res=$this->qImsAnswerMultipleChoice->imsExportResponsesDeclaration($questionIdent); - $this->assertTrue(is_string($res)); - //var_dump($res); - } -} -?> diff --git a/tests/main/exercice/export/qti2/qti2_export.test.php b/tests/main/exercice/export/qti2/qti2_export.test.php deleted file mode 100755 index 9592ed8df9..0000000000 --- a/tests/main/exercice/export/qti2/qti2_export.test.php +++ /dev/null @@ -1,86 +0,0 @@ -UnitTestCase(''); - } - - public function setUp() { - - //$objQuestion = Question::read(1); - $objQuestion = Question::read(1); - - $question = new Ims2Question(); - /* - $qst = $question->read(1); - if( !$qst or $qst->type == FREE_ANSWER) - { - return ''; - } - $question->id = $qst->id; - $question->type = $qst->type; - $question->question = $qst->question; - $question->description = $qst->description; - $question->weighting=$qst->weighting; - $question->position=$qst->position; - $question->picture=$qst->picture; - */ - - $this->qImsAssessmentItem = new ImsAssessmentItem($question); - //$this->qImsItem = new ImsItem(1); - //$this->qImsSection = new ImsSection(1); - } - - public function tearDown() { - $this-> qImsAssessmentItem = null; - $this-> qImsItem = null; - $this-> qImsSection = null; - } - -//Class ImsAssessmentItem - - /** - * Constructor. - * @param $question The Question object we want to export. - */ - /* - function testImsAssessmentItem() { - $question = array(); - $res = $this->qImsAssessmentItem->ImsAssessmentItem($question); - if(!is_null){ - $this->assertTrue(is_bool($res)); - } - var_dump($res); - } - */ - - function teststart_item() { - /* - $res = $this->qImsAssessmentItem->start_item(); - if(!is_null){ - $this->assertTrue(is_bool($res)); - } - var_dump($res); - */ - } - - - - - - - - - - -} -?> diff --git a/tests/main/exercice/export/scorm/scorm_classes.test.php b/tests/main/exercice/export/scorm/scorm_classes.test.php deleted file mode 100755 index eae2ed516c..0000000000 --- a/tests/main/exercice/export/scorm/scorm_classes.test.php +++ /dev/null @@ -1,219 +0,0 @@ -UnitTestCase('SCORM exercises export library - main/exercise/export/scorm/scorm_classes.test.php'); - } - - public function setUp() { - $this->sScormAnswerFillInBlanks = new ScormAnswerFillInBlanks(1); - $this->sScormAnswerFree = new ScormAnswerFree(1); - $this->sScormAnswerHotspot = new ScormAnswerHotspot(1); - $this->sScormAnswerMatching = new ScormAnswerMatching(1); - $this->sScormAnswerMultipleChoice = new ScormAnswerMultipleChoice(1); - $this->sScormAnswerTrueFalse = new ScormAnswerTrueFalse(1); - $this->sScormQuestion = new ScormQuestion(1); - } - - public function tearDown() { - $this-> sScormAnswerFillInBlanks = null; - $this-> sScormAnswerFree = null; - $this-> sScormAnswerHotspot = null; - $this-> sScormAnswerMatching = null; - $this-> sScormAnswerMultipleChoice = null; - $this-> sScormAnswerTrueFalse = null; - $this-> sScormQuestion = null; - } - - -//Class sScormAnswerFillInBlanks - - /** - * Export the text with missing words. - * - * As a side effect, it stores two lists in the class : - * the missing words and their respective weightings. - */ - - function testexport() { - $res= $this->sScormAnswerFillInBlanks->export(); - if(!is_null($res)){ - $this->assertTrue(is_array($res)); - } - //var_dump($res); - } - -//Class sScormAnswerFree - - /** - * Export the text with missing words. - * - * As a side effect, it stores two lists in the class : - * the missing words and their respective weightings. - * - */ - function testexportsScormAnswerFree() { - $res= $this->sScormAnswerFree->export(); - if(!is_null($res)){ - $this->assertTrue(is_array($res)); - } - //var_dump($res); - } - -//Class sScormAnswerHotspot - - /** - * Returns the javascript code that goes with HotSpot exercises - * @return string The JavaScript code - */ - - function testexportsScormAnswerHotspot() { - $res= $this->sScormAnswerHotspot->export(); - if(!is_null($res)){ - $this->assertTrue(is_array($res)); - } - //var_dump($res); - } - - function testgetjsheadersScormAnswerHotspot() { - $res= $this->sScormAnswerHotspot->get_js_header(); - if(!is_null($res)){ - $this->assertTrue(is_string($res)); - } - //var_dump($res); - } - - //Class sScormAnswerMatching - - /** - * Export the question part as a matrix-choice, with only one possible answer per line. - * @author Amand Tihon - */ - - function testexportsScormAnswerMatching() { - $res= $this->sScormAnswerMatching->export(); - if(!is_null($res)){ - $this->assertTrue(is_array($res)); - } - //var_dump($res); - } - -//Class sScormAnswerMultipleChoice - - /** - * Return HTML code for possible answers - */ - - function testexportsScormAnswerMultipleChoice() { - $res= $this->sScormAnswerMultipleChoice->export(); - if(!is_null($res)){ - $this->assertTrue(is_array($res)); - } - //var_dump($res); - } - -//Class sScormAnswerTrueFalse - - /** - * Return the XML flow for the possible answers. - * That's one , containing several - */ - - function testexportsScormAnswerTrueFalse() { - $res= $this->sScormAnswerTrueFalse->export(); - if(!is_null($res)){ - $this->assertTrue(is_array($res)); - } - //var_dump($res); - } - -//Class sScormQuestion - - function testcreateAnswersFormsScormQuestion() { - $form = ''; - $res= $this->sScormQuestion->createAnswersForm($form); - if(!is_null($res)){ - $this->assertTrue(is_bool($res)); - } - //var_dump($res); - } - - /** - * Return the XML flow for the possible answers. - * That's one , containing several - */ - - /*function testexportsScormQuestion() { - $res= $this->sScormQuestion->export(); - if(!is_null($res)){ - $this->assertTrue(is_array($res)); - } - //var_dump($res); - }*/ - - /** - * Returns an HTML-formatted question - */ - /* - function testgetQuestionHTMLsScormQuestion() { - $res= $this->sScormQuestion->getQuestionHTML(); - if(!is_null($res)){ - $this->assertTrue(is_array($res)); - } - //var_dump($res); - }*/ - - /** - * Return the JavaScript code bound to the question - */ - /* - function testgetQuestionJSsScormQuestion() { - $res= ScormQuestion::getQuestionJS(); - if(!is_null($res)){ - $this->assertTrue(is_array($res)); - } - //var_dump($res); - }*/ - - function testprocessAnswersCreationJSsScormQuestion() { - $form = ''; - $res= $this->sScormQuestion->processAnswersCreation($form); - if(!is_null($res)){ - $this->assertTrue(is_bool($res)); - } - //var_dump($res); - } - - /** - * Include the correct answer class and create answer - */ - - function testsetAnswersCreationJSsScormQuestion() { - $res= $this->sScormQuestion->setAnswer(); - if(!is_null($res)){ - $this->assertTrue(is_bool($res)); - } - //var_dump($res); - } -} -?> diff --git a/tests/main/exercice/fill_blanks.class.test.php b/tests/main/exercice/fill_blanks.class.test.php deleted file mode 100755 index 055e1072e5..0000000000 --- a/tests/main/exercice/fill_blanks.class.test.php +++ /dev/null @@ -1,45 +0,0 @@ -UnitTestCase(''); - } - - public function setUp() { - $this->fFillBlanks = new FillBlanks(); - } - - public function tearDown() { - $this->fFillBlanks = null; - } - - /** - * function which redifines Question::createAnswersForm - * @param the formvalidator instance - */ - /* - function testcreateAnswersForm() { - $form = new FormValidator('introduction_text'); - $res = $this->fFillBlanks->createAnswersForm($form); - $this->assertTrue(is_null($res)); - var_dump($res); - }*/ - - /** - * abstract function which creates the form to create / edit the answers of the question - * @param the formvalidator instance - */ - /* - function testprocessAnswersCreation() { - global $charset; - $form = new FormValidator('introduction_text'); - $res = $this->fFillBlanks->processAnswersCreation($form); - $this->assertTrue(is_null($res)); - var_dump($res); - }*/ - -} -?> diff --git a/tests/main/exercice/freeanswer.class.test.php b/tests/main/exercice/freeanswer.class.test.php deleted file mode 100755 index 6b1deb894a..0000000000 --- a/tests/main/exercice/freeanswer.class.test.php +++ /dev/null @@ -1,29 +0,0 @@ -assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * abstract function which creates the form to create / edit the answers of the question - * @param the formvalidator instance - */ - - function testprocessAnswersCreation () { - $form = new FormValidator('exercise_admin', 'post', api_get_self().'?exerciseId='.intval($_GET['exerciseId'])); - $res =FreeAnswer::processAnswersCreation($form); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - -} -?> diff --git a/tests/main/exercice/hotpotatoes.lib.test.php b/tests/main/exercice/hotpotatoes.lib.test.php deleted file mode 100755 index b8b6f93020..0000000000 --- a/tests/main/exercice/hotpotatoes.lib.test.php +++ /dev/null @@ -1,178 +0,0 @@ -UnitTestCase('Hotpotatoes exercises library - main/exercise/hotpotatoes.lib.test.php'); - } - - function testCheckImageName() { - $imgparams=array(); - $string=''; - $checked = myarraysearch($imgparams,$string); - $res=CheckImageName(&$imgparams,$string); - $this->assertTrue(is_bool($res)); - $this->assertTrue(is_bool($checked)); - //var_dump($res); - } - - function testCheckSubFolder() { - $path='Location: /main/exercise/'; - $res=CheckSubFolder($path); - $this->assertTrue(is_numeric($res)); - //var_dump($res); - } - - function testFillFolderName() { - $name='testnameofthefolder'; - $nsize=12; - $res=FillFolderName($name,$nsize); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - function testGenerateHiddenList() { - $imgparams=array('test'); - $res=GenerateHiddenList($imgparams); - $this->assertTrue(is_string($res)); - //var_dump($res); - - - } - - function testGenerateHpFolder() { - $folder='main/exercise/hotpotatoes.lib.php'; - $res=GenerateHpFolder($folder); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - function testGetComment() { - - $course_code = 'COURSETEST'; - $path = 'exercice_submit.php'; - $query ="select comment from $dbTable where path='$path'"; - $res=GetComment($path,$course_code); - $this->assertTrue(is_string($res)); - //var_dump($res); - - } - - /* Deprecated - function testGetFileName() { - $fname='main/exercise/hotpotatoes.lib.php'; - $res=GetFileName($fname); - $this->assertTrue(is_string($res)); - //var_dump($res); - }*/ - - function testGetFolderName() { - $fname='main/exercise/hotpotatoes.lib.php'; - $res=GetFolderName($fname); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - function testGetFolderPath() { - $fname='main/exercise/hotpotatoes.lib.php'; - $res=GetFolderPath($fname); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - function testGetImgName() { - $imgtag=''; - $res=GetImgName($imgtag); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - function testGetImgParams() { - $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); - } - - function testGetQuizName() { - $course_code = 'COURSETEST'; - $fname='exercice_submit.php'; - $fpath='main/exercise/exercice_submit.php'; - $res=GetQuizName($fname,$fpath); - - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - function testGetSrcName() { - $imgtag='src="test.jpg""'; - $res=GetSrcName($imgtag); - if(!is_string($res))$this->assertTrue(is_bool($res)); - //var_dump($res); - } - - function testhotpotatoes_init() { - $base = api_get_path(SYS_CODE_PATH); - $baseWorkDir=$base.'exercise/'; - $res=hotpotatoes_init($baseWorkDir); - $this->assertFalse($res); - //var_dump($res); - } - - function testHotPotGCt() { - $folder='/main/exercise'; - $flag=4; - $userID=1; - $res=HotPotGCt($folder,$flag,$userID); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - function testmyarraysearch() { - $array=array(); - $node=''; - $res=myarraysearch($array,$node); - if(!is_bool($res))$this->assertTrue(is_null($res)); - //var_dump($res); - } - - function testReadFileCont() { - $full_file_path=''; - $res=ReadFileCont($full_file_path); - if(!is_bool($res))$this->assertTrue(is_string($res)); - //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/exercise'; - $comment='testing this function'; - $comment = Database::escape_string($comment); - $query = "UPDATE $dbTable set comment='$comment' where path='$path'"; - $result = Database::query($query); - $res=SetComment($path,$comment); - $this->assertTrue(is_string($res)); - //var_dump($resu); - } - - function testWriteFileCont() { - $course_code = 'COURSETEST'; - $full_file_path='/main/exercise/'; - $content='test test test'; - $res=WriteFileCont($full_file_path,$content); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } -} -?> diff --git a/tests/main/forum/forumfunction.inc.test.php b/tests/main/forum/forumfunction.inc.test.php deleted file mode 100755 index d8e37ef6a0..0000000000 --- a/tests/main/forum/forumfunction.inc.test.php +++ /dev/null @@ -1,1248 +0,0 @@ -UnitTestCase('Test forum function'); - } - - public function __construct() { - // The constructor acts like a global setUp for the class - require_once api_get_path(SYS_TEST_PATH).'setup.inc.php'; - } - - /** - * This function add a attachment file into forum - * @param string a comment about file - * @param int last id from forum_post table - * @return void - */ - public function testadd_forum_attachment_file() { - global $_course; - $file_comment='testcoment'; - $last_id = 1; - $res = add_forum_attachment_file($file_comment,$last_id); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * This function approves a post = change - * - * @param $post_id the id of the post that will be deleted - * @param $action make the post visible or invisible - * @return string language variable - */ - - public function testapprove_post() { - $action= 'invisible'; - $post_id = 1; - $res = approve_post($post_id, $action); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - /** - * This function changes the lock status in the database - * - * @param $content what is it that we want to (un)lock: forum category, forum, thread, post - * @param $id the id of the content we want to (un)lock - * @param $action do we lock (=>locked value in db = 1) or unlock (=> locked value in db = 0) - * @return string, language variable - * @todo move to itemmanager - */ - - public function testchange_lock_status() { - $content = 'testcontent'; - $action= 'invisible'; - $id = 1; - $res = change_lock_status($content, $id, $action); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - /** - * This function changes the visibility in the database (item_property) - * - * @param $content what is it that we want to make (in)visible: forum category, forum, thread, post - * @param $id the id of the content we want to make invisible - * @param $target_visibility what is the current status of the visibility (0 = invisible, 1 = visible) - * @todo change the get parameter so that it matches the tool constants. - * @todo check if api_item_property_update returns true or false => returnmessage depends on it. - * @todo move to itemmanager - * @return string language variable - */ - - public function testchange_visibility() { - $content= 'testcontent'; - $target_visibility = 1; - $id = 1; - $res = change_visibility($content, $id, $target_visibility); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - /** - * This function gets the all information of the last (=most recent) post of the thread - * This can be done by sorting the posts that have the field thread_id=$thread_id and sort them by post_date - * @param $thread_id the id of the thread we want to know the last post of. - * @return an bool or array if there is a last post found, false if there is no post entry linked to that thread => thread will be deleted - */ - - public function testcheck_if_last_post_of_thread() { - $thread_id = 1; - $res = check_if_last_post_of_thread($thread_id); - if(!is_bool($res)) { - $this->assertTrue(is_array($res)); - } - //var_dump($res); - } - - /** - * This function counts the number of forums inside a given category - * @param $cat_id the id of the forum category - * @todo an additional parameter that takes the visibility into account. For instance $countinvisible=0 would return the number - * of visible forums, $countinvisible=1 would return the number of visible and invisible forums - * @return int the number of forums inside the given category - */ - - public function testcount_number_of_forums_in_category() { - $cat_id = 1; - $res = count_number_of_forums_in_category($cat_id); - $this->assertTrue(is_numeric($res)); - //var_dump($res); - } - - /** - * This function counts the number of post inside a thread user - * @param int Thread ID - * @param int User ID - * @return int the number of post inside a thread user - */ - - public function testcount_number_of_post_for_user_thread() { - $thread_id = 1; - $user_id = 1; - $res = count_number_of_post_for_user_thread($thread_id, $user_id); - $this->assertTrue(is_numeric($res)); - //var_dump($res); - } - - /** - * This function counts the number of post inside a thread - * @param int Thread ID - * @return int the number of post inside a thread - */ - - public function testcount_number_of_post_in_thread() { - $thread_id = 1; - $res = count_number_of_post_in_thread($thread_id); - $this->assertTrue(is_numeric($res)); - //var_dump($res); - } - - /** - * This function counts the number of user register in course - * @param int Course ID - * @return int the number of user register in course - */ - - public function testcount_number_of_user_in_course() { - global $cidReq; - $course_id = $cidReq; - $res = count_number_of_user_in_course($course_id); - $this->assertTrue(is_numeric($res)); - //var_dump($res); - } - - /** - * - * This function show current thread qualify . - * @param integer contains the information the current thread id - * @param integer contains the information the current session id - * @return array or null if is empty - */ - - public function testcurrent_qualify_of_thread() { - $thread_id = 1; - $session_id = 1; - $res = current_qualify_of_thread($thread_id,$session_id); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * Display the search results - * @return void HTML - display the results - */ - - public function testdisplay_forum_search_results() { - global $origin; - $search_term = 'testterm'; - ob_start(); - $res = display_forum_search_results($search_term); - ob_end_clean(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - - /** - * This function displays the user image from the profile, with a link to the user's details. - * @param int User's database ID - * @param str User's name - * @return string An HTML with the anchor and the image of the user - */ - - public function testdisplay_user_image() { - $name = 'testcontent'; - $user_id = 1; - $res = display_user_image($user_id,$name, $origin=''); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - /** - * This function displays the firstname and lastname of the user as a link to the user tool. - * @param string - * @return string HTML - */ - - public function testdisplay_user_link() { - $name = 'testcontent'; - $user_id = 1; - $res = display_user_link($user_id, $name, $origin=''); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - /** - * This function edit a attachment file into forum - * @param string a comment about file - * @param int Post Id - * @param int attachment file Id - * @return void - */ - - public function testedit_forum_attachment_file() { - $file_comment = 'testcontent'; - $id_attach = 1; - $post_id = 1; - $res = edit_forum_attachment_file($file_comment,$post_id,$id_attach); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * Display the search form for the forum and display the search results - * @return void display an HTML search results - */ - - public function testforum_search() { - ob_start(); - $res = forum_search(); - ob_end_clean(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** This function gets all the post written by an user - * @param int user id - * @param string db course name - * @return string - */ - - public function testget_all_post_from_user() { - global $_course; - $course_db = $_course['dbName']; - $user_id = 1; - $res = get_all_post_from_user($user_id, $course_db); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - /** - * Show a list with all the attachments according to the post's id - * @param the post's id - * @return array with the post info - */ - - public function testget_attachment() { - $post_id = 1; - $res = get_attachment($post_id); - $this->assertTrue(is_array($res)); - //var_dump($res); - } - - /** - * Retrieve all the information off the forum categories (or one specific) for the current course. - * The categories are sorted according to their sorting order (cat_order - * @param $id default ''. When an id is passed we only find the information about that specific forum category. If no id is passed we get all the forum categories. - * @return an array containing all the information about all the forum categories - */ - - public function testget_forum_categories() { - $res = get_forum_categories($id=''); - $this->assertTrue(is_array($res)); - //var_dump($res); - } - - /** - * This function retrieves all the information of a given forumcategory id - * @param $forum_id integer that indicates the forum - * @return array returns if there are category - * @return bool returns if there aren't category - */ - - public function testget_forumcategory_information() { - $cat_id = 1; - $res = get_forumcategory_information($cat_id); - if(!is_bool($res)){ - $this->assertTrue(is_array($res)); - } else { - $this->assertTrue(is_bool($res)); - } - //var_dump($res); - } - - /** - * Retrieve all the forums (regardless of their category) or of only one. The forums are sorted according to the forum_order. - * Since it does not take the forum category into account there probably will be two or more forums that have forum_order=1, ... - * @return an array containing all the information about the forums (regardless of their category) - * @todo check $sql4 because this one really looks fishy. - */ - - public function testget_forums() { - $res = get_forums($id=''); - if(!is_bool($res)){ - $this->assertTrue(is_array($res)); - } else { - $this->assertTrue(is_bool($res)); - } - //var_dump($res); - } - - /** - * This function retrieves all the fora in a given forum category - * @param integer $cat_id the id of the forum category - * @return an array containing all the information about the forums (regardless of their category) - */ - - public function testget_forums_in_category() { - $cat_id = 1; - $res = get_forums_in_category($cat_id); - if(!is_bool($res)){ - $this->assertTrue(is_array($res)); - } else { - $this->assertTrue(is_bool($res)); - } - //var_dump($res); - } - - /** - * This function gets all the forum information of the all the forum of the group - * @param integer $group_id the id of the group we need the fora of (see forum.forum_of_group) - * @return array - * @todo this is basically the same code as the get_forums function. Consider merging the two. - */ - - public function testget_forums_of_group() { - $group_id = 1; - $res = get_forums_of_group($group_id); - if(!is_null($res)){ - $this->assertTrue(is_array($res)); - } else { - $this->assertTrue(is_null($res)); - } - //var_dump($res); - } - - /** - * - * This function get qualify historical. - * @param integer contains the information the current user id - * @param integer contains the information the current thread id - * @param boolean contains the information of option to run - * @return array() - */ - - public function testGetThreadScoreHistory() { - $user_id = 1; - $thread_id = 1; - $opt = true; - $res = getThreadScoreHistory($user_id,$thread_id,$opt); - if(!is_null($res)){ - $this->assertTrue(is_array($res)); - } else { - $this->assertTrue(is_null($res)); - } - //var_dump($res); - } - - /** - * This functions gets all the last post information of a certain forum - * @param $forum_id the id of the forum we want to know the last post information of. - * @param $show_invisibles - * @return array containing all the information about the last post (last_post_id, last_poster_id, last_post_date, last_poster_name, last_poster_lastname, last_poster_firstname) - */ - - public function testget_last_post_information() { - $forum_id = 1; - $res = get_last_post_information($forum_id, $show_invisibles=false); - if(!is_null($res)){ - $this->assertTrue(is_array($res)); - } else { - $this->assertTrue(is_null($res)); - } - //var_dump($res); - } - - /** This function get the name of an thread by id - * @param int thread_id - * @return String - **/ - - public function testget_name_thread_by_id() { - $thread_id = 1; - $res = get_name_thread_by_id($thread_id); - if(!is_null($res)){ - $this->assertTrue(is_string($res)); - } else { - $this->assertTrue(is_null($res)); - } - //var_dump($res); - } - - /** This function get the name of an user by id - * @param user_id int - * return String - */ - - public function testget_name_user_by_id() { - $user_id = 1; - $res = get_name_user_by_id($user_id); - if(!is_null($res)){ - $this->assertTrue(is_string($res)); - } else { - $this->assertTrue(is_null($res)); - } - //var_dump($res); - } - - /** - * This function retrieves all the email adresses of the users who wanted to be notified - * about a new post in a certain forum or thread - * @param string $content does the user want to be notified about a forum or about a thread - * @param integer $id the id of the forum or thread - * @return array - */ - - public function testget_notifications() { - $id = 1; - $content = 'test message notified'; - $res = get_notifications($content,$id); - if(!is_null($res)){ - $this->assertTrue(is_array($res)); - } else { - $this->assertTrue(is_null($res)); - } - //var_dump($res); - } - - /** - * Get all the notification subscriptions of the user - * = which forums and which threads does the user wants to be informed of when a new - * post is added to this thread - * @param integer $user_id the user_id of a user (default = 0 => the current user) - * @param boolean $force force get the notification subscriptions (even if the information is already in the session - * @return array - */ - - public function testget_notifications_of_user() { - $res = get_notifications_of_user($user_id = 0, $force = false); - if(!is_null($res)){ - $this->assertTrue(is_string($res)); - } else { - $this->assertTrue(is_null($res)); - } - //var_dump($res); - } - - /** - * This function retrieves all the information of a post - * @param $forum_id integer that indicates the forum - * @return array returns - */ - - public function testget_post_information() { - $post_id = 1; - $res = get_post_information($post_id); - if(!is_null($res)){ - $this->assertTrue(is_array($res)); - } else { - $this->assertTrue(is_null($res)); - } - //var_dump($res); - } - - /** - * Retrieve all posts of a given thread - * @param int $thread_id integer that indicates the forum - * @return an array containing all the information about the posts of a given thread - */ - - public function testget_posts() { - $thread_id = 1; - $res = getPosts($thread_id); - if(!is_null($res)){ - $this->assertTrue(is_array($res)); - } else { - $this->assertTrue(is_null($res)); - } - //var_dump($res); - } - - /** - * This function retrieves information of statistical - * @param int Thread ID - * @param int User ID - * @param int Course ID - * @return array the information of statistical - */ - - public function testget_statistical_information() { - $thread_id = 1; - $user_id = 1; - $course_id = 1; - $res = get_statistical_information($thread_id, $user_id, $course_id); - if(!is_null($res)){ - $this->assertTrue(is_array($res)); - } else { - $this->assertTrue(is_null($res)); - } - //var_dump($res); - } - - /** - * This function retrieves all the information of a thread - * @param $forum_id integer that indicates the forum - * @return array returns - */ - - function testget_thread_information() { - $thread_id = 1; - $res = get_thread_information($thread_id); - if(!is_bool($res)){ - $this->assertTrue(is_array($res)); - } else { - $this->assertTrue(is_bool($res)); - } - //var_dump($res); - } - - /** - * This function return the posts inside a thread from a given user - * @param course code - * @param int Thread ID - * @param int User ID - * @return int the number of post inside a thread - */ - - public function testget_thread_user_post() { - global $_course; - $thread_id = 1; - $course_db = $_course['dbName']; - $user_id = 1; - $res = get_thread_user_post($course_db, $thread_id, $user_id ); - if(!is_null($res)){ - $this->assertTrue(is_array($res)); - } else { - $this->assertTrue(is_null($res)); - } - //var_dump($res); - } - /** - * @param string - * @param int - * @param int - * @param int - * @return void - */ - public function testget_thread_user_post_limit() { - global $_course; - $thread_id = 1; - $course_db = $_course['dbName']; - $user_id = 1; - $res = get_thread_user_post_limit($course_db, $thread_id, $user_id, $limit=10); - if(!is_null($res)){ - $this->assertTrue(is_array($res)); - } else { - $this->assertTrue(is_null($res)); - } - //var_dump($res); - } - - /** - * This function retrieves forum thread users details - * @param int Thread ID - * @param string Course DB name (optional) - * @return resource Array of type ([user_id=>w,lastname=>x,firstname=>y,thread_id=>z],[]) - */ - - public function testget_thread_users_details() { - $thread_id = 1; - $res = get_thread_users_details($thread_id); - if(!is_null($res)){ - $this->assertTrue(is_resource($res)); - } else { - $this->assertTrue(is_null($res)); - } - //var_dump($res); - } - - /** - * This function retrieves forum thread users not qualify - * @param int Thread ID - * @param string Course DB name (optional) - * @return array Array of type ([user_id=>w,lastname=>x,firstname=>y,thread_id=>z],[]) - */ - - public function testget_thread_users_not_qualify() { - $thread_id = 1; - $res = get_thread_users_not_qualify($thread_id, $db_name = null); - if(!is_null($res)){ - $this->assertTrue(is_resource($res)); - } else { - $this->assertTrue(is_null($res)); - } - //var_dump($res); - } - - /** - * This function retrieves forum thread users qualify - * @param int Thread ID - * @param string Course DB name (optional) - * @return array Array of type ([user_id=>w,lastname=>x,firstname=>y,thread_id=>z],[]) - */ - - public function testget_thread_users_qualify() { - $thread_id = 1; - $res = get_thread_users_qualify($thread_id, $db_name = null); - if(!is_bool($res)){ - $this->assertTrue(is_resource($res)); - } else { - $this->assertTrue(is_bool($res)); - } - //var_dump($res); - } - - /** - * Retrieve all the threads of a given forum - * @param int forum id - * @return an array containing all the information about the threads - */ - - public function testget_threads() { - $forum_id = 1; - $res = get_threads($forum_id); - if(!is_bool($res)){ - $this->assertTrue(is_array($res)); - } else { - $this->assertTrue(is_bool($res)); - } - //var_dump($res); - } - - /** - * This function retrieves all the unapproved messages for a given forum - * This is needed to display the icon that there are unapproved messages in that thread (only the courseadmin can see this) - * @param $forum_id the forum where we want to know the unapproved messages of - * @return array returns - */ - - public function testget_unaproved_messages() { - $forum_id = 1; - $res = get_unaproved_messages($forum_id); - if(!is_bool($res)){ - $this->assertTrue(is_array($res)); - } else { - $this->assertTrue(is_bool($res)); - } - //var_dump($res); - } - - /** - * This function is used to find all the information about what's new in the forum tool - * @return void - */ - - public function testget_whats_new() { - $res = get_whats_new(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * This function handles all the forum and forumcategories actions. This is a wrapper for the - * forum and forum categories. All this code code could go into the section where this function is - * called but this make the code there cleaner. - * @return void - */ - - public function testhandle_forum_and_forumcategories() { - $res = handle_forum_and_forumcategories(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * This function is called whenever something is made visible because there might be new posts and the user might have indicated that (s)he wanted - * to be informed about the new posts by mail. - * @param string - * @param int - * @return string language variable - */ - - public function testhandle_mail_cue() { - $content = 'test content'; - $id = 1; - $res = handle_mail_cue($content, $id); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - /** - * This function return the html syntax for the image - * @param $image_url The url of the image (absolute or relative) - * @param $alt The alt text (when the images cannot be displayed). http://www.w3.org/TR/html4/struct/objects.html#adef-alt - * @param $title The title of the image. Most browsers display this as 'tool tip'. http://www.w3.org/TR/html4/struct/global.html#adef-title - * @todo this is the same as the Display::xxx function, so it can be removed => all calls have to be changed also - * @return string url image - */ - - public function testicon() { - $image_url = api_get_path(WEB_IMG_PATH).'test.png'; - $res = icon($image_url,$alt='',$title=''); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - /** - * The thread view counter gets increased every time someone looks at the thread - * @param int - * @return void - */ - - public function testincrease_thread_view() { - $thread_id = 1; - $res = increase_thread_view($thread_id); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * This function displays the form for moving a post message to a different (already existing) or a new thread. - * @return void HTML - */ - - public function testmove_post_form() { - ob_start(); - $res = move_post_form(); - ob_end_clean(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * This function displays the form for moving a thread to a different (already existing) forum - * @return void HTML - */ - - public function testmove_thread_form() { - ob_start(); - $res = move_thread_form(); - ob_end_clean(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * This function moves a forum or a forum category up or down - * @param $content what is it that we want to make (in)visible: forum category, forum, thread, post - * @param $direction do we want to move it up or down. - * @param $id the id of the content we want to make invisible - * @todo consider removing the table_item_property calls here but this can prevent unwanted side effects when a forum does not have an entry in - * the item_property table but does have one in the forum table. - * @return string language variable - */ - - public function testmove_up_down() { - $content = 'test content'; - $direction = 'test direction'; - $id = 1; - $res = move_up_down($content, $direction, $id); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - /** - * Prepares a string or an array of strings for display by stripping slashes - * @param mixed String or array of strings - * @return mixed String or array of strings - */ - - public function testprepare4display() { - $res = prepare4display($input=''); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - /** - * Return the link to the forum search page - */ - - public function testsearch_link() { - $res = search_link(); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - /** - * This function sends the mails for the mail notification - * @param array - * @param array - * @return void - */ - - public function testsend_mail() { - $res = send_mail($user_info=array(), $thread_information=array()); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * This function sends the notification mails to everybody who stated that they wanted to be informed when a new post - * was added to a given thread. - * @param int id thread - * @param array reply information - * @return void - */ - - public function testsend_notification_mails() { - $thread_id = 1; - $reply_info = array('test'); - $res = send_notification_mails($thread_id, $reply_info); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * Get all the users who need to receive a notification of a new post (those subscribed to - * the forum or the thread) - * @param integer $forum_id the id of the forum - * @param integer $thread_id the id of the thread - * @param integer $post_id the id of the post - * @return bool - */ - - public function testsend_notifications() { - $res = send_notifications($forum_id=0, $thread_id=0, $post_id=0); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - /** - * This function stores which users have to be notified of which forums or threads - * @param string $content does the user want to be notified about a forum or about a thread - * @param integer $id the id of the forum or thread - * @return string language variable - */ - - public function testset_notification() { - $content = 'test content'; - $id = 1; - $res = set_notification($content,$id, $add_only = false); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - /** - * This public function displays the form that is used to add a forum category. - * @param array - * @return void HTML - */ - - public function testshow_add_forum_form() { - ob_start(); - $res = show_add_forum_form($inputvalues=array()); - ob_end_clean(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * This public function displays the form that is used to add a forum category. - * @param array input values - * @return void HTML - */ - - public function testshow_add_forumcategory_form() { - ob_start(); - $res = show_add_forumcategory_form($inputvalues=array()); - ob_end_clean(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * This public function displays the form that is used to add a post. This can be a new thread or a reply. - * @param $action is the parameter that determines if we are - * 1. newthread: adding a new thread (both empty) => No I-frame - * 2. replythread: Replying to a thread ($action = replythread) => I-frame with the complete thread (if enabled) - * 3. replymessage: Replying to a message ($action =replymessage) => I-frame with the complete thread (if enabled) (I first thought to put and I-frame with the message only) - * 4. quote: Quoting a message ($action= quotemessage) => I-frame with the complete thread (if enabled). The message will be in the reply. (I first thought not to put an I-frame here) - * @return void HTML - */ - - public function testshow_add_post_form() { - ob_start(); - $res = show_add_post_form($action='', $id='', $form_values=''); - ob_end_clean(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * This public function displays the form that is used to edit a forum category. - * This is more or less a copy from the show_add_forumcategory_form public function with the only difference that is uses - * some default values. I tried to have both in one public function but this gave problems with the handle_forum_and_forumcategories public function - * (storing was done twice) - * @param array - * @return void HTML - */ - - public function testshow_edit_forumcategory_form() { - ob_start(); - $res = show_edit_forumcategory_form($inputvalues=array()); - ob_end_clean(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * This public function displays the form that is used to edit a post. This can be a new thread or a reply. - * @param array contains all the information about the current post - * @param array contains all the information about the current thread - * @param array contains all info about the current forum (to check if attachments are allowed) - * @param array contains the default values to fill the form - * @return void - */ - - public function testshow_edit_post_form() { - ob_start(); - $current_post = array('test'); - $current_thread = array('test2'); - $current_forum = array('test3'); - $res = show_edit_post_form($current_post, $current_thread, $current_forum, $form_values='',$id_attach=0); - ob_end_clean(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * This public function show qualify. - * @param string contains the information of option to run - * @param string contains the information the current course id - * @param integer contains the information the current forum id - * @param integer contains the information the current user id - * @param integer contains the information the current thread id - * @return integer qualify - * @example $option=1 obtained the qualification of the current thread - */ - - public function testShowQualify() { - $option = 1; - $user_id = 1; - $thread_id = 1; - $res = showQualify($option, $user_id, $thread_id); - if(!is_numeric($res)){ - $this->assertTrue(is_null($res)); - } else { - $this->assertTrue(is_numeric($res)); - } - //var_dump($res); - } - - /** - * This function builds an array of all the posts in a given thread where the key of the array is the post_id - * It also adds an element children to the array which itself is an array that contains all the id's of the first-level children - * @return an array containing all the information on the posts of a thread - */ - - public function testcalculate_children() { - $rows = array(); - $res = calculate_children($rows); - $this->assertTrue(is_array($res)); - //var_dump($res); - } - - public function test_forum_recursive_sort() { - $rows = array(); - $res = forumRecursiveSort($rows, &$threads, $seed=0, $indent=0); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - - /** - * This public function stores the edit of a post in the forum_post table. - * @param array - * @return void HTML - */ - - public function teststore_edit_post() { - $values = array('test'); - ob_start(); - $res = store_edit_post($values); - ob_end_clean(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * This public function stores the forum in the database. The new forum is added to the end. - * @param array - * @return string language variable - */ - - public function teststore_forum() { - $values = array('test'); - ob_start(); - $res = store_forum($values); - ob_end_clean(); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - /** - * This public function stores the forum category in the database. The new category is added to the end. - * @param array - * @return void HMTL language variable - */ - - public function teststore_forumcategory() { - $values = array('test'); - ob_start(); - $res = store_forumcategory($values); - ob_end_clean(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * - * @param array - * @return string HTML language variable - */ - - public function teststore_move_post() { - $values = array('test'); - ob_start(); - $res = store_move_post($values); - ob_end_clean(); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - /** - * @param array - * @return string HTML language variable - */ - - public function teststore_move_thread() { - $values = array('test'); - ob_start(); - $res = store_move_thread($values); - ob_end_clean(); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - /** - * - * This public function store qualify historical. - * @param boolean contains the information of option to run - * @param string contains the information the current course id - * @param integer contains the information the current forum id - * @param integer contains the information the current user id - * @param integer contains the information the current thread id - * @param integer contains the information the current qualify - * @return void - * @example $option=1 obtained the qualification of the current thread - */ - - public function testSaveThreadScoreHistory() { - $option = 1; - $couser_id = 1; - $forum_id = 1; - $user_id = 1; - $thread_id = 1; - $current_qualify = 1; - $qualify_user_id = 1; - $res = saveThreadScoreHistory($option,$couser_id,$forum_id,$user_id,$thread_id,$current_qualify,$qualify_user_id); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * This public function stores a reply in the forum_post table. - * It also updates the forum_threads table (thread_replies +1 , thread_last_post, thread_date) - */ - - public function teststore_reply() { - $values = array('test'); - ob_start(); - $res = store_reply($values); - ob_end_clean(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * @param integer contains the information of user id - * @param integer contains the information of thread id - * @param integer contains the information of thread qualify - * @param integer contains the information of user id of qualifier - * @param integer contains the information of time - * @param integer contains the information of session id - * @return Array() optional - **/ - public function testSaveThreadScore() - { - $user_id = 1; - $thread_id = 1; - $qualify_time = 1; - $res = saveThreadScore( - $user_id, - $thread_id, - $thread_qualify = 0, - $qualify_user_id = 0, - $qualify_time, - $session_id = null - ); - - if (!is_bool($res)) { - $this->assertTrue(is_array($res)); - } else { - $this->assertTrue(is_bool($res)); - } - } - - /** - * This public function stores a new thread. This is done through an entry in the forum_thread table AND - * in the forum_post table because. The threads are also stored in the item_property table. (forum posts are not (yet)) - * @param array - * @return void HTML - */ - - public function teststore_thread() { - $values = array(); - ob_start(); - $res = store_thread($values); - ob_end_clean(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - - /** - * The relies counter gets increased every time somebody replies to the thread - * @param - * @return void - */ - - public function testupdate_thread() { - $thread_id = 1; - $last_post_id = 1; - $post_date = 1; - $res = update_thread($thread_id, $last_post_id,$post_date); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - /** - * Delete the all the attachments from the DB and the file according to the post's id or attach id(optional) - * @param post id - * @param attach id (optional) - * @return void - */ - - public function testdelete_attachment() { - global $_course; - $post_id = 1; - $res = delete_attachment($post_id,$id_attach=0); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * This public function deletes a forum or a forum category - * This public function currently does not delete the forums inside the category, nor the threads and replies inside these forums. - * For the moment this is the easiest method and it has the advantage that it allows to recover fora that were acidently deleted - * when the forum category got deleted. - * - * @param $content = what we are deleting (a forum or a forum category) - * @param $id The id of the forum category that has to be deleted. - * @return void - * @todo write the code for the cascading deletion of the forums inside a forum category and also the threads and replies inside these forums - * @todo config setting for recovery or not (see also the documents tool: real delete or not). - */ - - public function testdeleteForumCategoryThread() { - $content= 'testcontent'; - $id = 1; - $res = deleteForumCategoryThread($content, $id); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * This public function deletes the forum image if exists - * @param int forum id - * @return boolean true if success - */ - - public function testdelete_forum_image() { - $forum_id = 1; - $res = delete_forum_image($forum_id); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - /** - * This public function deletes a forum post. This separate public function is needed because forum posts do not appear in the item_property table (yet) - * and because deleting a post also has consequence on the posts that have this post as parent_id (they are also deleted). - * an alternative would be to store the posts also in item_property and mark this post as deleted (visibility = 2). - * We also have to decrease the number of replies in the thread table - * @return string language variable - * @param $post_id the id of the post that will be deleted - * @todo write recursive public function that deletes all the posts that have this message as parent - */ - - public function testdelete_post() { - $table_posts = Database :: get_course_table(TABLE_FORUM_POST); - $table_threads = Database :: get_course_table(TABLE_FORUM_THREAD); - $post_id = 1; - $res = delete_post($post_id); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - public function __destruct() { - // The destructor acts like a global tearDown for the class - require_once api_get_path(SYS_TEST_PATH).'teardown.inc.php'; - } -} -?> diff --git a/tests/main/gradebook/lib/be/attendancelink.class.test.php b/tests/main/gradebook/lib/be/attendancelink.class.test.php deleted file mode 100755 index e1730f5989..0000000000 --- a/tests/main/gradebook/lib/be/attendancelink.class.test.php +++ /dev/null @@ -1,135 +0,0 @@ -UnitTestCase('Test Attendance Link'); - } - - public function __construct() { - $this->UnitTestCase('Gradebook attendances library - main/gradebook/lib/be/attendancelink.class.test.php'); - // The constructor acts like a global setUp for the class - global $date; - TestManager::create_test_course('COURSEATTENDANCELINK'); - $this->attendance = new AttendanceLink(); - $this->attendance->set_course_code('COURSEATTENDANCELINK'); - $this->attendance->set_id (1); - $this->attendance->set_type (LINK_ATTENDANCE); - $this->attendance->set_ref_id (1) ; - $this->attendance->set_user_id (1); - $this->attendance->set_category_id(1); - $this->attendance->set_date ($date); - $this->attendance->set_weight (1); - $this->attendance->set_visible (1); - $this->attendance->set_session_id(1); - } - - public function testcalc_score() { - $res = $this->attendance->calc_score($stud_id = null); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * Generate an array of all attendances available. - * @return array 2-dimensional array - every element contains 2 subelements (id, name) - */ - - public function testget_all_links() { - $_SESSION['id_session'] = 1; - $res = $this->attendance->get_all_links(); - if(!is_array($res)){ - $this->assertTrue(is_null($res)); - } else { - $this->assertTrue(is_array($res)); - } - $_SESSION['id_session'] = null; - //var_dump($res); - } - - /** - * @return string description - */ - - public function testget_description() { - $res = $this->attendance->get_description(); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - public function testget_link() { - $res = $this->attendance->get_link(); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - public function testget_name() { - $res = $this->attendance->get_name(); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - public function testget_not_created_links() { - $res = $this->attendance->get_not_created_links(); - $this->assertTrue(is_array($res)); - //var_dump($res); - } - - public function testget_test_id() { - $res = $this->attendance->get_test_id(); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - public function testget_type_name() { - $res = $this->attendance->get_type_name(); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - /** - * Has anyone done this exercise yet ? - */ - - public function testhas_results() { - $res = $this->attendance->has_results(); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - public function testis_allowed_to_change_name() { - $res = $this->attendance->is_allowed_to_change_name(); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - public function testis_valid_link() { - $res = $this->attendance->is_valid_link(); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - public function testneeds_max() { - $res = $this->attendance->needs_max(); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - public function testneeds_name_and_description() { - $res = $this->attendance->needs_name_and_description(); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - public function testneeds_results() { - $res = $this->attendance->needs_results(); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - public function __destruct() { - // The destructor acts like a global tearDown for the class - TestManager::delete_test_course('COURSEATTENDANCELINK'); - } -} -?> diff --git a/tests/main/gradebook/lib/be/category.class.test.php b/tests/main/gradebook/lib/be/category.class.test.php deleted file mode 100755 index 84de01e4f4..0000000000 --- a/tests/main/gradebook/lib/be/category.class.test.php +++ /dev/null @@ -1,423 +0,0 @@ -UnitTestCase('Test Category Class'); - } - - public function __construct() { - $this->UnitTestCase('Gradebook categories library - main/gradebook/lib/be/category.class.test.php'); - // The constructor acts like a global setUp for the class - TestManager::create_test_course('COURSECATEGORYCLASS'); - $this->category = new Category(); - $this->category->set_id(1); - $this->category->set_name('test'); - $this->category->set_description('test description'); - $this->category->set_user_id(1); - $this->category->set_course_code('COURSECATEGORYCLASS'); - $this->category->set_certificate_min_score(20); - $this->category->set_parent_id(0); - $this->category->set_session_id(1); - $this->category->set_weight(1); - $this->category->set_visible(1); - } - - /** - * Insert this category into the database - */ - - public function testadd() { - $_SESSION['id_session'] = 1; - $res = $this->category->add(); - $this->assertTrue(is_null($res)); - $_SESSION['id_session'] = null; - //var_dump($res); - } - - /** - * Apply the same visibility to every subcategory, evaluation and link - */ - - public function testapply_visibility_to_children() { - $res = $this->category->apply_visibility_to_children(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * Calculate the score of this category - * @param $stud_id student id (default: all students - then the average is returned) - * @return array (score sum, weight sum) - * or null if no scores available - */ - - public function testcalc_score() { - $res = $this->category->calc_score($stud_id = null); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * Check if a category name (with the same parent category) already exists - * @param $name name to check (if not given, the name property of this object will be checked) - * @param $parent parent category - * @return bool - */ - - public function testdoes_name_exist() { - $name = 'test'; - $parent=1; - $res = $this->category->does_name_exist($name, $parent); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - /** - * Find category by name - * @param string $name_mask search string - * @return array category objects matching the search criterium - */ - - public function testfind_category() { - $name_mask = 'test'; - $allcat=array(); - $res = $this->category->find_category($name_mask,$allcat); - $this->assertTrue(is_array($res)); - //var_dump($res); - } - - /** - * Generate an array of all courses that a teacher is admin of. - * @return array 2-dimensional array - every element contains 2 subelements (code, title) - */ - - public function testget_all_courses() { - $user_id = 1; - $res = $this->category->get_all_courses($user_id); - $this->assertTrue(is_array($res)); - //var_dump($res); - } - - public function testget_certificate_min_score() { - $res = $this->category->get_certificate_min_score(); - $this->assertTrue(is_numeric($res)); - //var_dump($res); - } - - public function testget_course_code() { - $res = $this->category->get_course_code(); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - public function testget_description() { - $res = $this->category->get_description(); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - /** - * Get appropriate evaluations visible for the user - * @param int $stud_id student id (default: all students) - * @param boolean $recursive process subcategories (default: no recursion) - */ - - public function testget_evaluations() { - $res = $this->category->get_evaluations($stud_id = null, $recursive = false); - $this->assertTrue(is_array($res)); - //var_dump($res); - } - - public function testget_icon_name() { - $res = $this->category->get_icon_name(); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - public function testget_id() { - $res = $this->category->get_id(); - $this->assertTrue(is_numeric($res)); - //var_dump($res); - } - - public function testget_independent_categories_with_result_for_student() { - $cat_id=1; - $stud_id=1; - $res = $this->category->get_independent_categories_with_result_for_student($cat_id, $stud_id, $cats = array()); - $this->assertTrue(is_array($res)); - //var_dump($res); - } - - public function testget_item_type() { - $res = $this->category->get_item_type(); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - public function testget_links() { - $res = $this->category->get_links($stud_id = null, $recursive = false); - $this->assertTrue(is_array($res)); - //var_dump($res); - } - - public function testget_name() { - $res = $this->category->get_name(); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - public function testget_not_created_course_categories() { - $user_id = 1; - $res = $this->category->get_not_created_course_categories($user_id); - $this->assertTrue(is_array($res)); - //var_dump($res); - } - - public function testget_parent_id() { - $res = $this->category->get_parent_id(); - $this->assertTrue(is_numeric($res)); - //var_dump($res); - } - - /** - * Return array of Category objects where a student is subscribed to. - * @param int student id - * @param string Course code - * @param int Session id - */ - - public function testget_root_categories_for_student() { - $stud_id=1; - $res = $this->category->get_root_categories_for_student($stud_id, $course_code = null, $session_id = null); - $this->assertTrue(is_array($res)); - //var_dump($res); - } - - /** - * Return array of Category objects where a teacher is admin for. - * @param int user id (to return everything, use 'null' here) - * @param string course code (optional) - * @param int session id (optional) - */ - - public function testget_root_categories_for_teacher() { - $user_id=1; - $res = $this->category->get_root_categories_for_teacher($user_id, $course_code = null, $session_id = null); - $this->assertTrue(is_array($res)); - //var_dump($res); - } - - public function testget_session_id() { - $user_id=1; - $res = $this->category->get_session_id($user_id, $course_code = null, $session_id = null); - $this->assertTrue(is_numeric($res)); - //var_dump($res); - } - - /** - * Get appropriate subcategories visible for the user (and optionally the course and session) - * @param int $stud_id student id (default: all students) - * @param string Course code (optional) - * @param int Session ID (optional) - * @return array Array of subcategories - */ - - public function testget_subcategories() { - $res = $this->category->get_subcategories($stud_id = null, $course_code = null, $session_id = null); - $this->assertTrue(is_array($res)); - //var_dump($res); - } - - /** - * Generate an array of possible categories where this category can be moved to. - * Notice: its own parent will be included in the list: it's up to the frontend - * to disable this element. - * @return array 2-dimensional array - every element contains 3 subelements (id, name, level) - */ - - public function testget_target_categories() { - $res = $this->category->get_target_categories(); - if(is_array($res)) { - $this->assertTrue(is_array($res)); - } else { - $this->assertTrue(is_null($res)); - } - var_dump($res); - - } - - /** - * Generate an array of all categories the user can navigate to - */ - - public function testget_tree() { - $res = $this->category->get_tree(); - $this->assertTrue(is_array($res)); - //var_dump($res); - } - - public function testget_user_id() { - $res = $this->category->get_user_id(); - $this->assertTrue(is_numeric($res)); - //var_dump($res); - } - - public function testget_weight() { - $res = $this->category->get_weight(); - $this->assertTrue(is_numeric($res)); - //var_dump($res); - } - - /** - * Check if a category contains evaluations with a result for a given student - */ - - public function testhas_evaluations_with_results_for_student() { - $stud_id = 1; - $res = $this->category->has_evaluations_with_results_for_student($stud_id); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - /** - * Checks if the certificate is available for the given user in this category - * @param integer User ID - * @return boolean True if conditions match, false if fails - */ - - public function testis_certificate_available() { - $user_id = 1; - $res = $this->category->is_certificate_available($user_id); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - /** - * Is this category a course ? - * A category is a course if it has a course code and no parent category. - */ - - public function testis_course() { - $res = $this->category->is_course(); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - /** - * Can this category be moved to somewhere else ? - * The root and courses cannot be moved. - */ - - public function testis_movable() { - $res = $this->category->is_movable(); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - public function testis_visible() { - $res = $this->category->is_visible(); - $this->assertTrue(is_numeric($res)); - //var_dump($res); - } - - /** - * Retrieve categories and return them as an array of Category objects - * @param int category id - * @param int user id (category owner) - * @param string course code - * @param int parent category - * @param bool visible - * @param int session id (in case we are in a session) - * @param bool Whether to show all "session" categories (true) or hide them (false) in case there is no session id - */ - - public function testload() { - $res = $this->category->load($id = null, $user_id = null, $course_code = null, $parent_id = null, $visible = null, $session = null, $show_session_categories = true); - $this->assertTrue(is_array($res)); - //var_dump($res); - } - - /** - * Move this category to the given category. - * If this category moves from inside a course to outside, - * its course code must be changed, as well as the course code - * of all underlying categories and evaluations. All links will - * be deleted as well ! - */ - - public function testmove_to_cat() { - $res = $this->category->move_to_cat($this->category); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - - /** - * Update the properties of this category in the database - */ - - public function testsave() { - $res = $this->category->save(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * Show message resource delete - */ - - public function testshow_message_resource_delete() { - $course_id = 1; - $res = $this->category->show_message_resource_delete($course_id); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - /** - * Shows all information of an category - */ - - public function testshows_all_information_an_category() { - $res = $this->category->shows_all_information_an_category($selectcat=''); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * Not delete this category from the database,when visible=3 is category eliminated - */ - - public function testupdate_category_delete() { - $course_id = 1; - $res = $this->category->update_category_delete($course_id); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * Delete this evaluation from the database - */ - - public function testdelete() { - $res = $this->category->delete(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * Delete this category and every subcategory, evaluation and result inside - */ - - public function testdelete_all() { - $res = $this->category->delete_all(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - public function __destruct() { - // The destructor acts like a global tearDown for the class - TestManager::delete_test_course('COURSECATEGORYCLASS'); - } -} -?> diff --git a/tests/main/gradebook/lib/be/dropboxlink.class.test.php b/tests/main/gradebook/lib/be/dropboxlink.class.test.php deleted file mode 100755 index 7fdc4cfbfd..0000000000 --- a/tests/main/gradebook/lib/be/dropboxlink.class.test.php +++ /dev/null @@ -1,42 +0,0 @@ -UnitTestCase('Test Drop Box Link'); - } - - public function __construct() { - $this->UnitTestCase('Gradebook dropbox library - main/gradebook/lib/be/dropboxlink.class.test.php'); - // The constructor acts like a global setUp for the class - TestManager::create_test_course('COURSEDROPBOXLINK'); - $this->dropbox = new DropboxLink(); - $this->dropbox->set_course_code('COURSEDROPBOXLINK'); - $this->dropbox->set_name('test'); - } - - public function testget_type_name() { - $res = $this->dropbox->get_type_name(); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - public function testget_view_url() { - $stud_id = 1; - $res = $this->dropbox->get_view_url($stud_id); - //$this->assertTrue(is_null($res)); - //var_dump($res); - } - - public function testis_allowed_to_change_name() { - $res = $this->dropbox->is_allowed_to_change_name(); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - public function __destruct() { - // The destructor acts like a global tearDown for the class - TestManager::delete_test_course('COURSEDROPBOXLINK'); - } -} -?> diff --git a/tests/main/gradebook/lib/be/evaluation.class.test.php b/tests/main/gradebook/lib/be/evaluation.class.test.php deleted file mode 100755 index c2abdabab8..0000000000 --- a/tests/main/gradebook/lib/be/evaluation.class.test.php +++ /dev/null @@ -1,347 +0,0 @@ -UnitTestCase('Test Evaluation'); - } - - public function __construct() { - $this->UnitTestCase('Gradebook evaluation library - main/gradebook/lib/be/evaluation.class.test.php'); - // The constructor acts like a global setUp for the class - global $date; - TestManager::create_test_course('COURSEEVALUATION'); - $this->evaluation = new Evaluation(); - $this->evaluation-> set_id (1); - $this->evaluation-> set_name ('test'); - $this->evaluation-> set_description ('test description'); - $this->evaluation-> set_user_id (1); - $this->evaluation-> set_course_code ('COURSEEVALUATION'); - $this->evaluation-> set_category_id (1); - $this->evaluation-> set_date ($date); - $this->evaluation-> set_weight (1); - $this->evaluation-> set_max (1); - $this->evaluation-> set_visible (1); - } - - /** - * Insert this evaluation into the database - */ - - public function testadd() { - $res = $this->evaluation->add(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - public function testadd_evaluation_log() { - $idevaluation = 1; - $res = $this->evaluation->add_evaluation_log($idevaluation); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * Calculate the score of this evaluation - * @param $stud_id student id (default: all students who have results for this eval - then the average is returned) - * @return array (score, max) if student is given - * array (sum of scores, number of scores) otherwise - * or null if no scores available - */ - - public function testcalc_score() { - $res = $this->evaluation->calc_score($stud_id = null); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * Delete this evaluation from the database - */ - - public function testdelete() { - $res = $this->evaluation->delete(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * Delete all results for this evaluation - */ - - public function testdelete_results() { - $res = $this->evaluation->delete_results(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * Delete this evaluation and all underlying results. - */ - - public function testdelete_with_results() { - $res = $this->evaluation->delete_with_results(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * Check if an evaluation name (with the same parent category) already exists - * @param $name name to check (if not given, the name property of this object will be checked) - * @param $parent parent category - */ - - public function testdoes_name_exist() { - $name = 'test name'; - $parent = 1; - $res = $this->evaluation->does_name_exist($name, $parent); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - /** - * Find evaluations by name - * @param string $name_mask search string - * @return array evaluation objects matching the search criterium - * @todo can be written more efficiently using a new (but very complex) sql query - */ - //problem with the call get_evaluations(): Call to a member function get_evaluations() on a non-object - /*public function testfind_evaluations() { - $name_mask = 'test name mask'; - $selectcat = 1; - $res = Evaluation::find_evaluations($name_mask,$selectcat); - $this->assertTrue(is_array($res)); - //var_dump($res); - }*/ - - public function testget_category_id() { - $res = $this->evaluation->get_category_id(); - $this->assertTrue(is_numeric($res)); - //var_dump($res); - } - - public function testget_course_code() { - $res = $this->evaluation->get_course_code(); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - public function testget_date() { - $res = $this->evaluation->get_date(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - public function testget_description() { - $res = $this->evaluation->get_description(); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - /** - * Retrieve evaluations where a student has results for - * and return them as an array of Evaluation objects - * @param $cat_id parent category (use 'null' to retrieve them in all categories) - * @param $stud_id student id - */ - - public function testget_evaluations_with_result_for_student() { - $stud_id = 1; - $res = $this->evaluation->get_evaluations_with_result_for_student($cat_id = null, $stud_id); - $this->assertTrue(is_array($res)); - //var_dump($res); - } - - public function testget_icon_name() { - $res = $this->evaluation->get_icon_name(); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - public function testget_id() { - $res = $this->evaluation->get_id(); - $this->assertTrue(is_numeric($res)); - //var_dump($res); - } - - public function testget_item_type() { - $res = $this->evaluation->get_item_type(); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - public function testget_max() { - $res = $this->evaluation->get_max(); - $this->assertTrue(is_numeric($res)); - //var_dump($res); - } - - public function testget_name() { - $res = $this->evaluation->get_name(); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - /** - * Get a list of students that do not have a result record for this evaluation - */ - - public function testget_not_subscribed_students() { - $res = $this->evaluation->get_not_subscribed_students($first_letter_user = ''); - $this->assertTrue(is_array($res)); - //var_dump($res); - } - - /** - * Generate an array of possible categories where this evaluation can be moved to. - * Notice: its own parent will be included in the list: it's up to the frontend - * to disable this element. - * @return array 2-dimensional array - every element contains 3 subelements (id, name, level) - */ - - public function testget_target_categories() { - $res = $this->evaluation->get_target_categories(); - $this->assertTrue(is_array($res)); - //var_dump($res); - } - - public function testget_user_id() { - $res = $this->evaluation->get_user_id(); - $this->assertTrue(is_numeric($res)); - //var_dump($res); - } - - public function testget_weight() { - $res = $this->evaluation->get_weight(); - $this->assertTrue(is_numeric($res)); - //var_dump($res); - } - - /** - * Are there any results for this evaluation yet ? - * The 'max' property should not be changed then. - */ - - public function testhas_results() { - $res = $this->evaluation->has_results(); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - public function testis_valid_score() { - $score = 1; - $res = $this->evaluation->is_valid_score($score); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - public function testis_visible() { - $res = $this->evaluation->is_visible(); - $this->assertTrue(is_numeric($res)); - //var_dump($res); - } - - /** - * Retrieve evaluations and return them as an array of Evaluation objects - * @param $id evaluation id - * @param $user_id user id (evaluation owner) - * @param $course_code course code - * @param $category_id parent category - * @param $visible visible - */ - - public function testload() { - $res = $this->evaluation->load($id = null, $user_id = null, $course_code = null, $category_id = null, $visible = null); - $this->assertTrue(is_array($res)); - //var_dump($res); - } - - /** - * Move this evaluation to the given category. - * If this evaluation moves from inside a course to outside, - * its course code is also changed. - */ - - public function testmove_to_cat() { - $cat = $this->evaluation; - $res = $this->evaluation->move_to_cat($cat); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * Update the properties of this evaluation in the database - */ - - public function testsave() { - $res = $this->evaluation->save(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - public function testset_category_id() { - $res = $this->evaluation->set_category_id(1); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - public function testset_course_code() { - $res = $this->evaluation->set_course_code('COURSEEVALUATION'); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - public function testset_date() { - global $date; - $res = $this->evaluation->set_date('02/02/2010'); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - public function testset_description() { - $res = $this->evaluation->set_description('test description'); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - public function testset_id() { - $res = $this->evaluation->set_id(1); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - public function testset_max() { - $res = $this->evaluation->set_max(1); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - public function testset_name() { - $res = $this->evaluation->set_name('test name'); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - public function testset_user_id() { - $res = $this->evaluation->set_user_id(1); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - public function testset_visible() { - $res = $this->evaluation->set_visible(1); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - public function testset_weight() { - $res = $this->evaluation->set_weight(1); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - public function __destruct() { - // The destructor acts like a global tearDown for the class - TestManager::delete_test_course('COURSEEVALUATION'); - } -} -?> diff --git a/tests/main/gradebook/lib/be/exerciselink.class.test.php b/tests/main/gradebook/lib/be/exerciselink.class.test.php deleted file mode 100755 index 773fe039e2..0000000000 --- a/tests/main/gradebook/lib/be/exerciselink.class.test.php +++ /dev/null @@ -1,153 +0,0 @@ -UnitTestCase('Test Exercise Link'); - } - - public function __construct() { - $this->UnitTestCase('Gradebook exercises library - main/gradebook/lib/be/exerciselink.class.test.php'); - global $date; - // The constructor acts like a global setUp for the class - TestManager::create_test_course('COURSEEXERCISELINK'); - $this->exerciselink = new ExerciseLink(); - $this->exerciselink-> set_id (1); - $this->exerciselink-> set_name ('test'); - $this->exerciselink-> set_description ('test description'); - $this->exerciselink-> set_user_id (1); - $this->exerciselink-> set_course_code ('COURSEEXERCISELINK'); - $this->exerciselink-> set_category_id (1); - $this->exerciselink-> set_date ($date); - $this->exerciselink-> set_weight (1); - $this->exerciselink-> set_max (1); - $this->exerciselink-> set_visible (1); - } - - /** - * Generate an array of all exercises available. - * @return array 2-dimensional array - every element contains 2 subelements (id, name) - */ - - public function testget_all_links() { - $res = $this->exerciselink->get_all_links(); - $this->assertTrue(is_array($res)); - //var_dump($res); - } - - /** - * Get the score of this exercise. Only the first attempts are taken into account. - * @param $stud_id student id (default: all students who have results - then the average is returned) - * @return array (score, max) if student is given - * array (sum of scores, number of scores) otherwise - * or null if no scores available - */ - - public function testcalc_score() { - $res = $this->exerciselink->calc_score($stud_id = null); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - - - /** - * Get description to display: same as exercise description - */ - - public function testget_description() { - $res = $this->exerciselink->get_description(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * Get URL where to go to if the user clicks on the link. - * First we go to exercise_jump.php and then to the result page. - * Check this php file for more info. - */ - - public function testget_link() { - $res = $this->exerciselink->get_link(); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - /** - * Get name to display: same as exercise title - */ - - public function testget_name() { - $res = $this->exerciselink->get_name(); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - /** - * Generate an array of exercises that a teacher hasn't created a link for. - * @return array 2-dimensional array - every element contains 2 subelements (id, name) - */ - - public function testget_not_created_links() { - $_SESSION['id_session'] = 1; - $res = $this->exerciselink->get_not_created_links(); - $this->assertTrue(is_array($res)); - $_SESSION['id_session'] = null; - //var_dump($res); - } - - public function testget_type_name() { - $res = $this->exerciselink->get_type_name(); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - /** - * Has anyone done this exercise yet ? - */ - - public function testhas_results() { - $res = $this->exerciselink->has_results(); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - public function testis_allowed_to_change_name() { - $res = $this->exerciselink->is_allowed_to_change_name(); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - /** - * Check if this still links to an exercise - */ - - public function testis_valid_link() { - $res = $this->exerciselink->is_valid_link(); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - public function testneeds_max() { - $res = $this->exerciselink->needs_max(); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - public function testneeds_name_and_description() { - $res = $this->exerciselink->needs_name_and_description(); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - public function testneeds_results() { - $res = $this->exerciselink->needs_results(); - $this->assertTrue(is_bool($res)); - //var_dump($res); - } - - public function __destruct() { - // The destructor acts like a global tearDown for the class - TestManager::delete_test_course('COURSEEXERCISELINK'); - } -} -?> diff --git a/tests/main/gradebook/lib/be/forumthreadlink.class.test.php b/tests/main/gradebook/lib/be/forumthreadlink.class.test.php deleted file mode 100755 index d3e233be24..0000000000 --- a/tests/main/gradebook/lib/be/forumthreadlink.class.test.php +++ /dev/null @@ -1,42 +0,0 @@ -UnitTestCase('Test Forum Thread Link'); - } - - public function __construct() { - $this->UnitTestCase('Gradebook forum library - main/gradebook/lib/be/forumthreadlink.class.test.php'); - // The constructor acts like a global setUp for the class - TestManager::create_test_course('COURSEFORUMTHREAD'); - $this->forumthreadlink = new ForumThreadLink(); - $this->forumthreadlink->set_id(1); - $this->forumthreadlink->set_type(5); - $this->forumthreadlink->set_ref_id(1); - $this->forumthreadlink->set_user_id(1); - $this->forumthreadlink->set_course_code('COURSEFORUMTHREAD'); - $this->forumthreadlink->set_category_id(1); - $this->forumthreadlink->set_date(date); - $this->forumthreadlink->set_weight(1); - $this->forumthreadlink->set_visible('visible'); - - } - - public function testcalc_score() { - $res = $this->forumthreadlink->calc_score(null); - $this->assertNull($res); - //var_dump($res); - $res2 = $this->forumthreadlink->calc_score(1); - $this->assertTrue(is_array($res2)); - //var_dump($res2); - } - - - - public function __destruct() { - // The destructor acts like a global tearDown for the class - TestManager::delete_test_course('COURSEFORUMTHREAD'); - } - -} -?> \ No newline at end of file diff --git a/tests/main/inc/banner.inc.test.php b/tests/main/inc/banner.inc.test.php deleted file mode 100755 index e14ddf8226..0000000000 --- a/tests/main/inc/banner.inc.test.php +++ /dev/null @@ -1,21 +0,0 @@ -UnitTestCase('Banners library - main/inc/banner.inc.test.php'); - } - - public function testGetTabs() - { - ob_start(); - require_once(api_get_path(SYS_CODE_PATH).'inc/banner.inc.php'); - ob_end_clean(); - $res = get_tabs(); - $this->assertTrue(is_array($res)); - $this->assertTrue($res); - //var_dump($res); - } -} diff --git a/tests/main/inc/course_document.lib.test.php b/tests/main/inc/course_document.lib.test.php deleted file mode 100755 index d91337584b..0000000000 --- a/tests/main/inc/course_document.lib.test.php +++ /dev/null @@ -1,35 +0,0 @@ -UnitTestCase('Course documents display library - main/inc/course_document.inc.test.php'); - } - - public function testGetlist(){ - global $is_allowed_in_course; - $is_allowed_in_course = true; - $directory = api_get_path(SYS_COURSE_PATH).'/document/audio/'; - $res = getlist($directory); - if (is_bool($res)){ - $this->assertTrue(is_bool($res)); - $this->assertTrue($res ===false); - } else{ - $this->assertTrue(is_null($res)); - } - - - } - - public function testCheckAndCreateResourceDirectory(){ - global $_course, $_user; - global $group_properties, $to_group_id; - global $permissions_for_new_directories; - $repository_path=''; - $resource_directory=''; - $resource_directory_name=''; - $res = check_and_create_resource_directory($repository_path, $resource_directory, $resource_directory_name); - $this->assertTrue(is_bool($res)); - $this->assertTrue($res === true || $res === false); - } -} diff --git a/tests/main/inc/lib/access_url_edit_courses_to_url_functions.lib.test.php b/tests/main/inc/lib/access_url_edit_courses_to_url_functions.lib.test.php deleted file mode 100755 index 35a4357f6d..0000000000 --- a/tests/main/inc/lib/access_url_edit_courses_to_url_functions.lib.test.php +++ /dev/null @@ -1,35 +0,0 @@ -UnitTestCase('Access URL courses library - main/inc/lib/access_url_edit_courses_to_url_functions.lib.test.php'); - } - - public function setUp(){ - $this->AccessUrlEditCoursesToUrl = new Accessurleditcoursestourl(); - } - - public function tearDown(){ - $this->AccessUrlEditCoursesToUrl = null; - } - - public function TestSearchCourses(){ - global $_course, $user_id; - $needle = ''; - $id = $_course['id']; - $res = Accessurleditcoursestourl::search_courses($needle, $id); - $this->assertTrue($res); - $this->assertTrue(is_object($res)); - $this->assertFalse(is_null($res)); - //var_dump($res); - } - - - -} - -?> diff --git a/tests/main/inc/lib/access_url_edit_sessions_to_url_functions.lib.test.php b/tests/main/inc/lib/access_url_edit_sessions_to_url_functions.lib.test.php deleted file mode 100755 index f2bb8cbec3..0000000000 --- a/tests/main/inc/lib/access_url_edit_sessions_to_url_functions.lib.test.php +++ /dev/null @@ -1,32 +0,0 @@ -UnitTestCase('Access URL sessions library - main/inc/lib/access_url_edit_sessions_to_url_functions.lib.test.php'); - } - - public function setUp(){ - $this->AccessUrlEditSessionsToUrl = new Accessurleditsessionstourl(); - } - - public function tearDown(){ - $this->AccessUrlEditSessionsToUrl = null; - } - - public function TestSearchSessions(){ - global $_courses; - $needle = ''; - $id = $_courses['id']; - $res = Accessurleditsessionstourl::search_sessions($needle, $id); - $this->assertTrue($res); - $this->assertTrue(is_object($res)); - $this->assertFalse(is_null($res)); - //var_dump($res); - - } - -} -?> diff --git a/tests/main/inc/lib/access_url_edit_users_to_url_functions.lib.test.php b/tests/main/inc/lib/access_url_edit_users_to_url_functions.lib.test.php deleted file mode 100755 index 90d21f2f73..0000000000 --- a/tests/main/inc/lib/access_url_edit_users_to_url_functions.lib.test.php +++ /dev/null @@ -1,33 +0,0 @@ -UnitTestCase('Access URL users library - main/inc/lib/access_url_edit_users_to_url_functions.lib.test.php'); - } - - public function setUp(){ - $this->AccessUrlEditUsersToUrl = new AccessurleditUserstourl(); - } - - public function tearDown(){ - $this->AccessUrlEditUsersToUrl = null; - } - - public function TestSearchUsers(){ - global $_courses; - $needle = ''; - $id = $_courses['id']; - $res = AccessurleditUserstourl::search_users($needle, $id); - $this->assertTrue($res); - $this->assertTrue(is_object($res)); - $this->assertFalse(is_null($res)); - //var_dump($res); - - } - -} - -?> diff --git a/tests/main/inc/lib/add_course.lib.inc.test.php b/tests/main/inc/lib/add_course.lib.inc.test.php deleted file mode 100755 index cb6cdc4d41..0000000000 --- a/tests/main/inc/lib/add_course.lib.inc.test.php +++ /dev/null @@ -1,132 +0,0 @@ -UnitTestCase('Courses creation - main/inc/lib/add_course.lib.inc.test.php'); - } -/* - function TestCreateCourse(){ - global $_configuration; - $course_datos = array( - 'wanted_code'=> 'testcourse', - 'title'=>'prueba01', - 'tutor_name'=>'John Doe', - 'category_code'=>'Lang', - 'course_language'=>'english', - 'course_admin_id'=>'1', - 'db_prefix'=> $_configuration['db_prefix'], - 'firstExpirationDelay'=>'120' - ); - $res = create_course($course_datos['wanted_code'], $course_datos['title'], - $course_datos['tutor_name'], $course_datos['category_code'], - $course_datos['course_language'],$course_datos['course_admin_id'], - $course_datos['db_prefix'], $course_datos['firstExpirationDelay']); - //should be code string if succeeded (false if failed) - $this->assertTrue(is_string($res)); - }*/ - - function testRegisterCourse() { - global $_configuration; - $course = array( - 'courseSysCode'=> 'testcourse', - 'courseScreenCode' =>'testcourse', - 'courseRepository' =>'testcourse', - 'courseDbName' => $_configuration['db_prefix'].'testcourse', - 'titular' =>'John Doe', - 'category' =>'Lang', - 'title' =>'test course', - 'course_language' =>'english', - 'uidCreator'=> '1', - ); - $res = AddCourse::register_course($course['courseSysCode'],$course['courseScreenCode'], - $course['courseRepository'],$course['courseDbName'], - $course['titular'],$course['category'],$course['title'], - $course['course_language'],$course['uidCreator'], - null,null - ); - - $this->assertTrue($res === 0); - $res = CourseManager::delete_course($course['courseSysCode']); - - } - - function TestGenerateCourseCode(){ - global $charset; - $course_title = 'testcourse'; - $res = CourseManager::generate_course_code($course_title); - $this->assertTrue($res); - } - - - function TestDefineCourseKeys(){ - global $prefixAntiNumber, $_configuration; - $wantedCode = CourseManager::generate_course_code($wantedCode); - $res = AddCourse::define_course_keys(CourseManager::generate_course_code($wantedCode), null, null, null,null, null); - $this->assertTrue($res); - } - - function TestBrowseFolders(){ - $browse = array('path'=>'','file'=>'','media'=>''); - $res = AddCourse::browse_folders($browse['path'], $browse['files'],$browse['media']); - $this->assertFalse($res); - } - /* - // 1 excepcion - function TestSortPictures(){ - $picture = array('files'=>'science.jpg', 'type'=>'jpg'); - $res = sort_pictures($picture['file'],$picture['type']); - $this->assertTrue(is_array($res)); - //var_dump($res); - } - */ - /* - function TestFillCourseRepository(){ - $courseRepository = 'testcourse'; - $res = fill_course_repository($courseRepository); - $this->assertTrue($res); - } -*/ - - function TestFillDbCourse(){ - global $_configuration, $_user; - $courseDbName = $_configuration['table_prefix'].$courseDbName.$_configuration['db_glue']; - $courseRepository = (api_get_path(SYS_COURSE_PATH).$courseRepository . "/dropbox/.htaccess"); - $language = 'english'; - $language_interface = $language; - $default_document_array = array(); - $sys_course_path = api_get_path(SYS_COURSE_PATH); - $courseDbName = $_configuration['db_prefix'].$courseDbName.$_configuration['db_glue']; - $courseRepository = 'testcourse'; - $language = 'english'; - $default_document_array ='testdocument'; - $res = AddCourse::fill_db_course($courseDbName, $courseRepository, $language); - $this->assertTrue($res === 0); - } - - function TestString2Binary(){ - $variable = true; - $res = AddCourse::string2binary($variable); - $this->assertTrue($res); - } - - public function TestDeleteCourse(){ - $code = 'testcourse'; - $res = CourseManager::delete_course($code); - $path = api_get_path(SYS_PATH).'archive'; - if ($handle = opendir($path)) { - while (false !== ($file = readdir($handle))) { - if (strpos($file,$code)!==false) { - if (is_dir($path.'/'.$file)) { - rmdirr($path.'/'.$file); - } - } - } - closedir($handle); - } - } -} diff --git a/tests/main/inc/lib/add_courses_to_sessions_functions.lib.test.php b/tests/main/inc/lib/add_courses_to_sessions_functions.lib.test.php deleted file mode 100755 index a8c125d93b..0000000000 --- a/tests/main/inc/lib/add_courses_to_sessions_functions.lib.test.php +++ /dev/null @@ -1,34 +0,0 @@ -UnitTestCase('Courses-sessions library - main/inc/lib/add_courses_to_sessions_functions.lib.test.php'); - } - - public function setUp(){ - $this->TestAddCoursesToSessionFunctions = new AddCourseToSession(); - } - - public function tearDown(){ - $this->TestAddCoursesToSessionFunctions = null; - } - - public function TestSearchCourses(){ - global $_courses; - global $tbl_course, $tbl_session_rel_course, $id_session; - $needle = ''; - $type = ''; - $res = AddCourseToSession::search_courses($needle, $type); - $this->assertTrue($res); - $this->assertTrue(is_object($res)); - $this->assertFalse(is_null($res)); - //var_dump($res); - - } - -} - -?> diff --git a/tests/main/inc/lib/add_many_session_to_category_functions.lib.test.php b/tests/main/inc/lib/add_many_session_to_category_functions.lib.test.php deleted file mode 100755 index 8e81719059..0000000000 --- a/tests/main/inc/lib/add_many_session_to_category_functions.lib.test.php +++ /dev/null @@ -1,29 +0,0 @@ -UnitTestCase('Sessions to category library - main/inc/lib/add_many_session_to_category_functions.lib.test.php'); - } - - public function setUp(){ - $this-> AddManySessionToCategory = new AddManySessionToCategoryFunctions(); - } - - public function tearDown(){ - $this-> AddManySessionToCategory = null; - - } - public function Testsearchcourses(){ - global $_courses, $tbl_course, $tbl_session, $id_session; - $needle =''; - $type =''; - $res = AddManySessionToCategoryFunctions::search_courses($needle,$type); - $this->assertTrue($res); - $this->assertTrue(is_object($res)); - //var_dump($res); - } -} -?> diff --git a/tests/main/inc/lib/blog.lib.test.php b/tests/main/inc/lib/blog.lib.test.php deleted file mode 100755 index 82b6d50a19..0000000000 --- a/tests/main/inc/lib/blog.lib.test.php +++ /dev/null @@ -1,598 +0,0 @@ -UnitTestCase('Blog Manipulation tests'); - - } - - public function setUp() - { - $this-> oblog = new Blog(); - } - - public function tearDown() - { - $this->oblog = null; - } - - /* - * todo public function testGetBlobTitle() - * todo public function testGetBlogSubtitle() - * todo public function testGetBlogUsers() - * todo public function testCreateBlog() - * todo public function testEditBlog() - * todo public function testDeleteBlog() - * todo public function testCreatePost() - * todo public function testEditPost() - * todo public function testDeletePost() - * todo public function testCreateComment() - * todo public function testDeleteComment() - * todo public function testCreateTask() - * todo public function testEditTask() - * todo public function testDeleteTask() - * todo public function testDeleteAssignedTask() - * todo public function testGetPersonalTaskList() - * todo public function testChangeBlogVisibility() - * todo public function testDisplayBlogPosts() - * todo public function testDisplaySearchResults() - * todo public function testDisplayDayResults() - * todo public function testDisplayPost() - * todo public function testAddRating() - * todo public function testDisplayRating() - * todo public function testDisplayRatingForm() - * todo public function testGetThreadedComments() - * todo public function testDisplayformNewPost() - * todo public function testDisplayFormEditPost() - * todo public function testDisplayTaskList() - * todo public function testDisplayAssignedTaskList() - * todo public function testDisplayNewTaskForm() - * todo public function testDisplayEditTaskForm() - * todo public function testDisplayAssignTaskForm() - * todo public function testDisplayEditAssignedTaskForm() - * todo public function testAssignTask() - * todo public function testEditAssignedTask() - * todo public function testDisplaySelectTaskPost() - * todo public function testSetUserSubscribed() - * todo public function testSetUserUnsubscribed() - * todo public function testDisplayFormUserSubscribe() - * todo public function testDisplayFormUserUnsubscribe() - * todo public function testDisplayNewCommentForm() - * todo public function testDisplayMinimonthcalendar() - * todo public function testDisplayNewBlogForm() - * todo public function testDisplayEditBlogForm() - * todo public function testDisplayBlogList() - * todo public function testDisplayBlogList() - */ - - /** - * Test about get Title to a Blog - */ - - public function testGetBlogTitle(){ - - global $_course; - $res = $this->oblog->get_Blog_title(11); - $this->assertFalse($this->oblog->get_Blog_title(11)===String); - $this->assertTrue(is_String($res)); - } - - public function testGetBlogSubtitle(){ - $res = $this->oblog->get_Blog_subtitle(0); - $this->assertFalse($this->oblog->get_Blog_subtitle(0)=== null); - $this->assertTrue(is_String($res)); - $this->assertNotNull($res); - } - - public function testGetBlogUsers(){ - $res = $this->oblog->get_Blog_users(11); - $this->assertTrue($this->oblog->get_Blog_users(1110)===array()); - $this->assertTrue(is_array($res)); - } - - public function testCreateBlog(){ - global $_user; - $res = $this->oblog->create_Blog('testingBlog','pass'); - $this->assertTrue(is_null($res)); - $this->assertNull($res); - $this->assertFalse($res); - } - - public function testEditBlog(){ - global $_user; - $blog_id = 1; - $title = 'titulo1'; - $subtitle = 'subtitulo1'; - $res = $this->oblog->edit_Blog($blog_id, $title, $subtitle); - $this->assertNull($res); - $this->assertTrue($this->oblog->edit_Blog($blog_id, $title, $subtitle)=== $res); - $this->assertFalse($res); - } - - public function testDeleteBlog(){ - $blog_id = 1; - $res = $this->oblog->delete_Blog($blog_id); - $this->assertTrue(is_null($res)); - $this->assertFalse(is_array($res)); - } - - public function testCreatePost(){ - global $_user, $_course; - $title = 'xxxxtestxxxx'; - $full_text = 'xxxxx'; - $file_comment = 'xxxxx'; - $blog_id = 1; - $res = $this->oblog->create_post($title, $full_text, $file_comment, $blog_id); - $this->assertTrue($this->oblog->create_post($title, $full_text, $file_comment, $blog_id)=== null); - $this->assertNotNull(is_null,$res); - $this->assertFalse($res); - - } - - public function testEditPost(){ - ob_start(); - $post_id =3; - $title = 'xxTestxx'; - $full_text = 'testing public function'; - $Blog_id = 11; - $res = $this->oblog->edit_post(3,'xtestx','test',11); - ob_end_clean(); - $this->assertNotNull($this->oblog->edit_post(3, 'xtestx','test',11)===null); - $this->assertFalse($res); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - public function testDeletePost(){ - $Blog_id = 11; - $post_id = 21; - $res = $this->oblog->delete_post(11,21); - $this->assertTrue($this->oblog->delete_post(11,21)===null); - $this->assertNull(null,$res); - $this->assertTrue(is_null($res)); - //var_dump($res); - } - - public function testCreateComment(){ - global $_user, $_course, $Blog_table_attachment; - $res = $this->oblog->create_comment('tesingBlog','xxxxxxx','xxx',12,1,null); - $this->assertNotNull($this->oblog->create_comment('tesingBlog','xxxxxxx','xxx',12,1,null)===null); - $this->assertTrue(is_null($res)); - $this->assertFalse($res); - } - - public function testDeleteComment(){ - $res = $this->oblog->delete_comment(11,12,2); - $this->assertNotNull($this->oblog->delete_comment(11,12,2)===null); - $this->assertNull(null,$res); - } - - public function testCreateTask(){ - $res = $this->oblog->create_task(1,'xxx','xxxxxxx','xxxx','zzzzz','xxzz','blue'); - $this->assertNotNull($this->oblog->create_task(1,'xxx','xxxxxxx','xxxx','zzzzz','xxzz','blue')=== null); - $this->assertTrue(is_null($res)); - $this->assertFalse($res); - $this->assertFalse(null,$res); - } - - public function testEditTask() { - $blog_id = 1; - $task_id = 2; - $title = 'xxxxxx'; - $description = 'xx'; - $articleDelete = 'aaa'; - $articleEdit = 'axa'; - $commentsDelete = 'xax'; - $color = 'red'; - $res = $this->oblog->edit_task($blog_id, $task_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color); - //$res = Blog::edit_task(); - $this->assertTrue($this->oblog->edit_task($blog_id, $task_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color)===null); - $this->assertTrue(is_null($res)); - $this->assertFalse(is_string($res)); - $this->assertNull($res); - } - - public function testDeleteTask(){ - $blog_id = 1; - $task_id = 2; - $res = $this->oblog->delete_task($blog_id, $task_id); - $this->assertTrue($this->oblog->delete_task($blog_id, $task_id)===null); - $this->assertTrue(is_null($res)); - } - - public function testDeleteAssignedTask(){ - $blog_id = 1; - $task_id = 2; - $user_id = 1; - $res = $this->oblog->delete_assigned_task($blog_id, $task_id,$user_id); - $this->assertTrue($this->oblog->delete_assigned_task($blog_id, $task_id,$user_id)===null); - $this->assertNotNull(is_null($res)); - $this->assertFalse($res); - } - - public function testGetPersonalTaskList(){ - global $_user; - ob_start(); - $res = Blog::get_personal_task_list('a'); - $this->assertFalse($res); - ob_end_clean(); - } - - public function testChangeBlogVisibility(){ - $blog_id = 1; - $res = $this->oblog->change_blog_visibility($blog_id); - $this->assertTrue($this->oblog->change_blog_visibility($blog_id)=== null); - $this->assertTrue(is_null($res)); - } - - public function testDisplayBlogPosts(){ - ob_start(); - $blog_id = 1; - $filter = '1=1'; - $max_number_of_posts = 20; - $res = BLog::display_blog_posts($blog_id, $filter, $max_number_of_posts); - $this->assertTrue($this->oblog->display_blog_posts($blog_id, $filter, $max_number_of_posts)=== null); - ob_end_clean(); - $this->assertNull($res); - $this->assertTrue(is_null($res)); - $this->assertFalse(null, $res); - } - - public function testDisplaySearchResults(){ - ob_start(); - $blog_id = 1; - $query_string = '"SELECT post.*, user.lastname, user.firstname FROM $tbl_blogs_posts"'; - $res = $this->oblog->display_search_results($blog_id, $query_string); - ob_end_clean(); - $this->assertTrue(is_null($res)); - $this->assertNull($res); - } - - public function testDisplayDayResults(){ - ob_start(); - $blog_id = 1; - $query_string = '01-01-2010'; - $res = $this->oblog->display_day_results($blog_id, $query_string); - ob_end_clean(); - $this->assertTrue(is_null($res)); - $this->assertFalse($res); - $this->assertNull(null,$res); - } - - public function testDisplayPost(){ - ob_start(); - $blog_id = 1; - $post_id = 2; - $res = $this->oblog->display_post($blog_id, $post_id); - ob_end_clean(); - $this->assertTrue(is_null($res)); - $this->assertFalse($res); - } - - public function testAddRating(){ - global $_user; - $res = $this->oblog->add_rating(null,11,2,5); - $this->assertFalse($this->oblog->add_rating(null,11,2,5)=== bool); - $this->assertTrue(is_bool($res)); - $this->assertFalse(null,$res); - } - - public function testDisplayRating(){ - ob_start(); - $res = $this->oblog->display_rating('xxx',11,1); - $this->assertFalse($this->oblog->display_rating('xxx',11,1)===null); - $this->assertTrue(is_numeric($res)); - $this->assertFalse($res); - ob_end_clean(); - } - - public function testDisplayRatingForm(){ - global $_user; - $res = $this->oblog->display_rating_form('xxx',11,1,null); - $this->assertFalse($this->oblog->display_rating_form('xxx',11,1,null)===null); - $this->assertTrue(is_string($res)); - $this->assertNotNull($res,null); - } - - public function testGetThreadedComments(){ - ob_start(); - $current = 0; - $current_level = 0; - $blog_id = 1; - $post_id = 2; - $task_id = 0; - global $charset, $dataFormatLong; - $res = $this->oblog->get_threaded_comments($current, $current_level, $blog_id, $post_id, $task_id); - ob_end_clean(); - $this->assertFalse($res); - $this->assertTrue(is_null($res)); - } - - public function testDisplayFormNewPost(){ - ob_start(); - $blog_id = 1; - $res = Blog::display_form_new_post($blog_id); - $this->assertTrue(is_null($res)); - $this->assertNull($res); - ob_end_clean(); - } - - public function testDisplayFormEditPost(){ - ob_start(); - $blog_id = 1; - $post_id = 2; - $res = $this->oblog->display_form_edit_post($blog_id, $post_id); - $this->assertNotNull(is_null($res)); - $this->assertFalse($res); - ob_end_clean(); - //var_dump($res); - } - - public function testDisplayTaskList(){ - ob_start(); - $res = $this->oblog->display_task_list(11); - $this->assertTrue($this->oblog->display_task_list(11)===null); - ob_end_clean(); - } - - public function testDisplayAssignedTaskList(){ - ob_start(); - global $charset, $color2; - $res = $this->oblog->display_assigned_task_list(11); - $this->assertTrue($this->oblog->display_assigned_task_list(11)===null); - ob_end_clean(); - $this->assertFalse($res); - - } - - public function testDisplayNewTaskForm(){ - ob_start(); - $res = $this->oblog->display_new_task_form(11); - $this->assertTrue($this->oblog->display_new_task_form(11)===null); - ob_end_clean(); - $this->assertFalse($res); - - - } - - public function testDisplayEditTaskForm(){ - ob_start(); - $res = $this->oblog->display_edit_task_form(11,12); - $this->assertTrue($this->oblog->display_edit_task_form(11,12)===null); - ob_end_clean(); - $this->assertTrue(is_null($res)); - $this->assertFalse($res); - - } - - public function testDisplayAssignTaskForm(){ - ob_start(); - $res = $this->oblog->display_assign_task_form(11); - $this->assertTrue($this->oblog->display_assign_task_form(11)===null); - ob_end_clean(); - $this->assertFalse($res); - $this->assertTrue(is_null($res)); - - } - - public function testDisplayEditAssignedTaskForm(){ - global $MonthsLong; - ob_start(); - $res = $this-> oblog->display_edit_assigned_task_form(11,12,1); - $this->assertTrue($this->oblog->display_edit_assigned_task_form(11,12,1)===null); - ob_end_clean(); - $this->assertFalse($res); - - } - - public function testAssignTask(){ - ob_start(); - $res = $this->oblog->assign_task(11,1,12,null); - $this->assertTrue($this->oblog->assign_task(11,1,12,null)===null); - ob_end_clean(); - $this->assertFalse(is_numeric($res)); - $this->assertNull(null,$res); - - } - - public function testEditAssignedTask(){ - $task = array('blog_id'=>11, - 'user_id'=>1, - 'task_id'=>12, - 'target_date'=>'xxxxxxx', - 'old_user_id'=>10, - 'old_task_id'=>11, - 'old_target_date'=>'xxxzxxx' - ); - $res = $this->oblog->edit_assigned_task($task['blog_id'],$task['user_id'], $task['task_id'], $task['target_date'], $task['old_user_id'], $task['old_task_id'], $task['old_target_date']); - $this->assertNull($res); - $this->assertTrue(is_null($res)); - } - - public function testDisplaySelectTaskPost(){ - ob_start(); - $res = $this->oblog->display_select_task_post(11,12); - $this->assertTrue($this->oblog->display_select_task_post(11,12)===null); - ob_end_clean(); - $this->assertTrue(is_null($res)); - $this->assertFalse($res); - - } - - public function testSetUserSubscribed(){ - $res = $this->oblog->set_user_subscribed(11,12); - $this->assertTrue($this->oblog->set_user_subscribed(11,12)===null); - $this->assertFalse($res); - $this->assertTrue(is_null($res)); - } - - public function testUserUnsubscribed(){ - $res = $this->oblog->set_user_unsubscribed(11,12); - $this->assertTrue($this->oblog->set_user_unsubscribed(11,12)===null); - $this->assertFalse($res); - $this->assertTrue(is_null($res)); - } - - public function testDisplayFormUserSubscribe(){ - ob_start(); - $res = $this->oblog->display_form_user_subscribe(12); - $this->assertTrue($this->oblog->display_form_user_subscribe(12)===null); - ob_end_clean(); - $this->assertNotNull(is_null($res)); - $this->assertFalse($res); - - } - - /** - * this function have been tested modified the function - * display_form_user_unsubscribe in the blog.lib.php - * main_table and course_table. - * - */ - - public function testDisplayFormUserUnsubscribe(){ - - global $_user; - ob_start(); - $blog_id = '1'; - $res = Blog::display_form_user_unsubscribe($blog_id); - ob_end_clean(); - $this->assertTrue(is_null($res)); - $this->assertNull($res); - - } - - public function testDisplayFormUserRights(){ - ob_start(); - $res = $this->oblog->display_form_user_rights(12); - $this->assertTrue($this->oblog->display_form_user_rights(12)===null); - ob_end_clean(); - $this->assertFalse($res); - - } - - public function testDisplayNewCommentForm(){ - $blog_id = '12'; - $post_id='1'; - $title='test'; - ob_start(); - $res =$this->oblog->display_new_comment_form($blog_id,$post_id,$title); - ob_end_clean(); - $this->assertFalse($res); - $this->assertNotNull(is_null($res)); - - } - - public function testDisplayMinimonthcalendar(){ - global $_user,$DaysShort, $MonthsLong; - ob_start(); - $month = 12; - $year = 2010; - $blog_id = 1; - $res = $this->oblog->display_minimonthcalendar($month, $year, $blog_id); - $this->assertTrue($this->oblog->display_minimonthcalendar($month, $year, $blog_id)=== null); - ob_end_clean(); - $this->assertTrue(is_null($res)); - - } - - public function testDisplayNewBlogForm(){ - ob_start(); - $res = $this->oblog->display_new_blog_form(); - $this->assertFalse($res); - $this->assertTrue(is_null($res)); - $this->assertTrue($this->oblog->display_new_blog_form()===null); - ob_end_clean(); - } - - public function testDisplayEditBlogForm(){ - ob_start(); - $res = $this->oblog->display_edit_blog_form(12); - $this->assertTrue($this->oblog->display_edit_blog_form(12)===null); - ob_end_clean(); - $this->assertTrue(is_null($res)); - - } - - public function testDisplayBlogList(){ - ob_start(); - $res = $this->oblog->display_blog_list(); - $this->assertTrue($this->oblog->display_blog_list()===null); - ob_end_clean(); - $this->assertTrue(is_null($res)); - - } - - public function testGetBlogAttachment(){ - ob_start(); - ob_end_clean(); - global $_configuration; - $blog_id = '0'; - $post_id = null; - $comment_id = null; - $res = get_blog_attachment($blog_id, $post_id,$comment_id); - $this->assertFalse($res); - $this->assertTrue(is_array($res)); - } - - public function testDeleteAllBlogAttachment(){ - global $_course,$_configuration; - $blog_id = 1; - $post_id=null; - $comment_id=null; - $res = delete_all_blog_attachment($blog_id,$post_id,$comment_id); - $this->assertFalse($res); - $this->assertNull($res); - } - - public function testGetBlogPostFromUser(){ - global $_configuration; - $res = get_blog_post_from_user('chamilo_COURSETEST',1); - $this->assertFalse($res); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - public function testGetBlogCommentFromUser(){ - global $_configuration; - $course_datos['wanted_code'] = 'chamilo_COURSETEST'; - $user_id = 1; - $res = get_blog_comment_from_user($course_datos['wanted_code'],1); - $this->assertFalse($res); - $this->assertTrue(is_string($res)); - $path = api_get_path(SYS_PATH).'archive'; - if ($handle = opendir($path)) { - while (false !== ($file = readdir($handle))) { - if (strpos($file,'COURSETEST')!==false) { - if (is_dir($path.'/'.$file)) { - rmdirr($path.'/'.$file); - } - } - } - closedir($handle); - } - } -/* - public function testDeleteCourse() { - global $cidReq; - $resu = CourseManager::delete_course($cidReq); - } - - */ - - - - - -} -?> diff --git a/tests/main/inc/lib/database.lib.test.php b/tests/main/inc/lib/database.lib.test.php deleted file mode 100755 index 2a46801f62..0000000000 --- a/tests/main/inc/lib/database.lib.test.php +++ /dev/null @@ -1,173 +0,0 @@ -UnitTestCase('Database library - main/inc/lib/database.lib.test.php'); - } - - public function setUp() { - global $_configuration; - $this->dbase = new Database(); - } - - public function tearDown() { - $this->dbase = null; - } - - public function testAffectedRows() { - $res=$this->dbase->affected_rows(); - $this->assertTrue(is_numeric($res)); - } - - public function testCountRows() { - $table='class'; - $res=$this->dbase->count_rows($table); - if(!is_string($res)){ - $this->assertTrue(is_numeric($res)); - } - } - - public function testError() { - $res=$this->dbase->error(); - $this->assertTrue(is_string($res)); - } - - public function testEscapeString() { - $string='Lore"May'; - $res=$this->dbase->escape_string($string); - $this->assertTrue(is_string($res)); - } - - public function testFetchArray() { - $sql = 'select 1'; - $res=Database::query($sql); - $resu=$this->dbase->fetch_array($res); - $this->assertTrue(is_array($resu)); - $this->assertFalse(is_null($resu)); - } - - public function testFetchArrayError() { - $sql = 'SELECT 1'; - $res=Database::query($sql); - $resu=$this->dbase->fetch_array($res); - $this->assertTrue(is_array($resu)); - } - - function testFetchObject() { - $sql = 'SELECT 1'; - $res=Database::query($sql); - $resu=$this->dbase->fetch_object($res); - $this->assertTrue(is_object($resu)); - } - - function testFetchRow() { - $sql = 'SELECT 1'; - $res=Database::query($sql); - $resu=$this->dbase->fetch_row($res); - $this->assertTrue(is_array($resu)); - } - - /* // Contains a private unaccessible method, Database::fix_database_parameter(). - function testFixDatabaseParameterReturnString() { - $course_info = api_get_course_info(); - $database_name= $course_info["dbName"]; - $res=$this->dbase->fix_database_parameter($course_info); - $this->assertTrue(is_string($res)); - } - */ - - /* // Contains a private unaccessible method, Database::format_glued_course_table_name(). - function testFormatGluedCourseTableName() { - $database_name_with_glue=''; - $table=''; - $res=$this->dbase->format_glued_course_table_name($database_name_with_glue, $table); - $this->assertTrue(is_string($res)); - } - */ - - /* // Contains a private unaccessible method, Database::format_table_name(). - function testFormatTableName() { - $database=''; - $table=''; - $res=$this->dbase->format_table_name($database, $table); - $this->assertTrue(is_string($res)); - } - */ - - function testGetCourseInfo() { - $course_code='AYDD'; - $res=$this->dbase->get_course_info($course_code); - $this->assertTrue(is_array($res)); - } - - function testGetCourseList() { - $sql_query = "SELECT * FROM $table"; - $res=$this->dbase->get_course_list($sql_query); - $this->assertTrue(is_array($res)); - } - - function testGetCourseTable() { - $short_table_name=''; - $database_name=''; - $res=$this->dbase->get_course_table($short_table_name,$database_name); - $this->assertTrue(is_string($res)); - } - - function testGetMainDatabase() { - global $_configuration; - $res=$this->dbase->get_main_database(); - $this->assertTrue(is_string($res)); - } - - function testGetMainTable() { - $short_table_name=''; - $res=$this->dbase->get_main_table($short_table_name); - $this->assertTrue(is_string($res)); - } - - /* // Contains a private unaccessible method, Database::glue_course_database_name(). - function testGlueCourseDatabaseName() { - $database_name=''; - $res=$this->dbase->glue_course_database_name($database_name); - $this->assertTrue(is_string($res)); - $this->assertTrue($res); - } - */ - - function testInsertId() { - $res = $this->dbase->insert_id(); - $this->assertTrue(is_numeric($res)); - } - - function testNumRows() { - $sql = 'SELECT * FROM user'; - $res = Database::query($sql); - $resul=Database::num_rows($res); - $this->assertTrue(is_numeric($resul)); - } - - function testQuery() { - $sql = 'SELECT 1'; - $res = Database::query($sql); - $this->assertTrue(is_resource($res)); - } - - function testResult() { - $sql = 'SELECT email FROM user'; - $resource = Database::query($sql); - $res = Database::result($resource, 1); - $this->assertTrue(is_string($res)); - } - - function testStoreResult(){ - $sql = 'SELECT 1'; - $resource = $this->dbase->query($sql); - $res = $this->dbase->store_result($resource); - $this->assertTrue(is_array($res)); - } -} -?> diff --git a/tests/main/inc/lib/debug.lib.inc.test.php b/tests/main/inc/lib/debug.lib.inc.test.php deleted file mode 100755 index 6632f87d30..0000000000 --- a/tests/main/inc/lib/debug.lib.inc.test.php +++ /dev/null @@ -1,65 +0,0 @@ -UnitTestCase('Debug helper library - main/inc/lib/debug.lib.inc.test.php'); - } - function test_printr_is_string() { - $variable='br'; - ob_start(); - Debug::printr($variable); - $res=ob_get_contents(); - ob_end_clean(); - //print_r($res); - $this->assertTrue(is_string($res)); - $this->assertTrue(is_scalar($res)); - } - - function test_debug_course_is_string() { - global $_course; - ob_start(); - Debug::course($_course); - $res=ob_get_contents(); - ob_end_clean(); - //print_r($res); - $this->assertTrue(is_string($res)); - //var_dump($res); - - } - - function test_debug_paths_is_string() { - ob_start(); - Debug::debug_paths(); - $res=ob_get_contents(); - ob_end_clean(); - //print_r($res); - $this->assertTrue(is_string($res)); - $this->assertTrue(is_scalar($res)); - } - - function test_debug_user_is_array() { - global $_user; - ob_start(); - Debug::user($_user); - $res=ob_get_contents(); - ob_end_clean(); - //print_r($res); - $this->assertTrue(array($_user)); - //var_dump($res); - } - - function test_print_var_is_string() { - $var=''; - GLOBAL $DEBUG; - ob_start(); - Debug::print_var($var, $varName = "@"); - $res=ob_get_contents(); - ob_end_clean(); - //print_r($res); - $this->assertTrue(is_string($res)); - } -} -?> diff --git a/tests/main/inc/lib/display.lib.test.php b/tests/main/inc/lib/display.lib.test.php deleted file mode 100755 index 1738d155f6..0000000000 --- a/tests/main/inc/lib/display.lib.test.php +++ /dev/null @@ -1,256 +0,0 @@ -UnitTestCase('Display library - main/inc/display.lib.test.php'); - } - public function testdisplay_introduction_section() { - $tool=api_get_tools_lists($my_tool=null); - ob_start(); - $res = Display::display_introduction_section($tool); - ob_end_clean(); - $this->assertTrue(is_array($tool)); - //var_dump($tool); - } - - public function testdisplay_localised_html_file(){ - global $language_interface; - $doc_url = str_replace('/..', '', $doc_url); - $full_file_name=api_get_path(SYS_COURSE_PATH).'/index'.$doc_url; - ob_start(); - $res = Display::display_localised_html_file($full_file_name); - ob_end_clean(); - $this->assertTrue(is_string($full_file_name)); - //var_dump($full_file_name); - } - - public function testdisplay_sortable_table() { - $header=''; - $content=''; - global $origin; - ob_start(); - $res=Display::display_sortable_table($header, $content); - ob_end_clean(); - $this->assertNull($res); - //var_dump($res); - } - - /** - * Display a table with a special configuration - * @param array $header Titles for the table header - * each item in this array can contain 3 values - * - 1st element: the column title - * - 2nd element: true or false (column sortable?) - * - 3th element: additional attributes for - * th-tag (eg for column-width) - * - 4the element: additional attributes for the td-tags - * @param array $content 2D-array with the tables content - * @return void String about header - */ - public function testdisplay_sortable_config_table() { - $header=''; - $content=''; - global $origin; - ob_start(); - $res=Display::display_sortable_config_table($header, $content); - ob_end_clean(); - $this->assertNull($res); - //var_dump($res); - } - - /** - * Displays a normal message. It is recommended to use this public function - * to display any normal information messages. - * - * @param string $message - include any additional html - * tags if you need them - * @param bool Filter (true) or not (false) - * @return void String message - */ - public function testdisplay_normal_message() { - global $charset; - $message=api_htmlentities($message, ENT_QUOTES, api_is_xml_http_request() ? 'UTF-8' : $charset); - ob_start(); - $res=Display::display_normal_message($message); - ob_end_clean(); - $this->assertNull($res); - //var_dump($res); - } - - /** - * Display the reduced page header (without banner) - */ - // [/var/www/chamilo/main/inc/reduced_header.inc.php line 30] - exception -/* public function testdisplay_reduced_header() { - global $_plugins,$lp_theme_css,$mycoursetheme,$user_theme,$platform_theme; - global $httpHeadXtra, $htmlHeadXtra, $htmlIncHeadXtra, $_course, $_user, $text_dir, $plugins, $_user, $_cid, $interbreadcrumb, $charset, $language_file, $noPHP_SELF, $language_interface; - global $menu_navigation; - ob_start(); - $res=Display::display_reduced_header(); - ob_end_clean(); - $this->assertNull($res); - //var_dump($res); - } -*/ - /** - * Displays an confirmation message. Use this if something has been done successfully - * - * @param string $message - * @param bool Filter (true) or not (false) - * @return void String message - */ - public function testdisplay_confirmation_message() { - global $charset; - $message=api_htmlentities($message, ENT_QUOTES, api_is_xml_http_request() ? 'UTF-8' : $charset); - ob_start(); - $res=Display::display_confirmation_message($message); - ob_end_clean(); - $this->assertTrue(is_string($message)); - //var_dump($message); - } - - /** - * Displays an error message. - * @author Arthur Portugal - * @param string $message - include any additional html tags if you need them - * @param bool Filter (true) or not (false) - * @param object Not display the object in the test browser - * @return string Code HTML - */ - public function testdisplay_error_message() { - global $charset; - $message = "error message"; - ob_start(); - $res=Display::display_error_message($message); - ob_end_clean(); - $this->assertTrue(is_string($message)); - //var_dump($message); - } - - /** - * Display the page footer - * @author Arthur Portugal - * @return string Code HTML about the footer - */ -/* public function testdisplay_footer() { - global $_plugins; - ob_start(); - $res=Display::display_footer(); - ob_end_clean(); - $this->assertNull($res); - //var_dump($res); - } -*/ - /** - * Display the page header - * @param string The name of the page (will be showed in the page title) - * @param string Optional help file name - * @return string Display the hearders messages - */ - // [/var/www/chamilo/main/inc/header.inc.php line 31] - exception -/* public function testdisplay_header() { - global $_plugins,$lp_theme_css,$mycoursetheme,$user_theme,$platform_theme; - global $httpHeadXtra, $htmlHeadXtra, $htmlIncHeadXtra, $_course, $_user, $text_dir, $plugins, $_user, $rootAdminWeb, $_cid, $interbreadcrumb, $charset, $language_file, $noPHP_SELF; - global $menu_navigation; - $tool_name = ''; - $help = NULL; - $nameTools = $tool_name; - ob_start(); - $res=Display::display_header($tool_name, $help); - ob_end_clean(); - $this->assertNull($res); - //var_dump($res); - } -*/ - /** - * This public function displays an icon - * @param string $image the filename of the file (in the main/img/ folder - * @param string $alt_text the alt text (probably a language variable) - * @param array additional attributes (for instance height, width, onclick, ...) - * @return return icon like string in this test (path) - */ - public function testdisplay_icon() { - $image='file'; - ob_start(); - $res=Display::display_icon($image); - ob_end_clean(); - $this->assertNull($res); - //var_dump($res); - } - - /** - * Displays an warning message. Use this if you want to draw attention to something - * - * @author Arthur Portugal - * @param string $message - * @param bool Filter (true) or not (false) - * @return string with the message (also void) - */ - public function testdisplay_warning_message() { - $message="warning-message"; - ob_start(); - $res=Display::display_warning_message($message); - ob_end_clean(); - $this->assertNull($res); - //var_dump($res); - } - - /** - * Return an encrypted mailto hyperlink - * @author Arthur Portugal - * @param - $email (string) - e-mail - * @return - encrypted mailto hyperlink - */ - public function testencrypted_mailto_link() { - $email=''; - $clickable_text = null; - $style_class = ''; - ob_start(); - $res=Display::encrypted_mailto_link($email, $clickable_text, $style_class); - ob_end_clean(); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - /** - * Print an