function Task_Module_2( taskId, panel )
{
	Task_Module_2.superclass.constructor.call(this, taskId, panel);
	this._taskType = 2;
}

Rup.extend(Task_Module_2, Task_Module_Abstract);

Task_Module_2.prototype._createVariants = function( data )
{
    var oAnswersDiv = this._variantElement;
	oAnswersDiv.id = 'EduVariantDiv';
	
	sContStr = data.getAttribute('content');
	sContStr = sContStr.replace(/<v>(.*?)<\/v>/gi, "<span class=\"variant_type_2\">$1</span>");
	
	var oTmp = Rup.create("div");
	oAnswersDiv.innerHTML = "";
	oAnswersDiv.appendChild(oTmp);
	oTmp.innerHTML = sContStr;
	
	var aSpans = oTmp.getElementsByTagName("span");
	
	for( var i = aSpans.length - 1; 0 <= i ; i-- )
	{
		var oCurSpan = aSpans[i];
		if( oCurSpan.className == "variant_type_2" )
		{
			var oVariant = new Task_Variant_2({
				text: oCurSpan.innerHTML
			});
			
			this._variants.unshift(oVariant);
			
			oCurSpan.parentNode.replaceChild(oVariant.dom(), oCurSpan);
		}
	}
}

Task_Module_2.prototype.setAnswer = function(answerXml)
{
	var aAnswer = answerXml.getAttribute("rightanswer").split(",");
	
	for( var i = 0; i < this._variants.length; i++ )
	{
		if( aAnswer.indexOf((i+1).toString()) != -1 )
		{
			this._variants[i].setValue(1);
		}
		else
		{
			this._variants[i].setValue(0);
		}
	}
}

Task_Module_2.prototype._getAnswerString = function()
{
	var aAnswer = [];
	for( var i = 0; i < this._variants.length; i++ )
	{
		if( this._variants[i].getValue() )
		{
			aAnswer.push(i+1);
		}
	}
	
	return aAnswer.join(",");
}

Task_Module_2.prototype.compareAnswers = function()
{
	var answers = this._params.ranswer.split(',');
	var anscnt = 0;
	var correct = 0;
	for( var i = 0; i < this._variants.length; i++ )
	{
		var found = false;
		for (var j = 0; j < answers.length; j++)
			{if (i+1 == answers[j]) {found = true; break;} }
		
		if (found)
		{
			anscnt++;
			this._variants[i].addTextClassName('shouldbechecked');
			if (!this._variants[i].getValue())
				this._variants[i].addTextClassName('mistake')
			else 
				correct ++;
		}
		else
		{
			if (this._variants[i].getValue())
			{
				this._variants[i].addTextClassName('mistake');
				correct--;
			}
		}
	}
	return (anscnt > 0) ? Math.round(100*Math.max(0, correct)/anscnt) : 100;
}