summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/course_detail.html25
-rw-r--r--gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/course_details.html27
-rw-r--r--gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/course_units.html119
-rw-r--r--gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/create_course_structure.html42
-rw-r--r--gnowsys-ndf/gnowsys_ndf/ndf/urls/course.py6
-rw-r--r--gnowsys-ndf/gnowsys_ndf/ndf/views/course.py59
6 files changed, 188 insertions, 90 deletions
diff --git a/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/course_detail.html b/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/course_detail.html
index dc81f786..35890c4a 100644
--- a/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/course_detail.html
+++ b/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/course_detail.html
@@ -104,23 +104,32 @@
{% for each_cs in node.collection_set %}
{% get_node each_cs as cs_node %}
- cs_str = "<h6><b>"+{{forloop.counter}}+". {{cs_node.name}}</b></h6>"
+ cs_str = "<h6>"+{{forloop.counter}}+". {{cs_node.name}}</h6>"
$("#cs-div").append(cs_str)
{% if cs_node.collection_set %}
{% for each_css in cs_node.collection_set %}
{% get_node each_css as css_node %}
- css_str = "&nbsp;&nbsp;&nbsp;&nbsp;<h7><b>"+ {{forloop.counter}}+". {{css_node.name}}</b></h7><br>"
+ css_str = "&nbsp;&nbsp;<h7>"+ {{forloop.counter}}+". {{css_node.name}}</h7><br>"
$("#cs-div").append(css_str)
{% if css_node.collection_set %}
{% for each_unit in css_node.collection_set %}
{% get_node each_unit as unit_node %}
- {% if unit_node.member_of_names_list.0|lower == "page" or unit_node.member_of_names_list.0|lower == "quiz" %}
- k = "{% url unit_node.member_of_names_list.0|lower|concat:"_details" groupid unit_node.pk %}"
- {% else %}
- k = "{% url unit_node.member_of_names_list.0|lower|concat:"_detail" groupid unit_node.pk %}"
+ cu_str = "&nbsp;&nbsp;&nbsp;&nbsp;<h7>"+ {{forloop.counter}}+". {{unit_node.name}}</h7><br>"
+ $("#cs-div").append(cu_str)
+ {% if unit_node.collection_set %}
+ {% for each_res in unit_node.collection_set %}
+ {% get_node each_res as res_node %}
+ {% if res_node %}
+ {% if res_node.member_of_names_list.0|lower == "page" or res_node.member_of_names_list.0|lower == "quiz" %}
+ k = "{% url res_node.member_of_names_list.0|lower|concat:"_details" groupid res_node.pk %}"
+ {% else %}
+ k = "{% url res_node.member_of_names_list.0|lower|concat:"_detail" groupid res_node.pk %}"
+ {% endif %}
+ var str_unit = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+ {{forloop.counter}}+". <a href='"+k+"' target='_blank' class='unit_name'>{{res_node.name}}</a><br>"
+ $("#cs-div").append(str_unit)
+ {% endif %}
+ {% endfor %}
{% endif %}
- units_str = "&nbsp;&nbsp;&nbsp;&nbsp;-- <a href='"+k+"' target='_blank'>{{unit_node.name}}</a><br>"
- $("#cs-div").append(units_str)
{% endfor %}
{% endif %}
{% endfor %}
diff --git a/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/course_details.html b/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/course_details.html
index e9038c40..8a811d08 100644
--- a/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/course_details.html
+++ b/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/course_details.html
@@ -128,23 +128,32 @@
{% for each_cs in node.collection_set %}
{% get_node each_cs as cs_node %}
- cs_str = "<h6><b>"+{{forloop.counter}}+". {{cs_node.name}}</b></h6>"
+ cs_str = "<h6>"+{{forloop.counter}}+". {{cs_node.name}}</h6>"
$("#cs-div").append(cs_str)
{% if cs_node.collection_set %}
{% for each_css in cs_node.collection_set %}
{% get_node each_css as css_node %}
- css_str = "&nbsp;&nbsp;&nbsp;&nbsp;<h7><b>"+ {{forloop.counter}}+". {{css_node.name}}</b></h7><br>"
+ css_str = "&nbsp;&nbsp;<h7>"+ {{forloop.counter}}+". {{css_node.name}}</h7><br>"
$("#cs-div").append(css_str)
{% if css_node.collection_set %}
{% for each_unit in css_node.collection_set %}
{% get_node each_unit as unit_node %}
- {% if unit_node.member_of_names_list.0|lower == "page" or unit_node.member_of_names_list.0|lower == "quiz" %}
- k = "{% url unit_node.member_of_names_list.0|lower|concat:"_details" groupid unit_node.pk %}"
- {% else %}
- k = "{% url unit_node.member_of_names_list.0|lower|concat:"_detail" groupid unit_node.pk %}"
+ cu_str = "&nbsp;&nbsp;&nbsp;&nbsp;<h7>"+ {{forloop.counter}}+". {{unit_node.name}}</h7><br>"
+ $("#cs-div").append(cu_str)
+ {% if unit_node.collection_set %}
+ {% for each_res in unit_node.collection_set %}
+ {% get_node each_res as res_node %}
+ {% if res_node %}
+ {% if res_node.member_of_names_list.0|lower == "page" or res_node.member_of_names_list.0|lower == "quiz" %}
+ k = "{% url res_node.member_of_names_list.0|lower|concat:"_details" groupid res_node.pk %}"
+ {% else %}
+ k = "{% url res_node.member_of_names_list.0|lower|concat:"_detail" groupid res_node.pk %}"
+ {% endif %}
+ var str_unit = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+ {{forloop.counter}}+". <a href='"+k+"' target='_blank' class='unit_name'>{{res_node.name}}</a><br>"
+ $("#cs-div").append(str_unit)
+ {% endif %}
+ {% endfor %}
{% endif %}
- units_str = "&nbsp;&nbsp;&nbsp;&nbsp;-- <a href='"+k+"' target='_blank'>{{unit_node.name}}</a><br>"
- $("#cs-div").append(units_str)
{% endfor %}
{% endif %}
{% endfor %}
@@ -152,5 +161,3 @@
{% endfor %}
{% endblock %}
-
-
diff --git a/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/course_units.html b/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/course_units.html
index 1b53497a..a2ff60cd 100644
--- a/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/course_units.html
+++ b/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/course_units.html
@@ -65,6 +65,15 @@
{% endblock %}
{% block body_content %}
+
+ <div class="row">
+ <div class="small-6 columns end">
+ <label>Enter Unit Name</label>
+ </div>
+ <div class="small-6 columns">
+ <input type="text" id="unit_name" value="{% if unit_node %} {{unit_node.name}}{% endif %}">
+ </div>
+ </div>
{% block collection %}
<div class="collection_block_div">
<div class="choose">
@@ -94,10 +103,11 @@
</tr>
</table>
</div>
- <span data-tooltip title="You will be redirected to Course Authoring page" style="float:right;"><a href="{% url 'create_course_struct' group_id course_node.pk %}" class="done_units small button round" style="float:right;">Add more units later..</a></span>
+ <span data-tooltip title="You will be redirected to Course Authoring page" style="float:right;"><a href="{% url 'create_course_struct' group_id course_node.pk %}?app_id={{app_id}}&app_set_id={{app_set_id}}" class="done_units small button round" style="float:right;">Add more units later..</a></span>
<div class="resources_drawer_div row"></div>
<input type="button" value="Save Units" class="save_units small button round hide">
+ <input type="hidden" name="hidden_unit_node_id" id="hidden_unit_node_id">
</div>
{% endblock %}
@@ -110,6 +120,12 @@
$('td').click(function (event){
var resource_type_name = $(this).html()
var existing_resources;
+ if(!$("#hidden_unit_node_id").val()==""){
+ unit_node_id = $("#hidden_unit_node_id").val();
+ }
+ else{
+ unit_node_id = "{{unit_node.pk}}"
+ }
resp_dict = {}
$.ajax({
@@ -122,6 +138,7 @@
data:{
resource_type: resource_type_name,
css_node_id : "{{css_node.pk}}",
+ unit_node_id : unit_node_id,
widget_for: "create_course_structure",
csrfmiddlewaretoken: '{{ csrf_token }}'
},
@@ -140,49 +157,71 @@
// Save units
$(document).on('click','.save_units',function(){
var resources_in_RHS = []
+ unit_name_val = $("#unit_name").val()
total_resources_in_RHS = $(".resources_drawer_div").find("#create_course_structure_drawer2").children("li")
+ if(!$("#hidden_unit_node_id").val()==""){
+
+ unit_node_id = $("#hidden_unit_node_id").val();
+ }
+ else{
+ unit_node_id = "{{unit_node.pk}}"
+ }
- //check if right drawer has values
- if(total_resources_in_RHS.length > 0){
- //fetch right drawer values
- $.each(total_resources_in_RHS,function(i,v){
- resources_in_RHS.push(v.getAttribute('value'))
- });
-
- existing_list = JSON.stringify(resources_in_RHS)
- $.ajax({
-
- type: "POST",
-
- url: "{% url 'save_resources' groupid %}",
-
- datatype: "json",
-
- data:{
- list_of_res: existing_list,
- css_node: "{{css_node.pk}}",
- csrfmiddlewaretoken: '{{ csrf_token }}'
- },
-
- success: function (data) {
- resp_dict = data
- $(".resources_drawer_div").html("");
- $(".save_units").addClass("hide")
- $(".done_units").removeClass("hide")
- },
- });
-
- // $("#"+corr_resource_div).html("")
- // $("#"+corr_resource_div).next().css("display", "none");
- // $(".choose").css("display", "none");
- // $(".units-btn").removeClass("hide")
- // $(".course-sec-btn").removeAttr("disabled")
- // $(".units-btn").removeAttr("disabled")
- // $(".sub-section-btn").removeAttr("disabled")
- // $(".close-units-btn").addClass("hide")
+ if(unit_name_val){
+ //check if right drawer has values
+ if(total_resources_in_RHS.length > 0){
+ //fetch right drawer values
+ $.each(total_resources_in_RHS,function(i,v){
+ resources_in_RHS.push(v.getAttribute('value'))
+ });
+
+ existing_list = JSON.stringify(resources_in_RHS)
+ $.ajax({
+
+ type: "POST",
+
+ url: "{% url 'save_resources' groupid %}",
+
+ datatype: "json",
+
+ data:{
+ list_of_res: existing_list,
+ css_node: "{{css_node.pk}}",
+ unit_name: unit_name_val,
+ unit_node_id: unit_node_id,
+ csrfmiddlewaretoken: '{{ csrf_token }}'
+ },
+
+ success: function (data) {
+ resp_dict = JSON.parse(data)
+ console.log(data)
+ $(".resources_drawer_div").html("");
+ $(".save_units").addClass("hide")
+ $(".done_units").removeClass("hide")
+ if($("#hidden_unit_node_id").val()==""){
+ console.log("com"+resp_dict['cu_new_id'])
+ // $("#hidden_unit_node_id").attr('value',resp_dict['cu_new_id'])
+ $("#hidden_unit_node_id").val(resp_dict['cu_new_id'])
+ }
+ },
+ });
+
+ // $("#"+corr_resource_div).html("")
+ // $("#"+corr_resource_div).next().css("display", "none");
+ // $(".choose").css("display", "none");
+ // $(".units-btn").removeClass("hide")
+ // $(".course-sec-btn").removeAttr("disabled")
+ // $(".units-btn").removeAttr("disabled")
+ // $(".sub-section-btn").removeAttr("disabled")
+ // $(".close-units-btn").addClass("hide")
+ }
+ else{
+ alert("Please select any resource");
+ event.preventDefault();
+ }
}
else{
- alert("Please select any resource")
+ alert("Please enter name for unit");
event.preventDefault();
}
});
diff --git a/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/create_course_structure.html b/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/create_course_structure.html
index 30cf99ef..107120b9 100644
--- a/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/create_course_structure.html
+++ b/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/create_course_structure.html
@@ -4,6 +4,9 @@
{% load ndf_tags %}
{% block title %} {{title}} {% endblock %}
{% load pagination_tags %}
+{% block meta_content %}
+ <h3>{{cnode.name}}</h3>
+{% endblock %}
{% block style %}
@@ -27,7 +30,6 @@
.edit_course_structure_name{
width: 30%;
}
-
/* Setting css-properties for reveal-modal's label */
div.reveal-modal > label {
color: white;
@@ -66,7 +68,9 @@
border: 1px solid;
display:block;
}
-
+ .div_lbl{
+ margin-top: -5px;
+ }
#name{
margin: 5px !important;
@@ -100,11 +104,10 @@
.lbl_of_cs, .lbl_of_css{
white-space: nowrap;
- width: 100px;
overflow: hidden;
+ color:#0b8a91 !important;
text-overflow: ellipsis;
- font-weight: bold;
- font-size: 100%;
+ font-size: 150%;
}
.unit_name{
@@ -116,7 +119,6 @@
}
.div_lbl > label {
- min-width: 350px;
display: inline-block;
}
@@ -153,7 +155,7 @@
}
{% endblock %}
{% block body_content %}
- <h3>{{cnode.name}}</h3>
+
<div id="alertModal" class="reveal-modal medium alert-box radius" data-reveal data-alert action=>
<label id="alertModalLabel"></label>
@@ -201,11 +203,12 @@
<div class="row">
<div class="small-10 small-centered columns units-btn-div">
<div class="units-list"></div>
- <a class="button round expand hoverstyle units-btn"> + New Units</a>
+ <a class="button round expand hoverstyle units-btn new-units-btn"> + New Units</a>
</div>
</div>
</li>
+
<ul class="ul-course-section no-bullet">
<input type="button" class="button expand round hoverstyle course-sec-btn" value="+ New Section">
</ul>
@@ -287,6 +290,8 @@
//Global var declarations------------------------------------------------------------------------------
var cs_cloned_id = 1;
var css_cloned_id = 1;
+ var cu_cloned_id = 1;
+
var lbl_text;
$("#course_structure_minutes").addClass("css_mins_class")
$("#min_marks").addClass("min_marks_class")
@@ -713,7 +718,11 @@ var var_this;
//On click of 'Add Units' button-----------------------------------------------------------------------
$(document).on('click','.units-btn',function(){
css_node = $(this).data("cssId");
- turl = "{% url 'add_units' groupid %}?node_id="+ css_node+"&app_id={{app_id}}&app_set_id={{app_set_id}}&course_node={{cnode.pk}}"
+ var unit_node;
+ if($(this).data("unitId")){
+ unit_node = $(this).data("unitId");
+ }
+ turl = "{% url 'add_units' groupid %}?css_node_id="+ css_node+"&unit_node_id="+ unit_node+"&app_id={{app_id}}&app_set_id={{app_set_id}}&course_node={{cnode.pk}}"
$(this).attr("href",turl)
});
@@ -756,19 +765,12 @@ var var_this;
{% if css_node.collection_set %}
{% for each_unit in css_node.collection_set %}
{% get_node each_unit as unit_node %}
- {% if unit_node.member_of_names_list.0|lower == "page" or unit_node.member_of_names_list.0|lower == "quiz" %}
- k = "{% url unit_node.member_of_names_list.0|lower|concat:"_details" groupid unit_node.pk %}"
- {% else %}
- k = "{% url unit_node.member_of_names_list.0|lower|concat:"_detail" groupid unit_node.pk %}"
- {% endif %}
- var str_unit = "<a href='"+k+"' target='_blank' class='unit_name'>{{unit_node.name}}</a><br>"
- $("#"+cloned_ss_ele_id).find("div.units-list").append(str_unit)
+ str_unit = "<div class='row'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class='button expnad hoverstyle units-btn' data-unit-id='{{unit_node.pk}}' style='width:90%;' data-css-id='{{css_node.pk}}'>{{unit_node.name}}</a></div>"
+ $(".units-btn").before($("#course-unit-li-id").clone().attr('id',"{{unit_node.pk}}").removeClass("hide"))
+ $("#"+cloned_ss_ele_id).find(".new-units-btn").before(str_unit)
{% endfor %}
{% endif %}
-
-
-
{% endfor %}
{% endif %}
{% endfor %}
-{% endblock %} \ No newline at end of file
+{% endblock %}
diff --git a/gnowsys-ndf/gnowsys_ndf/ndf/urls/course.py b/gnowsys-ndf/gnowsys_ndf/ndf/urls/course.py
index 7b6fdab3..e8da8715 100644
--- a/gnowsys-ndf/gnowsys_ndf/ndf/urls/course.py
+++ b/gnowsys-ndf/gnowsys_ndf/ndf/urls/course.py
@@ -16,9 +16,9 @@ urlpatterns = patterns('gnowsys_ndf.ndf.views.course',
url(r'^/create_cs/$', 'save_course_section', name='save_course_section'),
url(r'^/create_css/$', 'save_course_sub_section', name='save_course_sub_section'),
url(r'^/course_sub_section_prop/$', 'course_sub_section_prop', name='course_sub_section_prop'),
- url(r'^resources/', 'get_resources', name='get_resources'),
- url(r'^add_units/', 'add_units', name='add_units'),
- url(r'^save_units/', 'save_resources', name='save_resources'),
+ url(r'^/resources/', 'get_resources', name='get_resources'),
+ url(r'^/add_units/', 'add_units', name='add_units'),
+ url(r'^/save_units/', 'save_resources', name='save_resources'),
url(r'^/change_node_name/$', 'change_node_name', name='change_node_name'),
url(r'^/change_order/$', 'change_order', name='change_order'),
)
diff --git a/gnowsys-ndf/gnowsys_ndf/ndf/views/course.py b/gnowsys-ndf/gnowsys_ndf/ndf/views/course.py
index 42baaea2..21657530 100644
--- a/gnowsys-ndf/gnowsys_ndf/ndf/views/course.py
+++ b/gnowsys-ndf/gnowsys_ndf/ndf/views/course.py
@@ -1063,17 +1063,27 @@ def add_units(request,group_id):
Actions:
* Redirects to course_units.html
'''
-
variable = None
- css_node_id = request.GET.get('node_id', '')
+ unit_node = None
+ css_node_id = request.GET.get('css_node_id', '')
+ unit_node_id = request.GET.get('unit_node_id', '')
course_node_id = request.GET.get('course_node', '')
-
+ app_id = request.GET.get('app_id', '')
+ app_set_id = request.GET.get('app_set_id', '')
css_node = node_collection.one({"_id": ObjectId(css_node_id)})
course_node = node_collection.one({"_id": ObjectId(course_node_id)})
-
+ title = "Course Units"
+ try:
+ unit_node = node_collection.one({"_id": ObjectId(unit_node_id)})
+ except:
+ unit_node = None
variable = RequestContext(request, {
'group_id': group_id, 'groupid': group_id,
'css_node': css_node,
+ 'title': title,
+ 'app_set_id':app_set_id,
+ 'app_id':app_id,
+ 'unit_node': unit_node,
'course_node': course_node
})
@@ -1099,13 +1109,17 @@ def get_resources(request, group_id):
try:
if request.is_ajax() and request.method == "POST":
css_node_id = request.POST.get('css_node_id', "")
+ unit_node_id = request.POST.get('unit_node_id', "")
widget_for = request.POST.get('widget_for', "")
resource_type = request.POST.get('resource_type', "")
resource_type = resource_type.strip()
list_resources = []
css_node = node_collection.one({"_id": ObjectId(css_node_id)})
-
+ try:
+ unit_node = node_collection.one({"_id": ObjectId(unit_node_id)})
+ except:
+ unit_node = None
if resource_type:
if resource_type == "Pandora":
resource_type = "Pandora_video"
@@ -1122,7 +1136,7 @@ def get_resources(request, group_id):
for each in res:
list_resources.append(each)
- drawer_template_context = edit_drawer_widget("CourseUnits", group_id, css_node, None, checked="collection_set", left_drawer_content=list_resources)
+ drawer_template_context = edit_drawer_widget("CourseUnits", group_id, unit_node, None, checked="collection_set", left_drawer_content=list_resources)
drawer_template_context["widget_for"] = widget_for
drawer_widget = render_to_string(
'ndf/drawer_widget.html',
@@ -1156,10 +1170,37 @@ def save_resources(request, group_id):
if request.is_ajax() and request.method == "POST":
list_of_res = json.loads(request.POST.get('list_of_res', ""))
css_node_id = request.POST.get('css_node', "")
- css_node = node_collection.one({"_id": ObjectId(css_node_id)})
+ unit_name = request.POST.get('unit_name', "")
+ unit_name = unit_name.strip()
+ unit_node_id = request.POST.get('unit_node_id', "")
+ css_node = node_collection.one({"_id": ObjectId(css_node_id)})
list_of_res_ids = [ObjectId(each_res) for each_res in list_of_res]
- node_collection.collection.update({'_id': css_node._id}, {'$set': {'collection_set':list_of_res_ids}},upsert=False,multi=False)
- css_node.reload()
+
+ try:
+ cu_new = node_collection.one({'_id': ObjectId(unit_node_id)})
+ except:
+ cu_new = None
+ if not cu_new:
+ cu_gst = node_collection.one({'_type': "GSystemType", 'name': "CourseUnit"})
+ cu_new = node_collection.collection.GSystem()
+ cu_new.member_of.append(cu_gst._id)
+ # set name
+ cu_new.name = unit_name.strip()
+ cu_new.modified_by = int(request.user.id)
+ cu_new.created_by = int(request.user.id)
+ cu_new.contributors.append(int(request.user.id))
+
+ cu_new.prior_node.append(css_node._id)
+ cu_new.save()
+ node_collection.collection.update({'_id': cu_new._id}, {'$set': {'name': unit_name }}, upsert=False, multi=False)
+
+ if cu_new._id not in css_node.collection_set:
+ node_collection.collection.update({'_id': css_node._id}, {'$push': {'collection_set': cu_new._id }}, upsert=False, multi=False)
+
+
+ node_collection.collection.update({'_id': cu_new._id}, {'$set': {'collection_set':list_of_res_ids}},upsert=False,multi=False)
+ cu_new.reload()
response_dict["success"] = True
+ response_dict["cu_new_id"] = str(cu_new._id)
return HttpResponse(json.dumps(response_dict))