<commit_before><?php
// $Id: /cvsroot/tikiwiki/tiki/lib/wiki-plugins/wikiplugin_miniquiz.php,v 1.10 2007-10-12 07:55:48 nyloth Exp $
/*
DEV NOTE
that plugin is not finished !! -- mose
\todo put message in an external file or source
\todo use smarty templates rather than hardcode html
*/

// Includes a miniquiz form

// fields to use in trackers to prepare miniquiz
// Question   the question
// Answer     correct answer
// Option a   false answer 
// Option b   false answer 
// Option c   false answer 
// Option d   false answer 
// Valid      indicates that the tracker item is to be used as a quiz item

function wikiplugin_miniquiz_help() {
	$help = tra("Displays an miniquiz").":\n";
	$help.= "~np~{MINIQUIZ(trackerId=>1)}Instructions::Feedback{MINIQUIZ}~/np~";
	return $help;
}

function wikiplugin_miniquiz_info() {
	return array(
		'name' => tra('Mini Quiz'),
		'documentation' => 'PluginMiniQuiz',
		'description' => tra('Displays a miniquiz'),
		'prefs' => array( 'feature_trackers', 'wikiplugin_miniquiz' ),
		'body' => tra('Instructions::Feedback'),
		'params' => array(
			'trackerId' => array(
				'required' => true,
				'name' => tra('Tracker'),
				'description' => tra('Tracker ID'),
			),
		),
	);
}

function rcmp($a, $b) { return mt_rand(-1, 1); }
function shuf(&$ar) { srand((double) microtime() * 10000000); uksort($ar, "rcmp"); }

function wikiplugin_miniquiz($data, $params) {
  global $tikilib, $user, $group, $prefs;
	global $trklib; include_once('lib/trackers/trackerlib.php');
	extract ($params,EXTR_SKIP);

	if ($prefs['feature_trackers'] != 'y' || !isset($trackerId) || !($tracker = $trklib->get_tracker($trackerId))) {
		return $smarty->fetch("wiki-plugins/error_tracker.tpl");
	}

	$items = $tikilib->list_tracker_items($trackerId,0,-1,'lastModif_desc','','o');
	foreach ($items['data'] as $it) {
		$id = $it['itemId'];
		foreach ($it['field_values'] as $val) {
			$field = $val['name'];
			$info["$id"]["$field"] = $val['value'];
		}
		$info["$id"]['qresult'] = 'n';
	}
	$back = '';
	$out = '';
	
	if ($tracker) {
		$success_mess[] = "Wow !";
		$success_mess[] = "Congratulation !";
		$success_mess[] = "Success !";
		$success_mess[] = "Excellent !";<commit_msg>[FIX] Missing global<commit_after><?php
// $Id: /cvsroot/tikiwiki/tiki/lib/wiki-plugins/wikiplugin_miniquiz.php,v 1.10 2007-10-12 07:55:48 nyloth Exp $
/*
DEV NOTE
that plugin is not finished !! -- mose
\todo put message in an external file or source
\todo use smarty templates rather than hardcode html
*/

// Includes a miniquiz form

// fields to use in trackers to prepare miniquiz
// Question   the question
// Answer     correct answer
// Option a   false answer 
// Option b   false answer 
// Option c   false answer 
// Option d   false answer 
// Valid      indicates that the tracker item is to be used as a quiz item

function wikiplugin_miniquiz_help() {
	$help = tra("Displays an miniquiz").":\n";
	$help.= "~np~{MINIQUIZ(trackerId=>1)}Instructions::Feedback{MINIQUIZ}~/np~";
	return $help;
}

function wikiplugin_miniquiz_info() {
	return array(
		'name' => tra('Mini Quiz'),
		'documentation' => 'PluginMiniQuiz',
		'description' => tra('Displays a miniquiz'),
		'prefs' => array( 'feature_trackers', 'wikiplugin_miniquiz' ),
		'body' => tra('Instructions::Feedback'),
		'params' => array(
			'trackerId' => array(
				'required' => true,
				'name' => tra('Tracker'),
				'description' => tra('Tracker ID'),
			),
		),
	);
}

function rcmp($a, $b) { return mt_rand(-1, 1); }
function shuf(&$ar) { srand((double) microtime() * 10000000); uksort($ar, "rcmp"); }

function wikiplugin_miniquiz($data, $params) {
  global $tikilib, $user, $group, $prefs, $smarty;
	global $trklib; include_once('lib/trackers/trackerlib.php');
	extract ($params,EXTR_SKIP);

	if ($prefs['feature_trackers'] != 'y' || !isset($trackerId) || !($tracker = $trklib->get_tracker($trackerId))) {
		return $smarty->fetch("wiki-plugins/error_tracker.tpl");
	}

	$items = $tikilib->list_tracker_items($trackerId,0,-1,'lastModif_desc','','o');
	foreach ($items['data'] as $it) {
		$id = $it['itemId'];
		foreach ($it['field_values'] as $val) {
			$field = $val['name'];
			$info["$id"]["$field"] = $val['value'];
		}
		$info["$id"]['qresult'] = 'n';
	}
	$back = '';
	$out = '';
	
	if ($tracker) {
		$success_mess[] = "Wow !";
		$success_mess[] = "Congratulation !";
		$success_mess[] = "Success !";
		$success_mess[] = "Excellent !";
{'fraction_non_alphanumeric': 0.192481884057971, 'fraction_numerical': 0.01358695652173913, 'mean_word_length': 4.360436893203883, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4810570', 'n_tokens_mistral': 1760, 'n_tokens_neox': 1632, 'n_words': 373}