Skip to content

Commit

Permalink
Merge pull request #274 from woothemes/release-1-4-8
Browse files Browse the repository at this point in the history
Release 1.4.8
  • Loading branch information
Dan Johnson committed Jan 22, 2014
2 parents b40fbe5 + 601102f commit fa00a31
Show file tree
Hide file tree
Showing 19 changed files with 420 additions and 208 deletions.
2 changes: 1 addition & 1 deletion assets/css/frontend.css

Large diffs are not rendered by default.

71 changes: 41 additions & 30 deletions assets/css/frontend.less
Original file line number Diff line number Diff line change
Expand Up @@ -37,33 +37,7 @@ License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2
}
.course-meta {
margin-bottom: 20px;
.status {
padding: .382em 1em;
.border_radius(5px);
color: #fff;
font-weight: bold;
background: darken(@bg_dark, 5%);
&:before {
.iconbefore();
}
&.completed {
background: @success;
&:before {
content: "\f00c";
}
}
&.in-progress {
&:before {
content: "\f110";
}
}
&.register {
background: @error;
a {
color: #fff;
}
}
}
clear: both;
.view-results {
text-align: right;
margin: 5px 0;
Expand Down Expand Up @@ -152,6 +126,39 @@ License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2
}
}

/* Status Indicators */

.course, .course-lessons, .course-container {
.status {
padding: .382em 1em;
.border_radius(5px);
color: #fff;
font-weight: bold;
background: darken(@bg_dark, 5%);
display: inline-block;
&:before {
.iconbefore();
}
&.completed {
background: @success;
&:before {
content: "\f00c";
}
}
&.in-progress {
&:before {
content: "\f110";
}
}
&.register {
background: @error;
a {
color: #fff;
}
}
}
}

