Minor format code.

1.9.x
Julio Montoya 12 years ago
parent d00530c963
commit e6a8a23526
  1. 185
      main/inc/lib/surveymanager.lib.php
  2. 7820
      main/survey/survey.lib.php
  3. 18
      main/survey/survey_list.php

@ -1,43 +1,41 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This library provides functions for user management.
* Include/require it in your code to use its functionality.
*
* @package chamilo.library
*/
/**
*
* Manage the "versioning" of a conditional survey
* @package chamilo.survey
* */
*
* @package chamilo.survey
*/
class SurveyTree
{
public $surveylist;
public $plainsurveylist;
public $numbersurveys;
public $surveylist;
public $plainsurveylist;
public $numbersurveys;
/**
* Sets the surveylist and the plainsurveylist
*/
public function __construct()
/**
* Sets the surveylist and the plainsurveylist
*/
public function __construct()
{
// Database table definitions
$table_survey = Database :: get_course_table(TABLE_SURVEY);
$table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION);
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
$table_survey = Database :: get_course_table(TABLE_SURVEY);
$table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION);
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
// searching
$search_restriction = SurveyUtil::survey_search_restriction();
if ($search_restriction) {
$search_restriction = ' AND '.$search_restriction;
}
// searching
$search_restriction = SurveyUtil::survey_search_restriction();
if ($search_restriction) {
$search_restriction = ' AND '.$search_restriction;
}
$course_id = api_get_course_int_id();
$course_id = api_get_course_int_id();
$sql = "SELECT survey.survey_id , survey.parent_id, survey_version, survey.code as name
FROM $table_survey survey LEFT JOIN $table_survey_question survey_question
$sql = "SELECT
survey.survey_id,
survey.parent_id,
survey_version,
survey.code as name
FROM $table_survey survey
LEFT JOIN $table_survey_question survey_question
ON survey.survey_id = survey_question.survey_id , $table_user user
WHERE
survey.c_id = $course_id AND
@ -45,84 +43,79 @@ class SurveyTree
survey.author = user.user_id
GROUP BY survey.survey_id";
$res = Database::query($sql);
$surveys_parents = array ();
$refs = array();
$list = array();
$last = array();
$plain_array=array();
$res = Database::query($sql);
$surveys_parents = array ();
$refs = array();
$list = array();
$plain_array=array();
while ($survey = Database::fetch_array($res,'ASSOC'))
{
$plain_array[$survey['survey_id']]=$survey;
$surveys_parents[]=$survey['survey_version'];
$thisref = &$refs[ $survey['survey_id'] ];
$thisref['parent_id'] = $survey['parent_id'];
$thisref['name'] = $survey['name'];
$thisref['id'] = $survey['survey_id'];
$thisref['survey_version'] = $survey['survey_version'];
if ($survey['parent_id'] == 0) {
$list[ $survey['survey_id'] ] = &$thisref;
} else {
$refs[ $survey['parent_id'] ]['children'][ $survey['survey_id'] ] = &$thisref;
}
}
while ($survey = Database::fetch_array($res,'ASSOC')) {
$plain_array[$survey['survey_id']]=$survey;
$surveys_parents[]=$survey['survey_version'];
$thisref = &$refs[ $survey['survey_id'] ];
$thisref['parent_id'] = $survey['parent_id'];
$thisref['name'] = $survey['name'];
$thisref['id'] = $survey['survey_id'];
$thisref['survey_version'] = $survey['survey_version'];
if ($survey['parent_id'] == 0) {
$list[ $survey['survey_id'] ] = &$thisref;
} else {
$refs[ $survey['parent_id'] ]['children'][ $survey['survey_id'] ] = &$thisref;
}
}
$this->surveylist = $list;
$this->plainsurveylist = $plain_array;
}
/**
* This function gets the parent id of a survey
*
* @param int survey id
* @return int survey parent id
*
* @author Julio Montoya <gugli100@gmail.com>, Dokeos
* @version September 2008
*/
public function getParentId($id)
/**
* This function gets the parent id of a survey
*
* @param int $id survey id
* @return int survey parent id
*
* @author Julio Montoya <gugli100@gmail.com>, Dokeos
* @version September 2008
*/
public function getParentId($id)
{
$node = $this->plainsurveylist[$id];
if (is_array($node)&& !empty($node['parent_id'])) {
return $node['parent_id'];
$node = $this->plainsurveylist[$id];
if (is_array($node)&& !empty($node['parent_id'])) {
return $node['parent_id'];
} else {
return -1;
return -1;
}
}
}
/**
* This function creates a list of all surveys id
* @param list of nodes
* @return array with the structure survey_id => survey_name
* @author Julio Montoya <gugli100@gmail.com>
* @version September 2008
*/
public function createList ($list)
/**
* This function creates a list of all surveys id
* @param array $list of nodes
* @return array with the structure survey_id => survey_name
* @author Julio Montoya <gugli100@gmail.com>
* @version September 2008
*/
public function createList($list)
{
$result = array();
if (is_array($list)) {
foreach ($list as $key=>$node) {
if (isset($node['children']) && is_array($node['children'])) {
//echo $key; echo '--<br>';
//print_r($node);
//echo '<br>';
$result[$key]= $node['name'];
$re = self::createList($node['children']);
if (!empty($re)) {
if (is_array($re)) {
foreach ($re as $key=>$r) {
$result[$key]=''.$r;
$result = array();
if (is_array($list)) {
foreach ($list as $key => $node) {
if (isset($node['children']) && is_array($node['children'])) {
$result[$key]= $node['name'];
$re = self::createList($node['children']);
if (!empty($re)) {
if (is_array($re)) {
foreach ($re as $key => $r) {
$result[$key] = '' . $r;
}
} else {
$result[]=$re;
}
}
} else {
$result[$key]=$node['name'];
}
}
}
$result[] = $re;
}
}
} else {
$result[$key] = $node['name'];
}
}
}
return $result;
}
return $result;
}
}

