Completed
Push — master ( 78b9e3...efb4fd )
by Dwain
04:49
created
includes/lib/woo-functions.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -3,11 +3,11 @@  discard block
 block discarded – undo
3 3
 /**
4 4
  * Queue updates for the WooUpdater
5 5
  */
6
-if ( ! function_exists( 'woothemes_queue_update' ) ) {
7
-	function woothemes_queue_update( $file, $file_id, $product_id ) {
6
+if ( ! function_exists('woothemes_queue_update')) {
7
+	function woothemes_queue_update($file, $file_id, $product_id) {
8 8
 		global $woothemes_queued_updates;
9 9
 
10
-		if ( ! isset( $woothemes_queued_updates ) )
10
+		if ( ! isset($woothemes_queued_updates))
11 11
 			$woothemes_queued_updates = array();
12 12
 
13 13
 		$plugin             = new stdClass();
@@ -23,56 +23,56 @@  discard block
 block discarded – undo
23 23
  * Load installer for the WooThemes Updater.
24 24
  * @return $api Object
25 25
  */
26
-if ( ! class_exists( 'WooThemes_Updater' ) && ! function_exists( 'woothemes_updater_install' ) ) {
27
-	function woothemes_updater_install( $api, $action, $args ) {
26
+if ( ! class_exists('WooThemes_Updater') && ! function_exists('woothemes_updater_install')) {
27
+	function woothemes_updater_install($api, $action, $args) {
28 28
 		$download_url = 'http://woodojo.s3.amazonaws.com/downloads/woothemes-updater/woothemes-updater.zip';
29 29
 
30
-		if ( 'plugin_information' != $action ||
30
+		if ('plugin_information' != $action ||
31 31
 			false !== $api ||
32
-			! isset( $args->slug ) ||
32
+			! isset($args->slug) ||
33 33
 			'woothemes-updater' != $args->slug
34 34
 		) return $api;
35 35
 
36 36
 		$api = new stdClass();
37 37
 		$api->name = 'WooThemes Updater';
38 38
 		$api->version = '';
39
-		$api->download_link = esc_url( $download_url );
39
+		$api->download_link = esc_url($download_url);
40 40
 		return $api;
41 41
 	}
42 42
 
43
-	add_filter( 'plugins_api', 'woothemes_updater_install', 10, 3 );
43
+	add_filter('plugins_api', 'woothemes_updater_install', 10, 3);
44 44
 }
45 45
 
46 46
 /**
47 47
  * WooUpdater Installation Prompts
48 48
  */
49
-if ( ! class_exists( 'WooThemes_Updater' ) && ! function_exists( 'woothemes_updater_notice' ) ) {
49
+if ( ! class_exists('WooThemes_Updater') && ! function_exists('woothemes_updater_notice')) {
50 50
 
51 51
 	/**
52 52
 	 * Display a notice if the "WooThemes Updater" plugin hasn't been installed.
53 53
 	 * @return void
54 54
 	 */
55 55
 	function woothemes_updater_notice() {
56
-		$active_plugins = apply_filters( 'active_plugins', get_option('active_plugins' ) );
57
-		if ( in_array( 'woothemes-updater/woothemes-updater.php', $active_plugins ) ) return;
56
+		$active_plugins = apply_filters('active_plugins', get_option('active_plugins'));
57
+		if (in_array('woothemes-updater/woothemes-updater.php', $active_plugins)) return;
58 58
 
59 59
 		$slug = 'woothemes-updater';
60
-		$install_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $slug ), 'install-plugin_' . $slug );
61
-		$activate_url = 'plugins.php?action=activate&plugin=' . urlencode( 'woothemes-updater/woothemes-updater.php' ) . '&plugin_status=all&paged=1&s&_wpnonce=' . urlencode( wp_create_nonce( 'activate-plugin_woothemes-updater/woothemes-updater.php' ) );
60
+		$install_url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin='.$slug), 'install-plugin_'.$slug);
61
+		$activate_url = 'plugins.php?action=activate&plugin='.urlencode('woothemes-updater/woothemes-updater.php').'&plugin_status=all&paged=1&s&_wpnonce='.urlencode(wp_create_nonce('activate-plugin_woothemes-updater/woothemes-updater.php'));
62 62
 
63
-		$message = '<a href="' . esc_url( $install_url ) . '">Install the WooThemes Updater plugin</a> to get updates for your WooThemes plugins.';
63
+		$message = '<a href="'.esc_url($install_url).'">Install the WooThemes Updater plugin</a> to get updates for your WooThemes plugins.';
64 64
 		$is_downloaded = false;
65
-		$plugins = array_keys( get_plugins() );
66
-		foreach ( $plugins as $plugin ) {
67
-			if ( strpos( $plugin, 'woothemes-updater.php' ) !== false ) {
65
+		$plugins = array_keys(get_plugins());
66
+		foreach ($plugins as $plugin) {
67
+			if (strpos($plugin, 'woothemes-updater.php') !== false) {
68 68
 				$is_downloaded = true;
69
-				$message = '<a href="' . esc_url( admin_url( $activate_url ) ) . '">Activate the WooThemes Updater plugin</a> to get updates for your WooThemes plugins.';
69
+				$message = '<a href="'.esc_url(admin_url($activate_url)).'">Activate the WooThemes Updater plugin</a> to get updates for your WooThemes plugins.';
70 70
 			}
71 71
 		}
72
-		echo '<div class="updated fade"><p>' . $message . '</p></div>' . "\n";
72
+		echo '<div class="updated fade"><p>'.$message.'</p></div>'."\n";
73 73
 	}
74 74
 
75
-	add_action( 'admin_notices', 'woothemes_updater_notice' );
75
+	add_action('admin_notices', 'woothemes_updater_notice');
76 76
 }
77 77
 
78 78
 /**
@@ -81,11 +81,11 @@  discard block
 block discarded – undo
81 81
  * @param  $version Version to check against
82 82
  * @return @boolean
83 83
  */
84
-if( ! function_exists( 'sensei_check_woocommerce_version' ) ) {
85
-	function sensei_check_woocommerce_version( $version = '2.1' ) {
86
-		if ( Sensei_WC::is_woocommerce_active() ) {
84
+if ( ! function_exists('sensei_check_woocommerce_version')) {
85
+	function sensei_check_woocommerce_version($version = '2.1') {
86
+		if (Sensei_WC::is_woocommerce_active()) {
87 87
 			global $woocommerce;
88
-			if( version_compare( $woocommerce->version, $version, ">=" ) ) {
88
+			if (version_compare($woocommerce->version, $version, ">=")) {
89 89
 			    return true;
90 90
 			}
91 91
 		}
Please login to merge, or discard this patch.
includes/class-sensei-grading-user-quiz.php 1 patch
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly
3 3
 
4 4
 /**
5 5
  * Sensei Grading User Quiz Class
@@ -22,10 +22,10 @@  discard block
 block discarded – undo
22 22
 	 * @since  1.3.0
23 23
 	 * @return  void
24 24
 	 */
25
-	public function __construct ( $user_id = 0, $quiz_id = 0 ) {
26
-		$this->user_id = intval( $user_id );
27
-		$this->quiz_id = intval( $quiz_id );
28
-		$this->lesson_id = get_post_meta( $this->quiz_id, '_quiz_lesson', true );
25
+	public function __construct($user_id = 0, $quiz_id = 0) {
26
+		$this->user_id = intval($user_id);
27
+		$this->quiz_id = intval($quiz_id);
28
+		$this->lesson_id = get_post_meta($this->quiz_id, '_quiz_lesson', true);
29 29
 	} // End __construct()
30 30
 
31 31
 	/**
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 * @return array
36 36
 	 */
37 37
 	public function build_data_array() {
38
-		$data_array = Sensei_Utils::sensei_get_quiz_questions( $this->quiz_id );
38
+		$data_array = Sensei_Utils::sensei_get_quiz_questions($this->quiz_id);
39 39
 		return $data_array;
40 40
 	} // End build_data_array()
41 41
 
@@ -60,94 +60,94 @@  discard block
 block discarded – undo
60 60
         $lesson_id = $this->lesson_id;
61 61
         $user_id = $this->user_id;
62 62
 
63
-		?><form name="<?php esc_attr_e( 'quiz_' . $this->quiz_id ); ?>" action="" method="post">
64
-			<?php wp_nonce_field( 'sensei_manual_grading', '_wp_sensei_manual_grading_nonce' ); ?>
65
-			<input type="hidden" name="sensei_manual_grade" value="<?php esc_attr_e( $this->quiz_id ); ?>" />
66
-			<input type="hidden" name="sensei_grade_next_learner" value="<?php esc_attr_e( $this->user_id ); ?>" />
63
+		?><form name="<?php esc_attr_e('quiz_'.$this->quiz_id); ?>" action="" method="post">
64
+			<?php wp_nonce_field('sensei_manual_grading', '_wp_sensei_manual_grading_nonce'); ?>
65
+			<input type="hidden" name="sensei_manual_grade" value="<?php esc_attr_e($this->quiz_id); ?>" />
66
+			<input type="hidden" name="sensei_grade_next_learner" value="<?php esc_attr_e($this->user_id); ?>" />
67 67
 			<div class="total_grade_display">
68
-				<span><?php esc_attr_e( __( 'Grade:', 'woothemes-sensei' ) ); ?></span>
68
+				<span><?php esc_attr_e(__('Grade:', 'woothemes-sensei')); ?></span>
69 69
 				<span class="total_grade_total"><?php echo $user_quiz_grade_total; ?></span> / <span class="quiz_grade_total"><?php echo $quiz_grade_total; ?></span> (<span class="total_grade_percent"><?php echo $quiz_grade; ?></span>%)
70 70
 			</div>
71 71
 			<div class="buttons">
72
-				<input type="submit" value="<?php esc_attr_e( __( 'Save', 'woothemes-sensei' ) ); ?>" class="grade-button button-primary" title="Saves grades as currently marked on this page" />
73
-				<input type="button" value="<?php esc_attr_e( __( 'Auto grade', 'woothemes-sensei' ) ); ?>" class="autograde-button button-secondary" title="Where possible, automatically grades questions that have not yet been graded" />
74
-				<input type="reset" value="<?php esc_attr_e( __( 'Reset', 'woothemes-sensei' ) ); ?>" class="reset-button button-secondary" title="Resets all questions to ungraded and total grade to 0" />
72
+				<input type="submit" value="<?php esc_attr_e(__('Save', 'woothemes-sensei')); ?>" class="grade-button button-primary" title="Saves grades as currently marked on this page" />
73
+				<input type="button" value="<?php esc_attr_e(__('Auto grade', 'woothemes-sensei')); ?>" class="autograde-button button-secondary" title="Where possible, automatically grades questions that have not yet been graded" />
74
+				<input type="reset" value="<?php esc_attr_e(__('Reset', 'woothemes-sensei')); ?>" class="reset-button button-secondary" title="Resets all questions to ungraded and total grade to 0" />
75 75
 			</div>
76 76
 			<div class="clear"></div><br/><?php
77 77
 
78
-		$lesson_status_id = Sensei_Utils::sensei_get_activity_value( array( 'post_id' => $this->lesson_id, 'user_id' => $this->user_id, 'type' => 'sensei_lesson_status', 'field' => 'comment_ID' ) );
79
-		$user_quiz_grade = get_comment_meta( $lesson_status_id, 'grade', true );
78
+		$lesson_status_id = Sensei_Utils::sensei_get_activity_value(array('post_id' => $this->lesson_id, 'user_id' => $this->user_id, 'type' => 'sensei_lesson_status', 'field' => 'comment_ID'));
79
+		$user_quiz_grade = get_comment_meta($lesson_status_id, 'grade', true);
80 80
 		$correct_answers = 0;
81 81
 
82
-		foreach( $questions as $question ) {
82
+		foreach ($questions as $question) {
83 83
 			$question_id = $question->ID;
84 84
 			++$count;
85 85
 
86 86
 			$type = false;
87 87
 			$type_name = '';
88 88
 
89
-			$type = Sensei()->question->get_question_type( $question_id );
89
+			$type = Sensei()->question->get_question_type($question_id);
90 90
 
91
-			$question_answer_notes = Sensei()->quiz->get_user_question_feedback( $lesson_id, $question_id, $user_id );
91
+			$question_answer_notes = Sensei()->quiz->get_user_question_feedback($lesson_id, $question_id, $user_id);
92 92
 
93 93
 
94
-			$question_grade_total = Sensei()->question->get_question_grade( $question_id );
94
+			$question_grade_total = Sensei()->question->get_question_grade($question_id);
95 95
 			$quiz_grade_total += $question_grade_total;
96 96
 
97
-			$right_answer = get_post_meta( $question_id, '_question_right_answer', true );
98
-			$user_answer_content = Sensei()->quiz->get_user_question_answer( $lesson_id, $question_id, $user_id );
99
-			$type_name = __( 'Multiple Choice', 'woothemes-sensei' );
97
+			$right_answer = get_post_meta($question_id, '_question_right_answer', true);
98
+			$user_answer_content = Sensei()->quiz->get_user_question_answer($lesson_id, $question_id, $user_id);
99
+			$type_name = __('Multiple Choice', 'woothemes-sensei');
100 100
 			$grade_type = 'manual-grade';
101 101
 
102
-			switch( $type ) {
102
+			switch ($type) {
103 103
 				case 'boolean':
104
-					$type_name = __( 'True/False', 'woothemes-sensei' );
105
-					$right_answer = ucfirst( $right_answer );
106
-					$user_answer_content = ucfirst( $user_answer_content );
104
+					$type_name = __('True/False', 'woothemes-sensei');
105
+					$right_answer = ucfirst($right_answer);
106
+					$user_answer_content = ucfirst($user_answer_content);
107 107
 					$grade_type = 'auto-grade';
108 108
 				break;
109 109
 				case 'multiple-choice':
110
-					$type_name = __( 'Multiple Choice', 'woothemes-sensei' );
110
+					$type_name = __('Multiple Choice', 'woothemes-sensei');
111 111
 					$grade_type = 'auto-grade';
112 112
 				break;
113 113
 				case 'gap-fill':
114
-					$type_name = __( 'Gap Fill', 'woothemes-sensei' );
114
+					$type_name = __('Gap Fill', 'woothemes-sensei');
115 115
 
116
-					$right_answer_array = explode( '||', $right_answer );
117
-					if ( isset( $right_answer_array[0] ) ) { $gapfill_pre = $right_answer_array[0]; } else { $gapfill_pre = ''; }
118
-					if ( isset( $right_answer_array[1] ) ) { $gapfill_gap = $right_answer_array[1]; } else { $gapfill_gap = ''; }
119
-					if ( isset( $right_answer_array[2] ) ) { $gapfill_post = $right_answer_array[2]; } else { $gapfill_post = ''; }
116
+					$right_answer_array = explode('||', $right_answer);
117
+					if (isset($right_answer_array[0])) { $gapfill_pre = $right_answer_array[0]; } else { $gapfill_pre = ''; }
118
+					if (isset($right_answer_array[1])) { $gapfill_gap = $right_answer_array[1]; } else { $gapfill_gap = ''; }
119
+					if (isset($right_answer_array[2])) { $gapfill_post = $right_answer_array[2]; } else { $gapfill_post = ''; }
120 120
 
121
-					if( ! $user_answer_content ) {
121
+					if ( ! $user_answer_content) {
122 122
 						$user_answer_content = '______';
123 123
 					}
124 124
 
125
-					$right_answer = $gapfill_pre . ' <span class="highlight">' . $gapfill_gap . '</span> ' . $gapfill_post;
126
-					$user_answer_content = $gapfill_pre . ' <span class="highlight">' . $user_answer_content . '</span> ' . $gapfill_post;
125
+					$right_answer = $gapfill_pre.' <span class="highlight">'.$gapfill_gap.'</span> '.$gapfill_post;
126
+					$user_answer_content = $gapfill_pre.' <span class="highlight">'.$user_answer_content.'</span> '.$gapfill_post;
127 127
 					$grade_type = 'auto-grade';
128 128
 
129 129
 				break;
130 130
 				case 'multi-line':
131
-					$type_name = __( 'Multi Line', 'woothemes-sensei' );
131
+					$type_name = __('Multi Line', 'woothemes-sensei');
132 132
 					$grade_type = 'manual-grade';
133 133
 				break;
134 134
 				case 'single-line':
135
-					$type_name = __( 'Single Line', 'woothemes-sensei' );
135
+					$type_name = __('Single Line', 'woothemes-sensei');
136 136
 					$grade_type = 'manual-grade';
137 137
 				break;
138 138
 				case 'file-upload':
139
-					$type_name = __( 'File Upload', 'woothemes-sensei' );
139
+					$type_name = __('File Upload', 'woothemes-sensei');
140 140
 					$grade_type = 'manual-grade';
141 141
 
142 142
 					// Get uploaded file
143
-					if( $user_answer_content ) {
143
+					if ($user_answer_content) {
144 144
 						$attachment_id = $user_answer_content;
145 145
 						$answer_media_url = $answer_media_filename = '';
146
-						if( 0 < intval( $attachment_id ) ) {
147
-							$answer_media_url = wp_get_attachment_url( $attachment_id );
148
-							$answer_media_filename = basename( $answer_media_url );
149
-							if( $answer_media_url && $answer_media_filename ) {
150
-								$user_answer_content = sprintf( __( 'Submitted file: %1$s', 'woothemes-sensei' ), '<a href="' . esc_url( $answer_media_url ) . '" target="_blank">' . esc_html( $answer_media_filename ) . '</a>' );
146
+						if (0 < intval($attachment_id)) {
147
+							$answer_media_url = wp_get_attachment_url($attachment_id);
148
+							$answer_media_filename = basename($answer_media_url);
149
+							if ($answer_media_url && $answer_media_filename) {
150
+								$user_answer_content = sprintf(__('Submitted file: %1$s', 'woothemes-sensei'), '<a href="'.esc_url($answer_media_url).'" target="_blank">'.esc_html($answer_media_filename).'</a>');
151 151
 							}
152 152
 						}
153 153
 					} else {
@@ -160,12 +160,12 @@  discard block
 block discarded – undo
160 160
 			}
161 161
 			$user_answer_content = (array) $user_answer_content;
162 162
 			$right_answer = (array) $right_answer;
163
-			$question_title = sprintf( __( 'Question %d: ', 'woothemes-sensei' ), $count ) . $type_name;
163
+			$question_title = sprintf(__('Question %d: ', 'woothemes-sensei'), $count).$type_name;
164 164
 
165 165
 			$graded_class = '';
166
-			$user_question_grade = Sensei()->quiz->get_user_question_grade( $lesson_id, $question_id, $user_id );
166
+			$user_question_grade = Sensei()->quiz->get_user_question_grade($lesson_id, $question_id, $user_id);
167 167
 			$graded_class = 'ungraded';
168
-			if ( 0 == $question_grade_total && 0 == intval( $user_question_grade ) ) {
168
+			if (0 == $question_grade_total && 0 == intval($user_question_grade)) {
169 169
 				// Question skips grading
170 170
 				$grade_type = 'zero-graded';
171 171
 				$graded_class = '';
@@ -173,86 +173,86 @@  discard block
 block discarded – undo
173 173
 				++$graded_count;
174 174
 				$user_question_grade = 0;
175 175
 			}
176
-			elseif( intval( $user_question_grade ) > 0 ) {
176
+			elseif (intval($user_question_grade) > 0) {
177 177
 				$graded_class = 'user_right';
178 178
 				++$correct_answers;
179 179
 				$user_quiz_grade_total += $user_question_grade;
180 180
 				++$graded_count;
181 181
 			} else {
182
-				if( ! is_string( $user_question_grade ) && intval( $user_question_grade ) == 0 ) {
182
+				if ( ! is_string($user_question_grade) && intval($user_question_grade) == 0) {
183 183
 					$graded_class = 'user_wrong';
184 184
 					++$graded_count;
185 185
 				}
186 186
 				$user_question_grade = 0;
187 187
 			}
188 188
 
189
-			?><div class="postbox question_box <?php esc_attr_e( $type ); ?> <?php esc_attr_e( $grade_type ); ?> <?php esc_attr_e( $graded_class ); ?>" id="<?php esc_attr_e( 'question_' . $question_id . '_box' ); ?>">
189
+			?><div class="postbox question_box <?php esc_attr_e($type); ?> <?php esc_attr_e($grade_type); ?> <?php esc_attr_e($graded_class); ?>" id="<?php esc_attr_e('question_'.$question_id.'_box'); ?>">
190 190
 				<div class="handlediv" title="Click to toggle"><br></div>
191 191
 				<h3 class="hndle"><span><?php echo $question_title; ?></span></h3>
192 192
 				<div class="inside">
193 193
 					<div class="sensei-grading-actions">
194 194
 						<div class="actions">
195
-							<input type="hidden" class="question_id" value="<?php esc_attr_e( $question_id ); ?>" />
196
-							<input type="hidden" class="question_total_grade" name="question_total_grade" value="<?php echo esc_attr( $question_grade_total ); ?>" />
197
-							<span class="grading-mark icon_right"><input type="radio" class="<?php esc_attr_e( 'question_' . $question_id . '_right_option' ); ?>" name="<?php esc_attr_e( 'question_' . $question_id ); ?>" value="right" <?php checked( $graded_class, 'user_right', true ); ?> /></span>
198
-							<span class="grading-mark icon_wrong"><input type="radio" class="<?php esc_attr_e( 'question_' . $question_id . '_wrong_option' ); ?>" name="<?php esc_attr_e( 'question_' . $question_id ); ?>" value="wrong" <?php checked( $graded_class, 'user_wrong', true ); ?> /></span>
199
-							<input type="number" class="question-grade" name="<?php esc_attr_e( 'question_' . $question_id . '_grade' ); ?>" id="<?php esc_attr_e( 'question_' . $question_id . '_grade' ); ?>" value="<?php echo esc_attr( $user_question_grade ); ?>" min="0" max="<?php echo esc_attr( $question_grade_total ); ?>" />
195
+							<input type="hidden" class="question_id" value="<?php esc_attr_e($question_id); ?>" />
196
+							<input type="hidden" class="question_total_grade" name="question_total_grade" value="<?php echo esc_attr($question_grade_total); ?>" />
197
+							<span class="grading-mark icon_right"><input type="radio" class="<?php esc_attr_e('question_'.$question_id.'_right_option'); ?>" name="<?php esc_attr_e('question_'.$question_id); ?>" value="right" <?php checked($graded_class, 'user_right', true); ?> /></span>
198
+							<span class="grading-mark icon_wrong"><input type="radio" class="<?php esc_attr_e('question_'.$question_id.'_wrong_option'); ?>" name="<?php esc_attr_e('question_'.$question_id); ?>" value="wrong" <?php checked($graded_class, 'user_wrong', true); ?> /></span>
199
+							<input type="number" class="question-grade" name="<?php esc_attr_e('question_'.$question_id.'_grade'); ?>" id="<?php esc_attr_e('question_'.$question_id.'_grade'); ?>" value="<?php echo esc_attr($user_question_grade); ?>" min="0" max="<?php echo esc_attr($question_grade_total); ?>" />
200 200
 							<span class="question-grade-total"><?php echo $question_grade_total; ?></span>
201 201
 						</div>
202 202
 					</div>
203 203
 					<div class="sensei-grading-answer">
204
-						<h4><?php echo apply_filters( 'sensei_question_title', $question->post_title ); ?></h4>
205
-						<?php echo apply_filters( 'the_content', $question->post_content );?>
204
+						<h4><?php echo apply_filters('sensei_question_title', $question->post_title); ?></h4>
205
+						<?php echo apply_filters('the_content', $question->post_content); ?>
206 206
 						<p class="user-answer"><?php
207
-							foreach ( $user_answer_content as $_user_answer ) {
207
+							foreach ($user_answer_content as $_user_answer) {
208 208
 
209
-                                if( 'multi-line' == Sensei()->question->get_question_type( $question->ID ) ){
209
+                                if ('multi-line' == Sensei()->question->get_question_type($question->ID)) {
210 210
 
211
-                                    $_user_answer = htmlspecialchars_decode( nl2br( esc_html($_user_answer) ) );
211
+                                    $_user_answer = htmlspecialchars_decode(nl2br(esc_html($_user_answer)));
212 212
 
213 213
                                 }
214 214
 
215
-								echo apply_filters( 'sensei_answer_text', $_user_answer ) . "<br>";
215
+								echo apply_filters('sensei_answer_text', $_user_answer)."<br>";
216 216
 							}
217 217
 						?></p>
218 218
 						<div class="right-answer">
219
-							<h5><?php _e( 'Correct answer', 'woothemes-sensei' ) ?></h5>
219
+							<h5><?php _e('Correct answer', 'woothemes-sensei') ?></h5>
220 220
 							<span class="correct-answer"><?php
221
-								foreach ( $right_answer as $_right_answer ) {
221
+								foreach ($right_answer as $_right_answer) {
222 222
 
223
-									echo apply_filters( 'sensei_answer_text', $_right_answer ) . "<br>";
223
+									echo apply_filters('sensei_answer_text', $_right_answer)."<br>";
224 224
 
225 225
 								}
226 226
 							?></span>
227 227
 						</div>
228 228
 						<div class="answer-notes">
229
-							<h5><?php _e( 'Grading Notes', 'woothemes-sensei' ) ?></h5>
230
-							<textarea class="correct-answer" name="questions_feedback[<?php esc_attr_e( $question_id ); ?>]" placeholder="<?php _e( 'Add notes here...', 'woothemes-sensei' ) ?>"><?php echo $question_answer_notes; ?></textarea>
229
+							<h5><?php _e('Grading Notes', 'woothemes-sensei') ?></h5>
230
+							<textarea class="correct-answer" name="questions_feedback[<?php esc_attr_e($question_id); ?>]" placeholder="<?php _e('Add notes here...', 'woothemes-sensei') ?>"><?php echo $question_answer_notes; ?></textarea>
231 231
 						</div>
232 232
 					</div>
233 233
 				</div>
234 234
 			</div><?php
235 235
 		}
236 236
 
237
-		$quiz_grade = intval( $user_quiz_grade );
237
+		$quiz_grade = intval($user_quiz_grade);
238 238
 		$all_graded = 'no';
239
-		if( intval( $count ) == intval( $graded_count ) ) {
239
+		if (intval($count) == intval($graded_count)) {
240 240
 			$all_graded = 'yes';
241 241
 		}
242 242
 
243
-		?>  <input type="hidden" name="total_grade" id="total_grade" value="<?php esc_attr_e( $user_quiz_grade_total ); ?>" />
244
-			<input type="hidden" name="total_questions" id="total_questions" value="<?php esc_attr_e( $count ); ?>" />
245
-			<input type="hidden" name="quiz_grade_total" id="quiz_grade_total" value="<?php esc_attr_e( $quiz_grade_total ); ?>" />
246
-			<input type="hidden" name="total_graded_questions" id="total_graded_questions" value="<?php esc_attr_e( $graded_count ); ?>" />
247
-			<input type="hidden" name="all_questions_graded" id="all_questions_graded" value="<?php esc_attr_e( $all_graded ); ?>" />
243
+		?>  <input type="hidden" name="total_grade" id="total_grade" value="<?php esc_attr_e($user_quiz_grade_total); ?>" />
244
+			<input type="hidden" name="total_questions" id="total_questions" value="<?php esc_attr_e($count); ?>" />
245
+			<input type="hidden" name="quiz_grade_total" id="quiz_grade_total" value="<?php esc_attr_e($quiz_grade_total); ?>" />
246
+			<input type="hidden" name="total_graded_questions" id="total_graded_questions" value="<?php esc_attr_e($graded_count); ?>" />
247
+			<input type="hidden" name="all_questions_graded" id="all_questions_graded" value="<?php esc_attr_e($all_graded); ?>" />
248 248
 			<div class="total_grade_display">
249
-				<span><?php esc_attr_e( __( 'Grade:', 'woothemes-sensei' ) ); ?></span>
249
+				<span><?php esc_attr_e(__('Grade:', 'woothemes-sensei')); ?></span>
250 250
 				<span class="total_grade_total"><?php echo $user_quiz_grade_total; ?></span> / <span class="quiz_grade_total"><?php echo $quiz_grade_total; ?></span> (<span class="total_grade_percent"><?php echo $quiz_grade; ?></span>%)
251 251
 			</div>
252 252
 			<div class="buttons">
253
-				<input type="submit" value="<?php esc_attr_e( 'Save' ); ?>" class="grade-button button-primary" title="Saves grades as currently marked on this page" />
254
-				<input type="button" value="<?php esc_attr_e( __( 'Auto grade', 'woothemes-sensei' ) ); ?>" class="autograde-button button-secondary" title="Where possible, automatically grades questions that have not yet been graded" />
255
-				<input type="reset" value="<?php esc_attr_e( __( 'Reset', 'woothemes-sensei' ) ); ?>" class="reset-button button-secondary" title="Resets all questions to ungraded and total grade to 0" />
253
+				<input type="submit" value="<?php esc_attr_e('Save'); ?>" class="grade-button button-primary" title="Saves grades as currently marked on this page" />
254
+				<input type="button" value="<?php esc_attr_e(__('Auto grade', 'woothemes-sensei')); ?>" class="autograde-button button-secondary" title="Where possible, automatically grades questions that have not yet been graded" />
255
+				<input type="reset" value="<?php esc_attr_e(__('Reset', 'woothemes-sensei')); ?>" class="reset-button button-secondary" title="Resets all questions to ungraded and total grade to 0" />
256 256
 			</div>
257 257
 			<div class="clear"></div>
258 258
 			<script type="text/javascript">
@@ -271,4 +271,4 @@  discard block
 block discarded – undo
271 271
  * for backward compatibility
272 272
  * @since 1.9.0
273 273
  */
274
-class WooThemes_Sensei_Grading_User_Quiz extends Sensei_Grading_User_Quiz{}
274
+class WooThemes_Sensei_Grading_User_Quiz extends Sensei_Grading_User_Quiz {}
Please login to merge, or discard this patch.
includes/shortcodes/class-sensei-shortcode-user-messages.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly
3 3
 /**
4 4
  *
5 5
  * Renders the [sensei_user_messages] shortcode. The current users messages.
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
      * @param string $content
30 30
      * @param string $shortcode the shortcode that was called for this instance
31 31
      */
32
-    public function __construct( $attributes, $content, $shortcode ){
32
+    public function __construct($attributes, $content, $shortcode) {
33 33
 
34 34
         $this->setup_messages_query();
35 35
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
      *
41 41
      * @return mixed
42 42
      */
43
-    public function setup_messages_query(){
43
+    public function setup_messages_query() {
44 44
 
45 45
         $user = wp_get_current_user();
46 46
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
             ),
60 60
         );
61 61
 
62
-        $this->messages_query  = new WP_Query( $args );
62
+        $this->messages_query = new WP_Query($args);
63 63
     }
64 64
 
65 65
     /**
@@ -67,22 +67,22 @@  discard block
 block discarded – undo
67 67
      *
68 68
      * @return string $content
69 69
      */
70
-    public function render(){
70
+    public function render() {
71 71
 
72
-        if( !is_user_logged_in() ){
72
+        if ( ! is_user_logged_in()) {
73 73
 
74
-            Sensei()->notices->add_notice( __('Please login to view your messages.','woothemes-sensei') , 'alert'  );
74
+            Sensei()->notices->add_notice(__('Please login to view your messages.', 'woothemes-sensei'), 'alert');
75 75
 
76
-        } elseif( 0 == $this->messages_query->post_count ){
76
+        } elseif (0 == $this->messages_query->post_count) {
77 77
 
78
-            Sensei()->notices->add_notice( __( 'You do not have any messages.', 'woothemes-sensei') , 'alert'  );
78
+            Sensei()->notices->add_notice(__('You do not have any messages.', 'woothemes-sensei'), 'alert');
79 79
         }
80 80
 
81
-        $messages_disabled_in_settings =  ! ( ! isset( Sensei()->settings->settings['messages_disable'] )
82
-                                            || ! Sensei()->settings->settings['messages_disable'] ) ;
81
+        $messages_disabled_in_settings = ! ( ! isset(Sensei()->settings->settings['messages_disable'])
82
+                                            || ! Sensei()->settings->settings['messages_disable']);
83 83
 
84 84
         // don't show anything if messages are disable
85
-        if( $messages_disabled_in_settings ){
85
+        if ($messages_disabled_in_settings) {
86 86
             return '';
87 87
         }
88 88
 
Please login to merge, or discard this patch.
includes/class-sensei-autoloader.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // security check, don't load file outside WP
2
+if ( ! defined('ABSPATH')) exit; // security check, don't load file outside WP
3 3
 /**
4 4
  * Sensei Autoloader Class
5 5
  *
@@ -27,21 +27,21 @@  discard block
 block discarded – undo
27 27
      * Constructor
28 28
      * @since 1.9.0
29 29
      */
30
-    public function __construct(){
30
+    public function __construct() {
31 31
 
32 32
         // make sure we do not override an existing autoload function
33
-        if( function_exists('__autoload') ){
34
-           spl_autoload_register( '__autoload' );
33
+        if (function_exists('__autoload')) {
34
+           spl_autoload_register('__autoload');
35 35
         }
36 36
 
37 37
         // setup a relative path for the current autoload instance
38
-        $this->include_path = trailingslashit( untrailingslashit( dirname( __FILE__ ) ) );
38
+        $this->include_path = trailingslashit(untrailingslashit(dirname(__FILE__)));
39 39
 
40 40
         //setup the class file map
41 41
         $this->initialize_class_file_map();
42 42
 
43 43
         // add Sensei custom auto loader
44
-        spl_autoload_register( array( $this, 'autoload' )  );
44
+        spl_autoload_register(array($this, 'autoload'));
45 45
 
46 46
     }
47 47
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      *
52 52
      * @since 1.9.0
53 53
      */
54
-    public function initialize_class_file_map(){
54
+    public function initialize_class_file_map() {
55 55
 
56 56
         $this->class_file_map = array(
57 57
 
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
             /**
64 64
              * Admin
65 65
              */
66
-            'Sensei_Welcome'            => 'admin/class-sensei-welcome.php' ,
67
-            'Sensei_Learner_Management' => 'admin/class-sensei-learner-management.php' ,
66
+            'Sensei_Welcome'            => 'admin/class-sensei-welcome.php',
67
+            'Sensei_Learner_Management' => 'admin/class-sensei-learner-management.php',
68 68
 
69 69
             /**
70 70
              * Shortcodes
@@ -93,38 +93,38 @@  discard block
 block discarded – undo
93 93
     /**
94 94
      * Autoload all sensei files as the class names are used.
95 95
      */
96
-    public function autoload( $class ){
96
+    public function autoload($class) {
97 97
 
98 98
         // only handle classes with the word `sensei` in it
99
-        if( ! is_numeric( strpos ( strtolower( $class ), 'sensei') ) ){
99
+        if ( ! is_numeric(strpos(strtolower($class), 'sensei'))) {
100 100
 
101 101
             return;
102 102
 
103 103
         }
104 104
 
105 105
         // exit if we didn't provide mapping for this class
106
-        if( isset( $this->class_file_map[ $class ] ) ){
106
+        if (isset($this->class_file_map[$class])) {
107 107
 
108
-            $file_location = $this->include_path . $this->class_file_map[ $class ];
109
-            require_once( $file_location);
108
+            $file_location = $this->include_path.$this->class_file_map[$class];
109
+            require_once($file_location);
110 110
             return;
111 111
 
112 112
         }
113 113
 
114 114
         // check for file in the main includes directory
115
-        $class_file_path = $this->include_path . 'class-'.str_replace( '_','-', strtolower( $class ) ) . '.php';
116
-        if( file_exists( $class_file_path ) ){
115
+        $class_file_path = $this->include_path.'class-'.str_replace('_', '-', strtolower($class)).'.php';
116
+        if (file_exists($class_file_path)) {
117 117
 
118
-            require_once( $class_file_path );
118
+            require_once($class_file_path);
119 119
             return;
120 120
         }
121 121
 
122 122
         // lastly check legacy types
123
-        $stripped_woothemes_from_class = str_replace( 'woothemes_','', strtolower( $class ) ); // remove woothemes
124
-        $legacy_class_file_path = $this->include_path . 'class-'.str_replace( '_','-', strtolower( $stripped_woothemes_from_class ) ) . '.php';
125
-        if( file_exists( $legacy_class_file_path ) ){
123
+        $stripped_woothemes_from_class = str_replace('woothemes_', '', strtolower($class)); // remove woothemes
124
+        $legacy_class_file_path = $this->include_path.'class-'.str_replace('_', '-', strtolower($stripped_woothemes_from_class)).'.php';
125
+        if (file_exists($legacy_class_file_path)) {
126 126
 
127
-            require_once( $legacy_class_file_path );
127
+            require_once($legacy_class_file_path);
128 128
             return;
129 129
         }
130 130
 
Please login to merge, or discard this patch.
includes/theme-integrations/theme-integration-loader.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
      *
36 36
      * @since 1.9.0
37 37
      */
38
-    private function setup_themes(){
38
+    private function setup_themes() {
39 39
 
40 40
         $this->themes = array(
41 41
             'twentyeleven',
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      *
55 55
      * @since 1.9.0
56 56
      */
57
-    private function setup_currently_active_theme(){
57
+    private function setup_currently_active_theme() {
58 58
 
59 59
         $this->active_theme = get_option('template');
60 60
 
@@ -67,33 +67,33 @@  discard block
 block discarded – undo
67 67
      *
68 68
      * @since 1.9.0
69 69
      */
70
-    private function possibly_load_supported_theme_wrappers(){
70
+    private function possibly_load_supported_theme_wrappers() {
71 71
 
72
-        if ( in_array( $this->active_theme, $this->themes ) ){
72
+        if (in_array($this->active_theme, $this->themes)) {
73 73
 
74 74
             // setup file and class names
75
-            $supported_theme_class_file = trailingslashit( Sensei()->plugin_path ) . 'includes/theme-integrations/' . $this->active_theme . '.php';
76
-            $supported_theme_class_name  = 'Sensei_'. ucfirst( $this->active_theme  );
75
+            $supported_theme_class_file = trailingslashit(Sensei()->plugin_path).'includes/theme-integrations/'.$this->active_theme.'.php';
76
+            $supported_theme_class_name = 'Sensei_'.ucfirst($this->active_theme);
77 77
 
78 78
             // load the file or exit if there is no file for this theme
79
-            if( ! file_exists( $supported_theme_class_file ) ){
79
+            if ( ! file_exists($supported_theme_class_file)) {
80 80
                 return;
81 81
             }
82
-            include_once( $supported_theme_class_file );
83
-            include_once( 'twentytwelve.php' );
82
+            include_once($supported_theme_class_file);
83
+            include_once('twentytwelve.php');
84 84
             //initialize the class or exit if there is no class for this theme
85
-            if( ! class_exists( $supported_theme_class_name ) ){
85
+            if ( ! class_exists($supported_theme_class_name)) {
86 86
                 return;
87 87
             }
88 88
             $supported_theme = new $supported_theme_class_name;
89 89
 
90 90
             // remove default wrappers
91
-            remove_action( 'sensei_before_main_content', array( Sensei()->frontend, 'sensei_output_content_wrapper' ), 10 );
92
-            remove_action( 'sensei_after_main_content', array( Sensei()->frontend, 'sensei_output_content_wrapper_end' ), 10 );
91
+            remove_action('sensei_before_main_content', array(Sensei()->frontend, 'sensei_output_content_wrapper'), 10);
92
+            remove_action('sensei_after_main_content', array(Sensei()->frontend, 'sensei_output_content_wrapper_end'), 10);
93 93
 
94 94
             // load the supported theme wrappers
95
-            add_action( 'sensei_before_main_content', array( $supported_theme, 'wrapper_start' ), 10 );
96
-            add_action( 'sensei_after_main_content', array( $supported_theme, 'wrapper_end' ), 10 );
95
+            add_action('sensei_before_main_content', array($supported_theme, 'wrapper_start'), 10);
96
+            add_action('sensei_after_main_content', array($supported_theme, 'wrapper_end'), 10);
97 97
         }
98 98
     }
99 99
 
Please login to merge, or discard this patch.
includes/theme-integrations/twentyfifteen.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
      * Output opening wrappers
14 14
      * @since 1.9.0
15 15
      */
16
-    public function wrapper_start(){
16
+    public function wrapper_start() {
17 17
 
18 18
         // output inline styles
19 19
         $this->print_styles();
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
      *
31 31
      * @since 1.9.0
32 32
      */
33
-    private function print_styles(){?>
33
+    private function print_styles() {?>
34 34
 
35 35
         <style>
36 36
             @media screen and (min-width: 59.6875em){
Please login to merge, or discard this patch.
includes/theme-integrations/_s.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
      * Output opening wrappers
14 14
      * @since 1.9.0
15 15
      */
16
-    public function wrapper_start(){ ?>
16
+    public function wrapper_start() { ?>
17 17
         <div id="primary" class="content-area">
18 18
             <main id="main" class="site-main" role="main">
19 19
 
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
      *
25 25
      * @since 1.9.0
26 26
      */
27
-    public function wrapper_end(){ ?>
27
+    public function wrapper_end() { ?>
28 28
 
29 29
             </main> <!-- main-site -->
30 30
           </div> <!-- content-area -->
Please login to merge, or discard this patch.
includes/theme-integrations/twentythirteen.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
      * Output opening wrappers
14 14
      * @since 1.9.0
15 15
      */
16
-    public function wrapper_start(){
16
+    public function wrapper_start() {
17 17
     ?>
18 18
 
19 19
         <div id="primary" class="site-content">
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
      *
27 27
      * @since 1.9.0
28 28
      */
29
-    public function wrapper_end(){ ?>
29
+    public function wrapper_end() { ?>
30 30
 
31 31
 			</div>
32 32
 		</div>
Please login to merge, or discard this patch.
includes/theme-integrations/twentysixteen.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,4 +7,4 @@
 block discarded – undo
7 7
  *
8 8
  * @since 1.9.0
9 9
 */
10
-Class Sensei_Twentysixteen extends Sensei__S{ }
10
+Class Sensei_Twentysixteen extends Sensei__S { }
Please login to merge, or discard this patch.