Community Forums

ATutor Modules

Certificate Mod. Install Issue


You must be signed-in to post.

AuthorSubject
 
Page: 1
theugpa
Subject: Certificate Mod. Install IssueQuote this post in your reply
I am having trouble installing the Cert. mod. It is working except for the download certificate section. I understand there is something on line 100 to change, however, I don't know what I am suppose to change. Every time a student attempts to download the file and error message is displayed.

I only want to use the default certificate and I haven't changed any file/folder locations. Can someone help me find what I need to do to get this mod working!

In addition I have included the script for the download_certificate.php below.

Additional Information:
Operating system ATutor is installed on - Windows
Hosted By: Go Daddy
URL to aTutor: www.ugpalogin.com/atutor/
URL to aTutor cert.: www.ugpalogin.com/atutor/mods/certify/


<?php
define('AT_INCLUDE_PATH', '../../include/');

require (AT_INCLUDE_PATH.'vitals.inc.php');
require 'certify_functions.php';

// authenticate(AT_PRIV_CERTIFY); // TODO: Find correct privileges

if (isset($_GET['certify_id']))
$certify_id = $addslashes($_GET['certify_id']);

$filebase = AT_CONTENT_DIR .'certify/cert_'.$_SESSION['member_id'].'_'.$certify_id.'.';
$templatefile = AT_CONTENT_DIR .'certify/template_'.$certify_id.'.pdf';
if (file_exists($templatefile)) {
$template = $templatefile;
} else {
$template = dirname(realpath('test.pdf')).'/mods/certify/test.pdf';
}


if (!file_exists($filebase.'pdf')) {
// Fetch cached scores

$sql = '

SELECT
'.TABLE_PREFIX.'courses.title AS coursetitle,
'.TABLE_PREFIX.'members.first_name,
'.TABLE_PREFIX.'members.second_name,
'.TABLE_PREFIX.'members.last_name,
'.TABLE_PREFIX.'members.email,
'.TABLE_PREFIX.'certify.title AS certifytitle

FROM '.TABLE_PREFIX.'members
INNER JOIN '.TABLE_PREFIX.'certify ON '.TABLE_PREFIX.'certify.certify_id = '.$certify_id.'
INNER JOIN '.TABLE_PREFIX.'courses ON '.TABLE_PREFIX.'certify.course_id = '.TABLE_PREFIX.'courses.course_id

WHERE '.TABLE_PREFIX.'members.member_id = '.$_SESSION['member_id'].'
';

//echo $sql;
//exit();

$result = mysql_query($sql, $db) or die(mysql_error() . $sql);

if ( !$row = mysql_fetch_assoc($result)) { // Probably a hack attempt, so aborting should be sufficient
echo "Oh no you don't!";
exit();
}

if ( getCertificateProgress($_SESSION['member_id'], $certify_id)<100 ) { // Probably a hack attempt, so aborting should be sufficient
echo "Oh no you don't!";
exit();
}

// Generate FDF


$params = array(
'course_name' => iconv("UTF-8", "ISO-8859-1//IGNORE", $row['coursetitle']),
'full_name' => iconv("UTF-8", "ISO-8859-1//IGNORE", implode(' ',array($row['first_name'],$row['second_name'],$row['last_name']))),
'email' => $row['email'],
'test_name' => iconv("UTF-8", "ISO-8859-1//IGNORE", $row['certifytitle']),
'score' => iconv("UTF-8", "ISO-8859-1//IGNORE", 'Bestått'),
'issued_date' => iconv("UTF-8", "ISO-8859-1//IGNORE", date('j. F Y'))
);

$fdfparams = '';
foreach ($params as $key => $value) {
$fdfparams .= '<</T('.$key.')/V('.$value.')>>';
}

//$filename = tempnam('', 'atutor_certify');
$filename = $filebase.'fdf';

$handle = fopen($filename,'wb');
fwrite($handle,"%FDF-1.2
%\xE2\xE3\xCF\xD3
1 0 obj
<<
/FDF << /Fields [ ".$fdfparams."]
/F (http://www.helsekompetanse.no/test.pdf) /ID [ <".md5(time()).">
] >>
>>
endobj
trailer
<<
/Root 1 0 R

>>
%%EOF");
fclose($handle);

// Flatten with PDF

$output = array();
$return_var = 0;

// $exec = '/default_certificate.pdf
'.$template.' fill_form '.$filename.' output '.$filebase.'pdf flatten';
$exec = '/usr/bin/pdftk '.$template.' fill_form '.$filename.' output '.$filebase.'pdf flatten';
exec($exec, $output, $return_var);

//unlink($filename);
}

if (file_exists($filebase.'pdf')) {

// Send PDF
header('Content-Description: File Transfer');
header('Content-Type: application/pdf');
header('Content-Disposition: attachment; filename="'.basename($filebase.'pdf').'"'); // TODO: Fix better filename
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($filebase.'pdf'));
//ob_clean();
//flush();
readfile($filebase.'pdf');

} else {
echo "PDFTK failed - not installed or wrong path?";
exit;
}
?>
Posted: 2010-07-08 09:58:32
greg

Avatar for greg
Subject: Re: Certificate Mod. Install IssueQuote this post in your reply
You might talk to the folks at atutor.no/ , who created the module.
Posted: 2010-07-22 10:15:09
zhulin
Subject: Re: Certificate Mod. Install IssueQuote this post in your reply
I am sure that your posting is exactly what I want to know,so may I share it.I will be feel exciting if you permit me to do so.There are two conventional built-in methods of developing Python with C/C++. The first is composing an expansion, which includes developing a wrapper for C that Python imports, creates, and then can perform. The second is built-in way of developing these 'languages' is known as embedding, and is where C and C++ are given immediate accessibility the Python translator.


tags
[url=http://www.mmo2buy.com/RS2007-Gold.html]Buy RS 2007 Gold[/url]
[url=http://www.fifacoins2buy.com/]Buy Fifa 13 Coins[/url]
[url=http://www.solorsgold.com/gold]RS 3 Gold[/url]
Posted: 2013-10-12 04:46:39
 
Page: 1

You must be signed-in to post.

Related Articles