示例#1
0
 /**
  * Gets answer statistics
  *
  * @access public
  * @param int $ID
  * @param int $user
  * @return array
  */
 public static function getAnswerStatistics($ID, $user)
 {
     $answers = array();
     $quiz = ThemexCore::getPostRelations(0, $ID, 'quiz_lesson', true);
     if (!empty($quiz)) {
         $relations = explode(' ; ', ThemexCore::getUserRelations($user, $quiz, 'answers', true) . ' ');
         foreach ($relations as $relation) {
             $answer = array();
             $relation = explode(' , ', $relation);
             if (count($relation) == 3) {
                 $answer['question'] = themex_value($relation, 0);
                 $answer['answer'] = themex_value($relation, 1);
                 $answer['result'] = themex_value($relation, 2);
                 $answers[] = $answer;
             }
         }
     }
     return $answers;
 }
 /**
  * Renders page title
  *
  * @access public
  * @return void
  */
 public static function renderPageTitle()
 {
     global $post;
     $type = get_post_type();
     $out = wp_title('', false);
     if (is_single()) {
         if ($type == 'post') {
             $categories = wp_get_post_terms($post->ID, 'category');
             if (!empty($categories)) {
                 $out = $categories[0]->name;
             }
         } else {
             if (in_array($type, array('lesson', 'quiz'))) {
                 if ($type == 'lesson') {
                     $out = __('Lesson', 'academy');
                     $lesson = $post->ID;
                 } else {
                     $out = __('Quiz', 'academy');
                     $lesson = ThemexCore::getPostRelations($post->ID, 0, 'quiz_lesson', true);
                 }
                 $course = ThemexCore::getPostRelations($lesson, 0, 'lesson_course', true);
                 if ($course != 0) {
                     $out = get_the_title($course);
                 }
             } else {
                 $types = get_post_types(null, 'objects');
                 $out = $types[$type]->labels->name;
             }
         }
     } else {
         if (is_tax()) {
             $out = single_term_title('', false);
         } else {
             if (get_query_var('author')) {
                 if (get_query_var('author') == get_current_user_id()) {
                     $out = __('My Profile', 'academy');
                 } else {
                     $out = __('Profile', 'academy');
                 }
             }
         }
     }
     if (empty($out)) {
         $out = __('Archives', 'academy');
     }
     echo $out;
 }
示例#3
0
 /**
  * Gets related post
  *
  * @access public
  * @param int $ID
  * @param mixed $type
  * @param bool $single
  * @return array
  */
 public static function getRelatedPost($ID, $type, $single = false)
 {
     $order = new WC_Order($ID);
     $products = $order->get_items();
     if (!empty($products)) {
         $ID = wp_list_pluck($products, 'product_id');
     }
     $relations = array_merge(array(0), ThemexCore::getPostRelations(0, $ID, $type));
     $posts = get_posts(array('numberposts' => -1, 'post_type' => array('course', 'plan'), 'post__in' => $relations));
     if (!empty($posts)) {
         if ($order->user_id) {
             foreach ($posts as &$post) {
                 $post->post_author = $order->user_id;
             }
         }
         if ($single) {
             $posts = reset($posts);
         }
     }
     return $posts;
 }
示例#4
0
 /**
  * Filters lesson columns
  *
  * @access public
  * @param mixed $query
  * @return mixed
  */
 public static function filterLessonColumns($query)
 {
     global $pagenow;
     if (is_admin() && $pagenow == 'edit.php' && isset($_GET['lesson_course'])) {
         $lessons = ThemexCore::getPostRelations(0, intval($_GET['lesson_course']), 'lesson_course');
         if (!empty($lessons)) {
             $query->set('post__in', $lessons);
         }
     }
     return $query;
 }
示例#5
0
<?php

get_header();
the_post();
ThemexLesson::refresh(ThemexCore::getPostRelations($post->ID, 0, 'quiz_lesson', true), true);
ThemexCourse::refresh(ThemexLesson::$data['course'], true);
$layout = ThemexCore::getOption('lessons_layout', 'right');
if ($layout == 'left') {
    ?>
<aside class="sidebar column fourcol">
	<?php 
    get_sidebar('lesson');
    ?>
</aside>
<div class="column eightcol last">
<?php 
} else {
    ?>
<div class="eightcol column">
<?php 
}
?>
	<h1><?php 
the_title();
?>
</h1>
	<?php 
the_content();
?>
	<div class="quiz-listing">
		<form id="quiz_form" action="<?php 
示例#6
0
 /**
  * Renders background
  *
  * @access public
  * @return void
  */
 public static function renderBackground()
 {
     global $post;
     $out = '';
     if (ThemexCore::getOption('background_type', 'fullwidth') != 'tiled') {
         $background = ThemexCore::getOption('background_image', THEME_URI . 'images/bgs/site_bg.jpg');
         if (is_page()) {
             $background = ThemexCore::getPostMeta($post->ID, 'page_background', $background);
         } else {
             if (is_singular('course')) {
                 $background = ThemexCore::getPostMeta($post->ID, 'course_background', $background);
             } else {
                 if (is_singular('lesson')) {
                     $course = ThemexCore::getPostRelations($post->ID, 0, 'lesson_course', true);
                     if ($course != 0) {
                         $background = ThemexCore::getPostMeta($course, 'course_background', $background);
                     }
                 }
             }
         }
         $out = '<img src="' . $background . '" class="fullwidth" alt="" />';
     }
     echo $out;
 }