Closed nfreear closed 10 years ago
By "patch" I mean commit, of course!
Example of Javascript usage -- juxtalearn-quiz-scaffold.js
// SlickQuiz-WP/admin.js: callback.
$.fn.setPreSaveQuiz(function () {
var trickytopic = $('#jlq-trickytopic option:selected', qEdit)
// Append some "extra" data to the SlickQuiz POST.
return { tricky_topic_id: trickytopic.val(), TODO: 123 };
});
Example of PHP usage -- juxtalearn_quiz_scaffold.php
<?php
// Simplified (actually a PHP class)
add_action('slickquiz_save_quiz', 'slickquiz_save_quiz');
function slickquiz_save_quiz( $quiz, $mode = 'create_draft' ) {
$data = json_decode( $_POST['json'] );
$extra = $data->extra;
// Save $extra data in model for my third-party plugin.
//...
}
Background: JuxtaLearn is an educational technology project. We're looking at ways to "scaffold" a quiz, to help teachers write more effective quizzes about "tricky topics" in STEM (science, tech., engineering and math) learning. The extra data mentioned above relates to the scaffolding.
Hi, I'd like to propose a way for third-party WP plugins to save extra meta-data at the same time that a SlickQuiz is saved/ updated.
The attached patch contains PHP and Javascript proposals:
$.fn.setPreSaveQuiz()
, which accepts a callback. The Javascript callback returns any extra data that it wants sent with the Ajax POST.Note, the Javascript needs tidying up - see comments in the patch. Please can you advise on the neatest way for me to hook into
plugin.config
?PHP: a new Wordpress action
slickquiz_save_quiz
, which is called for each of the methods,SlickQuizFunctions::create_draft_quiz()
.. ::create_published_quiz()
.. ::update_draft_quiz()
.. ::update_published_quiz()
.The action can be used by a third-party plugin to manipulate the extra data attached by the Javascript callback.
I attach a patch for SlickQuiz-WordPress, and a patch showing how I intend using the mods. in IET-OU/ ..wp-juxtalearn-quiz.
I welcome your feedback. Thanks,
Nick