Feature/ranking question type - #285
Open
Sunilshah-7 wants to merge 7 commits into
Open
Conversation
…on, argument empty error and static list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
rankingquestion typeImplements the
rankingproposal discussed in the issue.API
Matches what we agreed in the issue:
Stored as a single pipe-joined string in ranked order (
swift|red|fearless|...), following themc_multipleconvention.Implementation approach
No new dependency. ~120 lines of Pointer Events drag logic in
inst/js/ranking.jsrather than pulling in a library. Pointer Events give mouse and touch one code path (native HTML5 drag-and-drop is unusable here - it doesn't fire ontouch devices).
What I evaluated:
sortable, but isn't loaded by default and Shiny's build is 253KB — 5.6× SortableJSshinyjquisortableis byte-identical to the upstream releaseTradeoff as I see it: vendoring is tested and near-zero review/maintenance cost (upgrades are a file swap), but because
include-resources.lua+--embed-resourcesinline everything injs_files, it would be baked into every rendered survey whether or not it uses a ranking question. Hand-rolling keeps the payload and the diff small andmatches the style of the existing
inst/js/files, but means surveydown owns drag-and-drop bug reports going forward — andsorting's cross-bin dragging in the follow-up is meaningfully harder to hand-roll than ranking's single-list reorder.Files changed
inst/js/ranking.js(new)inst/css/surveydown.css.sd-ranking-*styles; position numbers via CSS countersinst/lua/include-resources.luaranking.jsR/question_types.Rqt_render_ranking(),qt_restore_ranking(), registry entryR/config.R.sd-ranking-list, extract options, map class →rankingR/ui.Rman/sd_question.RdNEWS.mdReproducible steps
Please let me know additional test cases and reviews for this feature.