Esempio n. 1
0
 /**
  * Constructor of the class Category
  * @author - Hubert Borderiou
  * If you give an in_id and no in_name, you get info concerning the category of id=in_id
  * otherwise, you've got an category objet avec your in_id, in_name, in_descr
  * @todo fix this function
  *
  * @param int $in_id
  * @param string $in_name
  * @param string $in_description
  * @param int $parent_id
  * @param string $type Posible values: all, simple, global
  * @param int $course_id
  * @param int visibility
  */
 public function Testcategory($in_id = 0, $in_name = '', $in_description = "", $parent_id = 0, $type = 'simple', $course_id = null, $visibility = 1)
 {
     if ($in_id != 0 && $in_name == "") {
         $tmpobj = new Testcategory();
         $tmpobj->getCategory($in_id);
         $this->id = $tmpobj->id;
         $this->name = $tmpobj->name;
         $this->title = $tmpobj->name;
         $this->description = $tmpobj->description;
         $this->parent_id = $tmpobj->parent_id;
         $this->parent_path = $this->name;
         $this->c_id = $tmpobj->c_id;
         $this->root = $tmpobj->root;
         $this->visibility = $tmpobj->visibility;
         if (!empty($tmpobj->parent_id)) {
             $category = new Testcategory($tmpobj->parent_id);
             $this->parent_path = $category->parent_path . ' > ' . $this->name;
         }
     } else {
         $this->id = $in_id;
         $this->name = $in_name;
         $this->description = $in_description;
         $this->parent_id = $parent_id;
         $this->visibility = $visibility;
     }
     $this->type = $type;
     if (!empty($course_id)) {
         $this->course_id = $course_id;
     } else {
         $this->course_id = api_get_course_int_id();
     }
 }
 /**
  * Constructor of the class Category
  * @author - Hubert Borderiou
  * If you give an in_id and no in_name, you get info concerning the category of id=in_id
  * otherwise, you've got an category objet avec your in_id, in_name, in_descr
  *
  * @param int $in_id
  * @param string $in_name
  * @param string $in_description
  */
 public function Testcategory($in_id = 0, $in_name = '', $in_description = "")
 {
     if ($in_id != 0 && $in_name == "") {
         $tmpobj = new Testcategory();
         $tmpobj->getCategory($in_id);
         $this->id = $tmpobj->id;
         $this->name = $tmpobj->name;
         $this->description = $tmpobj->description;
     } else {
         $this->id = $in_id;
         $this->name = $in_name;
         $this->description = $in_description;
     }
 }
Esempio n. 3
0
     if (empty($mediaId)) {
         echo 0;
         break;
     }
     $categoryId = $question->allQuestionWithMediaHaveTheSameCategory($exerciseId, $mediaId, null, null, true);
     if (!empty($categoryId)) {
         $category = new Testcategory($categoryId);
         echo json_encode(array('title' => $category->title, 'value' => $category->id));
     } else {
         echo -1;
     }
     break;
 case 'exercise_category_exists':
     $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : 'simple';
     $category = new Testcategory(null, null, null, null, $type);
     $category->getCategory($_REQUEST['id']);
     if (empty($category->id)) {
         echo 0;
     } else {
         $courseId = api_get_course_int_id();
         if (isset($courseId)) {
             // Global
             if ($category->c_id == 0) {
                 echo 1;
                 exit;
             } else {
                 // Local
                 if ($category->c_id == $courseId) {
                     echo 1;
                     exit;
                 }