Welcome Guest, Not a member yet? Register   Sign In
Generate a pdf certificate after finishing exam
#1

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>
Reply
#2

Just put your code into it's own method and call it from within your finish
button method.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(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>
Using and  Heart  CodeIgniter for more than 8 years and own a CodeIgniter website generator at thephpcode.com.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB