Пример #1
0
<?php

$cid = isset($_POST['cid']) ? $_POST['cid'] : '';
$course = course_load($cid);
if (isset($_POST['submit'])) {
    if (course_is_empty($_POST['id'])) {
        delete_course($_POST['id']);
        sleep(1);
        header('location: ' . currentURL() . '?p=course');
        print 'Course deleted. Click <a href="?p=course">here</a> to view created courses';
    } else {
        print '<span style="color: red;">This course contains ' . count_posts_from_cid($_POST['id']) . ' post' . (count_posts_from_cid($_POST['id']) == 0 || count_posts_from_cid($_POST['id']) == 1 ? '' : 's') . '. Please delete all the posts before deleting the course</span>';
    }
}
?>
<h3>Do you want to delete the course "<?php 
print $course['Course_Name'];
?>
"?</h3>
<form method="post" action="">
	<input type="hidden" name="id" value="<?php 
print $cid;
?>
"/>
	<input type="submit" name="submit" value="Delete" />
	<a class="button" href="?p=course">Cancel</a>
</form>
Пример #2
0
function chart_questions_per_course()
{
    $output = '';
    $courses = courses_load_from_uid($_SESSION['uid']);
    $output .= '<h2>Number of questions and their figures in your courses</h2><div id="mychart" style="width: 1024px; min-height: 320px;"></div>';
    $output .= '<script>
				(function() {
					YUI().use("charts-legend", function (Y)
					{
						var myDataValues = [
			   ';
    for ($i = 0; $i < count($courses); $i++) {
        $output .= '
							{course: "' . $courses[$i]['Course_Code'] . '", "Questions": ' . count_posts_from_cid($courses[$i]['Course_ID']) . ', "Likes": ' . count_post_likes_from_cid($courses[$i]['Course_ID']) . ', "Dislikes": ' . count_post_dislikes_from_cid($courses[$i]['Course_ID']) . ', "Follows": ' . count_post_follows_from_cid($courses[$i]['Course_ID']) . ', "Comments": ' . count_comments_from_cid($courses[$i]['Course_ID']) . ($i != count($courses) - 1 ? '},' : '}');
    }
    $output .= '		];
						var myAxes = {
							values:{
								position:"left",
								type:"numeric",
								maximum: "NumericAxis",
								minimum: 0,
								roundingMethod: "niceNumber",
								alwaysShowZero:true
							}
						};
						var styleDef = {
							axes: { 
								course: { 
									label: {
										rotation: -90
									}
								}
							}
						};
						var mychart = new Y.Chart({
						legend: {
							position: "right",
							width: 350,
							height: 350,
							styles: {
								hAlign: "center",
								hSpacing: 4
							}
						},
						dataProvider:myDataValues, 
						render:"#mychart",
						type: "column",
						axes:myAxes,
						styles: styleDef,
						interactionType:"marker",
						seriesKeys:["Questions","Likes","Dislikes","Follows","Comments"],
                        horizontalGridlines: true,
                        verticalGridlines: true,
						categoryKey:"course",
						tooltip: {
							styles: { 
								backgroundColor: "#414042",
								color: "#fff",
								borderColor: "#fff",
								textAlign: "center"
							}
						}
						});
					});
				})();
				</script>';
    return $output;
}