Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 146... Línea 146...
146
        $fh = fopen($filepath, 'w+');
146
        $fh = fopen($filepath, 'w+');
147
        if (!$fh) {
147
        if (!$fh) {
148
            return false;
148
            return false;
149
        }
149
        }
150
        foreach ($data as $line) {
150
        foreach ($data as $line) {
151
            fputcsv($fh, $line);
151
            fputcsv($fh, $line, escape: '\\');
152
        }
152
        }
153
        fclose($fh);
153
        fclose($fh);
Línea 154... Línea 154...
154
 
154
 
155
        return $fs->create_file_from_pathname($filerecord, $filepath);
155
        return $fs->create_file_from_pathname($filerecord, $filepath);
Línea 288... Línea 288...
288
        $analysablesvalues = array();
288
        $analysablesvalues = array();
289
        foreach ($files as $file) {
289
        foreach ($files as $file) {
290
            $rh = $file->get_content_file_handle();
290
            $rh = $file->get_content_file_handle();
Línea 291... Línea 291...
291
 
291
 
292
            // Copy the var names as they are, all files should have the same var names.
292
            // Copy the var names as they are, all files should have the same var names.
Línea 293... Línea 293...
293
            $varnames = fgetcsv($rh);
293
            $varnames = fgetcsv($rh, escape: '\\');
Línea 294... Línea 294...
294
 
294
 
295
            $analysablesvalues[] = fgetcsv($rh);
295
            $analysablesvalues[] = fgetcsv($rh, escape: '\\');
296
 
296
 
Línea 297... Línea 297...
297
            // Copy the columns as they are, all files should have the same columns.
297
            // Copy the columns as they are, all files should have the same columns.
298
            $columns = fgetcsv($rh);
298
            $columns = fgetcsv($rh, escape: '\\');
299
        }
299
        }
Línea 314... Línea 314...
314
        $wh = fopen($tmpfilepath, 'w');
314
        $wh = fopen($tmpfilepath, 'w');
315
        if (!$wh) {
315
        if (!$wh) {
316
            throw new \moodle_exception('errorcannotwritedataset', 'analytics', '', $tmpfilepath);
316
            throw new \moodle_exception('errorcannotwritedataset', 'analytics', '', $tmpfilepath);
317
        }
317
        }
Línea 318... Línea 318...
318
 
318
 
319
        fputcsv($wh, $varnames);
319
        fputcsv($wh, $varnames, escape: '\\');
320
        fputcsv($wh, $values);
320
        fputcsv($wh, $values, escape: '\\');
Línea 321... Línea 321...
321
        fputcsv($wh, $columns);
321
        fputcsv($wh, $columns, escape: '\\');
322
 
322
 
323
        // Iterate through all files and add them to the tmp one. We don't want file contents in memory.
323
        // Iterate through all files and add them to the tmp one. We don't want file contents in memory.
Línea 400... Línea 400...
400
        fgets($rh);
400
        fgets($rh);
401
        fgets($rh);
401
        fgets($rh);
Línea 402... Línea 402...
402
 
402
 
Línea 403... Línea 403...
403
        $calculations = array();
403
        $calculations = array();
404
 
404
 
405
        $headers = fgetcsv($rh);
405
        $headers = fgetcsv($rh, escape: '\\');
Línea 406... Línea 406...
406
        // Get rid of the sampleid column name.
406
        // Get rid of the sampleid column name.
407
        array_shift($headers);
407
        array_shift($headers);
Línea 408... Línea 408...
408
 
408
 
409
        while ($columns = fgetcsv($rh)) {
409
        while ($columns = fgetcsv($rh, escape: '\\')) {