.lesson {
.lesson-meta {
margin: 0 0 1.618em;
Expand Down Expand Up @@ -217,15 +224,15 @@ License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2
position: absolute;
right: 0;
top: 50%;
width: 100%;
width: 50%;
z-index: 2;
text-align: right;
span {
text-align: right;
}
&.has_notes {
cursor: help;
span {
cursor: help;
border-bottom: 1px dotted;
}
}
Expand All @@ -244,7 +251,7 @@ License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2
position: absolute;
top: 20px;
right: 0;
width: 50%;
width: 100%;
background: #FFF;
border: 1px solid;
.border_radius();
Expand All @@ -256,8 +263,12 @@ License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2
&.essay-paste, &.gap-fill, &.multi-line, &.single-line {
.answer_message {
position: relative;
width: 100%;
margin: 10px 0;
text-align: right;
.notes {
width: 50%;
}
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions assets/js/general-frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ jQuery(document).ready( function($) {
}, 1200);
});

jQuery(".answer_message.has_notes").mouseover(function() {
jQuery(this).children(".notes").show();
jQuery(".answer_message.has_notes span").mouseover(function() {
jQuery(this).siblings(".notes").show();
});
jQuery(".answer_message.has_notes").mouseout(function() {
jQuery(this).children(".notes").hide();
jQuery(".answer_message.has_notes span").mouseout(function() {
jQuery(this).siblings(".notes").hide();
});
});

Expand Down
8 changes: 4 additions & 4 deletions assets/js/lesson-metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ jQuery(document).ready( function($) {
* @access public
*/
jQuery.fn.resetAddQuestionForm = function() {
jQuery( '#add-new-question' ).find('div').children('input').each( function() {
jQuery( '#add-new-question' ).find('div').find('input').each( function() {
if ( jQuery( this ).attr( 'type' ) != 'radio' ) {
jQuery(this).attr( 'value', '' );
} // End If Statement
});
jQuery( '#add-new-question' ).find('div').children('textarea').each( function() {
jQuery( '#add-new-question' ).find('div').find('textarea').each( function() {
jQuery(this).attr( 'value', '' );
});
}
Expand Down Expand Up @@ -505,14 +505,14 @@ jQuery(document).ready( function($) {
break;
} // End Switch Statement
// Handle Required Fields
jQuery( '#add-new-question' ).find( 'div.question_required_fields' ).children('p').children( 'input' ).each( function() {
jQuery( '#add-new-question' ).find( 'div.question_required_fields' ).find( 'input' ).each( function() {
if ( jQuery( this ).attr( 'type' ) != 'radio' ) {
dataToPost += '&' + jQuery( this ).attr( 'name' ) + '=' + encodeURIComponent( jQuery( this ).attr( 'value' ) );
} // End If Statement
});
// Handle Question Input Fields
var radioCount = 0;
jQuery( '#add-new-question' ).find( 'div.' + divFieldsClass ).children('p').children( 'input' ).each( function() {
jQuery( '#add-new-question' ).find( 'div.' + divFieldsClass ).find( 'input' ).each( function() {
if ( jQuery( this ).attr( 'type' ) == 'radio' ) {
// Only get the selected radio button
if ( radioCount == 0 ) {
Expand Down
12 changes: 12 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
*** Sensei Changelog ***

2014.01.23 - version 1.4.8
* New - Allowing access to courses when WooCommerce order is marked as processing
* Fix - Ensuring that all purchased courses show up on the My Courses page
* Fix - Fixing auto grading when all user's answers are incorrect
* Fix - IE compatibility fix for course completion
* Fix - Fixing update script so that all questions are not reset to multiple choice on update
* Fix - Fixing sanitisation of answer input fields
* Fix - Fixing saving of true/false questions
* Fix - Ensuring that new questions do not contain data from previous question added
* Fix - Preventing completed courses widget from showing all courses if none are completed
* Tweak - General CSS tweaks

2013.12.13 - version 1.4.7
* Fix - Fixing add question function for WordPress 3.8+

Expand Down
4 changes: 4 additions & 0 deletions classes/class-woothemes-sensei-course.php
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,10 @@ public function load_user_courses_content( $user = false, $manage = false ) {
$active_html = '';

if( $user ) {

// Allow action to be run before My Courses content has loaded
do_action( 'sensei_before_my_courses', $user->ID );

// Logic for Active and Completed Courses
if ( isset( $woothemes_sensei->settings->settings[ 'my_course_amount' ] ) && ( 0 < absint( $woothemes_sensei->settings->settings[ 'my_course_amount' ] ) ) ) {
$amount = absint( $woothemes_sensei->settings->settings[ 'my_course_amount' ] );
Expand Down
106 changes: 105 additions & 1 deletion classes/class-woothemes-sensei-frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ public function __construct () {
add_action( 'woocommerce_thankyou', array( $this, 'course_link_from_order' ), 10, 1 );
add_action( 'woocommerce_view_order', array( $this, 'course_link_from_order' ), 10, 1 );

// Make sure correct courses are marked as active on My Courses page
add_action( 'sensei_before_my_courses', array( $this, 'activate_purchased_courses' ), 10, 1 );

} // End __construct()

/**
Expand Down Expand Up @@ -1362,7 +1365,10 @@ public function sensei_course_start() {

do_action( 'sensei_user_course_start', $current_user->ID, $post->ID );

echo '<script type="text/javascript">window.location.reload();</script>';
// Refresh page to avoid re-posting
?>
<script type="text/javascript"> window.location = '<?php echo get_permalink( $post->ID ); ?>'; </script>
<?php
} // End If Statement
} // End If Statement
} // End sensei_course_start()
Expand Down Expand Up @@ -1764,5 +1770,103 @@ public function course_link_from_order( $order_id ) {
$woocommerce->show_messages();
}

/**
* Activate all purchased courses for user
* @since 1.4.8
* @param integer $user_id User ID
* @return void
*/
public function activate_purchased_courses( $user_id = 0 ) {

if( $user_id ) {

if( WooThemes_Sensei_Utils::sensei_is_woocommerce_activated() ) {

// Get all user's orders
$order_args = array(
'post_type' => 'shop_order',
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => '_customer_user',
'value' => $user_id
)
),
'tax_query' => array(
array(
'taxonomy' => 'shop_order_status',
'field' => 'slug',
'terms' => array( 'completed', 'processing' )
)
)
);
$orders = get_posts( $order_args );

$product_ids = array();
$order_ids = array();
foreach( $orders as $post ) {

// Only process each order once
$processed = get_post_meta( $post->ID, 'sensei_products_processed', true );
if( $processed && $processed == 'processed' ) {
continue;
}

// Get course product IDs from order
$order = new WC_Order( $post->ID );
$items = $order->get_items();
foreach( $items as $item ) {
$product_id = $item['product_id'];
$product_ids[] = $product_id;
}

$order_ids[] = $post->ID;
}

if( count( $product_ids ) > 0 ) {

// Get all courses from user's orders
$course_args = array(
'post_type' => 'course',
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => '_course_woocommerce_product',
'value' => $product_ids,
'compare' => 'IN'
)
)
);
$courses = get_posts( $course_args );

foreach( $courses as $course ) {

// Ignore course if already completed
$course_completed = WooThemes_Sensei_Utils::sensei_get_activity_value( array( 'post_id' => $course->ID, 'user_id' => $user_id, 'type' => 'sensei_course_end', 'field' => 'comment_content' ) );
if( '' != $course_completed ) {
continue;
}

// Ignore course if already started
$course_started = WooThemes_Sensei_Utils::sensei_get_activity_value( array( 'post_id' => $course->ID, 'user_id' => $user_id, 'type' => 'sensei_course_start', 'field' => 'comment_content' ) );
if( '' != $course_started ) {
continue;
}

// Mark course as started by user
WooThemes_Sensei_Utils::user_start_course( $user_id, $course->ID );
}
}

if( count( $order_ids ) > 0 ) {
foreach( $order_ids as $order_id ) {
// Mark order as processed
update_post_meta( $order_id, 'sensei_products_processed', 'processed' );
}
}
}
}
}

} // End Class
?>
2 changes: 1 addition & 1 deletion classes/class-woothemes-sensei-lesson.php
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ public function enqueue_scripts( $hook ) {
if ( ( ( isset( $post_type ) && in_array( $post_type, $allowed_post_types ) ) && ( isset( $hook ) && in_array( $hook, $allowed_post_type_pages ) ) ) || ( isset( $hook ) && in_array( $hook, $allowed_hooks ) ) ) {

// Load the lessons script
wp_enqueue_script( 'woosensei-lesson-metadata', $woothemes_sensei->plugin_url . 'assets/js/lesson-metadata.js', array( 'jquery' ), '1.4.7' );
wp_enqueue_script( 'woosensei-lesson-metadata', $woothemes_sensei->plugin_url . 'assets/js/lesson-metadata.js', array( 'jquery' ), '1.4.8' );
wp_enqueue_script( 'woosensei-lesson-chosen', $woothemes_sensei->plugin_url . 'assets/chosen/chosen.jquery.min.js', array( 'jquery' ), '1.3.0' );
wp_enqueue_script( 'woosensei-chosen-ajax', $woothemes_sensei->plugin_url . 'assets/chosen/ajax-chosen.jquery.min.js', array( 'jquery', 'woosensei-lesson-chosen' ), '1.4.6' );
$translation_strings = array();
Expand Down
Loading

0 comments on commit fa00a31

Please sign in to comment.