Ejemplo n.º 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 
    }
}
Ejemplo n.º 2
0
            $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;
    }
    wp_enqueue_media();
    global $tr;
    $user = new StudyPressUserWP();
    $managerCourse = new CourseManager();
    $course = null;
    $error_course_update = "";
    $error_course_add = "";
    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) {
            $course = $managerCourse->getById($v->sanitized['id']);
            if ($course) {
                if (isset($_POST['update'])) {
                    if ($user->isAdministrator()) {
                        if (isset($_POST['course']) && isset($_POST['course']['categories']) && isset($_POST['course']['users'])) {
Ejemplo n.º 3
0
 $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;
                         }
                         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>";
                         }
                     }
Ejemplo n.º 4
0
 public function getCoursesByAuthor($authorId)
 {
     $user = new StudyPressUserWP($authorId);
     if ($user->isAdministrator()) {
         return $this->getAll();
     }
     $courses = array();
     $result = $this->_access->getResults($this->_access->prepare("SELECT " . StudyPressDB::COL_ID_COURSE_USERS_N_COURSE . " FROM " . StudyPressDB::getTableName_CourseUsers() . " WHERE " . StudyPressDB::COL_ID_USERS_USERS_N_COURSE . " = '%d' ORDER BY " . StudyPressDB::COL_ID_COURSE_USERS_N_COURSE . " DESC ", $authorId));
     foreach ($result as $row) {
         $id = $row[StudyPressDB::COL_ID_COURSE_USERS_N_COURSE];
         $course = $this->getById($id);
         array_push($courses, $course);
     }
     return $courses;
 }
Ejemplo n.º 5
0
 $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());
         if ($result && $result->isValide()) {
             if (function_exists('bp_is_active') && bp_is_active('groups') && $spConfiguration['bp_shareResult'] === 'true' && StudyPressUserWP::isLoggedIn()) {
                 $btn_buddypress_share = "<button class='btn-buddypress' id='btn-social' title='BuddyPress'><span>Buddypress</span></button>";
Ejemplo n.º 6
0
        $v->AddRules(array('quizId' => array('type' => 'numeric', 'required' => 'true', 'min' => '1', 'max' => '999999', 'trim' => 'true'), 'userId' => 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 {
            $managerQuiz = new QuizManager();
            if ($quiz = $managerQuiz->getById($v->sanitized['quizId'])) {
                $resultQuiz = $managerQuiz->getResultOfQuizByUser($quiz->getId(), $v->sanitized['userId']);
                if ($resultQuiz) {
                    $result['body'] = "";
                    foreach ($resultQuiz->getQuestions() as $q) {
                        $result['body'] .= $q->getContentSlideWithErrors();
                    }
                    $classe = $resultQuiz->getNote() > 50 ? "green" : "red";
                    $result['pourcentage'] = $tr->__("Note") . " : <span class='" . $classe . "'>" . $resultQuiz->getNote() . "%</span>";
                    $result['quiz'] = $tr->__("Name of quiz") . " : " . $quiz->getName();
                    $user = new StudyPressUserWP($v->sanitized['userId']);
                    $result['user'] = $tr->__("User") . " : " . $user->displayName();
                    $result['result'] = "true";
                    echo json_encode($result);
                }
            }
        }
    }
} else {
    if (!defined('ABSPATH')) {
        exit;
    }
    $managerResult = new QuizManager();
    require_once __ROOT_PLUGIN__ . "Views/admin/resultQuiz.view.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) {
Ejemplo n.º 8
0
        //rule Name
        $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 {
Ejemplo n.º 9
0
</style>

<h1>
    <?php 
$tr->_e("Course");
?>


</h1>

<div class="container-fluid">

<?php 
sp_display_link_help();
$user = new StudyPressUserWP();
?>


    <div class="row">

        <div class="<?php 
echo $user->isAdministrator() ? "col-md-8" : "col-md-12";
?>
">
            <h3><?php 
$tr->_e('All courses');
?>
</h3>
            <div class="alert alert-danger" role="alert" <?php 
echo $error_course_remove == '' ? 'style=\'display:none\'' : '';
Ejemplo n.º 10
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";
        }
    }
}
Ejemplo n.º 11
0
"/>

                        </div>




                    </div>
                    <div class="form-group">
                        <label for="courseId"><?php 
$tr->_e("Associate to a course");
?>
*</label>
                        <select name="lesson[courseId]" id="courseId" class="form-control">
                            <?php 
$userCourse = new StudyPressUserWP($lesson->getAuthorId());
$courses = $managerCourse->getCoursesByAuthor($userCourse->id());
foreach ($courses as $course) {
    $selected = $course->getId() === $lesson->getCourseId() ? "selected" : "";
    echo "<option value='" . $course->getId() . "' " . $selected . ">" . $course->getName() . "</option>";
}
?>

                        </select>
                    </div>



                    <div class="col-md-6">
                        <div class="panel panel-default">
                            <div class="panel-heading"><?php 
Ejemplo n.º 12
0
 $v->run();
 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 {
Ejemplo n.º 13
0
                    $image = "quiz";
                    $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">
Ejemplo n.º 14
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());
            }
        }
    }
}
Ejemplo n.º 15
0
 public function getStringAuthors()
 {
     global $tr;
     if (!count($this->_authors)) {
         $allName[] = $tr->__("None");
     } else {
         foreach ($this->_authors as $authorId) {
             $user = new StudyPressUserWP($authorId);
             $allName[] = $user->displayName();
         }
     }
     return implode(", ", $allName);
 }
