Пример #1
0
function sp_notice_sp_migrate()
{
    $sp_user = new StudyPressUserWP();
    global $tr;
    $user_id = $sp_user->id();
    if (isset($_GET['sp_ignore_migrate']) && $_GET['sp_ignore_migrate'] == '0') {
        update_user_meta($user_id, 'sp_menu_add_warning_migrate', false);
    }
    if (get_user_meta($user_id, 'sp_menu_add_warning_migrate', true)) {
        ?>

        <div class="error">
                <?php 
        echo $tr->__("This is a fresh installation of StudyPress. Since the version 1.0 contains multiple new functionalities and has a new way to organize lessons and courses, all courses that you have created were assigned to one category. Don't forget to reorganize your courses. ") . " | <a href='?page=id_Cours&sp_ignore_migrate=0'>" . $tr->__('Hide Notice') . "</a>";
        ?>

        </div>

    <?php 
    }
}
<?php

global $tr;
require_once '_AutoLoadClassAjax.php';
$aResponse['error'] = false;
$aResponse['message'] = '';
if (StudyPressUserWP::isLoggedIn()) {
    if (isset($_POST['action'])) {
        if (htmlentities($_POST['action'], ENT_QUOTES, 'UTF-8') == 'rating') {
            $lessonId = (int) (isset($_POST['idBox']) ? $_POST['idBox'] : 0);
            $value = (int) (isset($_POST['rate']) ? $_POST['rate'] : 0);
            $userId = (int) (isset($_POST['user']) ? $_POST['user'] : 0);
            $managerRate = new RateQualityManager();
            $currentUser = new StudyPressUserWP();
            if ($value >= 1 && $value <= 5 && $currentUser->id() === $userId) {
                if ($rate = $managerRate->voteExist($lessonId, $userId)) {
                    $rate->setValue($value);
                    $rate->setDateRate(StudyPressDB::getCurrentDateTime());
                    $managerRate->update($rate->getId(), $rate);
                } else {
                    $managerRate->add(new RateQuality(array('value' => $value, 'userId' => $userId, 'activityId' => $lessonId, 'dateRate' => StudyPressDB::getCurrentDateTime())));
                }
                if ($managerRate->isError()) {
                    $success = false;
                } else {
                    $success = true;
                }
            } else {
                $success = false;
            }
            if ($success) {
global $tr;
require_once '_AutoLoadClassAjax.php';
$aResponse['error'] = false;
$aResponse['message'] = '';
if (StudyPressUserWP::isLoggedIn()) {
    if (isset($_POST['action'])) {
        if (htmlentities($_POST['action'], ENT_QUOTES, 'UTF-8') == 'rating') {
            $activityId = (int) (isset($_POST['idBox']) ? $_POST['idBox'] : 0);
            $value = (int) (isset($_POST['rate']) ? $_POST['rate'] : 0);
            $userId = (int) (isset($_POST['user']) ? $_POST['user'] : 0);
            $domainId = (int) (isset($_POST['domain']) ? $_POST['domain'] : 0);
            $managerRate = new RateDomainManager();
            $managerDomain = new DomainManager();
            $currentUser = new StudyPressUserWP();
            if ($value >= 1 && $value <= 5 && $currentUser->id() === $userId && $managerDomain->getById($domainId)) {
                if ($rate = $managerRate->voteExist($activityId, $userId, $domainId)) {
                    $rate->setValue($value);
                    $rate->setDateRate(StudyPressDB::getCurrentDateTime());
                    $managerRate->update($rate->getId(), $rate);
                } else {
                    $managerRate->add(new RateDomain(array('value' => $value, 'userId' => $userId, 'activityId' => $activityId, 'dateRate' => StudyPressDB::getCurrentDateTime(), 'domainId' => $domainId)));
                }
                if ($managerRate->isError()) {
                    $success = false;
                } else {
                    $success = true;
                }
            } else {
                $success = false;
            }
Пример #4
0
        $v->addRule('name', 'string', true, 1, 200, true);
        //rule Image
        if (isset($_POST['quiz']['pictureurl']) && !empty($_POST['quiz']['pictureurl'])) {
            $v->addRule('pictureurl', 'numeric', true, 1, 999999, true);
        }
        if (isset($_POST['quiz']['courseId']) && !empty($_POST['quiz']['courseId'])) {
            $v->addRule('courseId', 'numeric', true, 1, 99999, true);
        } else {
            $v->errors['courseId'] = $tr->__("You must create a course");
        }
        $v->run();
        if (sizeof($v->errors) > 0) {
            $error_quiz_add = $v->getMessageErrors();
        } else {
            $currentUser = new StudyPressUserWP();
            $id_quiz = $managerQuiz->add(new Quiz(array('pictureUrl' => isset($v->sanitized['pictureurl']) ? $v->sanitized['pictureurl'] : '', 'name' => $v->sanitized['name'], 'author' => $currentUser->displayName(), 'authorId' => $currentUser->id(), 'courseId' => $v->sanitized['courseId'])));
        }
    }
}
if (isset($_POST['remove'])) {
    if (isset($_POST['id']) && !empty($_POST['id'])) {
        $v = new validation();
        $v->addSource($_POST['id']);
        foreach ($_POST['id'] as $key => $value) {
            $v->addRule($key, 'numeric', true, 1, 9999999, true);
        }
        $v->run();
        if (sizeof($v->errors) > 0) {
            $error_quiz_remove = $v->getMessageErrors();
        } else {
            foreach ($v->sanitized as $value) {
Пример #5
0
                        $v->AddRules(array('id' => array('type' => 'numeric', "required" => true, 'min' => '1', 'max' => '999999', 'trim' => true), 'description' => array('type' => 'string', "required" => true, 'min' => '0', 'max' => '999999', 'trim' => true)));
                        if (isset($_POST['course']['pictureId']) && !empty($_POST['course']['pictureId'])) {
                            $v->addRule('pictureId', 'numeric', true, 1, 999999, true);
                        }
                        $v->run();
                        if (sizeof($v->errors)) {
                            $error_course_update = $v->getMessageErrors();
                        } else {
                            if ($course = $managerCourse->getById($v->sanitized['id'])) {
                                $course->setDescription($v->sanitized['description']);
                                if (isset($v->sanitized['pictureId'])) {
                                    $course->setPictureId($v->sanitized['pictureId']);
                                }
                                $managerCourse->update($course->getId(), $course);
                            }
                        }
                    }
                }
            } else {
                wp_die("Access denied !");
            }
            if ($user->isAdministrator() || in_array($user->id(), $course->getAuthors())) {
                require_once __ROOT_PLUGIN__ . "Views/admin/modCourse.view.php";
            } else {
                wp_die("Access denied !");
            }
        } else {
            echo "<h3>" . $tr->__("Page not found") . " !!</h3>";
        }
    }
}
Пример #6
0
 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;
                         }
                         if (isset($_POST['type_share']) && $_POST['type_share'] === 'result') {
                             $action = $user->displayName() . " " . $tr->__("obtained") . " " . $resultQuiz->getNote() . "% " . $tr->__("in") . " : <a href='{$permalink}'>" . $activity->getName() . "</a>";
                         } else {
                             $action = $user->displayName() . $tr->__(" shared Quiz") . " : " . "<a href='{$permalink}' style='display: block'>" . $activity->getName() . "</a>";
                         }
                     }
                     if ($type === "lesson") {
Пример #7
0
if ($id !== null) {
    $currentUser = new StudyPressUserWP();
    $v = new validation();
    $v->addSource(array('id' => $id));
    $v->AddRules(array('id' => array('type' => 'numeric', 'required' => 'true', 'min' => '1', 'max' => '999999', 'trim' => 'true')));
    $v->run();
    if (sizeof($v->errors) > 0) {
        $tr->_e("The value of the identifier of the shortcode is incorrect");
    } else {
        $managerQuiz = new QuizManager();
        $quiz = $managerQuiz->getById($v->sanitized['id']);
        if ($quiz) {
            $sp_btn_share = "<button class='btn-share' title='" . $tr->__("Share") . "'>" . $tr->__("Share") . "</button>";
            $btn_buddypress_share = "";
            $btn_social_share = "";
            $v = $currentUser->isLoggedIn() ? sha1($currentUser->id()) : "";
            $path_json = "Public/Quiz/" . $quiz->getId() . $v . ".json";
            $json_file = __ROOT_PLUGIN__ . $path_json;
            $sp_user = new StudyPressUserWP($quiz->getAuthorId());
            $sp_userName = $sp_user->firstName() . ' ' . $sp_user->lastName();
            $sp_userLink = StudyPressUserWP::getUserPostsLink($quiz->getAuthorId());
            $items = array();
            $owl['items'][] = array('name' => $tr->__('Presentation'), 'content' => slide_presentation_quiz($quiz, $sp_userName));
            $resultContent = "";
            if ($spConfiguration['share_socialNetwork'] === 'true') {
                $btn_social_share = "<button class='btn-facebook' id='btn-social' title='Facebook'> <span>facebook</span ></button>";
                $btn_social_share .= "<button class='btn-twitter' id='btn-social' title='Twitter'> <span>Twitter</span></button>";
                $btn_social_share .= "<button class='btn-google' id='btn-social'  title='Google+'> <span>Google+</span></button>";
                $btn_social_share .= "<button class='btn-linkedin' id='btn-social' title='LinkedIn'> <span>LinkedIn</span></button>";
            }
            $result = $managerQuiz->getResultOfQuizByUser($id, $currentUser->id());
Пример #8
0
                        <th><?php 
$tr->_e("Publication");
?>
</th>
                    </tr>

                </thead>
                <tbody>
                
                <?php 
$__lessons = array();
$currentUser = new StudyPressUserWP();
if ($currentUser->isAdministrator()) {
    $__lessons = $managerLesson->getAllWithoutSlides();
} else {
    $__courses = $managerCourse->getCoursesByAuthor($currentUser->id());
    foreach ($__courses as $c) {
        $_lessons = $managerLesson->getLessonsOfCourse($c->getId());
        $__lessons = array_merge($__lessons, $_lessons);
    }
}
if (empty($__lessons)) {
    echo "<tr><td colspan='5'>" . $tr->__("No lessons") . "</td></tr>";
} else {
    foreach ($__lessons as $row) {
        $url_mod_lesson = "?page=mod-lesson&id=" . $row->getId();
        $url_delete_lesson = "?page=id_Cours&type=delete&id=" . $row->getId();
        ?>
                        <tr class="tr-div" >
                            <td><input type='checkbox' name="id[]" value='<?php 
        echo $row->getId();
Пример #9
0
 function sp_notice_warning_migrate()
 {
     $sp_user = new StudyPressUserWP();
     add_user_meta($sp_user->id(), 'sp_menu_add_warning_migrate', true, true);
 }
Пример #10
0
?>
</th>
                    <th><?php 
$tr->_e('Lessons');
?>
</th>
                    <th><?php 
$tr->_e('Quiz');
?>
</th>
                </tr>
                </thead>
                <tbody>
                
                <?php 
$__courses = $managerCourse->getCoursesByAuthor($user->id());
$colSpan = $user->isAdministrator() ? "7" : "6";
if (empty($__courses)) {
    echo "<tr><td colspan='" . $colSpan . "'>" . $tr->__('No Courses') . "</td></tr>";
} else {
    foreach ($__courses as $row) {
        $url_mod_course = "?page=mod-course&id=" . $row->getId();
        ?>
                    <tr>
                        <?php 
        if ($user->isAdministrator()) {
            ?>
                        <td><input type='checkbox' name="id[]" value='<?php 
            echo $row->getId();
            ?>
'/></td>
Пример #11
0
                $responseHtml = "";
                foreach ($questionsNoConnected as $q) {
                    $responseHtml[] = $q->getContentSlideWithErrors();
                }
                $result['qcm'] = $responseHtml;
            }
            $class = (int) $poucentage >= 50 ? "green" : "red";
            $result['content'] = "<div class='sp-postit'><p>" . $tr->__("You obtained") . ":</p><strong class='" . $class . "'>" . $poucentage . "% </strong></div>";
            $result['result'] = 'true';
            echo json_encode($result);
        }
    }
}
if (isset($_POST['type']) && $_POST['type'] === "start") {
    if (isset($_POST['quizId']) && isset($_POST['date'])) {
        require_once '_AutoLoadClassAjax.php';
        global $tr;
        if (StudyPressUserWP::isLoggedIn()) {
            $date = $_POST['date'];
            $quizId = (int) $_POST['quizId'];
            $managerQuiz = new QuizManager();
            if ($quiz = $managerQuiz->getById($quizId)) {
                $user = new StudyPressUserWP();
                $managerQuiz->saveResult($quizId, $user->id(), null, null, null, null, $date, "false");
                echo "true";
            }
        } else {
            echo "true";
        }
    }
}
Пример #12
0
 if (!sizeof($v->errors) > 0) {
     $quiz = $managerQuiz->getById($v->sanitized['id']);
     if ($quiz) {
         if (isset($_POST['update'])) {
             //var_dump($_POST);
             $v = new validation();
             $v->addSource($_POST['quiz']);
             $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['quiz']['note']) ? json_encode($_POST['quiz']['note']) : "";
             $glossaires = isset($_POST['quiz']['glossary']) ? json_encode($_POST['quiz']['glossary']) : "";
             if (sizeof($v->errors) > 0) {
                 $error_quiz_update = $v->getMessageErrors();
             } else {
                 $currentUser = new StudyPressUserWP();
                 if ($managerCourse->getCoursesByAuthor($currentUser->id())) {
                     $quiz = $managerQuiz->getById($v->sanitized['id']);
                     $quiz->setName($v->sanitized['name']);
                     $quiz->setCourseId($v->sanitized['courseId']);
                     $quiz->setDescription($v->sanitized['description']);
                     $quiz->setDuration($v->sanitized['duree']);
                     $quiz->setPictureUrl($v->sanitized['pictureurl']);
                     $quiz->setTags($notes);
                     $quiz->setGlossary($glossaires);
                     $managerQuiz->update($v->sanitized['id'], $quiz);
                     $quiz = $managerQuiz->getById($v->sanitized['id']);
                 }
             }
         }
     } else {
         wp_die("Access denied !");
Пример #13
0
                    $type = $tr->__("Quiz");
                    $manager = $managerQuiz;
                }
                $med_image_url = wp_get_attachment_image_src($activity->getPictureUrl(), $size = 'thumbnail');
                if (!$med_image_url[0]) {
                    $med_image_url[0] = __ROOT_PLUGIN__2 . "images/" . $image . ".png";
                }
                ?>


                <li>
                    <div>
                        <?php 
                if (StudyPressUserWP::isLoggedIn()) {
                    $user = new StudyPressUserWP();
                    if ($manager->isDone($activity->getId(), $user->id())) {
                        $nbrDone++;
                        ?>
                                <!--<div class="border-green"></div>--><p class="done" title="<?php 
                        echo $tr->__("Done");
                        ?>
">
                                <span class="glyphicon glyphicon-ok"></span></p>
                            <?php 
                    }
                }
                ?>


                        <div class="thumb">
                            <img src="<?php 
Пример #14
0
        ?>
"> <?php 
        echo $row->getNote();
        ?>
%</td>
                        <td> <?php 
        echo $row->getNbrCorrectResponse() . "/" . $row->getNbrQuestions();
        ?>
</td>
                        <td> <?php 
        echo $row->getDateResult();
        ?>
</td>
                        <td>
                            <a id="get-responses" data-id ="<?php 
        echo $user->id();
        ?>
" href="#">
                                <span class="glyphicon glyphicon-new-window"  data-toggle="modal" data-target="#myModal" aria-hidden="true" title="Afficher"></span>
                            </a>
                        </td>
                    </tr>

                <?php 
    }
    ?>
                </tbody>

                <?php 
}
?>