From 8795caf686549e793d0e422c328c93832077857f Mon Sep 17 00:00:00 2001 From: adityacp Date: Fri, 18 Nov 2016 09:26:57 +0530 Subject: Added Hide field in FileUpload --- yaksh/models.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/yaksh/models.py b/yaksh/models.py index 8907df0..fbc527e 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -386,6 +386,7 @@ class FileUpload(models.Model): file = models.FileField(upload_to=get_upload_dir, blank=True) question = models.ForeignKey(Question, related_name="question") extract = models.BooleanField(default=False) + hide = models.BooleanField(default=False) def remove(self): if os.path.exists(self.file.path): @@ -401,6 +402,12 @@ class FileUpload(models.Model): self.extract = True self.save() + def set_hide_status(self): + if self.hide: + self.hide = False + else: + self.hide = True + self.save() ############################################################################### class Answer(models.Model): -- cgit From d3ee68891f96642262c8ec3765f69a3a3f3f39a7 Mon Sep 17 00:00:00 2001 From: adityacp Date: Fri, 18 Nov 2016 09:29:06 +0530 Subject: changed views to get only unhided files --- yaksh/views.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/yaksh/views.py b/yaksh/views.py index c3d743b..2eeef90 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -182,6 +182,7 @@ def edit_question(request, question_id=None): form = FileForm(request.POST, request.FILES) files = request.FILES.getlist('file_field') extract_files_id = request.POST.getlist('extract') + hide_files_id = request.POST.getlist('hide') if files: for file in files: FileUpload.objects.get_or_create(question=question_instance, file=file) @@ -189,6 +190,10 @@ def edit_question(request, question_id=None): files = FileUpload.objects.filter(id__in=extract_files_id) for file in files: file.set_extract_status() + if hide_files_id: + files = FileUpload.objects.filter(id__in=hide_files_id) + for file in files: + file.set_hide_status() if question_form.is_valid(): new_question = question_form.save(commit=False) test_case_type = question_form.cleaned_data.get('test_case_type') @@ -432,7 +437,7 @@ def show_question(request, question, paper, error_message=None): reason='Your time is up!' return complete(request, reason, paper.attempt_number, paper.question_paper.id) test_cases = question.get_test_cases() - files = FileUpload.objects.filter(question_id=question.id) + files = FileUpload.objects.filter(question_id=question.id, hide=False) context = {'question': question, 'paper': paper, 'error_message': error_message, 'test_cases': test_cases, 'files': files, 'last_attempt': question.snippet.encode('unicode-escape')} -- cgit From 70c28a87d0768df6d68e7098741c49f68a11ec50 Mon Sep 17 00:00:00 2001 From: adityacp Date: Fri, 18 Nov 2016 09:32:18 +0530 Subject: fixed tooltip and Show files which are not hidden for a question --- yaksh/static/yaksh/js/course.js | 24 ++++++++++++------------ yaksh/static/yaksh/js/question_filter.js | 8 ++++---- yaksh/templates/yaksh/add_question.html | 7 +++++-- yaksh/templates/yaksh/question.html | 9 +++++---- 4 files changed, 26 insertions(+), 22 deletions(-) diff --git a/yaksh/static/yaksh/js/course.js b/yaksh/static/yaksh/js/course.js index 3a21f0d..5b79e68 100644 --- a/yaksh/static/yaksh/js/course.js +++ b/yaksh/static/yaksh/js/course.js @@ -1,37 +1,37 @@ $(document).ready(function(){ -$(".checkall").click( function(){ - if($(this).attr("checked")) { +$(".checkall").change( function(){ + if($(this).prop("checked")) { $("#enroll-all input:checkbox").each(function(index, element) { - $(this).attr('checked', true); + $(this).prop('checked', true); }); } else { $("#enroll-all input:checkbox").each(function(index, element) { - $(this).attr('checked', false); + $(this).prop('checked', false); }); } }); -$(".enroll").click( function(){ - if($(this).attr("checked")) { +$(".enroll").change( function(){ + if($(this).prop("checked")) { $("#enroll input:checkbox").each(function(index, element) { - $(this).attr('checked', true); + $(this).prop('checked', true); }); } else { $("#enroll input:checkbox").each(function(index, element) { - $(this).attr('checked', false); + $(this).prop('checked', false); }); } }); -$(".reject").click( function(){ - if($(this).attr("checked")) { +$(".reject").change( function(){ + if($(this).prop("checked")) { $("#reject input:checkbox").each(function(index, element) { - $(this).attr('checked', true); + $(this).prop('checked', true); }); } else { $("#reject input:checkbox").each(function(index, element) { - $(this).attr('checked', false); + $(this).prop('checked', false); }); } }); diff --git a/yaksh/static/yaksh/js/question_filter.js b/yaksh/static/yaksh/js/question_filter.js index 065b06b..aa3a229 100644 --- a/yaksh/static/yaksh/js/question_filter.js +++ b/yaksh/static/yaksh/js/question_filter.js @@ -32,15 +32,15 @@ $(document).ready(function(){ question_filter() }); - $("#checkall").live("click", function(){ - if($(this).attr("checked")) { + $("#checkall").change(function(){ + if($(this).prop("checked")) { $("#filtered-questions input:checkbox").each(function(index, element) { - $(this).attr('checked', true); + $(this).prop('checked', true); }); } else { $("#filtered-questions input:checkbox").each(function(index, element) { - $(this).attr('checked', false); + $(this).prop('checked', false); }); } }); diff --git a/yaksh/templates/yaksh/add_question.html b/yaksh/templates/yaksh/add_question.html index 9822333..e1b05fe 100644 --- a/yaksh/templates/yaksh/add_question.html +++ b/yaksh/templates/yaksh/add_question.html @@ -27,11 +27,14 @@ Partial Grading: {{ form.partial_grading }} Test Case Type: {{ form.test_case_type }}{{ form.test_case_type.errors }} File: {{ upload_form.file_field }}{{ upload_form.file_field.errors }} - {% if uploaded_files %}
Uploaded files:
Check the box to delete or extract files
+ {% if uploaded_files %}
Uploaded files:
Check on delete to delete files, + extract to extract files and hide to hide files from student(if required)
{% for file in uploaded_files %}  delete  {% if file.extract %} dont extract{% else %} - extract{% endif %}
+ extract{% endif %}   + {% if file.hide %} show{% else %} + hide{% endif %}
{{ file.file.name }}
{% endfor %}{% endif %} diff --git a/yaksh/templates/yaksh/question.html b/yaksh/templates/yaksh/question.html index bfb235b..74ac786 100644 --- a/yaksh/templates/yaksh/question.html +++ b/yaksh/templates/yaksh/question.html @@ -107,9 +107,12 @@ function call_skip(url) {% for qid in paper.questions.all %} {% if qid in paper.questions_unanswered.all %} {% if qid.id == question.id %} -
  • {{ forloop.counter }}
  • +
  • {{ forloop.counter }}
  • {% else %} -
  • {{ forloop.counter }}
  • +
  • {{ forloop.counter }}
  • {% endif %} {% endif %} {% if qid in paper.questions_answered.all %} @@ -152,9 +155,7 @@ function call_skip(url) {% if files %}

    Files to download for this question

    {% for f_name in files %} - {% if f_name.question_id == question.id %}
    {{f_name.file.name}}
    - {% endif %} {% endfor %} {% endif %} -- cgit From 70a96748e8ad240c0038f657d292a2e000355ace Mon Sep 17 00:00:00 2001 From: adityacp Date: Fri, 18 Nov 2016 12:45:59 +0530 Subject: changed assignment upload directory --- yaksh/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yaksh/models.py b/yaksh/models.py index fbc527e..f048126 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -65,7 +65,7 @@ test_status = ( ) def get_assignment_dir(instance, filename): - return '%s/%s' % (instance.user.roll_number, instance.assignmentQuestion.id) + return '%s/%s/%s' % (instance.user.user, instance.assignmentQuestion.id, filename) def get_model_class(model): ctype = ContentType.objects.get(app_label="yaksh", model=model) -- cgit From 95c8c368d9f34cb05c5edd90f8697ec5d00c5a92 Mon Sep 17 00:00:00 2001 From: adityacp Date: Fri, 18 Nov 2016 14:26:08 +0530 Subject: changed function name from set_hide_status to toggle_hide_status --- yaksh/models.py | 2 +- yaksh/views.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/yaksh/models.py b/yaksh/models.py index f048126..2018198 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -402,7 +402,7 @@ class FileUpload(models.Model): self.extract = True self.save() - def set_hide_status(self): + def toggle_hide_status(self): if self.hide: self.hide = False else: diff --git a/yaksh/views.py b/yaksh/views.py index 2eeef90..b6cf578 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -193,7 +193,7 @@ def edit_question(request, question_id=None): if hide_files_id: files = FileUpload.objects.filter(id__in=hide_files_id) for file in files: - file.set_hide_status() + file.toggle_hide_status() if question_form.is_valid(): new_question = question_form.save(commit=False) test_case_type = question_form.cleaned_data.get('test_case_type') -- cgit