<commit_before>
function createQuestFilters() {
	return '\n\n<div class="fhq_task_filters"> <div>Filter by status quests: \n'
	+ '<input id="filter_open" class="fhq_task_checkbox" type="checkbox" onclick="reloadQuests();" checked />\n'
	+ '<label class="fhq_task_label lite_green_check" for="filter_open">open (<font id="filter_open_count">0</font>) </label> \n'
	+ '<input id="filter_current" class="fhq_task_checkbox" type="checkbox" onclick="reloadQuests();" checked/> \n'
	+ '<label class="fhq_task_label lite_green_check" for="filter_current">in progress (<font id="filter_current_count">0</font>) </label> \n'
	+ '<input id="filter_completed" class="fhq_task_checkbox" type="checkbox" onclick="reloadQuests();" />\n'
	+ '<label class="fhq_task_label lite_green_check" for="filter_completed">completed (<font id="filter_completed_count">0</font>) </label> \n'
	+ '</div>\n'
	+ '<div id="filter_by_subject"></div> \n'
	+ '</div> \n'
	+ '<div id="quests"></div> \n';
}


function createQuestInfo(quest) {

	var questid = quest.questid;
	var name = quest.name
	var score = quest.score;
	var subject = quest.subject;
	var status = quest.status;
	var solved = quest.count_user_solved;
	solved = solved == null ? "?" : solved;

	var content = '\n\n<div class="fhq_quest_info" onclick="showQuest(' + questid + ');"><div class="fhq_quest_info_row">\n';
	content += '<div class="fhq_quest_info_cell_img">';
	content += '<img  width="100px" src="templates/base/images/quest_icons/' + subject + '.png">';
	content += '</div>';
	
	content += '<div class="fhq_quest_info_cell_content">';
	content += '<div class="fhq_quest_caption">' + questid + ' ' + name + '</div>';
	content += '<div class="fhq_quest_score">' + subject + ' +' + score + '</div>';
	content += '<div class="fhq_quest_caption">solved: ' + solved + '</div>';
	
	/*if (status == 'open')
		content += '<div class="fhq_quest_score">take quest</div>';*/
					
	// content += '<font class="fhq_task" size="1">Status: ' + status + '</font>\n';
	content += '</div>';
	content += '</div></div>\n';
	return content;
}

