• Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
v3.5.2 Latest
Buy Hosting

Expose "Mark this post as the correct answer"

Scheduled Pinned Locked Moved Unsolved Technical Support
q&a
8 Posts 2 Posters 157 Views
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • phenomlabP Offline
    phenomlabP Offline
    phenomlab
    wrote on last edited by
    #1

    is there any way that "Mark this post as the correct answer" from the Q&A plugin can be moved out of the dropdown it sits in, and placed inside the post itself? I'd like to do this so that the process is simplified - it's currently buried, which isn't very intuitive if you do not know where to look.

    Thanks

    1 Reply Last reply
    0
  • julianJ Offline
    julianJ Offline
    julian GNU/Linux
    wrote on last edited by
    #2

    In the Q&A plugin, it basically makes a call to socket.emit('plugins.QandA.toggleSolved({ tid });, so your theme can be updated to expose the control, and you can wire it up that way.

    That's the bulk of it, really. The plugin also calls alerts.alert and ajaxify.refresh, but you can also do those on your own:

    	function toggleSolved() {
    		var tid = ajaxify.data.tid;
    		socket.emit('plugins.QandA.toggleSolved', { tid: tid }, function (err, data) {
    			if (err) {
    				return alertType('error', err);
    			}
    
    			alertType('success', data.isSolved ? '[[qanda:thread.alert.solved]]' : '[[qanda:thread.alert.unsolved]]');
    			ajaxify.refresh();
    		});
    	}
    
    phenomlabP 1 Reply Last reply
    2
  • phenomlabP Offline
    phenomlabP Offline
    phenomlab
    replied to julian on last edited by
    #3

    @julian Thanks. I'm going to be doing this in Harmony 🙂

    1 Reply Last reply
    0
  • julianJ Offline
    julianJ Offline
    julian GNU/Linux
    wrote on last edited by julian
    #4

    It's funny you ask because last night I discovered Carnegie Mellon University's "Foundations of Software Engineering" course uses a fork of NodeBB for a term project... one of the tasks looks to be adding the "toggle solved" button to the UI 😆

    ... but they're not using the Q&A plugin so I feel safe sharing this particular answer 😉

    phenomlabP 1 Reply Last reply
    2
  • phenomlabP Offline
    phenomlabP Offline
    phenomlab
    replied to julian on last edited by phenomlab
    #5

    @julian thinking about this it might be quicker to call the function directly using some jQuery and triggering off an element ID? However, I expect there to be multiple values that need to be passed along with the function, so maybe this isn't such a good idea 😱

    julianJ 1 Reply Last reply
    0
  • julianJ Offline
    julianJ Offline
    julian GNU/Linux
    replied to phenomlab on last edited by julian
    #6

    @phenomlab the actual client-side function method Q&A calls (the one attached to the event) is sadly internal and inaccessible to mere mortals 😆

    phenomlabP 1 Reply Last reply
    1
  • phenomlabP Offline
    phenomlabP Offline
    phenomlab
    replied to julian on last edited by phenomlab
    #7

    @julian thought so 😃 thanks

    Edit - actually, looking at this function, I can't see why it can't be invoked by jQuery?

    function markPostAsAnswer() {
    		var tid = ajaxify.data.tid;
    		var pid = $(this).parents('[data-pid]').attr('data-pid');
    
    		socket.emit('plugins.QandA.toggleSolved', { tid: tid, pid: pid }, function (err, data) {
    			if (err) {
    				return alertType('error', err);
    			}
    
    			alertType('success', data.isSolved ? '[[qanda:post.alert.correct_answer]]' : '[[qanda:thread.alert.unsolved]]');
    			ajaxify.refresh();
    		});
    	}
    
    1 Reply Last reply
    0
  • julianJ Offline
    julianJ Offline
    julian GNU/Linux
    wrote on last edited by
    #8
    This post is deleted!
    1 Reply Last reply
    0

Copyright © 2023 NodeBB | Contributors
  • Login

  • Don't have an account? Register

  • Login or register to search.
Powered by NodeBB Contributors
  • First post
    Last post
0
  • Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development