summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
authoradityacp2017-03-15 17:55:34 +0530
committeradityacp2017-03-15 17:55:34 +0530
commit5e500f3344a13d375d018312936280d88d47c93c (patch)
tree3a0375d11eafdd25e70e96914c518bd54e532b4e /yaksh
parentf1eb06d3740eb21558576e5f5489972e45cab038 (diff)
downloadonline_test-5e500f3344a13d375d018312936280d88d47c93c.tar.gz
online_test-5e500f3344a13d375d018312936280d88d47c93c.tar.bz2
online_test-5e500f3344a13d375d018312936280d88d47c93c.zip
Change templates and js
- Support multiple files uploading in assignment - Create new check field to grade assignement based question - Add js changes
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/hook_evaluator.py7
-rw-r--r--yaksh/static/yaksh/js/add_question.js36
-rw-r--r--yaksh/templates/exam.html2
-rw-r--r--yaksh/templates/yaksh/add_question.html1
-rw-r--r--yaksh/templates/yaksh/question.html2
5 files changed, 37 insertions, 11 deletions
diff --git a/yaksh/hook_evaluator.py b/yaksh/hook_evaluator.py
index 2cc4578..052d220 100644
--- a/yaksh/hook_evaluator.py
+++ b/yaksh/hook_evaluator.py
@@ -17,6 +17,7 @@ class HookEvaluator(BaseEvaluator):
self.user_answer = metadata.get('user_answer')
self.file_paths = metadata.get('file_paths')
self.partial_grading = metadata.get('partial_grading')
+ self.assignment_files = metadata.get('assign_files')
# Set test case data values
self.hook_code = test_case_data.get('hook_code')
@@ -26,6 +27,8 @@ class HookEvaluator(BaseEvaluator):
# Delete the created file.
if self.files:
delete_files(self.files)
+ if self.assign_files:
+ delete_files(self.assign_files)
def check_code(self):
""" Function evaluates user answer by running a python based hook code
@@ -47,6 +50,10 @@ class HookEvaluator(BaseEvaluator):
Returns (False, error_msg, 0.0): If mandatory arguments are not files or if
the required permissions are not given to the file(s).
"""
+ if self.file_paths:
+ self.files = copy_files(self.file_paths)
+ if self.assignment_files:
+ self.assign_files = copy_files(self.assignment_files)
success = False
mark_fraction = 0.0
try:
diff --git a/yaksh/static/yaksh/js/add_question.js b/yaksh/static/yaksh/js/add_question.js
index 8ca22eb..05752b4 100644
--- a/yaksh/static/yaksh/js/add_question.js
+++ b/yaksh/static/yaksh/js/add_question.js
@@ -111,16 +111,34 @@ function textareaformat()
});
- $('#id_type').bind('focus', function(event){
- var type = document.getElementById('id_type');
- type.style.border = '1px solid #ccc';
- });
+ $('#id_type').bind('focus', function(event){
+ var type = document.getElementById('id_type');
+ type.style.border = '1px solid #ccc';
+ });
+
+ $('#id_language').bind('focus', function(event){
+ var language = document.getElementById('id_language');
+ language.style.border = '1px solid #ccc';
+ });
+ document.getElementById('my').innerHTML = document.getElementById('id_description').value ;
- $('#id_language').bind('focus', function(event){
- var language = document.getElementById('id_language');
- language.style.border = '1px solid #ccc';
- });
- document.getElementById('my').innerHTML = document.getElementById('id_description').value ;
+
+ if (document.getElementById('id_grade_assignment_upload').checked ||
+ document.getElementById('id_type').val() == 'upload'){
+ $("#id_grade_assignment_upload").prop("disabled", false);
+ }
+ else{
+ $("#id_grade_assignment_upload").prop("disabled", true);
+ }
+
+ $('#id_type').change(function() {
+ if ($(this).val() == "upload"){
+ $("#id_grade_assignment_upload").prop("disabled", false);
+ }
+ else{
+ $("#id_grade_assignment_upload").prop("disabled", true);
+ }
+ });
}
function autosubmit()
diff --git a/yaksh/templates/exam.html b/yaksh/templates/exam.html
index 02ff70a..a18a962 100644
--- a/yaksh/templates/exam.html
+++ b/yaksh/templates/exam.html
@@ -73,7 +73,7 @@
{% block main %}
{% endblock %}
</div>
- {% if question.type == 'code' %}
+ {% if question.type == 'code' or question.type == 'upload' %}
{% if error_message %}
<div class="row" id="error_panel">
{% for error in error_message %}
diff --git a/yaksh/templates/yaksh/add_question.html b/yaksh/templates/yaksh/add_question.html
index 75802b4..ae70774 100644
--- a/yaksh/templates/yaksh/add_question.html
+++ b/yaksh/templates/yaksh/add_question.html
@@ -25,6 +25,7 @@
<tr><td>Tags: <td>{{ qform.tags }}
<tr><td>Snippet: <td>{{ qform.snippet }}
<tr><td>Partial Grading: <td>{{ qform.partial_grading }}
+ <tr><td>Grade Assignment Upload:<td> {{ qform.grade_assignment_upload }}
<tr><td> File: <td> {{ fileform.file_field }}{{ fileform.file_field.errors }}
{% if uploaded_files %}<br><b>Uploaded files:</b><br>Check on delete to delete files,
extract to extract files and hide to hide files from student(if required)<br>
diff --git a/yaksh/templates/yaksh/question.html b/yaksh/templates/yaksh/question.html
index 9dd0de5..2a93cfb 100644
--- a/yaksh/templates/yaksh/question.html
+++ b/yaksh/templates/yaksh/question.html
@@ -188,7 +188,7 @@ function call_skip(url)
{% endif %}
{% if question.type == "upload" %}
<p>Upload assignment file for the said question<p>
- <input type=file id="assignment" name="assignment">
+ <input type=file id="assignment" name="assignment" multiple="">
<hr>
{% endif %}
{% if question.type == "code" %}