From 4583cdbe0f19c9b133fd2614ec8077fc972182fb Mon Sep 17 00:00:00 2001 From: adityacp Date: Tue, 18 Feb 2020 14:15:46 +0530 Subject: Preview question description and solution --- yaksh/static/yaksh/js/add_question.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'yaksh') diff --git a/yaksh/static/yaksh/js/add_question.js b/yaksh/static/yaksh/js/add_question.js index 310fed5..4d134cd 100644 --- a/yaksh/static/yaksh/js/add_question.js +++ b/yaksh/static/yaksh/js/add_question.js @@ -76,6 +76,10 @@ function textareaformat() document.getElementById('id_tags').setAttribute('class','form-control'); $("[id*="+'test_case_args'+"]").attr('placeholder', 'Command Line arguments for bash only'); + var desc_preview = "

"; + var sol_preview = "

"; + $(desc_preview).insertBefore("#id_description"); + $(sol_preview).insertBefore("#id_solution"); $('#id_snippet').bind('keydown', function( event ){ if(navigator.userAgent.match("Gecko")) @@ -105,11 +109,11 @@ function textareaformat() }); $('#id_description').bind('keypress', function (event){ - document.getElementById('rendered_text').innerHTML = document.getElementById('id_description').value ; + document.getElementById('desc_preview').innerHTML = document.getElementById('id_description').value ; }); $('#id_solution').bind('keypress', function (event){ - document.getElementById('rend_solution').innerHTML = document.getElementById('id_solution').value ; + document.getElementById('sol_preview').innerHTML = document.getElementById('id_solution').value ; }); $('#id_type').bind('focus', function(event){ @@ -122,6 +126,10 @@ function textareaformat() language.style.border = '1px solid #ccc'; }); + + document.getElementById('desc_preview').innerHTML = document.getElementById('id_description').value ; + document.getElementById('sol_preview').innerHTML = document.getElementById('id_solution').value ; + var question_type = document.getElementById('id_type').value if (document.getElementById('id_grade_assignment_upload').checked || question_type == 'upload'){ -- cgit