Ejemplo n.º 16
0

                    <?php 
} else {
    ?>

                        <div class="row">
                            <div class="col-md-4">
                                <h4><?php 
    echo $tr->__("Authors");
    ?>
:</h4>
                                <ul class="list-group">
                                    <?php 
    foreach ($course->getAuthors() as $authorId) {
        $userNicename = new StudyPressUserWP($authorId);
        echo "<li class='list-group-item'>" . $userNicename->displayName() . "</li>";
    }
    ?>
                                </ul>
                            </div>



                            <div class="col-md-4">

                                <h4><?php 
    echo $tr->__("Categories");
    ?>
:</h4>
                                <ul class="list-group">
Ejemplo n.º 17
0
 function sp_notice_warning_migrate()
 {
     $sp_user = new StudyPressUserWP();
     add_user_meta($sp_user->id(), 'sp_menu_add_warning_migrate', true, true);
 }
Ejemplo n.º 18
0
<?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') {
            $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;
Ejemplo n.º 19
0
                        <th><?php 
$tr->_e("Author");
?>
</th>
                        <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();
Ejemplo n.º 20
0
<?php

if (!defined('ABSPATH')) {
    exit;
}
wp_enqueue_media();
global $tr;
$managerCourse = new CourseManager();
$error_course_add = "";
$error_course_remove = "";
$user = new StudyPressUserWP();
if ($user->isAdministrator()) {
    if (isset($_POST['add'])) {
        if (isset($_POST['course']) && !empty($_POST['course'])) {
            $v1 = new validation();
            $v2 = new validation();
            $v1->addSource($_POST['course']);
            $v1->addRule('name', 'string', true, 1, 200, true);
            $v1->addRule('desc', 'string', true, 0, 999999, true);
            if (isset($_POST['course']['pictureId']) && !empty($_POST['course']['pictureId'])) {
                $v1->addRule('pictureId', 'numeric', true, 1, 999999, true);
            }
            foreach ($_POST['course'] as $key => $value) {
                if (preg_match('/^[0-9]{1,}$/', $key)) {
                    $v1->addRule($key . "", 'numeric', true, 1, 200, true);
                }
            }
            if (isset($_POST['course']['users'])) {
                $v2->addSource($_POST['course']['users']);
                foreach ($_POST['course']['users'] as $key => $value) {
                    if (preg_match('/^[0-9]{1,}$/', $key)) {
Ejemplo n.º 21
0
</th>
                    <th><?php 
$tr->_e('Details');
?>
</th>
                </tr>
                </thead>
                <tbody>

                <?php 
$__results = $managerResult->getResultByQuiz($_GET['id']);
if (empty($__results)) {
    echo "<tr><td colspan='7'>" . $tr->__('No results') . "</td></tr>";
} else {
    foreach ($__results as $row) {
        $user = new StudyPressUserWP($row->getUserId());
        ?>
                    <tr>
                        <td> <?php 
        echo $user->displayName();
        ?>
 </a></td>
                        <td class="<?php 
        echo $row->getNote() >= 50 ? "green" : "red";
        ?>
"> <?php 
        echo $row->getNote();
        ?>
%</td>
                        <td> <?php 
        echo $row->getNbrCorrectResponse() . "/" . $row->getNbrQuestions();