Ejemplo n.º 1
0
public static System.Web.WebPages.HelperResult QuizBlock(FillInBlock block, BlockRenderContext context)
{
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {


 
	var value = "";
	var quizRes = "";
	QuizBlockData model = context.GetBlockData(block) ?? new QuizBlockData(new QuizModel(), 1, QuizState.NotPassed);
	if (model.QuizState != QuizState.NotPassed && model.QuizModel.AnswersToQuizes[block.Id].FirstOrDefault() != null)
	{
		value = model.QuizModel.AnswersToQuizes[block.Id].FirstOrDefault();
		quizRes = (model.QuizState == QuizState.Total)
			? (model.QuizModel.AnswersToQuizes[block.Id][1] == "False" ? "wrong-quiz" : "right-quiz") : "";
	}
	var sample = block.Sample;

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t<div class=\"quiz quiz-block-input\">\r\n\t\t<label>\r\n\t\t\t<input autocomplete=\"off\" cla" +
"ss=\"form-control ");


      WebViewPage.WriteTo(@__razor_helper_writer, quizRes);

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\" value=\"");


                       WebViewPage.WriteTo(@__razor_helper_writer, value);

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\" id=\'");


                                    WebViewPage.WriteTo(@__razor_helper_writer, block.Id + "quizBlock");

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\' maxlength=\"");


                                                                         WebViewPage.WriteTo(@__razor_helper_writer, QuizController.MAX_FILLINBLOCK_SIZE);

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\">\r\n\t\t</label>\r\n\t</div>\r\n");


	if (model.QuizState == QuizState.Total)
	{

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t\t<div>Правильный ответ: ");


WebViewPage.WriteTo(@__razor_helper_writer, sample);

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "</div>\r\n");


		if (!string.IsNullOrEmpty(block.Explanation))
		{

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t\t\t<div class=\"text-muted\">");


WebViewPage.WriteTo(@__razor_helper_writer, block.Explanation);

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "</div>\r\n");


		}
	}

});

}
Ejemplo n.º 2
0
public static System.Web.WebPages.HelperResult QuizBlock(FillInBlock block, BlockRenderContext context)
{
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {


 
	var value = "";
	var quizRes = "";
	QuizBlockData model = context.GetBlockData(block) ?? new QuizBlockData(new QuizModel(), 1, QuizState.NotPassed);
	if (model.QuizState != QuizState.NotPassed && model.QuizModel.AnswersToQuizes[block.Id].FirstOrDefault() != null)
	{
		var answers = model.QuizModel.AnswersToQuizes[block.Id];
		var userAnswer = answers.FirstOrDefault();
		value = userAnswer.Text;
		quizRes = model.QuizState == QuizState.Total
			? (userAnswer.IsRightAnswer ? "right-quiz" : "wrong-quiz") : "";
	}
	var sample = block.Sample;
	var readonlyAttr = context.CanUserFillQuiz ? "" : "readonly";

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t<div class=\"quiz quiz-block-input\">\r\n\t\t<label ");


WebViewPage.WriteTo(@__razor_helper_writer, GetGuestOnclick(context.IsGuest));

WebViewPage.WriteLiteralTo(@__razor_helper_writer, ">\r\n");


 			if (block.Multiline)
			{

WebViewPage.WriteLiteralTo(@__razor_helper_writer, " \t\t\t\t<textarea class=\"form-control ");


WebViewPage.WriteTo(@__razor_helper_writer, quizRes);

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\" id=\'");


       WebViewPage.WriteTo(@__razor_helper_writer, block.Id + "quizBlock");

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\' maxlength=\"");


                                            WebViewPage.WriteTo(@__razor_helper_writer, QuizController.MAX_FILLINBLOCK_SIZE);

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\" ");


                                                                                  WebViewPage.WriteTo(@__razor_helper_writer, GetGuestDisable(context.IsGuest));

WebViewPage.WriteLiteralTo(@__razor_helper_writer, " ");


                                                                                                                    WebViewPage.WriteTo(@__razor_helper_writer, readonlyAttr);

WebViewPage.WriteLiteralTo(@__razor_helper_writer, " cols=\"70\" rows=\"5\">");


                                                                                                                                                     WebViewPage.WriteTo(@__razor_helper_writer, value);

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "</textarea>\r\n");


			}
			else
			{

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t\t\t\t<input\r\n\t\t\t\t\tautocomplete=\"off\"\r\n\t\t\t\t\tclass=\"form-control ");


WebViewPage.WriteTo(@__razor_helper_writer, quizRes);

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\"\r\n\t\t\t\t\tvalue=\"");


WebViewPage.WriteTo(@__razor_helper_writer, value);

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\" id=\'");


WebViewPage.WriteTo(@__razor_helper_writer, block.Id + "quizBlock");

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\'\r\n\t\t\t\t\tmaxlength=\"");


WebViewPage.WriteTo(@__razor_helper_writer, QuizController.MAX_FILLINBLOCK_SIZE);

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\"\r\n\t\t\t\t\tsize=\"68\"\r\n\t\t\t\t\t");


WebViewPage.WriteTo(@__razor_helper_writer, GetGuestDisable(context.IsGuest));

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\r\n\t\t\t\t\t");


WebViewPage.WriteTo(@__razor_helper_writer, readonlyAttr);

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "/>\r\n");


			}

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t\t</label>\r\n\t</div>\r\n");


	if (model.QuizState == QuizState.Total)
	{
		if (model.ShowCorrectAnswer)
		{

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t\t\t<div>Правильный ответ: ");


WebViewPage.WriteTo(@__razor_helper_writer, sample);

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "</div>\r\n");


		}
		if (!string.IsNullOrEmpty(block.Explanation))
		{

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t\t\t<div class=\"text-muted\">");


WebViewPage.WriteTo(@__razor_helper_writer, block.Explanation);

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "</div>\r\n");


		}
	}

});

}
Ejemplo n.º 3
0
		private IEnumerable<QuizInfoForDb> CreateQuizInfoForDb(FillInBlock fillInBlock, string data)
		{
			if (data.Length > MAX_FILLINBLOCK_SIZE)
				data = data.Substring(0, MAX_FILLINBLOCK_SIZE);
			var isTrue = fillInBlock.Regexes.Any(regex => regex.Regex.IsMatch(data));
			return new List<QuizInfoForDb>
			{
				new QuizInfoForDb
				{
					QuizId = fillInBlock.Id,
					ItemId = null,
					IsRightAnswer = isTrue,
					Text = data,
					QuizType = typeof(FillInBlock),
					IsRightQuizBlock = isTrue
				}
			};
		}
Ejemplo n.º 4
0
		private IEnumerable<QuizInfoForDb> CreateQuizInfoForDb(FillInBlock fillInBlock, string data)
		{
			if (data.Length > MAX_FILLINBLOCK_SIZE)
				data = data.Substring(0, MAX_FILLINBLOCK_SIZE);
			var isRightAnswer = true;
			if (fillInBlock.Regexes != null)
				isRightAnswer = fillInBlock.Regexes.Any(regex => regex.Regex.IsMatch(data));
			var blockScore = isRightAnswer ? fillInBlock.MaxScore : 0;
			return new List<QuizInfoForDb>
			{
				new QuizInfoForDb
				{
					QuizId = fillInBlock.Id,
					ItemId = null,
					IsRightAnswer = isRightAnswer,
					Text = data,
					QuizType = typeof(FillInBlock),
					QuizBlockScore = blockScore,
					QuizBlockMaxScore = fillInBlock.MaxScore
				}
			};
		}