private IEnumerable <QuizInfoForDb> CreateQuizInfoForDb(IsTrueBlock isTrueBlock, IGrouping <string, QuizAnswer> data) { var isTrue = isTrueBlock.IsRight(data.First().ItemId); return(new List <QuizInfoForDb> { new QuizInfoForDb { QuizId = isTrueBlock.Id, ItemId = null, IsRightAnswer = isTrue, Text = data.First().ItemId, QuizType = typeof(IsTrueBlock), IsRightQuizBlock = isTrue } }); }
private IEnumerable <QuizInfoForDb> CreateQuizInfoForDb(IsTrueBlock isTrueBlock, IGrouping <string, QuizAnswer> data) { var isTrue = isTrueBlock.IsRight(data.First().ItemId); var blockScore = isTrue ? isTrueBlock.MaxScore : 0; return(new List <QuizInfoForDb> { new QuizInfoForDb { BlockId = isTrueBlock.Id, ItemId = null, IsRightAnswer = isTrue, Text = data.First().ItemId, BlockType = typeof(IsTrueBlock), QuizBlockScore = blockScore, QuizBlockMaxScore = isTrueBlock.MaxScore } }); }
private IEnumerable <QuizInfoForDb> CreateQuizInfoForDb(IsTrueBlock isTrueBlock, IGrouping <string, QuizAnswer> data) { // Здесь двойной баг. В запросе из браузера текст преедается в ItemId, а не Text, поэтому работает. В базу правильно: ItemId всегда null, а значение в Text var isTrue = isTrueBlock.IsRight(data.First().ItemId); var blockScore = isTrue ? isTrueBlock.MaxScore : 0; return(new List <QuizInfoForDb> { new QuizInfoForDb { BlockId = isTrueBlock.Id, ItemId = null, IsRightAnswer = isTrue, Text = data.First().ItemId, BlockType = typeof(IsTrueBlock), QuizBlockScore = blockScore, QuizBlockMaxScore = isTrueBlock.MaxScore } }); }
public static System.Web.WebPages.HelperResult QuizBlock(IsTrueBlock block, BlockRenderContext context) { return(new System.Web.WebPages.HelperResult(__razor_helper_writer => { var tchecked = ""; var fchecked = ""; var trueItemClass = ""; var falseItemClass = ""; var ttitle = ""; var ftitle = ""; 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 userAnswer = model.QuizModel.AnswersToQuizes[block.Id].FirstOrDefault() == "True"; tchecked = userAnswer ? "checked" : ""; fchecked = userAnswer ? "" : "checked"; if (model.QuizState == QuizState.Total) { trueItemClass = block.Answer ? "right-quiz" : userAnswer ? "wrong-quiz" : ""; falseItemClass = !block.Answer ? "right-quiz" : !userAnswer ? "wrong-quiz" : ""; } } if (model.QuizState == QuizState.Total) { ttitle = (block.Answer ? "Правильный" : "Неправильный") + " вариант"; ftitle = (!block.Answer ? "Правильный" : "Неправильный") + " вариант"; } WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t<div class=\"radio quiz-block-mark\" id=\""); WebViewPage.WriteTo(@__razor_helper_writer, block.Id + "_quizBlock"); WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\">\r\n\t\t<div class=\"quiz\">\r\n\t\t\t<label class=\""); WebViewPage.WriteTo(@__razor_helper_writer, trueItemClass); WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\" title=\""); WebViewPage.WriteTo(@__razor_helper_writer, ttitle); WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\" "); WebViewPage.WriteTo(@__razor_helper_writer, GetGuestOnclick(context.IsGuest)); WebViewPage.WriteLiteralTo(@__razor_helper_writer, ">\r\n\t\t\t\t<input autocomplete=\"off\" "); WebViewPage.WriteTo(@__razor_helper_writer, tchecked); WebViewPage.WriteLiteralTo(@__razor_helper_writer, " id=\'"); WebViewPage.WriteTo(@__razor_helper_writer, block.Id + "quizBlock" + "True"); WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\' name=\'"); WebViewPage.WriteTo(@__razor_helper_writer, block.Id + "group"); WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\' type=\"radio\" "); WebViewPage.WriteTo(@__razor_helper_writer, GetGuestDisable(context.IsGuest)); WebViewPage.WriteLiteralTo(@__razor_helper_writer, ">\r\n\t\t\t\tВерно\r\n\t\t\t</label>\r\n"); if (model.QuizState == QuizState.Total && block.Answer) { WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t\t\t\t<i class=\"glyphicon glyphicon-ok\" style=\"color: green\" title=\""); WebViewPage.WriteTo(@__razor_helper_writer, ttitle); WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\"></i>\r\n"); } WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t\t</div>\r\n\t\t<div class=\"quiz\">\r\n\t\t\t<label class=\""); WebViewPage.WriteTo(@__razor_helper_writer, falseItemClass); WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\" title=\""); WebViewPage.WriteTo(@__razor_helper_writer, ftitle); WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\" "); WebViewPage.WriteTo(@__razor_helper_writer, GetGuestOnclick(context.IsGuest)); WebViewPage.WriteLiteralTo(@__razor_helper_writer, ">\r\n\t\t\t\t<input autocomplete=\"off\" "); WebViewPage.WriteTo(@__razor_helper_writer, fchecked); WebViewPage.WriteLiteralTo(@__razor_helper_writer, " id=\'"); WebViewPage.WriteTo(@__razor_helper_writer, block.Id + "quizBlock" + "False"); WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\' name=\'"); WebViewPage.WriteTo(@__razor_helper_writer, block.Id + "group"); WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\' type=\"radio\" "); WebViewPage.WriteTo(@__razor_helper_writer, GetGuestDisable(context.IsGuest)); WebViewPage.WriteLiteralTo(@__razor_helper_writer, ">\r\n\t\t\t\tНеверно\r\n\t\t\t</label>\r\n"); if (model.QuizState == QuizState.Total && !block.Answer) { WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t\t\t\t<i class=\"glyphicon glyphicon-ok\" style=\"color: green\" title=\""); WebViewPage.WriteTo(@__razor_helper_writer, ftitle); WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\"></i>\r\n"); } WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t\t</div>\r\n\t</div>\r\n"); if (model.QuizState == QuizState.Total && !string.IsNullOrEmpty(block.Explanation)) { WebViewPage.WriteLiteralTo(@__razor_helper_writer, "\t\t<div class=\"text-muted\">"); WebViewPage.WriteTo(@__razor_helper_writer, block.Explanation); WebViewPage.WriteLiteralTo(@__razor_helper_writer, "</div>\r\n"); } })); }