<?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"> <?php
$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) {
$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") { $action = $user->displayName() . $tr->__(" shared Lesson") . " : " . "<a href='{$permalink}' style='display: block'>" . $activity->getName() . "</a>"; } $content = "<a href='{$permalink}' style='display: block'><img src='{$med_image_url}' width='150' height='150' /> </a>\r\n " . (isset($_POST['comment']) ? $_POST['comment'] : ""); if (count($_POST['groups']) === 1 && $_POST['groups'][0] === '0') { $activity_id = bp_activity_add(array('user_id' => $user->id(), 'component' => 'groups', 'type' => 'activity_update', 'action' => $action, 'content' => $content, 'item_id' => '0')); echo "true"; } else { if (count($_POST['groups']) > 1) { foreach ($_POST['groups'] as $groupId) { if ($groupId === '0') {
$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']))); } } } $course->setAuthors($authors); $managerCourse->update($courseId, $course); add_action('admin_init', 'sp_notice_warning_migrate'); function sp_notice_warning_migrate()
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); }
$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"; }
</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(); ?> </td> <td> <?php echo $row->getDateResult();