private static TagUl GetAnswerList(IEnumerable <TestAnswer> answers) { return(ul[answers.Select(x => li.Style("margin-bottom:15px;")[x.IsRight.GetValueOrDefault() ? (object)div.Style("border:2px solid Green;padding:5px;border-radius: 5px;")[ TestText(x.Description), TestControls.AnswerFileView(x.Id, false, true)] : div[TestText(x.Description), TestControls.AnswerFileView(x.Id, false, true)] ])]); }
object GetAnswerText(TestAnswer answer) { var file = TestControls.AnswerFileView(answer.Id, false); var desc = TestReadOnlyView.TestText(answer.Description); if (file == null) { return(desc); } return(H.l(desc, br, TestControls.AnswerFileView(answer.Id, false))); }
public static object ComparisonView(TestQuestion model) { var answers1 = model.TestAnswers.Where(x => x.ComparableId.HasValue); var answers2 = model.TestAnswers.Where(x => x.ComparableId == null); var compare = answers1.Select(x => Tuple.Create(x, answers2.FirstOrDefault(y => y.Id == x.ComparableId.Value))); return(l( table[ compare.Select(x => tr[ td[x.Item2.GetOrDefault(a => TestText(a.Description)), br, TestControls.AnswerFileView(x.Item2.Id, false)], td[TestText(x.Item1.Description), br, TestControls.AnswerFileView(x.Item1.Id, false)] ])])); }
public override object Get() { object answerControl = null; switch (Model.TestQuestion.Type) { case TestQuestionType.OneAnswer: case TestQuestionType.ManyAnswers: answerControl = ControlFor(x => x.IsRight); break; case TestQuestionType.Comparison: answerControl = Select2For(Model.ComparableAnswer.GetOrDefault(x => x.Description), x => x.ComparableId, Url.Action <TestEditController>(c => c.GetAnswersAuto(Model.TestQuestion.Id, null))); break; case TestQuestionType.Sort: answerControl = ControlFor(x => x.Sort); break; default: throw new Exception("TestQuestionType out of range"); } return(l( Tabs(_.List("�עגוע", "�איכ"), AjaxForm(Url.Action <TestEditController>(x => x.EditAnswer(null)))[ HiddenFor(x => x.Id), HiddenFor(x => x.QuestionId), ControlFor(x => x.Description), answerControl, SaveButton() ], TestControls.TestFileUpload(TestControls.AnswerFileView(Model.Id, true), Url.Action <TestEditController>(c => c.UploadAnswerFile(Model.Id, null)), Url.Action <TestEditController>(c => c.DeleteAnswerFile(Model.Id)), Url.Action <TestEditController>(c => c.GetAnswerFileControl(Model.Id)), Model.Id == 0 )) )); }