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());
<?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) {
$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 { $managerLesson = new LessonManager(); $lesson = $managerLesson->getById($v->sanitized['id']); if ($lesson) { $sp_btn_share = "<button class='btn-share' title='" . $tr->__("Share") . "'>" . $tr->__("Share") . "</button>"; $btn_buddypress_share = ""; $btn_social_share = ""; $json_file = __ROOT_PLUGIN__ . "Public/Lesson/" . sha1($lesson->getId()) . ".json"; $sp_user = new StudyPressUserWP($lesson->getAuthorId()); $sp_userName = $sp_user->firstName() . ' ' . $sp_user->lastName(); $sp_userLink = StudyPressUserWP::getUserPostsLink($lesson->getAuthorId()); 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>"; } 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>"; } $items = array(); $owl['items'][] = array('name' => $tr->__('Presentation'), 'content' => slide_presentation_lesson($lesson, $sp_userName)); foreach ($lesson->getSlides() as $slide) { $content = $slide->content(); $name = $slide->name(); $owl['items'][] = array('name' => $name, 'content' => do_shortcode($content)); }