From bfd1fbfed756343783ccedf5e33d851e18c53a5b Mon Sep 17 00:00:00 2001 From: jayashrri Date: Sat, 28 Sep 2019 21:14:08 +0530 Subject: [PATCH 1/5] Pass paper type selected from home as URL parameter --- searchapp/static/student_view.js | 4 ++++ searchapp/templates/home.html | 6 +++--- searchapp/views.py | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/searchapp/static/student_view.js b/searchapp/static/student_view.js index 5d799d4..40629f9 100644 --- a/searchapp/static/student_view.js +++ b/searchapp/static/student_view.js @@ -596,6 +596,10 @@ function populate_subjects(value,text, $selectedItem) { }); }); +function set_paper_type(type){ + window.location.href="student_view" + "?type=" + type; +} + function download_token(token) { let request = new XMLHttpRequest(); let url = BASE_DIR + '/download_test_and_generic_docx'; diff --git a/searchapp/templates/home.html b/searchapp/templates/home.html index ce661b0..b2f784b 100644 --- a/searchapp/templates/home.html +++ b/searchapp/templates/home.html @@ -21,19 +21,19 @@
-
Test Paper +
Test Paper

A Test Paper is a worksheet in the format of the board question paper.Great for pre-board preparation and to practice all the question types. The fellow needs to choose which chapters to test.
-
Generic Paper +
Generic Paper

A Generic Paper is designed as per the fellow requirements. You can choose the chapters and the number of questions of each type. Great for specific question type and differentiated practice.
-
Customized Paper +
Customized Paper

A customized paper is generated based on the performance of each student. The fellow uploads the tracker of the class, diff --git a/searchapp/views.py b/searchapp/views.py index 3409f8f..6215b5a 100644 --- a/searchapp/views.py +++ b/searchapp/views.py @@ -55,9 +55,10 @@ def contact(request): def student_view(request): + paper_type = request.GET.get('type') board_list = Board.objects.all().values_list('board', flat=True) board_list = list(board_list) - return render(request, 'student_view.html', {'data': board_list}) + return render(request, 'student_view.html', {'data': board_list, 'type': paper_type}) def login_view(request): From ae3f84b4cc7106f05ba2f5db2abd2eb399fd0ae4 Mon Sep 17 00:00:00 2001 From: jayashrri Date: Sat, 28 Sep 2019 22:42:59 +0530 Subject: [PATCH 2/5] Display selected type in student view instead of dropdown --- searchapp/static/student_view.js | 43 +++++++++++++++---------- searchapp/static/student_view_style.css | 6 ++-- searchapp/templates/student_view.html | 13 ++------ 3 files changed, 32 insertions(+), 30 deletions(-) diff --git a/searchapp/static/student_view.js b/searchapp/static/student_view.js index 40629f9..27c4881 100644 --- a/searchapp/static/student_view.js +++ b/searchapp/static/student_view.js @@ -1,23 +1,24 @@ $(document).ready(function(){ // on selecting type of worksheet - $('#worksheetType').dropdown({ - onChange: function (value, text, $selectedItem) { - if(value == 'test') { - $("#test-div").show(); - $("#generic-div").hide(); - $("#customized-div").hide(); - } else if(value == 'generic') { - $("#test-div").hide(); - $("#generic-div").show(); - $("#customized-div").hide(); - } else if(value == 'customized') { - $("#test-div").hide(); - $("#generic-div").hide(); - $("#customized-div").show(); - } - }, - }); + function display_form_sections (value) { + if(value == 'test') { + $('#worksheetType').text('Test Paper'); + $("#test-div").show(); + $("#generic-div").hide(); + $("#customized-div").hide(); + } else if(value == 'generic') { + $('#worksheetType').text('Generic Paper'); + $("#test-div").hide(); + $("#generic-div").show(); + $("#customized-div").hide(); + } else if(value == 'customized') { + $('#worksheetType').text('Customized Paper'); + $("#test-div").hide(); + $("#generic-div").hide(); + $("#customized-div").show(); + } + } // function called when submit button clicked function submit_click(e) { @@ -580,6 +581,14 @@ function populate_subjects(value,text, $selectedItem) { }, }); + if(window.location.pathname == "/student_view"){ + const urlParams = new URLSearchParams(window.location.search); + let value = urlParams.get('type'); + if(['test','generic','customized'].includes(value)) + display_form_sections(value); + else window.location.href="/"; + } + $('#upload').click(upload_click); $("#submit").click(submit_click); $("#add-chapter-button").click(add_chapter); diff --git a/searchapp/static/student_view_style.css b/searchapp/static/student_view_style.css index 93a3783..e6c8d1c 100644 --- a/searchapp/static/student_view_style.css +++ b/searchapp/static/student_view_style.css @@ -2,8 +2,10 @@ margin-top:2%; margin-left:auto; margin-right:auto; - width:50%; - display:block; + text-align:center; + font-size: 17px; + color: black; + font-weight: 800; } #subject_splits { diff --git a/searchapp/templates/student_view.html b/searchapp/templates/student_view.html index d3e68ff..d9cd7fe 100644 --- a/searchapp/templates/student_view.html +++ b/searchapp/templates/student_view.html @@ -12,19 +12,10 @@ {% endblock %} {% block student_view %} - +

-