blob: 6c1d5331c3d2926c5688ec8abd5f1461c7545239 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
{% extends "manage.html" %}
{% block subtitle %}Add Question{% endblock %}
{% block css %}
<link rel="stylesheet" href="{{ URL_ROOT }}/static/exam/css/question_quiz.css" type="text/css" />
{% endblock %}
{% block script %}
<script type="text/javascript" src="{{ URL_ROOT }}/static/exam/css/min.js"></script>
<script type="text/javascript">
function increase(frm)
{
if(frm.points.value == "")
{
frm.points.value = "0.5";
return;
}
frm.points.value = parseFloat(frm.points.value) + 0.5;
}
function decrease(frm)
{
if(frm.points.value > 0)
{
frm.points.value = parseFloat(frm.points.value) - 0.5;
}
else
{
frm.points.value=0;
}
}
function textareaformat()
{
document.getElementById('id_type').setAttribute('class','select-type');
document.getElementById('id_points').setAttribute('class','mini-text');
$('#id_description').bind('focus', function( event ){
document.getElementById("id_description").rows=5;
document.getElementById("id_description").cols=40;
});
$('#id_description').bind('blur', function( event ){
document.getElementById("id_description").rows=1;
document.getElementById("id_description").cols=40;
});
$('#id_description').bind('keypress', function (event){
document.getElementById('my').innerHTML = document.getElementById('id_description').value ;
});
$('#id_test').bind('focus', function( event ){
document.getElementById("id_test").rows=5;
document.getElementById("id_test").cols=40;
});
$('#id_test').bind('blur', function( event ){
document.getElementById("id_test").rows=1;
document.getElementById("id_test").cols=40;
});
$('#id_options').bind('focus', function( event ){
document.getElementById("id_options").rows=5;
document.getElementById("id_options").cols=40;
});
$('#id_options').bind('blur', function( event ){
document.getElementById("id_options").rows=1;
document.getElementById("id_options").cols=40;
});
$('#id_type').bind('change',function(event){
var value = document.getElementById('id_type').value;
if(value == 'mcq')
{
document.getElementById('id_options').style.visibility='visible';
document.getElementById('label_option').innerHTML="Options :"
}
else
{
document.getElementById('id_options').style.visibility='hidden';
document.getElementById('label_option').innerHTML = "";
}
});
document.getElementById('my').innerHTML = document.getElementById('id_description').value ;
var value = document.getElementById('id_type').value;
if(value == 'mcq')
{
document.getElementById('id_options').style.visibility='visible';
document.getElementById('label_option').innerHTML="Options :"
}
else
{
document.getElementById('id_options').style.visibility='hidden';
document.getElementById('label_option').innerHTML = "";
}
}
function autosubmit()
{
if (document.getElementById('id_type').value == 'mcq')
{
var value = document.getElementById('id_options').value;
if(value.split('\n').length != 4)
{
alert("Enter 4 options. One option per line.");
return false;
}
return true;
}
}
</script>
{% endblock %}
{% block onload %} onload='javascript:textareaformat();' {% endblock %}
{% block manage %}
<form action="" method="post" name=frm onSubmit="return autosubmit();">
{% csrf_token %}
<center><table class=span1>
<tr><td>Summary: <td>{{ form.summary }}{{ form.summary.errors }}
<tr><td>Points:<td><button class="btn-mini" type="button" onClick="increase(frm);">+</button>{{ form.points }}<button class="btn-mini" type="button" onClick="decrease(frm);"">-</button>{{ form.points.errors }} Active: {{ form.active }}{{form.active.errors}} Type: {{ form.type }}{{form.type.errors}}
<tr><td><strong>Rendered: </strong><td><p id='my'></p>
<tr><td>Description: <td>{{ form.description}} {{form.description.errors}}
<tr><td>Test: <td>{{ form.test }}{{form.test.errors}}
<tr><td id='label_option'>Options: <td>{{ form.options }} {{form.options.errors}}
</table></center>
<center><button class="btn" type="submit" name="savequestion">Save</button>
<button class="btn" type="button" name="button" onClick='location.replace("{{URL_ROOT}}/exam/manage/questions/");'>Cancel</button> </center>
</form>
{% endblock %}
|