function stats_report_major_students_progress_form
Search API
7.x reports.major-students-progress.inc | stats_report_major_students_progress_form() |
6.x reports.major-students-progress.inc | stats_report_major_students_progress_form() |
Simply display a form letting the user select an available major.
File
- modules/
stats/ reports.major-students-progress.inc, line 23 - This file handles the more complicated Major Students Progress csv export report, since it is part of a batch process.
Code
function stats_report_major_students_progress_form() {
$form = array();
$school_id = intval(@$_REQUEST ['school_id']);
$school_select_title = "Major Students Progress - Select School";
// If schools is enabled, first ask for the school.
if (module_enabled("schools") && !isset($_REQUEST ['school_id'])) {
fp_goto("stats/select-school", "title=$school_select_title&redirect=stats/reports/major-students-progress");
return;
}
else if (module_enabled('schools')) {
// Display what school we selected, link to change.
$form ['selected_school_name'] = array(
'value' => "<div class='current-school'>" . t("Current school: ") . "<strong>" . schools_get_school_name_for_id($school_id) . "</strong>
- " . l(t("Change?"), "stats/select-school", "title=$school_select_title&redirect=stats/reports/major-students-progress") . "</div>",
);
}
$form ['school_id'] = array(
'type' => 'hidden',
'value' => $school_id,
);
$last_major = @$_SESSION ["stats_report_major_students_progress"][$school_id]["last_major"];
$form ["major"] = array(
"label" => t("Please select a major:"),
"type" => "select",
"hide_please_select" => TRUE,
"options" => stats_draw_majors_pulldown($last_major, FALSE, FALSE, t("Please select a major"), TRUE, FALSE, TRUE, $school_id),
"value" => $last_major,
);
$form ["submit_btn"] = array(
"type" => "submit",
"spinner" => TRUE,
"value" => t("Submit and generate CSV"),
);
// If we have previously generated a CSV within the last hour, display it here.
$last_timestamp = @$_SESSION ["stats_report_major_students_progress"][$school_id]["last_timestamp"];
$last_batch_id = @$_SESSION ["stats_report_major_students_progress"][$school_id]["last_batch_id"];
$html = $m = "";
if (time() < $last_timestamp + (60 * 60)) {
$html .= "<hr><p>" . t("Last CSV report was generated for @major on @time. It will remain for 1 hour.", array("@major" => $last_major, "@time" => format_date(convert_time($last_timestamp)))) . "</p>";
$html .= "<p>" . l(t("Download CSV for ") . $last_major, "stats/download-csv-from-batch/$last_batch_id", "filename=" . urlencode("major_student_progress__" . $last_major)) . "</p>";
$form ["mark" . $m++] = array(
"value" => $html,
);
}
// If the Batch module isn't enabled, stop right here!!!
if (!function_exists("batch_set")) {
$form = array();
$form ["markup"] = array(
"value" => "<p><b>" . t("To use this report, the Batch module must be enabled. Please ask your administrator
to enable the Batch module.") . "</b></p>",
);
}
return $form;
}