Mass Exam Marker Plugin
A Moodle plugin to help mark massive exams.
|
Variables | |
$year = $_GET['semester'] | |
$course = $_GET['course'] | |
$calc = new stats() | |
$booklet_pg_sql = $GLOBALS['DB']->get_records_sql('SELECT page_id, {mem_pages}.booklet_id, max_pages, page_num, page_marks, page_marks_max, student_id FROM {mem_booklet_data}, {mem_pages} WHERE course_id=? and year_semester_origin=? and {mem_pages}.booklet_id={mem_booklet_data}.booklet_id', array($course, $year)) | |
$max_pages = current($booklet_pg_sql)->max_pages | |
$booklet_keys = array() | |
$sids = array() | |
foreach($booklet_keys as $k) | $booklets = array_fill_keys($booklet_keys, array_fill(1,$max_pages,0)) |
$pagemarks = array_fill(1,$max_pages,array()) | |
$pagemarks_max = array_fill(1,$max_pages,-1) | |
foreach($booklet_pg_sql as $o) | $output = fopen('php://output', 'w') |
$column_title = array('Student ID','Booklet ID',) | |
$totalScore = array() | |
foreach($booklets as $k=> $v) | $stats = array( "mean" => array("","Mean"), "median" => array("","Median"), "spread" => array("","Spread"), "max" => array("","Maximum"), "min" => array("","Minimum")) |
foreach ($booklet_pg_sql as $pg) $booklet_keys = array() |
$booklet_pg_sql = $GLOBALS['DB']->get_records_sql('SELECT page_id, {mem_pages}.booklet_id, max_pages, page_num, page_marks, page_marks_max, student_id FROM {mem_booklet_data}, {mem_pages} WHERE course_id=? and year_semester_origin=? and {mem_pages}.booklet_id={mem_booklet_data}.booklet_id', array($course, $year)) |
SQL query to retrieve all pages data and relevant booklet data.
foreach ($booklet_keys as $k) $booklets = array_fill_keys($booklet_keys, array_fill(1,$max_pages,0)) |
Booklets array has an array which contains pages of marks.
$calc = new stats() |
initializes class whoese methods relate to statistical calculations
$column_title = array('Student ID','Booklet ID',) |
Names of the Columns of the CSV, the first row to be put into the CSV
$course = $_GET['course'] |
course holds the course-id.
$max_pages = current($booklet_pg_sql)->max_pages |
foreach ($booklet_pg_sql as $o) $output = fopen('php://output', 'w') |
Populate the booklets with an associated array of page_numbers containing the page marks and then if not already defined, assigned the maximum score that page can achieve. Create a file pointer connected to the output stream.
$pagemarks = array_fill(1,$max_pages,array()) |
Pagemarks has an array that has each mark per page.
$pagemarks_max = array_fill(1,$max_pages,-1) |
$sids = array() |
foreach ($booklets as $k=> $v) $stats = array( "mean" => array("","Mean"), "median" => array("","Median"), "spread" => array("","Spread"), "max" => array("","Maximum"), "min" => array("","Minimum")) |
Output into CSV all the booklet pages' marks, and total. Statistics array. At end is 1 row mean of pages and everything, 2nd row is std-dev of pages and everything more specifically, use the booklet_id as row name e.g. this row is "mean" thus 5 rows in total: Mean, Median, Spread, Maximum, Minimum.
$totalScore = array() |
$year = $_GET['semester'] |
year holds the semester of the course, e.g. 2014 FALL