CodeIgniter Forums
Generate a pdf certificate after finishing exam - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Choosing CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=8)
+--- Thread: Generate a pdf certificate after finishing exam (/showthread.php?tid=71817)



Generate a pdf certificate after finishing exam - cndunga - 09-27-2018

I have an online exam system which is able to generate a pdf certificate once a click on the view download button. However, I would like the system to automatically generate a pdf certificate once a user clicks on the Finish button. Please help.

My part of my exam controller

if ($this->input->post('Finish') == 'Finish') {
foreach ($this->input->post() as $key=>$value) {
$useroptions[$key] = $value;

if ($key != 'Finish') {
if (intval($value) == 0) {
$not_attempted++;
}

if($answers[$key] == intval($value)){
$score++;
}
}
}


The view for the download button is

<div class="col-md-4">
                        <a href="<?php echo base_url();?>user/certificate/<?php echo $h->quiz_id;?>" target="_blank">
                           <div class="btn bg-primary  exam-histry-btn">Download Certificate </div>
                        </a>


RE: Generate a pdf certificate after finishing exam - InsiteFX - 09-27-2018

Just put your code into it's own method and call it from within your finish
button method.


RE: Generate a pdf certificate after finishing exam - msnisha - 09-27-2018

(09-27-2018, 03:13 AM)You can do that by doing the same code inside User controller and inside the certificate function in the end of finish button code. If the finish button also inside the same controller you could call the method directly by passing the required parameters. Wrote:
PHP Code:
$this->certificate(quiz_id


cndungaI have an online exam system which is able to generate a pdf certificate once a click on the view download button. However, I would like the system to automatically generate a pdf certificate once a user clicks on the Finish button. Please help.

My part of my exam controller

if ($this->input->post('Finish') == 'Finish') {
foreach ($this->input->post() as $key=>$value) {
$useroptions[$key] = $value;

if ($key != 'Finish') {
if (intval($value) == 0) {
$not_attempted++;
}

if($answers[$key] == intval($value)){
$score++;
}
}
}


The view for the download button is

<div class="col-md-4">
                        <a href="<?php echo base_url();?>user/certificate/<?php echo $h->quiz_id;?>" target="_blank">
                           <div class="btn bg-primary  exam-histry-btn">Download Certificate </div>
                        </a>