function reloadQuests()
{
	var quests = document.getElementById("quests");
	if (!quests)
		return;
	quests.innerHTML = "Please wait...";
	
	var params = {};
	params.filter_open = document.getElementById("filter_open").checked;
	params.filter_current = document.getElementById("filter_current").checked;
	params.filter_completed = document.getElementById("filter_completed").checked;

	// filter
	var arr = []
	var elems = document.getElementsByName("filter_subjects");
	for (var i = 0; i < elems.length; i++) {
		if (elems[i].checked)
			arr.push(elems[i].getAttribute("subject"));
	}
	params.filter_subjects = arr.join(",");
	
	// alert(createUrlFromObj(params));
	send_request_post(
		'api/quests/list.php',
		createUrlFromObj(params),
		function (obj) {
			if (obj.result == 'fail')
			{
				quests.innerHTML = obj.error.message;
				return;
			}
			
			// var current_game = obj.current_game;
			document.getElementById("filter_open_count").innerHTML = obj.status.open;
			document.getElementById("filter_current_count").innerHTML = obj.status.current;
			document.getElementById("filter_completed_count").innerHTML = obj.status.completed;
			var filter_by_subject = document.getElementById('filter_by_subject');
			if (filter_by_subject.innerHTML == "")
			{
				filter_by_subject.innerHTML = 'Filter by subject: \n';
				for (var k in obj.subjects) {
					filter_by_subject.innerHTML += '<input name="filter_subjects" subject="' + k + '" id="filter_subject_' + k + '" type="checkbox" class="fhq_task_checkbox" onclick="reloadQuests();" checked/>'<commit_msg>added selection game when try load tasks<commit_after>
function createQuestFilters() {
	return '\n\n<div class="fhq_task_filters"> <div>Filter by status quests: \n'
	+ '<input id="filter_open" class="fhq_task_checkbox" type="checkbox" onclick="reloadQuests();" checked />\n'
	+ '<label class="fhq_task_label lite_green_check" for="filter_open">open (<font id="filter_open_count">0</font>) </label> \n'
	+ '<input id="filter_current" class="fhq_task_checkbox" type="checkbox" onclick="reloadQuests();" checked/> \n'
	+ '<label class="fhq_task_label lite_green_check" for="filter_current">in progress (<font id="filter_current_count">0</font>) </label> \n'
	+ '<input id="filter_completed" class="fhq_task_checkbox" type="checkbox" onclick="reloadQuests();" />\n'
	+ '<label class="fhq_task_label lite_green_check" for="filter_completed">completed (<font id="filter_completed_count">0</font>) </label> \n'
	+ '</div>\n'
	+ '<div id="filter_by_subject"></div> \n'
	+ '</div> \n'
	+ '<div id="quests"></div> \n';
}


function createQuestInfo(quest) {

	var questid = quest.questid;
	var name = quest.name
	var score = quest.score;
	var subject = quest.subject;
	var status = quest.status;
	var solved = quest.count_user_solved;
	solved = solved == null ? "?" : solved;

	var content = '\n\n<div class="fhq_quest_info" onclick="showQuest(' + questid + ');"><div class="fhq_quest_info_row">\n';
	content += '<div class="fhq_quest_info_cell_img">';
	content += '<img  width="100px" src="templates/base/images/quest_icons/' + subject + '.png">';
	content += '</div>';
	
	content += '<div class="fhq_quest_info_cell_content">';
	content += '<div class="fhq_quest_caption">' + questid + ' ' + name + '</div>';
	content += '<div class="fhq_quest_score">' + subject + ' +' + score + '</div>';
	content += '<div class="fhq_quest_caption">solved: ' + solved + '</div>';
	
	/*if (status == 'open')
		content += '<div class="fhq_quest_score">take quest</div>';*/
					
	// content += '<font class="fhq_task" size="1">Status: ' + status + '</font>\n';
	content += '</div>';
	content += '</div></div>\n';
	return content;
}

function reloadQuests()
{
	var quests = document.getElementById("quests");
	if (!quests)
		return;
	quests.innerHTML = "Please wait...";
	
	var params = {};
	params.filter_open = document.getElementById("filter_open").checked;
	params.filter_current = document.getElementById("filter_current").checked;
	params.filter_completed = document.getElementById("filter_completed").checked;

	// filter
	var arr = []
	var elems = document.getElementsByName("filter_subjects");
	for (var i = 0; i < elems.length; i++) {
		if (elems[i].checked)
			arr.push(elems[i].getAttribute("subject"));
	}
	params.filter_subjects = arr.join(",");
	
	// alert(createUrlFromObj(params));
	send_request_post(
		'api/quests/list.php',
		createUrlFromObj(params),
		function (obj) {
			if (obj.result == 'fail')
			{
				quests.innerHTML = obj.error.message;
				if (obj.error.code == 1094) {
					changeGame();
				}
				return;
			}

			// var current_game = obj.current_game;
			document.getElementById("filter_open_count").innerHTML = obj.status.open;
			document.getElementById("filter_current_count").innerHTML = obj.status.current;
			document.getElementById("filter_completed_count").innerHTML = obj.status.completed;
			var filter_by_subject = document.getElementById('filter_by_subject');
			if (filter_by_subject.innerHTML == "")
			{
				filter_by_subject.innerHTML = 'Filter by subject: \n';
				for (var k in obj.subjects) {
					filter_by_subject.innerHTML += '<input name="filter_subjects" subject="' + k + '" id="filter_subject_' + k + '" type="checkbox" class="fhq_task_checkbox" onclick="reloadQuests();" checked/>'
{'fraction_non_alphanumeric': 0.1838845787396216, 'fraction_numerical': 0.0027221995372260785, 'mean_word_length': 5.216582064297801, 'pattern_counts': {'":': 0, '<': 91, '<?xml version=': 0, '>': 89, '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': '313335', 'n_tokens_mistral': 2629, 'n_tokens_neox': 2431, 'n_words': 471}