$sqlcount = " SELECT count(*)\n FROM {emarking_exams} as e\nINNER JOIN {course} as c ON (e.course = c.id)\nINNER JOIN {course_categories} as cc ON (cc.id = c.category)\nWHERE (cc.path LIKE '%/{$categoryid}' OR cc.path LIKE '%/{$categoryid}/%') AND e.status {$statussql}"; // Get the count so we can use pagination. $examscount = $DB->count_records_sql($sqlcount, $params); $sql = "SELECT e.*,\n\t\t\tc.id as courseid,\n\t\t\tc.fullname as coursefullname,\n\t\t\tu.id as userid,\n\t\t\tCONCAT(u.firstname, ' ', u.lastname) as userfullname,\n\t\t\tcc.name as category,\n\t\t\te.printingcost as cost\n\t\tFROM {emarking_exams} as e\n\t\tINNER JOIN {course} as c ON (e.course = c.id)\n\t\tINNER JOIN {user} as u ON (e.requestedby = u.id)\n\t\tINNER JOIN {course_categories} as cc ON (cc.id = c.category)\n\t\tWHERE (cc.path LIKE '%/{$categoryid}' OR cc.path LIKE '%/{$categoryid}/%') AND e.status {$statussql}\n\t\tORDER BY " . $order; // Getting all print orders. $exams = $DB->get_records_sql($sql, $params, $page * $perpage, ($page + 1) * $perpage); // Status = 1 means still not downloaded. $currentdate = time(); $current = 0; foreach ($exams as $exam) { // Url for the course. $urlcourse = new moodle_url('/course/view.php', array('id' => $exam->course)); // Url for the user profile of the person who requested the exam. $urlprofile = new moodle_url('/user/profile.php', array('id' => $exam->userid)); // Calculate the total pages and pages to print for this exam. $pagestoprint = emarking_exam_total_pages_to_print($exam); $actions = html_writer::start_tag("div", array("class" => "printactions")); // Download exam link. if ($exam->status == EMARKING_EXAM_PROCESSED) { $actions .= html_writer::div($OUTPUT->pix_icon("i/down", get_string("download"), null, array("examid" => $exam->id, "class" => "downloademarking"))); } else { if ($exam->status == EMARKING_EXAM_UPLOADED) { $actions .= html_writer::div($OUTPUT->pix_icon("i/scheduled", get_string('examgenerationscheduled', 'mod_emarking'), null)); } else { if ($exam->status == EMARKING_EXAM_BEING_PROCESSED) { if (is_siteadmin()) { $actions .= $OUTPUT->action_icon(new moodle_url('/mod/emarking/print/printorders.php', array('category' => $categoryid, 'examid' => $exam->id, 'action' => 'resetexam')), new pix_icon('i/configlock', get_string('examgenerationinprogress', 'mod_emarking'))); } else { $actions .= html_writer::div($OUTPUT->pix_icon('i/configlock', get_string('examgenerationinprogress', 'mod_emarking'), null)); } } else {
// The context for the page is a course if ($cmid > 0) { $context = context_module::instance($cm->id); } else { $context = context_course::instance($course->id); } // First check that the user is logged in require_login(); if (isguestuser()) { die; } $newexam = $DB->get_record('emarking_exams', array('id' => $examid)); if ($newexam && $downloadform) { $coursecat = $DB->get_record('course_categories', array('id' => $course->category)); $requestedbyuser = $DB->get_record('user', array('id' => $newexam->requestedby)); emarking_create_printform($context, $newexam, $USER, $requestedbyuser, $coursecat, emarking_exam_total_pages_to_print($newexam), $course); die; } require_capability('mod/emarking:grade', $context); // URL for current page and eMarking home $url = new moodle_url('/mod/emarking/exams.php', array('id' => $cmid, 'course' => $course->id)); if ($cmid > 0) { $urladd = new moodle_url('/mod/emarking/newprintorder.php', array('cm' => $cm->id)); } else { $urladd = new moodle_url('/mod/emarking/newprintorder.php', array('course' => $course->id)); } $PAGE->set_url($url); $PAGE->requires->js('/mod/emarking/js/printorders.js'); $PAGE->set_context($context); $PAGE->set_course($course); if ($cmid > 0) {
/** * Creates a PDF form for the copy center to print * * @param unknown $context * @param unknown $exam * @param unknown $userrequests * @param unknown $useraccepts * @param unknown $category * @param unknown $totalpages * @param unknown $course */ function emarking_create_printform($context, $exam, $userrequests, $useraccepts, $category, $course) { global $CFG; require_once $CFG->dirroot . "/mod/assign/feedback/editpdf/fpdi/fpdi2tcpdf_bridge.php"; require_once $CFG->dirroot . "/mod/assign/feedback/editpdf/fpdi/fpdi.php"; $originalsheets = $exam->totalpages + $exam->extrasheets; $copies = $exam->totalstudents + $exam->extraexams; $totalpages = emarking_exam_total_pages_to_print($exam); $pdf = new FPDI(); $pdf->setSourceFile($CFG->dirroot . "/mod/emarking/img/printformtemplate.pdf"); // Adds the form page from the template $pdf->AddPage(); $tplIdx = $pdf->importPage(1); $pdf->useTemplate($tplIdx, 0, 0, 0, 0, $adjustPageSize = true); // Copy / Printing $pdf->SetXY(32, 48.5); $pdf->Write(1, "x"); // Date $pdf->SetXY(153, 56); $pdf->Write(1, core_text::strtoupper(date('d'))); $pdf->SetXY(163, 56); $pdf->Write(1, core_text::strtoupper(date('m'))); $pdf->SetXY(173, 56); $pdf->Write(1, core_text::strtoupper(date('Y'))); // Requested by $pdf->SetXY(95, 69); $pdf->Write(1, core_text::strtoupper($useraccepts->firstname . " " . $useraccepts->lastname)); // Cost center $pdf->SetXY(95, 75.5); $pdf->Write(1, core_text::strtoupper($category->idnumber)); // UAI campus $pdf->SetXY(95, 80.8); $pdf->Write(1, core_text::strtoupper("")); // Originals $pdf->SetXY(35, 106.5); $pdf->Write(1, core_text::strtoupper($originalsheets)); // Copies $pdf->SetXY(60, 106.5); $pdf->Write(1, core_text::strtoupper("--")); // Number of printings $pdf->SetXY(84, 106.5); $pdf->Write(1, core_text::strtoupper($copies)); // Black and white $pdf->SetXY(106, 106.5); $pdf->Write(1, "x"); // Total pages $pdf->SetXY(135, 106.5); $pdf->Write(1, core_text::strtoupper($totalpages)); // Number of printings Total $pdf->SetXY(84, 133.8); $pdf->Write(1, core_text::strtoupper("")); // Total pages Total $pdf->SetXY(135, 133.8); $pdf->Write(1, core_text::strtoupper("")); // Páginas totales Total $pdf->SetXY(43, 146); $pdf->Write(1, core_text::strtoupper($course->fullname . " , " . $exam->name)); // Recepcionado por Nombre $pdf->SetXY(30, 164.5); $pdf->Write(1, core_text::strtoupper("")); // Recepcionado por RUT $pdf->SetXY(127, 164.5); $pdf->Write(1, core_text::strtoupper("")); $pdf->Output("PrintForm" . $exam->id . ".pdf", "I"); // se genera el nuevo pdf }
/** * * * * creates email to course manager, teacher and non-editingteacher, when a printing order has been created. * * @param unknown_type $exam * @param unknown_type $course */ function emarking_send_newprintorder_notification($exam, $course) { global $USER; $postsubject = $course->fullname . ' : ' . $exam->name . '. ' . get_string('newprintorder', 'mod_emarking') . ' [' . $exam->id . ']'; $examhasqr = $exam->headerqr ? get_string('yes') : get_string('no'); $pagestoprint = emarking_exam_total_pages_to_print($exam); // Create the email to be sent $posthtml = ''; $posthtml .= '<table><tr><th colspan="2">' . get_string('newprintorder', 'mod_emarking') . '</th></tr>'; $posthtml .= '<tr><td>' . get_string('examid', 'mod_emarking') . '</td><td>' . $exam->id . '</td></tr>'; $posthtml .= '<tr><td>' . get_string('fullnamecourse') . '</td><td>' . $course->fullname . '</td></tr>'; $posthtml .= '<tr><td>' . get_string('shortnamecourse') . '</td><td>' . $course->shortname . '</td></tr>'; $posthtml .= '<tr><td>' . get_string('requestedby', 'mod_emarking') . '</td><td>' . $USER->lastname . ' ' . $USER->firstname . '</td></tr>'; $posthtml .= '<tr><td>' . get_string('examdate', 'mod_emarking') . '</td><td>' . date("d M Y - H:i", $exam->examdate) . '</td></tr>'; $posthtml .= '<tr><td>' . get_string('extrasheets', 'mod_emarking') . '</td><td>' . $exam->extrasheets . '</td></tr>'; $posthtml .= '<tr><td>' . get_string('extraexams', 'mod_emarking') . '</td><td>' . $exam->extraexams . '</td></tr>'; $posthtml .= '<tr><td>' . get_string('headerqr', 'mod_emarking') . '</td><td>' . $examhasqr . '</td></tr>'; $posthtml .= '<tr><td>' . get_string('totalpagesprint', 'mod_emarking') . '</td><td>' . $pagestoprint . '</td></tr>'; $posthtml .= '</table>'; $posthtml .= ''; // Create the email to be sent $posttext = get_string('newprintorder', 'mod_emarking') . '\\n'; $posttext .= get_string('examid', 'mod_emarking') . ' : ' . $exam->id . '\\n'; $posttext .= get_string('fullnamecourse') . ': ' . $course->fullname . '\\n'; $posttext .= get_string('shortnamecourse') . ': ' . $course->shortname . '\\n'; $posttext .= get_string('requestedby', 'mod_emarking') . ': ' . $USER->lastname . ' ' . $USER->firstname . '\\n'; $posttext .= get_string('examdate', 'mod_emarking') . ': ' . date("d M Y - H:i", $exam->examdate) . '\\n'; $posttext .= get_string('extrasheets', 'mod_emarking') . ': ' . $exam->extrasheets . '\\n'; $posttext .= get_string('extraexams', 'mod_emarking') . ': ' . $exam->extraexams . '\\n'; $posttext .= get_string('headerqr', 'mod_emarking') . ': ' . $examhasqr . '\\n'; $posttext .= get_string('totalpagesprint', 'mod_emarking') . ': ' . $pagestoprint . '\\n'; emarking_send_notification($exam, $course, $postsubject, $posttext, $posthtml); }