File diff suppressed because it is too large Load Diff

@ -147,8 +147,8 @@ if (isset($_POST['action']) && $_POST['action']) {
echo '<div class="actions">';
if (!api_is_course_coach() || $extend_rights_for_coachs == 'true') {
// Action links
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/create_new_survey.php?'.api_get_cidreq().'&amp;action=add">'.Display::return_icon('new_survey.png', get_lang('CreateNewSurvey'),'',ICON_SIZE_MEDIUM).'</a> ';
// Action links
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/create_new_survey.php?'.api_get_cidreq().'&amp;action=add">'.Display::return_icon('new_survey.png', get_lang('CreateNewSurvey'),'',ICON_SIZE_MEDIUM).'</a> ';
}
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;search=advanced">'.Display::return_icon('search.png', get_lang('Search'),'',ICON_SIZE_MEDIUM).'</a>';
echo '</div>';
@ -167,34 +167,34 @@ Display :: display_footer();
function get_number_of_surveys()
{
return SurveyUtil::get_number_of_surveys();
return SurveyUtil::get_number_of_surveys();
}
function get_survey_data($from, $number_of_items, $column, $direction)
{
return SurveyUtil::get_survey_data($from, $number_of_items, $column, $direction);
return SurveyUtil::get_survey_data($from, $number_of_items, $column, $direction);
}
function modify_filter($survey_id)
{
return SurveyUtil::modify_filter($survey_id);
return SurveyUtil::modify_filter($survey_id);
}
function get_number_of_surveys_for_coach()
{
return SurveyUtil::get_number_of_surveys_for_coach();
return SurveyUtil::get_number_of_surveys_for_coach();
}
function get_survey_data_for_coach($from, $number_of_items, $column, $direction)
{
return SurveyUtil::get_survey_data_for_coach($from, $number_of_items, $column, $direction);
return SurveyUtil::get_survey_data_for_coach($from, $number_of_items, $column, $direction);
}
function modify_filter_for_coach($survey_id)
{
return SurveyUtil::modify_filter_for_coach($survey_id);
return SurveyUtil::modify_filter_for_coach($survey_id);
}
function anonymous_filter($anonymous)
{
return SurveyUtil::anonymous_filter($anonymous);
return SurveyUtil::anonymous_filter($anonymous);
}

Loading…
Cancel
Save