<commit_before><?
/**
 * @file
 * @version 1.0
 * @date 07/09/2014
 * @author <NAME> <<EMAIL>> 
 * 	
 */

require "../../../lib.php";
require_once "{$root}/lib/Twig/Autoloader.php";

/**
 * Parse CSV data into an array.
 * 
 * @param string $data Raw CSV data
 * 
 * @returns list of parsed modules: (ModuleID, Title)
 */
function parseModulesCSV($data) {
	$lines = explode("\n",$data);
	$modules = array();
	foreach($lines as $line) {
		$csv = str_getcsv($line);
		if (count($csv) < 2)
			continue;
			
		$modules[] = array(
			"ModuleID"=>strtolower($csv[0]),
			"ModuleTitle"=>$csv[1]
		);
	}
	return $modules;
}

/**
 * 
 * Add array of modules into database
 * 
 * @param parsed-modules $modules The list of parsed modules (from parseModulesCSV())
 * @param int $questionnaireID The questionnaire ID
 */
function insertModules($modules, $questionnaireID) {
	global $db;
	$dbmodule = new tidy_sql($db, "
REPLACE INTO Modules (ModuleID, QuestionaireID, ModuleTitle) VALUES (?, ?, ?)", "sis");<commit_msg>Fix module import case sensitivity issue<commit_after><?
/**
 * @file
 * @version 1.0
 * @date 07/09/2014
 * @author <NAME> <<EMAIL>> 
 * 	
 */

require "../../../lib.php";
require_once "{$root}/lib/Twig/Autoloader.php";

/**
 * Parse CSV data into an array.
 * 
 * @param string $data Raw CSV data
 * 
 * @returns list of parsed modules: (ModuleID, Title)
 */
function parseModulesCSV($data) {
	$lines = explode("\n",$data);
	$modules = array();
	foreach($lines as $line) {
		$csv = str_getcsv($line);
		if (count($csv) < 2)
			continue;
			
		$modules[] = array(
			"ModuleID"=>strtoupper($csv[0]),
			"ModuleTitle"=>$csv[1]
		);
	}
	return $modules;
}

/**
 * 
 * Add array of modules into database
 * 
 * @param parsed-modules $modules The list of parsed modules (from parseModulesCSV())
 * @param int $questionnaireID The questionnaire ID
 */
function insertModules($modules, $questionnaireID) {
	global $db;
	$dbmodule = new tidy_sql($db, "
REPLACE INTO Modules (ModuleID, QuestionaireID, ModuleTitle) VALUES (?, ?, ?)", "sis");
{'fraction_non_alphanumeric': 0.18030377266046055, 'fraction_numerical': 0.012738853503184714, 'mean_word_length': 3.8160377358490565, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3214168', 'n_tokens_mistral': 763, 'n_tokens_neox': 706, 'n_words': 186}