Skip to content

Commit 8bddd54

Browse files
committed
Version 5.0
1 parent 1a0989e commit 8bddd54

23 files changed

Lines changed: 602 additions & 376 deletions

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ None yet.
7070
4. The submissions dashboard to capture feedback for machine learning.
7171

7272
# Changelog
73+
## 5.0 (Checkbox Improvements)
74+
- Scores can have different SOAP note sections.
75+
- Added Date questions that display a calendar date picker.
76+
- Follow-up questions to multiple checkbox answers selected.
77+
7378
## 4.0 (Points)
7479
- Algorithms can generate a score (i.e., points).
7580
- Sort algorithms listing by title.

controllers/quizzes.php

Lines changed: 24 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -145,23 +145,42 @@ static function answer_question() {
145145
$question = $wpdb->get_row($wpdb->prepare("SELECT * FROM ".CHAINED_QUESTIONS." WHERE id=%d", intval($_POST['question_id'])));
146146

147147
// prepare $answer var
148-
// $answer = ($question->qtype == 'checkbox') ? @$_POST['answers'] : @$_POST['answer'];
149148
$answer = '';
150149
$answer_text = '';
151-
if ($question->qtype == 'text') {
150+
151+
switch($question->qtype) {
152+
case 'text':
153+
$answer = @$_POST['answers'];
154+
$answer_text = @$_POST['answer_texts'];
155+
break;
156+
case 'date':
157+
$answer = @$_POST['answers'];
158+
$answer_text = @$_POST['answer_texts'];
159+
break;
160+
case 'checkbox':
161+
$answer = @$_POST['answers'];
162+
break;
163+
case 'radio':
164+
$answer = @$_POST['answer'];
165+
break;
166+
}
167+
168+
169+
170+
/* if ($question->qtype == 'text') {
152171
$answer = @$_POST['answers'];
153172
$answer_text = @$_POST['answer_texts'];
154173
} elseif ($question->qtype == 'checkbox') {
155174
$answer = @$_POST['answers'];
156175
} else {
157176
$answer = @$_POST['answer'];
158-
}
177+
} */
159178

160179
// Check to make sure answer is provided.
161180
if(empty($answer)) $answer = 0;
162181
$answer = esc_sql($answer);
163182

164-
// Convert radio button answers into an array. Text and checkbox answers will arrive as an array.
183+
// Convert multiple answers into an array. Text and checkbox answers will arrive as an array.
165184
/** Might be able to avoid this code if radio buttons are named as an array in the form input. */
166185
if(!is_array($answer)) $answer = array($answer);
167186
if (!is_array($answer_text)) $answer_text = array($answer_text);
@@ -173,7 +192,7 @@ static function answer_question() {
173192
// figure out next question
174193
$next_question = $_question->next($question, $answer);
175194

176-
// NEW! Store the answer
195+
// Store the answer
177196
if(!empty($_SESSION['chained_completion_id'])) {
178197
//$i = 0;
179198
for ($i = 0; $i < count($answer); $i++) {
@@ -203,45 +222,6 @@ static function answer_question() {
203222
}
204223
}
205224

206-
/* // store the answer
207-
if(!empty($_SESSION['chained_completion_id'])) {
208-
if(is_array($answer)) {
209-
$answer = implode(",", $answer);
210-
//$answer = chained_int_array($answer);
211-
212-
// Get all the provider notes corresponding to the answers.
213-
$provider_notes = $wpdb->get_results("SELECT provider_note FROM ".CHAINED_CHOICES." WHERE id in (".$answer.")");
214-
$prepared_answer = "";
215-
$i = 0;
216-
foreach($provider_notes as $note) {
217-
$prepared_answer .= $note->provider_note . " " . $answer_text[$i] . " ";
218-
$i++;
219-
}
220-
$answer_text = $prepared_answer;
221-
}
222-
223-
$comments = empty($_POST['comments']) ? '' : sanitize_text_field($_POST['comments']);
224-
225-
// make sure to avoid duplicates and only update the answer if it already exists
226-
$exists = $wpdb->get_var($wpdb->prepare("SELECT id FROM ".CHAINED_USER_ANSWERS."
227-
WHERE quiz_id=%d AND completion_id=%d AND question_id=%d",
228-
$quiz->id, intval($_SESSION['chained_completion_id']), $question->id));
229-
230-
if($exists) {
231-
$wpdb->query($wpdb->prepare("UPDATE ".CHAINED_USER_ANSWERS." SET
232-
answer=%s, answer_text=%s, points=%f, comments=%s WHERE quiz_id=%d AND completion_id=%d AND question_id=%d",
233-
$answer, $answer_text, $points, $comments, $quiz->id, intval($_SESSION['chained_completion_id']), $question->id));
234-
}
235-
else {
236-
$wpdb->query($wpdb->prepare("INSERT INTO ".CHAINED_USER_ANSWERS." SET
237-
quiz_id=%d, completion_id=%d, question_id=%d, answer=%s, answer_text=%s, points=%f, comments=%s",
238-
$quiz->id, intval($_SESSION['chained_completion_id']), $question->id, $answer, $answer_text, $points, $comments));
239-
}
240-
241-
// update the "completed" record as non empty
242-
$wpdb->query($wpdb->prepare("UPDATE ".CHAINED_COMPLETED." SET not_empty=1 WHERE id=%d", intval($_SESSION['chained_completion_id'])));
243-
} */
244-
245225
if(!empty($next_question->id)) {
246226
$question = $next_question;
247227
$choices = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".CHAINED_CHOICES."

controllers/results.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ static function manage() {
2222

2323
if(!empty($_POST['save']) and check_admin_referer('chained_result')) {
2424
try {
25-
$_POST['description'] = $_POST['description'.intval($_POST['id'])];
25+
$_POST['description'] = $_POST['description'.intval($_POST['id'])];
26+
$_POST['subjective'] = $_POST['subjective'.intval($_POST['id'])];
27+
$_POST['objective'] = $_POST['objective'.intval($_POST['id'])];
28+
$_POST['assessment'] = $_POST['assessment'.intval($_POST['id'])];
29+
$_POST['plan'] = $_POST['plan'.intval($_POST['id'])];
2630
$_result->save($_POST, $_POST['id']);
2731
}
2832
catch(Exception $e) {

css/main.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,12 @@ div.soap-note {
5959
background-color: #ffffff;
6060
padding: 10px;
6161
box-shadow: 5px 5px 10px #0D0D0D;
62+
}
63+
64+
.page-title {
65+
font-size: 32px;
66+
}
67+
68+
.warning-text {
69+
color: red;
6270
}

js/common.js

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ chainedQuiz.goon = function(quizID, url) {
1414
if(this.checked) anyChecked = true;
1515
});
1616

17-
if(!anyChecked && qType != 'text') {
17+
if(!anyChecked && qType != 'text' && qType != 'date') {
1818
alert(chained_i18n.please_answer);
1919
jQuery('#chained-quiz-action-' + quizID).removeAttr('disabled');
2020
return false;
@@ -45,38 +45,36 @@ chainedQuiz.goon = function(quizID, url) {
4545
data += '&chainedquiz_action=answer';
4646
this.questions_answered++;
4747
data += '&total_questions=' + this.questions_answered;
48-
49-
// console.log(data);
5048
jQuery.post(url, data, function(msg) {
51-
parts = msg.split("|CHAINEDQUIZ|");
52-
points = parseFloat(parts[0]);
53-
if(isNaN(points)) points = 0;
54-
chainedQuiz.points += points;
55-
56-
if(jQuery('body').scrollTop() > 250) {
57-
jQuery('html, body').animate({
58-
scrollTop: jQuery('#chained-quiz-wrap-'+quizID).offset().top -100
59-
}, 500);
60-
}
49+
parts = msg.split("|CHAINEDQUIZ|");
50+
points = parseFloat(parts[0]);
51+
if(isNaN(points)) points = 0;
52+
chainedQuiz.points += points;
53+
54+
if(jQuery('body').scrollTop() > 250) {
55+
jQuery('html, body').animate({
56+
scrollTop: jQuery('#chained-quiz-wrap-'+quizID).offset().top -100
57+
}, 500);
58+
}
59+
60+
jQuery('#chained-quiz-action-' + quizID).removeAttr('disabled');
61+
62+
// redirect?
63+
if(parts[1].indexOf('[CHAINED_REDIRECT]') != -1) {
64+
var sparts = parts[1].split('[CHAINED_REDIRECT]');
65+
window.location=sparts[1];
66+
}
67+
else {
68+
// load next question or the final screen
69+
jQuery('#chained-quiz-div-'+quizID).html(parts[1]);
6170

62-
jQuery('#chained-quiz-action-' + quizID).removeAttr('disabled');
63-
64-
// redirect?
65-
if(parts[1].indexOf('[CHAINED_REDIRECT]') != -1) {
66-
var sparts = parts[1].split('[CHAINED_REDIRECT]');
67-
window.location=sparts[1];
68-
}
69-
else {
70-
// load next question or the final screen
71-
jQuery('#chained-quiz-div-'+quizID).html(parts[1]);
72-
73-
// hide/show "go ahead" button depending on comment in the HTML code
74-
if(parts[1].indexOf('<!--hide_go_ahead-->') != -1) jQuery('#chained-quiz-action-' + quizID).hide();
75-
else jQuery('#chained-quiz-action-' + quizID).show();
76-
77-
jQuery('#chained-quiz-form-' + quizID + ' input[name=points]').val(chainedQuiz.points);
78-
chainedQuiz.initializeQuestion(quizID);
79-
}
71+
// hide/show "go ahead" button depending on comment in the HTML code
72+
if(parts[1].indexOf('<!--hide_go_ahead-->') != -1) jQuery('#chained-quiz-action-' + quizID).hide();
73+
else jQuery('#chained-quiz-action-' + quizID).show();
74+
75+
jQuery('#chained-quiz-form-' + quizID + ' input[name=points]').val(chainedQuiz.points);
76+
chainedQuiz.initializeQuestion(quizID);
77+
}
8078
});
8179
}
8280

media/green-tick-icon-100.png

-1.38 KB
Binary file not shown.

media/next-question-guide.png

48.8 KB
Loading

models/basic.php

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ static function install($update = false) {
88
global $wpdb;
99
$wpdb -> show_errors();
1010

11-
// If new activation, run the initiatlize some variables first.
11+
// If new activation, initialize some variables first.
1212
if(!$update) self::init();
1313

1414
// CHAINED_QUIZZES
@@ -116,25 +116,31 @@ static function install($update = false) {
116116
$wpdb->query($sql);
117117
}
118118

119-
// setup the default options (when not yet saved ever)
120-
if(get_option('chained_sender_name') == '') {
119+
// Setup the default options (when not yet saved ever)
120+
if (get_option('chained_sender_name') == '') {
121121
update_option('chained_sender_name', __('WordPress Admin', 'chained'));
122122
update_option('chained_sender_email', get_option('admin_email'));
123123
update_option('chained_admin_subject', __('User results on {{quiz-name}}', 'chained'));
124124
update_option('chained_user_subject', __('Your results on {{quiz-name}}', 'chained'));
125125
}
126126

127127
$current_version = get_option('chained_version');
128+
error_log("Current 'chained_version' = ".$current_version);
128129

129130
/** PERFORM VERSION-SPECIFIC UPGRADES HERE **/
130131
if ($current_version < '2.2') {
131132
update_option('chained_delete_data', 'no');
132-
} else if ($current_version < '4.0') {
133+
} elseif ($current_version < '4.0') {
133134
update_option('chained_debug_mode', 'off');
135+
} elseif ($current_version < '5.0') {
136+
$wpdb->query("ALTER TABLE ".CHAINED_RESULTS." ADD COLUMN subjective TEXT AFTER description;");
137+
$wpdb->query("ALTER TABLE ".CHAINED_RESULTS." ADD COLUMN objective TEXT AFTER subjective;");
138+
$wpdb->query("ALTER TABLE ".CHAINED_RESULTS." ADD COLUMN assessment TEXT AFTER objective;");
139+
$wpdb->query("ALTER TABLE ".CHAINED_RESULTS." ADD COLUMN plan TEXT AFTER assessment;");
134140
}
135141

136142
// Set the current plugin version number.
137-
update_option('chained_version', '4.0');
143+
update_option('chained_version', '5.0');
138144
// exit;
139145
}
140146

@@ -144,8 +150,9 @@ static function menu() {
144150

145151
add_menu_page(__('Triage Algorithm', 'chained'), __('Triage Algorithm', 'chained'), $chained_caps, "chained_quizzes", array('ChainedQuizQuizzes', "manage"));
146152
add_submenu_page('chained_quizzes', __('Algorithms', 'chained'), __('Algorithms', 'chained'), $chained_caps, 'chained_quizzes', array('ChainedQuizQuizzes', "manage"));
147-
add_submenu_page('chained_quizzes', __('Settings', 'chained'), __('Settings', 'chained'), 'manage_options', 'chainedquiz_options', array('ChainedQuiz','options'));
153+
add_submenu_page('chained_quizzes', __('Settings', 'chained'), __('Settings', 'chained'), 'manage_options', 'chainedquiz_options', array('ChainedQuiz','options'));
148154
add_submenu_page('chained_quizzes', __('Social Sharing', 'chained'), __('Social Sharing', 'chained'), $chained_caps, 'chainedquiz_social_sharing', array('ChainedSharing','options'));
155+
add_submenu_page('chained_quizzes', __('Help', 'chained'), __('Help', 'chained'), $chained_caps, 'chainedquiz_help', array('ChainedQuiz','help'));
149156

150157
add_submenu_page(NULL, __('Chained Quiz Results', 'chained'), __('Chained Quiz Results', 'chained'), $chained_caps, 'chainedquiz_results', array('ChainedQuizResults','manage'));
151158
add_submenu_page(NULL, __('Chained Quiz Questions', 'chained'), __('Chained Quiz Questions', 'chained'), $chained_caps, 'chainedquiz_questions', array('ChainedQuizQuestions','manage'));
@@ -165,7 +172,7 @@ static function scripts() {
165172
'chained-common',
166173
CHAINED_URL.'js/common.js',
167174
false,
168-
'4.0',
175+
'5.0',
169176
false
170177
);
171178
wp_enqueue_script("chained-common");
@@ -180,37 +187,28 @@ static function init() {
180187
load_plugin_textdomain( 'chained', false, CHAINED_RELATIVE_PATH."/languages/" );
181188
if (!session_id()) @session_start();
182189

183-
// define table names
190+
// Define table names as named constants.
184191
define( 'CHAINED_QUIZZES', $wpdb->prefix. "chained_quizzes");
185192
define( 'CHAINED_QUESTIONS', $wpdb->prefix. "chained_questions");
186193
define( 'CHAINED_CHOICES', $wpdb->prefix. "chained_choices");
187194
define( 'CHAINED_RESULTS', $wpdb->prefix. "chained_results");
188195
define( 'CHAINED_COMPLETED', $wpdb->prefix. "chained_completed");
189196
define( 'CHAINED_USER_ANSWERS', $wpdb->prefix. "chained_user_answers");
190-
define( 'CHAINED_VERSION', get_option('chained_version'));
197+
//define( 'CHAINED_VERSION', get_option('chained_version'));
191198

192-
// shortcodes
199+
// Register shortcodes offered by this plugin.
193200
add_shortcode('triage-algorithm', array("TriageShortcodes", "algorithmShortcodeHandler"));
194201
add_shortcode('triage-submissions', array("TriageShortcodes", "responsesShortcodeHandler"));
195202
add_shortcode('chained-share', array("ChainedSharing", "display"));
196203

197-
// once daily delete empty records older than 1 day
198-
// if(get_option('chainedquiz_cleanup') != date("Y-m-d") and defined('CHAINED_COMPLETED')) {
199-
// $wpdb->query("DELETE FROM ".CHAINED_COMPLETED." WHERE not_empty=0 AND datetime < '".current_time('mysql')."' - INTERVAL 24 HOUR");
200-
// update_option('chainedquiz_cleanup', date("Y-m-d"));
201-
// }
202-
203204
add_action('template_redirect', array('ChainedSharing', 'social_share_snippet'));
204205

205206
// default CSV separator if not set
206-
if(get_option('chained_csv_delim') == '') {
207+
if (get_option('chained_csv_delim') == '') {
207208
update_option('chained_csv_delim', ',');
208209
update_option('chained_csv_quotes', '1');
209210
}
210211

211-
// $version = get_option('chained_version');
212-
// if($version < '0.8') self::install(true);
213-
214212
// Go ahead and activate the plugin now by running the install script.
215213
self::install(true);
216214
}
@@ -264,6 +262,6 @@ static function options() {
264262
}
265263

266264
static function help() {
267-
require(CHAINED_PATH."/views/help.php");
265+
require(CHAINED_PATH."/views/help.html.php");
268266
}
269267
}

0 commit comments

Comments
 (0)