/** * Delete a vpl instance * * @return bool true if all OK **/ function delete_all() { global $DB; //Delete all data files vpl_delete_dir($this->get_data_directory()); //delete grade_item vpl_delete_grade_item($this->instance); //delete event $DB->delete_records('event', array('modulename' => VPL, 'instance' => $this->instance->id)); //Delete all submissions records $DB->delete_records('vpl_submissions', array('vpl' => $this->instance->id)); //delete vpl record $DB->delete_records(VPL, array('id' => $this->instance->id)); // Allways true return true; }
/** * Delete submitted files and own record * @return void **/ function delete() { global $DB; \mod_vpl\event\submission_deleted::log($this); vpl_delete_dir($this->get_data_directory()); $DB->delete_records('vpl_submissions', array('id' => $this->instance->id)); }
public static function scan_zip(&$simil, $zipname, $zipdata, $vpl, $filesselected = array(), $SPB) { global $CFG; $ext = strtoupper(pathinfo($zipname, PATHINFO_EXTENSION)); if ($ext != 'ZIP') { print_error('nozipfile'); } self::create_zip_file($zipname, $zipdata); $zip = new ZipArchive(); $zipfilename = self::get_zip_filepath($zipname); debugging("Unzip file " . $zipfilename, DEBUG_DEVELOPER); $SPB->set_value(get_string('unzipping', VPL)); if ($zip->open($zipfilename)) { $toremove = strlen($destdir); $SPB->set_max($zip->numFiles); $i = 1; for ($i = 0; $i < $zip->numFiles; $i++) { $SPB->set_value($i + 1); $filename = $zip->getNameIndex($i); if ($filename == false) { break; } $data = $zip->getFromIndex($i); if ($data) { debugging("Examining file " . $filename, DEBUG_DEVELOPER); //TODO remove if no GAP file vpl_file_from_zipfile::process_gap_userfile($filename); if (count($filesselected) > 0 && !isset($filesselected[basename($filename)])) { continue; } $sim = vpl_similarity_factory::get($filename); if ($sim) { //TODO locate userid $from = new vpl_file_from_zipfile($filename, $zipfile); $sim->init($data, $from); if ($sim->size > 10) { $simil[] = $sim; } } } } } //remove temp dir $SPB->set_value(get_string('cleaningtempdata') . ' ' . count($simil)); unlink($dirfilename); vpl_delete_dir($destdir); $SPB->set_value(count($listfiles)); }