php Plugin Name Interactive MCQ Description Interactive MCQ plugin with feedback, tickcross icons, and per-page score bar. Version 5.7 Author Exam Objective $mcq_show_scorebar = true; global flag Shortcodes add_shortcode('mcq_question', function($atts, $content = null) { static $id_counter = 0; global $mcq_show_scorebar; $id_counter++; $id = 'mcq_' . $id_counter; $atts = shortcode_atts([ 'title' = '', 'explanation' = '', 'showscore' = 'true' NEW attribute ], $atts); Disable score bar if shortcode has showscore=false if ($atts['showscore'] === 'false') { $mcq_show_scorebar = false; } ob_start(); div class=mcq-wrapper data-question-id=php echo esc_attr($id); div class=mcq-titlephp echo esc_html($atts['title']); div div class=mcq-optionsphp echo do_shortcode($content); div div class=mcq-explanation hidden data-original=php echo esc_attr($atts['explanation']); div div php return ob_get_clean(); }); add_shortcode('mcq_option', function($atts) { $a = shortcode_atts(['correct' = 'false', 'text' = ''], $atts); $is_correct = ($a['correct'] === 'true') '1' '0'; return 'button class=mcq-option data-correct=' . esc_attr($is_correct) . '' . esc_html($a['text']) . 'button'; }); Scripts and styles add_action('wp_footer', function () { global $post, $mcq_show_scorebar; if (!is_singular() strpos(get_post()-post_content, '[mcq_question') === false) return; Only show score bar if not disabled if ($mcq_show_scorebar) { echo 'div id=mcq-score-bar style=positionfixed;top16px;right16px;background#10b981;color#fff;padding8px 16px;border-radius8px;z-index9999;font-weight600;font-size14px;font-familysans-serif;box-shadow0 2px 6px rgba(0,0,0,0.2);Score span id=mcq-score0spandiv'; } style .mcq-wrapper { border 1px solid #dcdcdc !important; padding 24px !important; margin 24px auto !important; border-radius 12px !important; background #e6f5e6 !important; box-shadow 0 4px 10px rgba(0, 0, 0, 0.05) !important; font-family 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important; max-width 700px !important; } .mcq-title { font-size 16px !important; font-weight 600 !important; margin-bottom 20px !important; color #2c3e50 !important; } .mcq-options { display flex; flex-direction column; gap 4px !important; } .mcq-option { display flex !important; justify-content space-between !important; align-items center !important; text-align left !important; padding 12px 16px !important; border 1px solid #ccc !important; border-radius 8px !important; background #ffffff !important; color #333 !important; cursor pointer !important; transition background 0.25s ease, color 0.25s ease !important; font-size 15px !important; } .mcq-optionhover { background #e8f0fe !important; color #000 !important; } .mcq-option.correct { background #e0f7e9 !important; border-color #27ae60 !important; color #1e5631 !important; font-weight 600 !important; } .mcq-option.correctafter { content 2714 !important; color #27ae60 !important; font-size 18px !important; margin-left auto !important; } .mcq-option.wrong { background #fde8e8 !important; border-color #e74c3c !important; color #922b21 !important; font-weight 600 !important; } .mcq-option.wrongafter { content 2716 !important; color #e74c3c !important; font-size 18px !important; margin-left auto !important; } .mcq-explanation { margin-top 20px !important; background #ecfdf5 !important; padding 14px !important; border-left 5px solid #10b981 !important; font-size 15px !important; line-height 1.6 !important; border-radius 6px !important; display none !important; color #065f46 !important; animation fadeIn 0.4s ease-in-out; } .mcq-explanation.visible { display block !important; } .hidden { display none !important; } @keyframes fadeIn { from { opacity 0; transform translateY(10px); } to { opacity 1; transform translateY(0); } } style script document.addEventListener('DOMContentLoaded', function () { let score = 0; const scoreEl = document.getElementById('mcq-score'); document.querySelectorAll('.mcq-wrapper').forEach(function (wrapper) { let attempted = false; const explanationBox = wrapper.querySelector('.mcq-explanation'); const originalExplanation = explanationBox.dataset.original; wrapper.querySelectorAll('.mcq-option').forEach(btn = { btn.addEventListener('click', function () { if (btn.classList.contains('correct') btn.classList.contains('wrong')) return; const isCorrect = btn.dataset.correct === '1'; if (isCorrect) { btn.classList.add('correct'); if (!attempted && scoreEl) { score++; scoreEl.textContent = score; } explanationBox.textContent = originalExplanation; explanationBox.classList.add('visible'); } else { btn.classList.add('wrong'); } attempted = true; }); }); }); }); script php });