(function($){
	$.fn.getQuestionBank = function() {
		var _class = $(this).data("class");
		var _course = $(this).data("course");
		var _quiz = $(this).data("quiz");
		var el = $(this);
		$.ajax({
			type: "post",
			url: "contents/plugins/classroom_plus/ajax.php",
			data: {action: "cp_get_question_bank", class: _class, course: _course, quiz: _quiz}
		}).done(function(data){
			try {
				data = JSON.parse(data);
				$(el).html(data.display_html);
			}
			catch (err) {
				console.log(err);
				console.log(data);
			}
			finally {}
		})
	}

	$.fn.getGrading = function() {
		var _class = $(this).data("class");
		var _quiz = $(this).data("quiz");
		var el = $(this);
		$.ajax({
			type: "post",
			url: "contents/plugins/classroom_plus/ajax.php",
			data: {action: "cp_get_grading", class: _class, quiz: _quiz}
		}).done(function(data){
			try {
				data = JSON.parse(data);
				$(el).html(data.display_html);
				$("#students-table-table").initDataTableKoweb();
			}
			catch (err) {
				console.log(err);
				console.log(data);
			}
			finally {}
		})
	}
})(jQuery)

jQuery(document).ready(function($){
	$(document).on("click", "#tabs-icons-text-2-tab", function(e){
		$("#question-bank").getQuestionBank();
	})

	$(document).on("click", "#tabs-icons-text-3-tab", function(e){
		$("#grading").getGrading();
	})
})