ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
SurveyCategories Class Reference

Class SurveyCategories. More...

+ Collaboration diagram for SurveyCategories:

Public Member Functions

 SurveyCategories ()
 Constructor public.
 getCategoryCount ()
 Returns the number of categories.
 addCategoryAtPosition ($categoryname, $position, $other=0, $neutral=0, $label=null)
 Adds a category at a given position.
 moveCategoryUp ($index)
 moveCategoryDown ($index)
 addCategory ($categoryname, $other=0, $neutral=0, $label=null, $scale=null)
 Adds a category.
 addCategoryArray ($categories)
 Adds a category array.
 removeCategory ($index)
 Removes a category from the list of categories.
 removeCategories ($array)
 Removes many categories from the list of categories.
 removeCategoryWithName ($name)
 Removes a category from the list of categories.
 getCategory ($index)
 Returns the name of a category for a given index.
 getCategoryForScale ($scale)
 Returns the name of a category for a given index.
 getCategoryIndex ($name)
 Returns the index of a category with a given name.
 getIndex ($category)
 Returns the index of a category.
 getNewScale ()
 getScale ($index)
 flushCategories ()
 Empties the categories list.

Data Fields

 $categories

Detailed Description

Class SurveyCategories.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Version
Id:
class.SurveyCategories.php 25637 2010-09-09 16:41:31Z hschottm

Definition at line 36 of file class.SurveyCategories.php.

Member Function Documentation

SurveyCategories::addCategory (   $categoryname,
  $other = 0,
  $neutral = 0,
  $label = null,
  $scale = null 
)

Adds a category.

Adds a category

Parameters
integer$categorynameThe name of the category public
See Also
$categories

Definition at line 124 of file class.SurveyCategories.php.

{
array_push($this->categories, new ilSurveyCategory($categoryname, $other, $neutral, $label, $scale));
}
SurveyCategories::addCategoryArray (   $categories)

Adds a category array.

Adds a category array

Parameters
array$categoriesAn array with categories public
See Also
$categories

Definition at line 138 of file class.SurveyCategories.php.

References $categories.

{
$this->categories = array_merge($this->categories, $categories);
}
SurveyCategories::addCategoryAtPosition (   $categoryname,
  $position,
  $other = 0,
  $neutral = 0,
  $label = null 
)

Adds a category at a given position.

Adds a category at a given position

Parameters
string$categorynameThe name of the category
integer$positionThe position of the category (starting with index 0) public
See Also
$categories

Definition at line 81 of file class.SurveyCategories.php.

{
if (array_key_exists($position, $this->categories))
{
$head = array_slice($this->categories, 0, $position);
$tail = array_slice($this->categories, $position);
$this->categories = array_merge($head, array(new ilSurveyCategory($categoryname, $other, $neutral, $label)), $tail);
}
else
{
array_push($this->categories, new ilSurveyCategory($categoryname, $other, $neutral, $label));
}
}
SurveyCategories::flushCategories ( )

Empties the categories list.

Empties the categories list

public

See Also
$categories

Definition at line 307 of file class.SurveyCategories.php.

{
$this->categories = array();
}
SurveyCategories::getCategory (   $index)

Returns the name of a category for a given index.

Returns the name of a category for a given index

Parameters
integer$indexThe index of the category
Returns
string Category name public
See Also
$categories

Definition at line 207 of file class.SurveyCategories.php.

{
if (array_key_exists($index, $this->categories))
{
return $this->categories[$index];
}
else
{
return "";
}
}
SurveyCategories::getCategoryCount ( )

Returns the number of categories.

Returns the number of categories

Returns
integer The number of contained categories public
See Also
$categories

Definition at line 66 of file class.SurveyCategories.php.

{
return count($this->categories);
}
SurveyCategories::getCategoryForScale (   $scale)

Returns the name of a category for a given index.

Parameters
integer$scaleThe scale of the category
Returns
string Category object

Definition at line 225 of file class.SurveyCategories.php.

{
foreach ($this->categories as $cat)
{
if ($cat->scale == $scale) return $cat;
}
return null;
}
SurveyCategories::getCategoryIndex (   $name)

Returns the index of a category with a given name.

Parameters
string$nameThe name of the category public
See Also
$categories

Definition at line 241 of file class.SurveyCategories.php.

{
foreach ($this->categories as $index => $category)
{
if (strcmp($category->title, $name) == 0)
{
return $index;
}
}
return null;
}
SurveyCategories::getIndex (   $category)

Returns the index of a category.

Parameters
string$categoryThe category object public
See Also
$categories

Definition at line 260 of file class.SurveyCategories.php.

{
foreach ($this->categories as $index => $cat)
{
if ($cat == $category)
{
return $index;
}
}
return null;
}
SurveyCategories::getNewScale ( )

Definition at line 272 of file class.SurveyCategories.php.

Referenced by getScale().

{
$max = 0;
foreach ($this->categories as $index => $category)
{
if (is_object($category) && $category->scale > 0)
{
if ($category->scale > $max) $max = $category->scale;
}
}
return $max+1;
}

+ Here is the caller graph for this function:

SurveyCategories::getScale (   $index)

Definition at line 285 of file class.SurveyCategories.php.

References getNewScale().

{
$obj = $this->categories[$index];
if (is_object($obj) && $obj->scale > 0)
{
return $obj->scale;
}
else
{
$obj->scale = $this->getNewScale();
return $obj->scale;
}
}

+ Here is the call graph for this function:

SurveyCategories::moveCategoryDown (   $index)

Definition at line 105 of file class.SurveyCategories.php.

{
if ($index < (count($this->categories)-1))
{
$temp = $this->categories[$index+1];
$this->categories[$index + 1] = $this->categories[$index];
$this->categories[$index] = $temp;
}
}
SurveyCategories::moveCategoryUp (   $index)

Definition at line 95 of file class.SurveyCategories.php.

{
if ($index > 0)
{
$temp = $this->categories[$index-1];
$this->categories[$index - 1] = $this->categories[$index];
$this->categories[$index] = $temp;
}
}
SurveyCategories::removeCategories (   $array)

Removes many categories from the list of categories.

Removes many categories from the list of categories

Parameters
array$arrayAn array containing the index positions of the categories to be removed public
See Also
$categories

Definition at line 167 of file class.SurveyCategories.php.

{
foreach ($array as $index)
{
unset($this->categories[$index]);
}
$this->categories = array_values($this->categories);
}
SurveyCategories::removeCategory (   $index)

Removes a category from the list of categories.

Removes a category from the list of categories

Parameters
integer$indexThe index of the category to be removed public
See Also
$categories

Definition at line 152 of file class.SurveyCategories.php.

Referenced by removeCategoryWithName().

{
unset($this->categories[$index]);
$this->categories = array_values($this->categories);
}

+ Here is the caller graph for this function:

SurveyCategories::removeCategoryWithName (   $name)

Removes a category from the list of categories.

Removes a category from the list of categories

Parameters
string$nameThe name of the category to be removed public
See Also
$categories

Definition at line 185 of file class.SurveyCategories.php.

References removeCategory().

{
foreach ($this->categories as $index => $category)
{
if (strcmp($category->title, $name) == 0)
{
$this->removeCategory($index);
return;
}
}
}

+ Here is the call graph for this function:

SurveyCategories::SurveyCategories ( )

Constructor public.

Definition at line 52 of file class.SurveyCategories.php.

{
$this->categories = array();
}

Field Documentation

SurveyCategories::$categories

Definition at line 46 of file class.SurveyCategories.php.

Referenced by addCategoryArray().


The documentation for this class was generated from the following file: