public function InsertConfig(array $config) { $table = StudyPressDB::getTableNameConfiguration(); $this->_access->query('DELETE FROM ' . $table); foreach ($config as $name => $value) { $a = array(StudyPressDB::COL_NAME_CONFIG => $name, StudyPressDB::COL_VALUE_CONFIG => $value); $this->_access->insert($table, $a); } $this->_config = $config; }
public function updateOrders(array $idSlideOrder) { $ids = implode(',', array_keys($idSlideOrder)); $sql = "UPDATE " . StudyPressDB::getTableNameSlide() . " SET " . StudyPressDB::COL_ORDER_SLIDE . " = CASE " . StudyPressDB::COL_ID_SLIDE . " "; foreach ($idSlideOrder as $id => $ordinal) { $sql .= sprintf("WHEN %d THEN %d ", $id, $ordinal); } $sql .= "END WHERE " . StudyPressDB::COL_ID_SLIDE . " IN ({$ids})"; $this->_access->query($sql); }
public function getPropositionsOfQuestion($questionId) { $props = array(); $result = $this->_access->getResults($this->_access->prepare("SELECT * FROM " . StudyPressDB::getTableNamePropositions() . " WHERE " . StudyPressDB::COL_ID_QUESTION_PROPOSITION . " = '%d' ORDER BY " . StudyPressDB::COL_ORDER_PROPOSITION . " ASC", $questionId)); foreach ($result as $row) { $prop = self::returnedProposition($row); if ($prop) { array_push($props, $prop); } } return $props; }
$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) { $aResponse['message'] = 'Your rate has been successfuly recorded. Thanks for your rate :)'; $aResponse['server'] = $tr->__('Your rating has been recorded') . '<br />'; echo json_encode($aResponse); } else { $aResponse['error'] = true;
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; } if ($success) { $aResponse['message'] = $tr->__('Your rating has been recorded'); $aResponse['server'] = $tr->__('Your rating has been recorded') . '<br />'; echo json_encode($aResponse); } else { $aResponse['error'] = true;
function activate_studypress_plugin() { global $tr; $access = new AccessData(); $table = StudyPressDB::getTableNameCourse(); if ($access->getVar("SHOW TABLES LIKE '{$table}'") != $table) { $sql = "CREATE TABLE {$table} (\r\n " . StudyPressDB::COL_ID_COURSE . " BIGINT UNSIGNED AUTO_INCREMENT ,\r\n " . StudyPressDB::COL_NAME_COURSE . " VARCHAR(200),\r\n " . StudyPressDB::COL_DESCRIPTION_COURSE . " LONGTEXT ,\r\n " . StudyPressDB::COL_AVANCEMENT_COURSE . " VARCHAR(255) DEFAULT '0',\r\n " . StudyPressDB::COL_PICTURE_COURSE . " VARCHAR(255),\r\n " . StudyPressDB::COL_ID_POST_COURSE . " BIGINT DEFAULT NULL,\r\n PRIMARY KEY (" . StudyPressDB::COL_ID_COURSE . ")\r\n )"; $access->query($sql); } $table = StudyPressDB::getTableNameActivity(); if ($access->getVar("SHOW TABLES LIKE '{$table}'") != $table) { $sql = "CREATE TABLE {$table} (\r\n " . StudyPressDB::COL_ID_ACTIVITY . " BIGINT UNSIGNED AUTO_INCREMENT ,\r\n " . StudyPressDB::COL_ID_COURSE_ACTIVITY . " BIGINT UNSIGNED ,\r\n " . StudyPressDB::COL_NAME_ACTIVITY . " VARCHAR(200),\r\n " . StudyPressDB::COL_DURATION_ACTIVITY . " INT NOT NULL,\r\n " . StudyPressDB::COL_AUTEUR_ACTIVITY . " VARCHAR(200),\r\n " . StudyPressDB::COL_DESCRIPTION_ACTIVITY . " longtext ,\r\n " . StudyPressDB::COL_TAGS_ACTIVITY . " longtext ,\r\n " . StudyPressDB::COL_GLOSSARY_ACTIVITY . " longtext ,\r\n " . StudyPressDB::COL_PICTURE_ACTIVITY . " text,\r\n " . StudyPressDB::COL_SHORT_CODE_ACTIVITY . " VARCHAR(50),\r\n " . StudyPressDB::COL_ID_AUTEUR_ACTIVITY . " BIGINT,\r\n " . StudyPressDB::COL_ID_POST_ACTIVITY . " BIGINT DEFAULT NULL,\r\n " . StudyPressDB::COL_TYPE_ACTIVITY . " VARCHAR(10),\r\n " . StudyPressDB::COL_ORDER_ACTIVITY . " INT NOT NULL,\r\n PRIMARY KEY (" . StudyPressDB::COL_ID_ACTIVITY . "),\r\n FOREIGN KEY (" . StudyPressDB::COL_ID_COURSE_ACTIVITY . ") REFERENCES " . StudyPressDB::getTableNameCourse() . " (" . StudyPressDB::COL_ID_COURSE . ")\r\n )"; $access->query($sql); } $table = StudyPressDB::getTableNameSlide(); if ($access->getVar("SHOW TABLES LIKE '{$table}'") != $table) { $sql = "CREATE TABLE {$table} (\r\n " . StudyPressDB::COL_ID_SLIDE . " BIGINT UNSIGNED AUTO_INCREMENT ,\r\n " . StudyPressDB::COL_ID_LESSON_SLIDE . " BIGINT UNSIGNED,\r\n " . StudyPressDB::COL_NAME_SLIDE . " VARCHAR(200) ,\r\n " . StudyPressDB::COL_CONTENT_SLIDE . " longtext ,\r\n " . StudyPressDB::COL_ORDER_SLIDE . " INT NOT NULL,\r\n PRIMARY KEY (" . StudyPressDB::COL_ID_SLIDE . "),\r\n FOREIGN KEY (" . StudyPressDB::COL_ID_LESSON_SLIDE . ") REFERENCES " . StudyPressDB::getTableNameActivity() . " (" . StudyPressDB::COL_ID_ACTIVITY . ")\r\n )"; $access->query($sql); } $table = StudyPressDB::getTableName_CourseCategory(); if ($access->getVar("SHOW TABLES LIKE '{$table}'") != $table) { $sql = "CREATE TABLE {$table} (\r\n " . StudyPressDB::COL_ID_COURSE_CAT_N_COURSE . " BIGINT UNSIGNED,\r\n " . StudyPressDB::COL_ID_CATEGORY_CAT_N_COURSE . " BIGINT UNSIGNED,\r\n PRIMARY KEY (" . StudyPressDB::COL_ID_COURSE_CAT_N_COURSE . "," . StudyPressDB::COL_ID_CATEGORY_CAT_N_COURSE . "),\r\n FOREIGN KEY (" . StudyPressDB::COL_ID_CATEGORY_CAT_N_COURSE . ") REFERENCES\r\n " . StudyPressDB::getTableNameCategoryWP() . " (" . StudyPressDB::COL_ID_CATEGORY_WP . "),\r\n FOREIGN KEY (" . StudyPressDB::COL_ID_COURSE_CAT_N_COURSE . ") REFERENCES\r\n " . StudyPressDB::getTableNameCourse() . " (" . StudyPressDB::COL_ID_COURSE . ")\r\n )"; $access->query($sql); } $table = StudyPressDB::getTableName_CourseUsers(); if ($access->getVar("SHOW TABLES LIKE '{$table}'") != $table) { $sql = "CREATE TABLE {$table} (\r\n " . StudyPressDB::COL_ID_COURSE_CAT_N_COURSE . " BIGINT UNSIGNED,\r\n " . StudyPressDB::COL_ID_USERS_USERS_N_COURSE . " BIGINT UNSIGNED,\r\n PRIMARY KEY (" . StudyPressDB::COL_ID_COURSE_ACTIVITY . "," . StudyPressDB::COL_ID_USERS_USERS_N_COURSE . "),\r\n FOREIGN KEY (" . StudyPressDB::COL_ID_USERS_USERS_N_COURSE . ") REFERENCES\r\n " . StudyPressDB::getTableNameUsersWP() . " (" . StudyPressDB::COL_ID_USER_WP . "),\r\n FOREIGN KEY (" . StudyPressDB::COL_ID_COURSE_CAT_N_COURSE . ") REFERENCES\r\n " . StudyPressDB::getTableNameCourse() . " (" . StudyPressDB::COL_ID_COURSE . ")\r\n )"; $access->query($sql); } $table = StudyPressDB::getTableNameVisite(); if ($access->getVar("SHOW TABLES LIKE '{$table}'") != $table) { $sql = "CREATE TABLE {$table} (\r\n " . StudyPressDB::COL_ID_VISITE . " BIGINT UNSIGNED AUTO_INCREMENT,\r\n \t\t\t\t\t" . StudyPressDB::COL_ID_ACTIVITY_VISITE . " BIGINT UNSIGNED,\r\n \t\t\t\t\t" . StudyPressDB::COL_IP_VISITE . " VARCHAR(40),\r\n \t\t\t\t\t" . StudyPressDB::COL_DATE_VISITE . " DATETIME,\r\n\t\t\t\t\t" . StudyPressDB::COL_ID_USER_VISITE . " BIGINT UNSIGNED ,\r\n \t\t\t\t\t PRIMARY KEY (" . StudyPressDB::COL_ID_VISITE . "),\r\n\t\t\t\t\t FOREIGN KEY ( " . StudyPressDB::COL_ID_ACTIVITY_VISITE . " ) REFERENCES " . StudyPressDB::getTableNameActivity() . " (" . StudyPressDB::COL_ID_ACTIVITY . "),\r\n\t\t\t\t\t FOREIGN KEY ( " . StudyPressDB::COL_ID_USER_VISITE . " ) REFERENCES " . StudyPressDB::getTableNameUsersWP() . " (" . StudyPressDB::COL_ID_USER_WP . ")\r\n\t\t\t\t\t )"; $access->query($sql); } $table = StudyPressDB::getTableNameDomain(); if ($access->getVar("SHOW TABLES LIKE '{$table}'") != $table) { $sql = "CREATE TABLE {$table} (\r\n " . StudyPressDB::COL_ID_DOMAIN . " BIGINT UNSIGNED AUTO_INCREMENT,\r\n " . StudyPressDB::COL_NAME_DOMAIN . " VARCHAR(200) UNIQUE,\r\n \t\t\t\t\t" . StudyPressDB::COL_DESCRIPTION_DOMAIN . " LONGTEXT,\r\n \t\t\t\t\tPRIMARY KEY (" . StudyPressDB::COL_ID_DOMAIN . ")\r\n\t\t\t\t\t )"; $access->query($sql); } $table = StudyPressDB::getTableNameRateQuality(); if ($access->getVar("SHOW TABLES LIKE '{$table}'") != $table) { $sql = "CREATE TABLE {$table} (\r\n " . StudyPressDB::COL_ID_RATE_QUALITY . " BIGINT UNSIGNED AUTO_INCREMENT,\r\n \t\t\t\t\t" . StudyPressDB::COL_ID_ACTIVITY_RATE_QUALITY . " BIGINT UNSIGNED ,\r\n \t\t\t\t\t" . StudyPressDB::COL_VALUE_RATE_QUALITY . " INT NULL,\r\n \t\t\t\t\t" . StudyPressDB::COL_DATE_RATE_QUALITY . " DATETIME,\r\n\t\t\t\t\t" . StudyPressDB::COL_ID_USER_RATE_QUALITY . " BIGINT UNSIGNED,\r\n\t\t\t\t\t" . StudyPressDB::COL_IP_RATE_QUALITY . " INT UNSIGNED,\r\n \t\t\t\t\t PRIMARY KEY (" . StudyPressDB::COL_ID_RATE_QUALITY . "),\r\n \t\t\t\t\t FOREIGN KEY ( " . StudyPressDB::COL_ID_ACTIVITY_RATE_QUALITY . " ) REFERENCES " . StudyPressDB::getTableNameActivity() . " (" . StudyPressDB::COL_ID_ACTIVITY . "),\r\n\t\t\t\t\t FOREIGN KEY ( " . StudyPressDB::COL_ID_USER_RATE_QUALITY . " ) REFERENCES " . StudyPressDB::getTableNameUsersWP() . " (" . StudyPressDB::COL_ID_USER_WP . ")\r\n\t\t\t\t\t )"; $access->query($sql); } $table = StudyPressDB::getTableNameRateDomain(); if ($access->getVar("SHOW TABLES LIKE '{$table}'") != $table) { $sql = "CREATE TABLE {$table} (\r\n " . StudyPressDB::COL_ID_RATE_DOMAIN . " BIGINT UNSIGNED AUTO_INCREMENT,\r\n \t\t\t\t\t" . StudyPressDB::COL_ID_ACTIVITY_RATE_DOMAIN . " BIGINT UNSIGNED ,\r\n \t\t\t\t\t" . StudyPressDB::COL_VALUE_RATE_DOMAIN . " INT NULL,\r\n \t\t\t\t\t" . StudyPressDB::COL_DATE_RATE_DOMAIN . " DATETIME,\r\n\t\t\t\t\t" . StudyPressDB::COL_ID_USER_RATE_DOMAIN . " BIGINT UNSIGNED,\r\n\t\t\t\t\t" . StudyPressDB::COL_ID_DOMAIN_RATE_DOMAIN . " BIGINT UNSIGNED,\r\n\t\t\t\t\t" . StudyPressDB::COL_IP_RATE_DOMAIN . " INT UNSIGNED,\r\n \t\t\t\t\t PRIMARY KEY (" . StudyPressDB::COL_ID_RATE_DOMAIN . "),\r\n\t\t\t\t\t UNIQUE ( " . StudyPressDB::COL_ID_ACTIVITY_RATE_DOMAIN . "," . StudyPressDB::COL_ID_DOMAIN_RATE_DOMAIN . "," . StudyPressDB::COL_ID_USER_RATE_DOMAIN . " ),\r\n\t\t\t\t\t FOREIGN KEY ( " . StudyPressDB::COL_ID_ACTIVITY_RATE_QUALITY . " ) REFERENCES " . StudyPressDB::getTableNameActivity() . " (" . StudyPressDB::COL_ID_ACTIVITY . "),\r\n\t\t\t\t\t FOREIGN KEY ( " . StudyPressDB::COL_ID_USER_RATE_QUALITY . " ) REFERENCES " . StudyPressDB::getTableNameUsersWP() . " (" . StudyPressDB::COL_ID_USER_WP . "),\r\n\t\t\t\t\t FOREIGN KEY ( " . StudyPressDB::COL_ID_DOMAIN_RATE_DOMAIN . " ) REFERENCES " . StudyPressDB::getTableNameDomain() . " (" . StudyPressDB::COL_ID_DOMAIN . ")\r\n\t\t\t\t\t )"; $access->query($sql); } $table = StudyPressDB::getTableNameQuestions(); if ($access->getVar("SHOW TABLES LIKE '{$table}'") != $table) { $sql = "CREATE TABLE {$table} (\r\n " . StudyPressDB::COL_ID_QUESTION . " BIGINT UNSIGNED AUTO_INCREMENT ,\r\n " . StudyPressDB::COL_ID_QUIZ_QUESTION . " BIGINT UNSIGNED,\r\n " . StudyPressDB::COL_CONTENT_QUESTION . " TEXT,\r\n " . StudyPressDB::COL_ORDER_QUESTION . " INT NOT NULL,\r\n " . StudyPressDB::COL_TYPE_QUESTION . " VARCHAR(25) ,\r\n PRIMARY KEY (" . StudyPressDB::COL_ID_QUESTION . "),\r\n FOREIGN KEY (" . StudyPressDB::COL_ID_QUIZ_QUESTION . ") REFERENCES " . StudyPressDB::getTableNameActivity() . " (" . StudyPressDB::COL_ID_ACTIVITY . ")\r\n )"; $access->query($sql); } $table = StudyPressDB::getTableNamePropositions(); if ($access->getVar("SHOW TABLES LIKE '{$table}'") != $table) { $sql = "CREATE TABLE {$table} (\r\n " . StudyPressDB::COL_ID_PROPOSITION . " BIGINT UNSIGNED AUTO_INCREMENT ,\r\n " . StudyPressDB::COL_ID_QUESTION_PROPOSITION . " BIGINT UNSIGNED,\r\n " . StudyPressDB::COL_CONTENT_PROPOSITION . " TEXT ,\r\n " . StudyPressDB::COL_TYPE_PROPOSITION . " VARCHAR(10),\r\n " . StudyPressDB::COL_ORDER_PROPOSITION . " INT NOT NULL,\r\n " . StudyPressDB::COL_COL_PROPOSITION . " VARCHAR(255) ,\r\n PRIMARY KEY (" . StudyPressDB::COL_ID_PROPOSITION . "),\r\n FOREIGN KEY (" . StudyPressDB::COL_ID_QUESTION_PROPOSITION . ") REFERENCES " . StudyPressDB::getTableNameQuestions() . " (" . StudyPressDB::COL_ID_QUESTION . ")\r\n )"; $access->query($sql); } $table = StudyPressDB::getTableNameResultQuiz(); if ($access->getVar("SHOW TABLES LIKE '{$table}'") != $table) { $sql = "CREATE TABLE {$table} (\r\n " . StudyPressDB::COL_ID_RESULT . " BIGINT UNSIGNED AUTO_INCREMENT ,\r\n " . StudyPressDB::COL_ID_QUIZ_RESULT . " BIGINT UNSIGNED,\r\n " . StudyPressDB::COL_ID_USER_RESULT . " BIGINT UNSIGNED,\r\n " . StudyPressDB::COL_DATE_RESULT . " DATETIME,\r\n " . StudyPressDB::COL_RESPONSE_RESULT . " LONGTEXT,\r\n " . StudyPressDB::COL_NOTE_RESULT . " INT,\r\n " . StudyPressDB::COL_NBR_QUESTIONS_RESULT . " INT,\r\n " . StudyPressDB::COL_NBR_CORRECTS_RESULT . " INT,\r\n " . StudyPressDB::COL_DATE_BEGIN_RESULT . " VARCHAR(30),\r\n " . StudyPressDB::COL_VALIDATE_RESULT . " VARCHAR(6),\r\n PRIMARY KEY (" . StudyPressDB::COL_ID_RESULT . "),\r\n UNIQUE (" . StudyPressDB::COL_ID_QUIZ_RESULT . "," . StudyPressDB::COL_ID_USER_RESULT . "),\r\n FOREIGN KEY (" . StudyPressDB::COL_ID_QUIZ_RESULT . ") REFERENCES " . StudyPressDB::getTableNameActivity() . " (" . StudyPressDB::COL_ID_ACTIVITY . ")\r\n )"; $access->query($sql); } $table = StudyPressDB::getTableNameConfiguration(); if ($access->getVar("SHOW TABLES LIKE '{$table}'") != $table) { $sql = "CREATE TABLE {$table} (\r\n " . StudyPressDB::COL_ID_CONFIG . " BIGINT UNSIGNED AUTO_INCREMENT ,\r\n " . StudyPressDB::COL_NAME_CONFIG . " VARCHAR(200),\r\n " . StudyPressDB::COL_VALUE_CONFIG . " VARCHAR(10),\r\n PRIMARY KEY (" . StudyPressDB::COL_ID_CONFIG . ")\r\n )"; $access->query($sql); } $table = StudyPressDB::getTableName_GroupCourse(); if ($access->getVar("SHOW TABLES LIKE '{$table}'") != $table) { $sql = "CREATE TABLE {$table} (\r\n " . StudyPressDB::COL_ID_GROUP . " BIGINT UNSIGNED AUTO_INCREMENT,\r\n " . StudyPressDB::COL_ID_COURSE_GROUP . " BIGINT UNSIGNED,\r\n " . StudyPressDB::COL_ID_GROUP_BP . " BIGINT UNSIGNED,\r\n UNIQUE (" . StudyPressDB::COL_ID_GROUP_BP . "," . StudyPressDB::COL_ID_COURSE_GROUP . "),\r\n PRIMARY KEY (" . StudyPressDB::COL_ID_GROUP . "),\r\n FOREIGN KEY (" . StudyPressDB::COL_ID_COURSE_GROUP . ") REFERENCES\r\n " . StudyPressDB::getTableNameCourse() . " (" . StudyPressDB::COL_ID_COURSE . ")\r\n )"; $access->query($sql); } require_once 'Migration/v0.12tov1.0.php'; $nbrColumnOfCourse = $access->getResults("DESC " . StudyPressDB::getTableNameCourse()); if (count($nbrColumnOfCourse) < 6) { require_once 'Migration/1.0-to-1.1.php'; } require_once 'notices.php'; add_menu_page('Cours', 'studypress', 'publish_posts', 'id_Cours', 'display_courses', __ROOT_PLUGIN__2 . 'images/logo.png', '30'); add_submenu_page('id_Cours', $tr->__("Lessons"), $tr->__("Lessons"), 'publish_posts', 'id_Cours', 'display_courses'); function display_courses() { require_once __ROOT_PLUGIN__ . 'controllers/lesson.controller.php'; } add_submenu_page('id_Cours', 'Quizs', 'Quizs', 'publish_posts', 'quizs', 'display_quizs'); function display_quizs() { require_once __ROOT_PLUGIN__ . 'controllers/quiz.controller.php'; } add_submenu_page(null, 'Modifier Quiz', 'Modifier Quiz', 'publish_posts', 'mod-quiz', 'display_mod_quiz'); function display_mod_quiz() { require_once __ROOT_PLUGIN__ . 'controllers/modQuiz.controller.php'; } add_submenu_page(null, 'Result Quiz', 'Result Quiz', 'publish_posts', 'result-quiz', 'display_result_quiz'); function display_result_quiz() { require_once __ROOT_PLUGIN__ . 'controllers/resultQuiz.controller.php'; } add_submenu_page('id_Cours', $tr->__('Courses'), $tr->__('Courses'), 'publish_posts', 'courses', 'display_categories'); function display_categories() { require_once __ROOT_PLUGIN__ . 'controllers/course.controller.php'; } add_submenu_page(null, 'Modifier Cours', 'Modifier Cours', 'publish_posts', 'mod-course', 'display_mod_course'); function display_mod_course() { require_once __ROOT_PLUGIN__ . 'controllers/modCourse.controller.php'; } add_submenu_page(null, 'Modifier Leçon', 'Modifier Leçon', 'publish_posts', 'mod-lesson', 'display_mod_lesson'); function display_mod_lesson() { require_once __ROOT_PLUGIN__ . 'controllers/modLesson.controller.php'; } add_submenu_page('id_Cours', $tr->__('Parameters'), $tr->__('Parameters'), 'manage_options', 'sp_parameters', 'display_parameters'); function display_parameters() { require_once __ROOT_PLUGIN__ . 'controllers/configuration.controller.php'; } add_submenu_page('id_Cours', $tr->__('Help'), $tr->__('Help'), 'publish_posts', 'sp_help', 'display_help'); function display_help() { require_once __ROOT_PLUGIN__ . 'Views/admin/help.view.php'; } }
public function isDone($activityId, $userId) { $result = $this->_access->getVar($this->_access->prepare("SELECT COUNT(*) FROM " . StudyPressDB::getTableNameVisite() . " WHERE " . StudyPressDB::COL_ID_ACTIVITY_VISITE . " = '%d' AND " . StudyPressDB::COL_ID_USER_VISITE . " = '{$userId}'", $activityId)); return (int) $result !== 0 ? true : false; }
<?php $access = new AccessData(); $access->query("ALTER TABLE " . StudyPressDB::getTableNameCourse() . " ADD " . StudyPressDB::COL_PICTURE_COURSE . " VARCHAR(255)"); $access->query("ALTER TABLE " . StudyPressDB::getTableNameActivity() . " ADD " . StudyPressDB::COL_ORDER_ACTIVITY . " INT NOT NULL"); $access->query("ALTER TABLE " . StudyPressDB::getTableNameActivity() . " CHANGE notes " . StudyPressDB::COL_TAGS_ACTIVITY . " longtext"); $access->query("ALTER TABLE " . StudyPressDB::getTableNameVisite() . " CHANGE lesson_id " . StudyPressDB::COL_ID_ACTIVITY_VISITE . " BIGINT UNSIGNED"); $access->query("ALTER TABLE " . StudyPressDB::getTableNameVisite() . " CHANGE user_visite " . StudyPressDB::COL_ID_USER_VISITE . " BIGINT UNSIGNED"); $access->query("ALTER TABLE " . StudyPressDB::getTableNameQuestions() . " CHANGE col " . StudyPressDB::COL_TYPE_QUESTION . " VARCHAR(25)"); $access->query("UPDATE " . StudyPressDB::getTableNameQuestions() . " SET " . StudyPressDB::COL_TYPE_QUESTION . " = 'multiple'"); $access->query("ALTER TABLE " . StudyPressDB::getTableNameActivity() . " CHANGE picture_url " . StudyPressDB::COL_PICTURE_ACTIVITY . " text"); $access->query("ALTER TABLE " . StudyPressDB::getTableNameActivity() . " CHANGE activity_id " . StudyPressDB::COL_ID_ACTIVITY . " BIGINT UNSIGNED AUTO_INCREMENT"); $access->query("ALTER TABLE " . StudyPressDB::getTableNameSlide() . " CHANGE slide_id " . StudyPressDB::COL_ID_SLIDE . " BIGINT UNSIGNED AUTO_INCREMENT"); $access->query("ALTER TABLE " . StudyPressDB::getTableName_CourseUsers() . " CHANGE ID " . StudyPressDB::COL_ID_USERS_USERS_N_COURSE . " BIGINT UNSIGNED"); $access->query("ALTER TABLE " . StudyPressDB::getTableNameVisite() . " CHANGE visite_id " . StudyPressDB::COL_ID_VISITE . " BIGINT UNSIGNED AUTO_INCREMENT"); $access->query("ALTER TABLE " . StudyPressDB::getTableNameDomain() . " CHANGE domain_id " . StudyPressDB::COL_ID_DOMAIN . " BIGINT UNSIGNED AUTO_INCREMENT"); $access->query("ALTER TABLE " . StudyPressDB::getTableNameRateQuality() . " CHANGE ID " . StudyPressDB::COL_ID_USER_RATE_QUALITY . " BIGINT UNSIGNED"); $access->query("ALTER TABLE " . StudyPressDB::getTableNameRateQuality() . " CHANGE rate_id " . StudyPressDB::COL_ID_RATE_QUALITY . " BIGINT UNSIGNED AUTO_INCREMENT"); $access->query("ALTER TABLE " . StudyPressDB::getTableNameRateDomain() . " CHANGE ID " . StudyPressDB::COL_ID_USER_RATE_DOMAIN . " BIGINT UNSIGNED"); $access->query("ALTER TABLE " . StudyPressDB::getTableNameRateDomain() . " CHANGE rate_domain_id " . StudyPressDB::COL_ID_RATE_DOMAIN . " BIGINT UNSIGNED AUTO_INCREMENT"); $access->query("ALTER TABLE " . StudyPressDB::getTableNameQuestions() . " CHANGE question_id " . StudyPressDB::COL_ID_QUESTION . " BIGINT UNSIGNED AUTO_INCREMENT"); $access->query("ALTER TABLE " . StudyPressDB::getTableNamePropositions() . " CHANGE proposition_id " . StudyPressDB::COL_ID_PROPOSITION . " BIGINT UNSIGNED AUTO_INCREMENT"); $access->query("ALTER TABLE " . StudyPressDB::getTableNameResultQuiz() . " CHANGE ID " . StudyPressDB::COL_ID_USER_RESULT . " BIGINT UNSIGNED"); $access->query("ALTER TABLE " . StudyPressDB::getTableNameResultQuiz() . " CHANGE result_id " . StudyPressDB::COL_ID_RESULT . " BIGINT UNSIGNED AUTO_INCREMENT"); $manager = new CourseManager(); $courses = $manager->getAll(); foreach ($courses as $course) { $manager->update($course->getId(), $course); }
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; }
<?php $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']))); }
public function AVG($activityId) { $nbr = $this->_access->getVar("SELECT AVG(" . StudyPressDB::COL_VALUE_RATE_QUALITY . ") FROM " . StudyPressDB::getTableNameRateQuality() . " WHERE " . StudyPressDB::COL_ID_ACTIVITY_RATE_QUALITY . " = '" . $activityId . "'"); return $nbr ? $nbr : 0; }
public function isDone($activityId, $userId) { $result = $this->_access->getVar($this->_access->prepare("SELECT * FROM " . StudyPressDB::getTableNameResultQuiz() . " WHERE " . StudyPressDB::COL_ID_QUIZ_RESULT . " = '%d' AND " . StudyPressDB::COL_ID_USER_RESULT . " = '{$userId}' AND " . StudyPressDB::COL_VALIDATE_RESULT . " = 'true' ", $activityId)); return (int) $result !== 0 ? true : false; }
public function getById($id) { $result = $this->_access->getRow($this->_access->prepare("SELECT * FROM " . StudyPressDB::getTableNameDomain() . " WHERE " . StudyPressDB::COL_ID_DOMAIN . " = '%d'", $id)); $domain = self::returnedDomain($result); return $domain; }
public function AVG($activityId, $domainId) { $nbr = $this->_access->getVar("SELECT AVG(" . StudyPressDB::COL_VALUE_RATE_DOMAIN . ") FROM " . StudyPressDB::getTableNameRateDomain() . " WHERE " . StudyPressDB::COL_ID_ACTIVITY_RATE_DOMAIN . " = '" . $activityId . "' AND " . StudyPressDB::COL_ID_DOMAIN_RATE_DOMAIN . " = '" . $domainId . "'"); return $nbr ? $nbr : 0; }
function sp_delete_course_users($userId) { $access = new AccessData(); $access->delete(StudyPressDB::getTableName_CourseUsers(), array(StudyPressDB::COL_ID_USERS_USERS_N_COURSE => $userId)); }