$headeroptions->cellHtmlText = 'nombre:' . $quizname; //get_string('QuizName','blended').':<b>'.$quizname.'</b>'; $headeroptions->cellHtmlDate = ''; $headeroptions->cellHtmlUser = '******' . $fullname; //get_string('StudentName','blended').':'.$fullname; $headeroptions->cellCourseName = 'curso' . $coursename; //get_string('CourseName','blended').':'.$coursename; $headeroptions->marksize = 5; $headeroptions->marksName = 'EVAL'; $page_dims = array(); // add a page $pdf->AddPage(); $dims = new stdClass(); $dims->coords = array(); $page_dims[] = $dims; blended_print_page_header($pdf, $dims, "9901984610272", "22222222201", $headeroptions); $pdf->writeHTMLCell($columnsWidth, 1, '', '', $question->textHtml, $borderDescription, 0, 0, false); //$pdf->SetXY(10,10); // no importa el inicio en Y draw_multichoice_question($pdf, $dims, $question, $columnsWidth, 0, $markSize); draw_multichoice_question($pdf, $dims, $question2, $columnsWidth, 0, $markSize); $pdf->SetY(max($dims->coords[$question->id]->Y + $dims->coords[$question->id]->H, $dims->coords[$question2->id]->Y + $dims->coords[$question2->id]->H)); //TODO:row draw_multichoice_question($pdf, $dims, $question3, $columnsWidth, 0, $markSize); //Close and output PDF document $pdf->setLastH(1); // affects the inter-line space //illustrate_layout($pdf,$dims); $text = generate_template($dims, $fieldname); $pdf->writeHTMLCell('', '', '', '', $text, 1); $pdf->Output('labels.pdf', 'I'); /**
} else { $descartados->question[$i] = $original->question[$key]; $i++; unset($original->question[$key]); $control = 1; } } if ($control == 0) { illustrate_layout($pdf1, $dimsn[$page], $page, $uniqueid); break; } unset($original); $original = $descartados; unset($descartados); $i = 0; if (count($original) == 0 && count($descartados) == 0) { illustrate_layout($pdf1, $dimsn[$page], $page, $uniqueid); break; } else { if ($cols == $numcols - 1) { illustrate_layout($pdf1, $dimsn[$page], $page, $uniqueid); $page++; $dimsn[$page]->coords = array(); new_page($pdf1); blended_print_page_header($pdf1, $dimsn[$page], null, $activity_code, $headeroptions); $cols = -1; $x = 0; } } } $pdf1->Output('paperquiz.pdf', 'I');
function pdfAssignmentPage($code, $margins, $fullname, grade_item $item, $course, $blended, $gradingmarks = false) { global $CFG; $assignmentname = blended_get_item_name($item); $assignmenttimedue = blended_get_item_due_date($item); // if(isset($item->duedate)){ // $assignmenttimedue= $item->duedate ? userdate($item->duedate,"%A %d, %B, %Y") : ' '; // } // else if(isset($item->timedue)){ // $assignmenttimedue= $item->timedue ? userdate($item->timedue,"%A %d, %B, %Y") : ' '; // } $assignment_code = $item->id; $formatoptions = new stdClass(); $formatoptions->noclean = true; $item_desc = blended_get_item_description($item); $cellHtmlDescription = format_text($item_desc->text, $item_desc->format, $formatoptions); $coursename = $course->fullname; // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Blended Module'); $pdf->SetTitle('Submission form for activity "$assigment_name".'); $pdf->SetSubject('Blended module. (C)ITAST group. Juan Pablo de Castro'); $pdf->SetKeywords('Moodle, blended, ITAST'); //set margins $pdf->SetMargins($margins['left'], $margins['top'], $margins['right']); $pdf->SetFooterMargin(0); //PDF_MARGIN_FOOTER); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, $margins['bottom']); //set image scale factor $pdf->setImageScale(2.5); // set font $pdf->AddFont('courier', '', ''); $pdf->SetFont('courier', '', 10); // add a page $pdf->AddPage(); $dims = new stdClass(); $dims->coords = array(); $headeroptions = new stdClass(); $headeroptions->rowHeight = 6; $headeroptions->logoWidth = 30; $headeroptions->codebarWidth = 30; $headeroptions->logo_url = "pix/UVa_logo.jpg"; $headeroptions->codebarType = $blended->codebartype; $headeroptions->cellHtmlText = '<b>' . $assignmentname . '</b>'; $headeroptions->cellHtmlDate = get_string('duedate', 'blended') . ':<b>' . $assignmenttimedue . '</b>' . ' '; $headeroptions->cellHtmlUser = get_string('username', 'blended') . ':' . $fullname; $headeroptions->cellCourseName = get_string('course') . ':' . $coursename; $headeroptions->marksize = 5; $headeroptions->marksName = 'a'; $identifylabel = "printCourseLabels.php?a={$blended->id}&action=barcode&scale=2&code={$code}"; blended_print_page_header($pdf, $dims, $code, $assignment_code . "1", $headeroptions, '', $identifylabel, ''); $pdf->writeHTMLCell($pdf->getPageWidth() - $margins['left'] - $margins['right'], '', $margins['left'], '', $cellHtmlDescription, true, 0, 0, true); $pdf->Ln(); //Close and output PDF document ob_end_clean(); $pdf->Output('labels.pdf', 'I'); }
/** * Prints the quiz in the PDF object and writes the template * * @param unknown_type $pdf1 * @param unknown_type $numcols * @param unknown_type $columnsWidth * @param unknown_type $margins * @param unknown_type $original * @param unknown_type $dimsn * @param unknown_type $markSize * @param unknown_type $headeroptions * @param unknown_type $uniqueid * @param unknown_type $pdfFile */ function blended_print_quiz($pdf1, $numcols, $columnsWidth, $margins, $original, $dimsn, $markSize, $headeroptions, $uniqueid, $pdfFile) { $ordinal = 1; $i = 0; $item = new stdClass(); $Height = $pdf1->getPageHeight() - $margins['bottom']; $page = 1; while (count($original->question) > 0) { $dims = new stdClass(); $dims->coords = array(); $dimsn[$page] = $dims; debugging("<p>Create page {$page}</p>"); blended_new_page($pdf1); // Print page Header blended_print_page_header($pdf1, $dimsn[$page], null, $uniqueid, $headeroptions, $page); $topY = $pdf1->GetY(); for ($cols = 0; $cols < $numcols; $cols++) { debugging("<p>Filling up column {$cols}<p>"); $i = 0; $pending = new stdClass(); $pending->question = array(); $x = $cols * $columnsWidth + $margins['left']; $pdf1->SetY($topY); foreach ($original->question as $question_original) { $question = clone $question_original; if ($pdf1->GetY() + $question->height < $Height) { // There is room for this Question block $pdf1->SetX($x); //avoid a new line if there is a paragraph mark $question->questiontext = trim($question->questiontext); $paragraphmark = '<p align="justify">'; // TODO filter this with regular expressions $par_pos = strpos($question->questiontext, $paragraphmark); if ($par_pos !== false && $par_pos == 0) { $question->questiontext = "{$paragraphmark}{$ordinal})" . substr($question->questiontext, strlen($paragraphmark)); } else { // add an ordinal to the question for easy identification on the page $question->questiontext = "{$ordinal})" . $question->questiontext; } $ordinal++; //Print a question block $pdf1->SetFont($headeroptions->textStyle['font'], '', $headeroptions->textStyle['fontsize']); blended_draw_question($pdf1, $dimsn[$page], $question, $columnsWidth, 0, $markSize); $pdf1->ln(); debugging("<p>Item {$question->id} printed</p>"); } else { $pending->question[] = $question; debugging("<p>Item {$question->id} discarted, passed to next column.</p>"); unset($question); } } // iteration over questions // Start a new column unset($original); $original = $pending; //unset ($pending); debugging("<p>There are " . count($original->question) . " questions to print.</p>"); } // iterate over columns debugging("<p>Columns or questions exhausted. Ending page.</p>"); // save OMR information for this page blended_generate_omrfile($pdf1, $dimsn[$page], $page, $uniqueid, $pdfFile); // Start a new page $page++; debugging("<p>There are " . count($original->question) . " questions to print.</p>"); } //while(true) pages return $pdf1; }