Hello Everyone,
I am new to moodle hence kindly bear with me !!
I am developing a moodle plugin(block) which will collect some data(user/student data eg. number of assignment done etc) in newly created database in moodle then get csv file(get data from new created db in csv format) to apply some data mining techniques on data(csv file). I am planning to use "R" scripts to execute data mining/machine learning techniques(R scripts is the reason I am creating csv files). Utimately get output file in csv which will be uploaded to moodle database and then i will show results in block from database.
1. Is above plan feasible or am I missing something obvious ? can we create csv files at block level(in block folder itself) ? Is there a better way then above ?
2. Can i directly get data from moodle database in R, in order to avoid creating csv files ?
3.I have developed following code for above stated purpose and it runs without error but i dont see "test.csv" being generated. Aim is to generate this file in block itself so that i can later use it.
================================================================================
public function convert_to_csv($input_array, $output_file_name, $delimiter)
{
/** open raw memory as file, */
$f = fopen('php://memory', 'w');
foreach ($input_array as $line) {
fputcsv($f, $line, $delimiter);
}
/** rewrind the "file" with the csv lines **/
fseek($f, 0);
header('Content-Type: application/csv');
header('Content-Disposition: attachement; filename="' . $output_file_name . '";');
/** Send file to browser for download */
fpassthru($f);
}
public function preparing_testfile() {
$test = $DB->get_record('block_test', array() );
convert_to_csv($test, 'test.csv', ',');
}
==================================================================================
My assumptions : I cant apply data mining techniques(Decision tree, Neural networks) in php hence i need csv files then apply data mining techniques using some integration between php(in moodle) and data mining tool (e.g. R)
Any type of suggestions will be appreciated. Thanks in advance !!