Exemplo n.º 1
0
 public function getCourse(Slide $slide)
 {
     $result = $this->_access->getRow($this->_access->prepare("SELECT * FROM " . StudyPressDB::getTableNameLesson() . " WHERE " . StudyPressDB::COL_ID_ACTIVITY . " = '%d'", $slide->courseId()));
     return LessonManager::returnedLesson($result);
 }
Exemplo n.º 2
0
<?php

if (isset($_POST['type']) && $_POST['type'] === "order-activities") {
    if (isset($_POST['order']) && !empty($_POST['order'])) {
        require_once '_AutoLoadClassAjax.php';
        $managerLesson = new LessonManager();
        $v = new validation();
        $v->addSource($_POST['order']);
        foreach ($_POST['order'] as $key => $value) {
            if (preg_match('/^[0-9]{1,}$/', $key)) {
                $v->addRule($key, 'numeric', true, 1, 9999999, true);
            }
        }
        $v->run();
        if (sizeof($v->errors) > 0) {
            header("HTTP/1.0 400 Bad Request");
            echo $v->getMessageErrors();
        } else {
            $re = array();
            foreach ($v->sanitized as $ordre => $id) {
                $re[$id] = $ordre + 1;
                //+1 pour commencer de 1
            }
            $managerLesson->updateOrders($re);
            echo "true";
        }
    }
} else {
    if (!defined('ABSPATH')) {
        exit;
    }
Exemplo n.º 3
0
<?php

require_once '_AutoLoadClassAjax.php';
if (isset($_POST['id']) && !empty($_POST['id'])) {
    $v = new validation();
    $v->addSource($_POST);
    $v->addRule('id', 'numeric', true, 1, 99999, true);
    $v->run();
    if (sizeof($v->errors) === 0) {
        $managerLesson = new LessonManager();
        $managerQuiz = new QuizManager();
        $activity = $managerLesson->getById($v->sanitized['id']);
        if (!$activity) {
            $activity = $managerQuiz->getById($v->sanitized['id']);
        }
        if ($activity) {
            if (StudyPressUserWP::isLoggedIn()) {
                $currentUserId = new StudyPressUserWP();
                $currentUserId = $currentUserId->id();
                $managerLesson->setVisitedActivity($currentUserId, $activity->getId());
            }
        }
    }
}
Exemplo n.º 4
0
 public function getActivitiesOfCourse($courseId)
 {
     $activities = array();
     $result = $this->_access->getResults($this->_access->prepare("SELECT * FROM " . StudyPressDB::getTableNameActivity() . " WHERE " . StudyPressDB::COL_ID_COURSE_ACTIVITY . " = '%d' ORDER BY " . StudyPressDB::COL_ORDER_ACTIVITY . " ASC", $courseId));
     foreach ($result as $row) {
         $activity = array();
         if ($row[StudyPressDB::COL_TYPE_ACTIVITY] === "lesson") {
             $activity = LessonManager::returnedLesson($row);
         } else {
             $activity = QuizManager::returnedQuiz($row);
         }
         if ($activity) {
             $activities[] = $activity;
         }
     }
     return $activities;
 }
Exemplo n.º 5
0
 $c = new Configuration();
 $c = $c->getConfig();
 if ($c['bp_shareResult'] = 'true') {
     $v = new validation();
     $v->addSource($_POST);
     $v->addRule('quizId', 'numeric', true, 1, 9999999, true);
     $v->run();
     if (sizeof($v->errors) > 0) {
         header("HTTP/1.0 400 Bad Request");
         echo $v->getMessageErrors();
     } else {
         $manager = new QuizManager();
         $type = "quiz";
         $activity = $manager->getById($v->sanitized['quizId']);
         if (!$activity) {
             $manager = new LessonManager();
             $type = "lesson";
             $activity = $manager->getById($v->sanitized['quizId']);
         }
         if ($activity) {
             if (StudyPressUserWP::isLoggedIn()) {
                 $user = new StudyPressUserWP();
                 if ($manager->isDone($v->sanitized['quizId'], $user->id())) {
                     if (function_exists('bp_is_active') && bp_is_active('groups')) {
                         $permalink = get_permalink($activity->getPostId());
                         $med_image_url = $activity->getPicture();
                         if ($type === "quiz") {
                             $resultQuiz = $manager->getResultOfQuizByUser($v->sanitized['quizId'], $user->id());
                             if (!$resultQuiz) {
                                 exit;
                             }
Exemplo n.º 6
0
$access = new AccessData();
$user = new StudyPressUserWP();
$tableCat = StudyPressDB::getPrefix() . 'studi_category';
$tableCourse = StudyPressDB::getPrefix() . 'studi_course';
$tableSlides = StudyPressDB::getPrefix() . 'studi_slides';
$tableCategCourse = StudyPressDB::getPrefix() . 'studi_categ_cours';
if ($access->getVar("SHOW TABLES LIKE '{$tableCat}'") == $tableCat) {
    if ($access->getVar("SHOW TABLES LIKE '{$tableCourse}'") == $tableCourse) {
        $catWPId = wp_create_category('Temporary Category');
        $managerCourse = new CourseManager();
        $course = new Course(array('name' => 'Temporary Course', 'description' => '', 'authors' => array($user->id()), 'categories' => array($catWPId !== 0 ? $catWPId : 1)));
        $courseId = $managerCourse->add($course);
        $resultLesson = $access->getResults("SELECT * FROM {$tableCourse}");
        $authors = array();
        foreach ($resultLesson as $lesson) {
            $managerLesson = new LessonManager();
            if ($a = get_user_by('login', $lesson['author'])) {
                $authors[] = $a->ID;
            }
            $lessonId = $managerLesson->add(new Lesson(array('name' => $lesson['nom'] != "" ? $lesson['nom'] : "Course", 'author' => $a ? $a->display_name : $user->displayName(), 'authorId' => $a ? $a->ID : $user->id(), 'description' => $lesson['cours_des'], 'duration' => $lesson['duration'], 'courseId' => $courseId)));
            if (!in_array($user->id(), $authors)) {
                $authors[] = $user->id();
            }
            if ($access->getVar("SHOW TABLES LIKE '{$tableSlides}'") == $tableSlides) {
                $slidesResult = $access->getResults("SELECT * FROM {$tableSlides} WHERE course_id = '" . $lesson['course_id'] . "'");
                $managerSlide = new SlideManager();
                foreach ($slidesResult as $slide) {
                    $managerSlide->add(new Slide(array('courseId' => $lessonId, 'name' => $slide['slides_name'] != "" ? $slide['slides_name'] : "Slide", 'content' => $slide['slides_content'], 'order' => $slide['slides_order'])));
                }
            }
        }
Exemplo n.º 7
0
<?php

if (!defined('ABSPATH')) {
    exit;
}
wp_enqueue_media();
global $tr;
$managerLesson = new LessonManager();
$managerCourse = new CourseManager();
$error_lesson_add = "";
$error_lesson_remove = "";
if (isset($_GET['type']) && $_GET['type'] === "delete" && isset($_GET['id'])) {
    $validation = new validation();
    $validation->addSource(array('id' => $_GET['id']));
    $validation->addRule('id', 'numeric', true, 0, 1000000, true);
    $validation->run();
    if (sizeof($validation->errors) > 0) {
        $error_lesson_remove = $validation->getMessageErrors();
    } else {
        $lesson = $managerLesson->getById($validation->sanitized['id']);
        if ($lesson != null) {
            $managerLesson->delete($validation->sanitized['id']);
            if ($managerLesson->isError()) {
                $error_lesson_remove = $managerLesson->getMessageError();
            }
        }
    }
}
if (isset($_POST['add'])) {
    if (isset($_POST['lesson']) && !empty($_POST['lesson'])) {
        $v = new validation();
Exemplo n.º 8
0
<?php

/**
 * Created by PhpStorm.
 * User: Salim
 * Date: 03/02/2015
 * Time: 21:16
 */
if (isset($_POST['id_lesson'])) {
    require_once '_AutoLoadClassAjax.php';
    global $tr;
    $managerLesson = new LessonManager();
    $v = new validation();
    $v->addSource($_POST);
    $v->AddRules(array('id_lesson' => array('type' => 'numeric', 'required' => 'true', 'min' => '1', 'max' => '999999', 'trim' => 'true')));
    $v->run();
    /*
     * Si un/des champs ne est/sont pas valide(s)...
     *
     */
    if (sizeof($v->errors) > 0) {
        header("HTTP/1.0 400 Bad Request");
    } else {
        $lesson = $managerLesson->getById($v->sanitized['id_lesson']);
        if ($lesson) {
            $result = "";
            if (count($lesson->getSlides())) {
                foreach ($lesson->getSlides() as $slide) {
                    ?>

                    <li id="li-sotable" class="ui-state-default btn btn-default"
Exemplo n.º 9
0
<?php

global $tr;
if (isset($_POST['type']) && $_POST['type'] === "post") {
    if (isset($_POST['id'])) {
        require_once '_AutoLoadClassAjax.php';
        $managerLesson = new LessonManager();
        $v = new validation();
        $v->addSource($_POST);
        $v->AddRules(array('id' => array('type' => 'numeric', 'required' => 'true', 'min' => '1', 'max' => '999999', 'trim' => 'true')));
        $v->run();
        if (sizeof($v->errors) > 0) {
            header("HTTP/1.0 400 Bad Request");
        } else {
            $lesson = $managerLesson->getById($v->sanitized['id']);
            if ($lesson) {
                $btn_post = "<button type='button' id='post-lesson' data-id='" . $lesson->getId() . "' class='btn btn-primary'>" . $tr->__("Publish") . "</button>";
                $btn_remove = "<button type='button' id='post-lesson' data-id='" . $lesson->getId() . "' class='btn btn-danger'>" . $tr->__("Remove") . "</button>";
                if ($lesson->getPostId() === 0) {
                    $postId = $managerLesson->post($lesson);
                    if (AbstractActivityManager::isBuddyPressActive()) {
                        $permalink = get_permalink($postId);
                        $action = $lesson->getAuthor() . " " . $tr->__("shared a lesson") . " : " . "<a href='{$permalink}'>" . $lesson->getName() . "</a>";
                        $imageUrl = $lesson->getPicture();
                        $content = "<a href='{$permalink}'><img src='{$imageUrl}' width='150' height='150' /></a>";
                        $managerLesson->shareOnGroupsBP($lesson, $action, $content);
                    }
                    $result['result'] = "true";
                    $result['value'] = $btn_remove;
                    echo json_encode($result);
                } else {
Exemplo n.º 10
0
<?php

if (!defined('ABSPATH')) {
    exit;
}
wp_enqueue_media();
global $tr;
$user = new StudyPressUserWP();
$managerLesson = new LessonManager();
$managerCourse = new CourseManager();
$lesson = null;
$error_lesson_update = "";
$error_lesson_add_slide = "";
if (isset($_GET['id']) && !empty($_GET['id'])) {
    $v = new validation();
    $v->addSource($_GET);
    $v->addRule('id', 'numeric', true, 1, 9999999, true);
    $v->run();
    if (!sizeof($v->errors) > 0) {
        $lesson = $managerLesson->getById($v->sanitized['id']);
        if ($lesson) {
            if (isset($_POST['update'])) {
                $v = new validation();
                $v->addSource($_POST['lesson']);
                $v->AddRules(array('id' => array('type' => 'numeric', "required" => true, 'min' => '1', 'max' => '999999', 'trim' => true), 'name' => array('type' => 'string', "required" => true, 'min' => '1', 'max' => '400', 'trim' => true), 'description' => array('type' => 'string', "required" => true, 'min' => '0', 'max' => '999999', 'trim' => true), 'duree' => array('type' => 'numeric', "required" => true, 'min' => '0', 'max' => '999999', 'trim' => true), 'pictureurl' => array('type' => 'numeric', "required" => false, 'min' => '0', 'max' => '999999', 'trim' => true), 'courseId' => array('type' => 'numeric', "required" => false, 'min' => '0', 'max' => '999999', 'trim' => true)));
                $v->run();
                $notes = isset($_POST['lesson']['note']) ? json_encode($_POST['lesson']['note']) : "";
                $glossaires = isset($_POST['lesson']['glossary']) ? json_encode($_POST['lesson']['glossary']) : "";
                if (sizeof($v->errors) > 0) {
                    $error_lesson_update = $v->getMessageErrors();
                } else {