Beispiel #1
0
                if (isset($_GET['id']) && eF_checkParameter($_GET['id'], 'id') && isset($_GET['directions_ID']) && eF_checkParameter($_GET['directions_ID'], 'id')) {
                    $course = new EfrontCourse($_GET['id']);
                    if ($_GET['directions_ID'] != $course->course['directions_ID']) {
                        $updateCourseInstancesCategory = true;
                        //This means we need to update instances to match the course's new category
                    }
                    $course->course['directions_ID'] = $_GET['directions_ID'];
                    $course->persist();
                    if (isset($updateCourseInstancesCategory) && $updateCourseInstancesCategory) {
                        eF_updateTableData("courses", array("directions_ID" => $course->course['directions_ID']), "instance_source=" . $course->course['id']);
                    }
                }
                exit;
            } catch (Exception $e) {
                echo $e->getMessage() . ' (' . $e->getCode() . ')';
            }
        }
    }
} else {
    $directionsTree = new EfrontDirectionsTree();
    $directionsPaths = $directionsTree->toPathString(false);
    $flatTree = $directionsTree->getFlatTree();
    foreach ($flatTree as $key => $value) {
        $flatTree[$key]['pathString'] = $directionsPaths[$value['id']];
        $direction = new EfrontDirection($flatTree[$key]);
        $flatTree[$key]['lessons'] = sizeof($direction->getLessons());
        $flatTree[$key]['courses'] = sizeof($direction->getCourses());
    }
    unset($value);
    $smarty->assign("T_DIRECTIONS_DATA", $flatTree);
}
 /**
  * Delete category (statically)
  *
  * This function is used to delete an existing category.
  * This function is the same as EfrontDirection :: delete(),
  * except that it is called statically
  * <br/>Example:
  * <code>
  * try {
  *   EfrontDirection :: delete(32);					 //32 is the category id
  * } catch (Exception $e) {
  *   echo $e -> getMessage();
  * }
  * </code>
  *
  * @param mixed $category The category id or a category object
  * @return boolean True if everything is ok
  * @since 3.5.0
  * @access public
  * @static
  */
 public static function deleteDirection($category)
 {
     if (!$category instanceof EfrontDirection) {
         $category = new EfrontDirection($category);
     }
     return $category->delete();
 }
                 // the total_questions and questions fields of the array will be completed correctly in step 2
             } else {
                 $skills_to_cover[$key] = array("id" => $key, "questions_asked" => $_POST['skill_questions_count_' . $row], "total_questions" => 0, "questions" => array());
             }
         }
     }
 }
 // Three steps algorithm:
 // 1) get all lessons involved (from directions-> lessons, from directions->courses->lessons
 //    and from courses->lessons) posted. If no lessons posted then use all system lessons
 // 2) get the count for the questions of each lesson
 // 3) create a random assignment of questions according to posted values and availability
 /********** STEP 1 **********/
 // Get all lessons array for the courses and directions involved
 foreach ($directions_to_cover as $directionId => $directionInfo) {
     $direction = new EfrontDirection($directionId);
     // Get all direction lessons
     $directionLessons = $direction->getLessons();
     $directions_to_cover[$directionId]['lessons'] = array();
     $directions_to_cover[$directionId]['lessonsCount'] = sizeof($directionLessons);
     // used with rand()
     foreach ($directionLessons as $lessonId => $lesson) {
         $directions_to_cover[$directionId]['lessons'][] = $lessonId;
         if (!isset($lessons_to_cover[$lessonId])) {
             $lessons_to_cover[$lessonId] = array("id" => $lessonId, "questions_asked" => 0, "total_questions" => 0, "questions" => array());
         }
     }
     // Get all direction courses lessons
     $directionCourses = $direction->getCourses();
     foreach ($directionCourses as $courseId => $courseInfo) {
         $course = new EfrontCourse($courseId);