<commit_before><?
	defined('C5_EXECUTE') or die("Access Denied.");
	// basically a stub that includes some other files
	$u = new User();
	$uID=$u->getUserID();
?>

<div class="poll">
<?  
if ($controller->hasVoted()) { ?>
		<h3><?=t("You've voted on this survey.")?></h3>
		<br/>	
	<div style="">		
		<? 
		//available chart colors are duplicated in content/surveys.php
		$availableChartColors=array('00CCdd','cc3333','330099','FF6600','9966FF','dd7700','66DD00','6699FF','FFFF33','FFCC33','00CCdd','cc3333','330099','FF6600','9966FF','dd7700','66DD00','6699FF','FFFF33','FFCC33');
		$options = $controller->getPollOptions();
		$optionNames=array();
		$optionResults=array();
		$graphColors=array();
		$i = 1;
		$totalVotes=0;
		foreach($options as $opt) { 
			$optionNamesAbbrev[] = $i;
			$optionResults[]=$opt->getResults();
			$i++;
			$graphColors[]=array_pop($availableChartColors);
			$totalVotes+=intval($opt->getResults());
		}
		?>
		
		<strong><?=t("Question")?>: <?=$controller->getQuestion()?></strong>
		
		<div id="surveyResults" style=" <?=(!$_GET['dontGraphPoll'] && $totalVotes>0)?'float:left; width:45%':''?>">
			<table style="width:98%">
			<?	$i = 1; 
				foreach($options as $opt) { ?>
					<tr>
						<td width="55px" class="note" style="white-space:nowrap">
						<div class="surveySwatch" style="background:#<?=$graphColors[$i-1]?>"></div>&nbsp;<?=($totalVotes>0)?round($opt->getResults() / $totalVotes * 100):0 ?>% 
						</td>
						<td>
						<strong><?=$opt->getOptionName() ?></strong>
						</td>
					</tr>
					<? $i++; ?>
			<? } ?>
			</table>
			<div class="note" style="margin-top:8px"><?=intval($totalVotes)?> <?=(intval($totalVotes)==1)?t('Vote'):t('Votes')?></div>
		</div>
		<?
		//&chl= join('|',$optionNamesAbbrev) 
		if(count($optionNamesAbbrev) && !$_GET['dontGraphPoll'] && $totalVotes>0){ ?>
		<div >
		<img border="" src="http://chart.apis.google.com/chart?cht=p&chd=t:<?=join(',',$optionResults)?>&chs=180x180&chco=<?=join(',',$graphColors)?>" />
		</div>
		<? } ?>	
		<div class="spacer">&nbsp;</div>	
	</div><commit_msg>added alt attribute to auto generated chart from survey block<commit_after><?
	defined('C5_EXECUTE') or die("Access Denied.");
	// basically a stub that includes some other files
	$u = new User();
	$uID=$u->getUserID();
?>

<div class="poll">
<?  
if ($controller->hasVoted()) { ?>
		<h3><?=t("You've voted on this survey.")?></h3>
		<br/>	
	<div style="">		
		<? 
		//available chart colors are duplicated in content/surveys.php
		$availableChartColors=array('00CCdd','cc3333','330099','FF6600','9966FF','dd7700','66DD00','6699FF','FFFF33','FFCC33','00CCdd','cc3333','330099','FF6600','9966FF','dd7700','66DD00','6699FF','FFFF33','FFCC33');
		$options = $controller->getPollOptions();
		$optionNames=array();
		$optionResults=array();
		$graphColors=array();
		$i = 1;
		$totalVotes=0;
		foreach($options as $opt) { 
			$optionNamesAbbrev[] = $i;
			$optionResults[]=$opt->getResults();
			$i++;
			$graphColors[]=array_pop($availableChartColors);
			$totalVotes+=intval($opt->getResults());
		}
		?>
		
		<strong><?=t("Question")?>: <?=$controller->getQuestion()?></strong>
		
		<div id="surveyResults" style=" <?=(!$_GET['dontGraphPoll'] && $totalVotes>0)?'float:left; width:45%':''?>">
			<table style="width:98%">
			<?	$i = 1; 
				foreach($options as $opt) { ?>
					<tr>
						<td width="55px" class="note" style="white-space:nowrap">
						<div class="surveySwatch" style="background:#<?=$graphColors[$i-1]?>"></div>&nbsp;<?=($totalVotes>0)?round($opt->getResults() / $totalVotes * 100):0 ?>% 
						</td>
						<td>
						<strong><?=$opt->getOptionName() ?></strong>
						</td>
					</tr>
					<? $i++; ?>
			<? } ?>
			</table>
			<div class="note" style="margin-top:8px"><?=intval($totalVotes)?> <?=(intval($totalVotes)==1)?t('Vote'):t('Votes')?></div>
		</div>
		<?
		//&chl= join('|',$optionNamesAbbrev) 
		if(count($optionNamesAbbrev) && !$_GET['dontGraphPoll'] && $totalVotes>0){ ?>
		<div >
		<img border="" src="http://chart.apis.google.com/chart?cht=p&chd=t:<?=join(',',$optionResults)?>&chs=180x180&chco=<?=join(',',$graphColors)?>" alt="<?php echo t('survey results');?>" />
		</div>
		<? } ?>	
		<div class="spacer">&nbsp;</div>	
	</div>
{'fraction_non_alphanumeric': 0.26417769376181477, 'fraction_numerical': 0.04725897920604915, 'mean_word_length': 5.064469914040115, 'pattern_counts': {'":': 0, '<': 100, '<?xml version=': 0, '>': 122, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '2538565', 'n_tokens_mistral': 1909, 'n_tokens_neox': 1621, 'n_words': 222}