Skip to content

Commit 4d63fce

Browse files
committed
Version 4.0
1 parent 0f5c4c0 commit 4d63fce

17 files changed

Lines changed: 749 additions & 268 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+
## 4.0 (Points)
74+
- Algorithms can generate a score (i.e., points).
75+
- Sort algorithms listing by title.
76+
- Debug mode to turn on extra helpful text to find algorithm setup problems
77+
7378
## 3.0 (Algorithm Billing Codes)
7479
- Each algorithm can be given a billing code by free text to the email output portion of the algorithm setup.
7580

controllers/quizzes.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,8 @@ static function add_quiz() {
3030
}
3131
}
3232

33-
$output = __('Congratulations, you completed the <span>quiz!</span>
34-
<h2>{{result-title}}</h2>
35-
{{result-text}}
36-
37-
You achieved {{points}} points from {{questions}} questions.', 'chained');
33+
$output = __('Success: Algorithm Completed
34+
{{soap-note}}', 'chained');
3835
$is_published = false;
3936
include(CHAINED_PATH.'/views/quiz.html.php');
4037
} // end add_quiz
@@ -81,7 +78,7 @@ static function list_quizzes() {
8178
// select quizzes
8279
$quizzes = $wpdb->get_results("SELECT tQ.*, COUNT(tC.id) as submissions
8380
FROM ".CHAINED_QUIZZES." tQ LEFT JOIN ".CHAINED_COMPLETED." tC ON tC.quiz_id = tQ.id AND tC.not_empty=1
84-
GROUP BY tQ.id ORDER BY tQ.id DESC");
81+
GROUP BY tQ.id ORDER BY tQ.title ASC");
8582

8683
// now select all posts that have watu shortcode in them
8784
$posts=$wpdb->get_results("SELECT * FROM {$wpdb->posts}

default_config/chained_choices.sql

Lines changed: 402 additions & 0 deletions
Large diffs are not rendered by default.

default_config/chained_questions.sql

Lines changed: 152 additions & 0 deletions
Large diffs are not rendered by default.

default_config/chained_quizzes.sql

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
2+
SET time_zone = "+00:00";
3+
4+
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
5+
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
6+
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
7+
/*!40101 SET NAMES utf8mb4 */;
8+
9+
10+
TRUNCATE TABLE `wp_chained_quizzes`;
11+
INSERT INTO `wp_chained_quizzes` (`id`, `title`, `output`, `email_admin`, `email_user`, `require_login`, `times_to_take`, `save_source_url`, `set_email_output`, `email_output`) VALUES
12+
(18, 'Screening-General Anxiety Disorder', 'Congratulations, you completed the quiz!\r\n<h2>{{result-title}}</h2>\r\n{{result-text}}\r\n\r\nYou achieved {{points}} points from {{questions}} questions.', 1, 0, 0, 0, 0, 0, ''),
13+
(17, 'Comorbidity-HTN', '{{soap-note}}', 1, 0, 0, 0, 0, 1, '{{soap-note}}'),
14+
(3, 'Diarrhea', 'Thank you for completing the questionnaire.\r\n<h2>{{result-title}}</h2>\r\n{{result-text}}\r\n{{answers-table}}', 0, 0, 0, 0, 0, 0, ''),
15+
(16, 'Survey-Patient Feedback', 'Thank you for your feedback.\r\n\r\n[redirect url=\\\'http://app.windwake.io/Diabetes\\\' sec=\\\'1\\\']', 0, 0, 1, 0, 0, 1, '{{answers-table}}'),
16+
(9, 'Screening-Melvin\\\'s Regression Testing', '<strong>SOAP NOTE</strong>\r\n{{soap-note}}', 0, 0, 0, 0, 0, 1, '{{soap-note}}\r\n\r\n\r\n** This is system generated e-mail. Please do not reply to this message. **'),
17+
(10, 'Routine Diabetes Encounter v2', 'Thank you for completing this form.\r\n<h2>{{result-title}}</h2>\r\n{{result-text}}\r\n{{answers-table}}', 0, 0, 0, 0, 0, 0, ''),
18+
(11, 'Screening-Diabetes', 'Your answers have been accepted and sent to your doctor.\r\n\r\nWould you like to provide feedback about this diabetes triage system?   <a href=\\\"/diabetes/\\\">No</a>   |   <a href=\\\"/patient-feedback/\\\">Yes</a>\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n[redirect url=\\\'http://app.windwake.io/Diabetes\\\' sec=\\\'10\\\']', 1, 1, 1, 0, 1, 1, '{{soap-note}}\r\n\r\n<strong>Eligible diabetes billing codes:</strong>\r\n99214; 99394-7; G2012;'),
19+
(12, 'Weight Management', 'Thank you for completing this form.\r\n<h2>{{result-title}}</h2>\r\n{{result-text}}\r\n\r\n{{soap-note}}\r\n\r\n{{answers-table}}', 0, 0, 0, 0, 0, 0, ''),
20+
(15, 'Screening-Taylor\\\'s Diabetes Demo', '{{soap-note}}', 0, 0, 0, 0, 1, 1, '{{soap-note}}\r\n\r\n** This is system generated e-mail. Please do not reply to this message. **'),
21+
(19, 'Screening-Depression', '{{soap-note}}', 1, 0, 0, 0, 0, 1, '{{soap-note}}'),
22+
(20, 'Screening-ETOH', '{{soap-note}}', 1, 0, 0, 0, 0, 1, '{{soap-note}}');
23+
24+
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
25+
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
26+
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

media/green-tick-icon-100.png

1.38 KB
Loading

media/green-tick-icon-250.png

2.57 KB
Loading

models/basic.php

Lines changed: 43 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -114,53 +114,7 @@ static function install($update = false) {
114114
) DEFAULT CHARSET=utf8;";
115115

116116
$wpdb->query($sql);
117-
}
118-
119-
/**
120-
* Alter the old tables to include new columns from newer plugin versions.
121-
*/
122-
// chainedquiz_add_db_fields(array(
123-
// array("name" => 'autocontinue', 'type' => 'TINYINT UNSIGNED NOT NULL DEFAULT 0'),
124-
// array("name" => 'sort_order', 'type' => 'INT UNSIGNED NOT NULL DEFAULT 0'),
125-
// array("name" => 'accept_comments', 'type' => 'TINYINT UNSIGNED NOT NULL DEFAULT 0'),
126-
// array("name" => 'accept_comments_label', 'type' => "VARCHAR(255) NOT NULL DEFAULT ''"),
127-
// ), CHAINED_QUESTIONS);
128-
129-
// chainedquiz_add_db_fields(array(
130-
// array("name" => 'redirect_url', 'type' => "VARCHAR(255) NOT NULL DEFAULT ''"),
131-
// ), CHAINED_RESULTS);
132-
133-
// chainedquiz_add_db_fields(array(
134-
// array("name" => 'comments', 'type' => "TEXT"),
135-
// ), CHAINED_USER_ANSWERS);
136-
137-
// chainedquiz_add_db_fields(array(
138-
// array("name" => 'email_admin', 'type' => "TINYINT UNSIGNED NOT NULL DEFAULT 0"),
139-
// array("name" => 'email_user', 'type' => "TINYINT UNSIGNED NOT NULL DEFAULT 0"),
140-
// array("name" => 'require_login', 'type' => "TINYINT UNSIGNED NOT NULL DEFAULT 0"),
141-
// array("name" => 'times_to_take', 'type' => "INT UNSIGNED NOT NULL DEFAULT 0"),
142-
// array("name" => 'save_source_url', 'type' => "TINYINT UNSIGNED NOT NULL DEFAULT 0"),
143-
// array("name" => 'set_email_output', 'type' => "TINYINT UNSIGNED NOT NULL DEFAULT 0"),
144-
// array("name" => 'email_output', 'type' => "TEXT"),
145-
// ), CHAINED_QUIZZES);
146-
147-
// chainedquiz_add_db_fields(array(
148-
// array("name" => 'not_empty', 'type' => "TINYINT NOT NULL DEFAULT 0"), /*When initially creating a record, it is empty. If it remains so we have to delete it.*/
149-
// array("name" => 'source_url', 'type' => "VARCHAR(255) NOT NULL DEFAULT ''"), /* Page where the quiz is published */
150-
// array("name" => 'email', 'type' => "VARCHAR(255) NOT NULL DEFAULT ''"), /* email of non-logged in users when required */
151-
// ), CHAINED_COMPLETED);
152-
153-
// fix sort order once for old quizzes (in version 0.7.5)
154-
// if(get_option('chained_fixed_sort_order') != 1) {
155-
// ChainedQuizQuestions :: fix_sort_order_global();
156-
// update_option('chained_fixed_sort_order', 1);
157-
// }
158-
159-
// update not_empty = 1 for all completed records prior to version 0.8.7 and DB version 0.66
160-
// $version = get_option('chained_version');
161-
// if($version < 0.67) {
162-
// $wpdb->query("UPDATE ".CHAINED_COMPLETED." SET not_empty=1");
163-
// }
117+
}
164118

165119
// setup the default options (when not yet saved ever)
166120
if(get_option('chained_sender_name') == '') {
@@ -175,26 +129,27 @@ static function install($update = false) {
175129
/** PERFORM VERSION-SPECIFIC UPGRADES HERE **/
176130
if ($current_version < '2.2') {
177131
update_option('chained_delete_data', 'no');
132+
} else if ($current_version < '4.0') {
133+
update_option('chained_debug_mode', 'off');
178134
}
179135

180136
// Set the current plugin version number.
181-
update_option('chained_version', "3.0");
137+
update_option('chained_version', '4.0');
182138
// exit;
183139
}
184140

185-
// main menu
186-
static function menu() {
187-
$chained_caps = current_user_can('manage_options') ? 'manage_options' : 'chained_manage';
188-
189-
add_menu_page(__('Triage Algorithm', 'chained'), __('Triage Algorithm', 'chained'), $chained_caps, "chained_quizzes", array('ChainedQuizQuizzes', "manage"));
190-
add_submenu_page('chained_quizzes', __('Algorithms', 'chained'), __('Algorithms', 'chained'), $chained_caps, 'chained_quizzes', array('ChainedQuizQuizzes', "manage"));
191-
add_submenu_page('chained_quizzes', __('Settings', 'chained'), __('Settings', 'chained'), 'manage_options', 'chainedquiz_options', array('ChainedQuiz','options'));
192-
add_submenu_page('chained_quizzes', __('Social Sharing', 'chained'), __('Social Sharing', 'chained'), $chained_caps, 'chainedquiz_social_sharing', array('ChainedSharing','options'));
193-
194-
add_submenu_page(NULL, __('Chained Quiz Results', 'chained'), __('Chained Quiz Results', 'chained'), $chained_caps, 'chainedquiz_results', array('ChainedQuizResults','manage'));
195-
add_submenu_page(NULL, __('Chained Quiz Questions', 'chained'), __('Chained Quiz Questions', 'chained'), $chained_caps, 'chainedquiz_questions', array('ChainedQuizQuestions','manage'));
196-
add_submenu_page(NULL, __('Users Completed Quiz', 'chained'), __('Users Completed Quiz', 'chained'), $chained_caps, 'chainedquiz_list', array('ChainedQuizCompleted','manage'));
197-
141+
// main menu
142+
static function menu() {
143+
$chained_caps = current_user_can('manage_options') ? 'manage_options' : 'chained_manage';
144+
145+
add_menu_page(__('Triage Algorithm', 'chained'), __('Triage Algorithm', 'chained'), $chained_caps, "chained_quizzes", array('ChainedQuizQuizzes', "manage"));
146+
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'));
148+
add_submenu_page('chained_quizzes', __('Social Sharing', 'chained'), __('Social Sharing', 'chained'), $chained_caps, 'chainedquiz_social_sharing', array('ChainedSharing','options'));
149+
150+
add_submenu_page(NULL, __('Chained Quiz Results', 'chained'), __('Chained Quiz Results', 'chained'), $chained_caps, 'chainedquiz_results', array('ChainedQuizResults','manage'));
151+
add_submenu_page(NULL, __('Chained Quiz Questions', 'chained'), __('Chained Quiz Questions', 'chained'), $chained_caps, 'chainedquiz_questions', array('ChainedQuizQuestions','manage'));
152+
add_submenu_page(NULL, __('Users Completed Quiz', 'chained'), __('Users Completed Quiz', 'chained'), $chained_caps, 'chainedquiz_list', array('ChainedQuizCompleted','manage'));
198153
}
199154

200155
// CSS and JS
@@ -210,7 +165,7 @@ static function scripts() {
210165
'chained-common',
211166
CHAINED_URL.'js/common.js',
212167
false,
213-
'3.0',
168+
'4.0',
214169
false
215170
);
216171
wp_enqueue_script("chained-common");
@@ -266,7 +221,19 @@ static function options() {
266221
$roles = $wp_roles->roles;
267222

268223
if(!empty($_POST['ok']) and check_admin_referer('chained_options')) {
269-
// sender's email and email subjects
224+
// Roles
225+
if(current_user_can('manage_options')) {
226+
foreach($roles as $key=>$role) {
227+
$r=get_role($key);
228+
229+
if(@in_array($key, $_POST['manage_roles'])) {
230+
if(!$r->has_cap('chained_manage')) $r->add_cap('chained_manage');
231+
}
232+
else $r->remove_cap('chained_manage');
233+
}
234+
}
235+
236+
// Email Options
270237
update_option('chained_sender_name', sanitize_text_field($_POST['sender_name']));
271238
update_option('chained_sender_email', sanitize_email($_POST['sender_email']));
272239
update_option('chained_user_subject', sanitize_text_field($_POST['user_subject']));
@@ -276,26 +243,23 @@ static function options() {
276243
$_POST['csv_quotes'] = empty($_POST['csv_quotes']) ? 0 : 1;
277244
update_option('chained_csv_quotes', $_POST['csv_quotes']);
278245

279-
// user interface options
246+
// User Interface Options
280247
$hide_go_ahead = empty($_POST['hide_go_ahead']) ? 0 : 1;
281248
$ui = array('hide_go_ahead' => $hide_go_ahead);
282-
update_option('chained_ui', $ui);
283-
284-
if(current_user_can('manage_options')) {
285-
foreach($roles as $key=>$role) {
286-
$r=get_role($key);
287-
288-
if(@in_array($key, $_POST['manage_roles'])) {
289-
if(!$r->has_cap('chained_manage')) $r->add_cap('chained_manage');
290-
}
291-
else $r->remove_cap('chained_manage');
292-
}
293-
}
249+
update_option('chained_ui', $ui);
250+
251+
//CSV Exports
252+
$ui = get_option('chained_ui');
253+
$delim = get_option('chained_csv_delim');
254+
255+
// Uninstall settings
256+
/** PLACEHOLDER FOR FUTURE CODE */
257+
258+
// Debug Mode
259+
update_option('chained_debug_mode', sanitize_text_field($_POST['debug_mode']));
294260
}
295261

296-
$ui = get_option('chained_ui');
297-
$delim = get_option('chained_csv_delim');
298-
262+
299263
require(CHAINED_PATH."/views/options.html.php");
300264
}
301265

models/question.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ function save_choices($vars, $id) {
8383
}
8484

8585
$_POST['goto'.$choice->id] = sanitize_text_field($_POST['goto'.$choice->id]);
86-
//if(!is_numeric($_POST['points'.$choice->id])) $_POST['points'.$choice->id] = 0; // Points deprecated from questions.
86+
if(!is_numeric($_POST['points'.$choice->id])) $_POST['points'.$choice->id] = 0;
8787

8888
// else update
8989
$wpdb->query($wpdb->prepare("UPDATE ".CHAINED_CHOICES." SET
90-
choice=%s, provider_note=%s, assessment=%s, plan=%s, is_correct=%d, goto=%s WHERE id=%d",
91-
$_POST['answer'.$choice->id], $_POST['provider_note'.$choice->id], $_POST['assessment'.$choice->id], $_POST['plan'.$choice->id],
90+
choice=%s, points=%s, provider_note=%s, assessment=%s, plan=%s, is_correct=%d, goto=%s WHERE id=%d",
91+
$_POST['answer'.$choice->id], $_POST['points'.$choice->id], $_POST['provider_note'.$choice->id], $_POST['assessment'.$choice->id], $_POST['plan'.$choice->id],
9292
intval(@$_POST['is_correct'.$choice->id]), $_POST['goto'.$choice->id], $choice->id));
9393
}
9494

0 commit comments

Comments
 (0)