Article feedback/Version 5/Technical Design

Massively a work-in-progress. More of a loose notes page than anything else.

= Technical design =

Overview

 * 1) The "leave feedback" widgets
 * 2) various form elements (text area, rating widgets, feedback type radios, etc) are included or not, which can probably be handled within the same function ($.articleFeedback in modules/jquery.articleFeedback/jquery.articleFeedback.js) that renders the current one, with some logic added, based on the "buckets" as defined in the requirements, and given some CSS class or another to handle the different visual looks. Buckets are based on IP address, and it's fine to hard-code them, rather than use the database. It's a little too hard-coded at the moment, and I'm pretty sure I'd rather it be in PHP than JS, but that might not make sense, it's just opinion/preference.
 * 3) backend to save the data above, and frontend to pre-populate the feedback form with a user's previous feedback (assuming we have a user, and that user has previous feedback)
 * 4) Calls To Action - markup may well end up hard-coded in the JS, just stuffed into an array or something, and we just select a random key.
 * 5) The "view feedback" page
 * 6) moderation tools - hide, promote (to talk page), or flag various pieces of feedback.
 * 7) sorting and filtering options - good comments first (how that's defined is unclear), newest first - basically tools to hide the inevitable flood of spam "feedback"
 * 8) A special page, on the level of the talk pages - add a link to this in the not-quite-top-level navigation on said talk page.
 * 9) Need to work out which bits of this page are must-have-now vs must-have-eventually.
 * 10) Phase 1 will have a limited version with:
 * 11) Filters: All, Visible
 * 12) Moderation Tools: Hide this comment
 * 13) Sorting: By date only
 * 14) Pagination: Fixed at 50
 * 15) DB changes
 * 16) create article_feedback_buckets (name, id) table, with FKey in article_feedback.bucket
 * 17) alter table article_feedback drop columns aa_rating_id, aa_rating_value, add columns for created and modified timestamps, and is_submitted (boolean), and make bucket an actual FKey\
 * 18) rename article_fedback_pages and _revisions to something more descriptive of them being rollups
 * 19) Add rollups for option/select inputs

CREATE TABLE buckets ( bucket_id int PKey, name text NOT NULL UNIQUE ); CREATE TABLE article_field_groups ( group_id int PKey, name text NOT NULL UNIQUE ); CREATE TABLE article_fields ( field_id int PKey, name text NOT NULL UNIQUE, data_type enum(text boolean rating select) group_id int NULL (Fkey to article_field_groups.group_id) ); CREATE TABLE article_field_options ( option_id int PKey name text NOT NULL ); CREATE TABLE article_answers ( feedback_id int (FKEY to article_feedback.aa_id), field_id int (FKEY to article_fields.article_field_id), response_rating int, response_text text, response_bool boolean, response_option_id int (FKey article_field_options.option_id) ); CREATE TABLE article_feed_back_page_select_rollups_or_something_like_that ( aap_page_id integer unsigned NOT NULL,  aap_option_id integer unsigned NOT NULL,  aap_total integer unsigned NOT NULL,  aap_count integer unsigned NOT NULL,  PRIMARY KEY (aap_page_id, aap_rating_id) ) ; -- as above but for revisions

Page Flow

 * 1) (on pageload) - js to make aajx call to render form in enpty div or something
 * 2) php determines which option to render, returns HTML as well as which option is being rendered, and the article_feedback_id
 * 3) js sets up event binds etc on html
 * 4) form submits, js packs up form and art_fb_id, and makes ajax request to php api.
 * 5) php saves data, determines which CTA to return, js renders it

Tasks (to be split up)

 * SVN wrangling: get switched over to commit access instead of read-only (Greg, Reha locally)
 * Copy over new extension (ArcticleFeedbackV5) and commit (Greg)
 * Database changes
 * Table alters (and inserts for article_fields and article_field options)
 * Update install script
 * Update queries
 * Update display php
 * Drop a line in article_feedback and pass to js
 * Add bucket decision-making
 * Update submission php
 * Clear/insert (feedback id + page id) on article_answers
 * Update rollup code to handle bools and selects
 * Revamp js
 * Carry the feedback id and bucket id
 * Switch between forms based on bucket id
 * HTML into ajax response
 * Feedback dashboard page
 * Gut and replace with a super-simple list as above (use MoodBar as an example)