Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QUESTION Plugin to collect feeback and save in a excel file
#1
Hi guys I would like to create a plugin where for example you can provide feedback on some apprenticeship programmes like 1 to 10 ratings and a simple message box and this is then collected into an excel file that can be downloaded in the backend. How could I achire this ? I guess a plugin is required? Would anyone know how I would go about achieving this ?

Update

So far I have created a plugin following the hello-world example and got a csv file creating when I go to my plugin page in admin if none exists, and a download link if it does. Simple! but progress nonetheless.

Now, I get forbidden when I click to download the the file. Thus, what is the best place to store this csv file ?

Currently, I have created a my_plugin folder within the plugin folder, and within this the csv file is stored.

Also, now I have also got it write to the file if it exists when I go to the plugins admin page. But, I need to write the post data from a form! Therefore, How can I get the post data in the plugin php file to be able to use in a function I guess that will convert it to an array that could be appended to the file?

Is this possible in GET SIMPLE? like are you able to globally use plugin functions or get form to post to the plugin ?

My code so far:

PHP Code:
<?php
/*
Plugin Name: Hello World
Description: Gather Feedback 
Version: 1.0
Author: Vish Patel
*/
 
# get correct id for plugin
$thisfile=basename(__FILE__".php");
 
$plugin_folder_name 'hello-world';
$plugin_folder_path GSPLUGINPATH.$plugin_folder_name.'/';
$rel_plugin_folder_path substr(GSPLUGINPATHstrlen(GSROOTPATH)).$plugin_folder_name.'/';
# register plugin
register_plugin(
    
$thisfile//Plugin id
    
'Vish Feedback',     //Plugin name
    
'1.0',         //Plugin version
    
'Vish Patel',  //Plugin author
    
'http://www.cagintranet.com/'//author website
    
'Gather feedback and save to a CSV file'//Plugin description
    
'plugins'//page type - on which admin tab to display
    
'Feedback_admin'  //main function (administration)
);
 
# activate filter 
add_action('index-posttemplate','hello_world'); 
 
# add a link in the admin tab 'theme'
add_action('plugins-sidebar','createSideMenu',array($thisfile,'Vish Feedback'));
 
# functions
function hello_world() {
    echo 
'<p>Hello World</p>';
}
 function 
createPath($path) {
    if (
is_dir($path)) return true;
    
$prev_path substr($path0strrpos($path'/', -2) + );
    
$return createPath($prev_path);
    return (
$return && is_writable($prev_path)) ? mkdir($path) : false;
}
function 
Feedback_admin() {
    global 
$plugin_folder_path;
    global 
$filename;
    global 
$year;
    global 
$month;
    global 
$path;
    global 
$rel_plugin_folder_path;
    
$year date("Y");   
    
$month date("m");   
    
$path $plugin_folder_path.$year.'/'.$month.'/';   
    
createPath($path);
    
$filename $path."vish.csv";
    if (
file_exists($filename)) {
    
/*
        echo "The file $filename exists";
        $list = array("vish,n/a,nonw,na/n");

        $file = fopen($filename,"a");

        foreach ($list as $line)
        {
            fputcsv($file,explode(',',$line));
        }

        fclose($file);
    */
       
echo("<a href='../{$rel_plugin_folder_path}{$year}/{$month}/vish.csv' download>Download Current months feedback spreadsheet</a>");
    } else {
   
$ourFileHandle fopen($filename'w') or die("can't open file");
   
$headers = ['Apprenticeship_Programme''Rating''Programme_Performance''Quality_Of_Programme'];
   
fputcsv($ourFileHandle$headers);
   
fclose($ourFileHandle);
}
}
?>
Reply
#2
You wouldn't need a plugin. I think google forms will help you create a survey form or a poll and record the inputs. Actually quite a number of external form data forwarders will do that https://www.infiniforms.io/ for instance (provided without recommendation - I haven't used them).
Reply
#3
(2017-03-21, 08:49:16)Timbow Wrote: You wouldn't need a plugin. I think google forms will help you create a survey form or a poll and record the inputs. Actually quite a number of external form data forwarders will do that https://www.infiniforms.io/ for instance (provided without recommendation - I haven't used them).

I see where you are coming from. But, I would like to incorporate it into my site so that for example off a modal for a particular apprenticeship programme a user a can click a link that opens a feedback modal with a form, which then has the feedback for that programme written to say a csv file. This is then to be downloadable/viewable in the admin area of the GMS.
Reply




Users browsing this thread: 1 Guest(s)