summaryrefslogtreecommitdiff
path: root/yaksh/static/yaksh/js
diff options
context:
space:
mode:
Diffstat (limited to 'yaksh/static/yaksh/js')
-rw-r--r--yaksh/static/yaksh/js/add_quiz.js14
-rw-r--r--yaksh/static/yaksh/js/course.js3
-rw-r--r--yaksh/static/yaksh/js/design_course.js26
-rw-r--r--yaksh/static/yaksh/js/edit_question.js10
-rw-r--r--yaksh/static/yaksh/js/lesson.js78
-rw-r--r--yaksh/static/yaksh/js/requesthandler.js2
6 files changed, 109 insertions, 24 deletions
diff --git a/yaksh/static/yaksh/js/add_quiz.js b/yaksh/static/yaksh/js/add_quiz.js
index f4067ed..57993ef 100644
--- a/yaksh/static/yaksh/js/add_quiz.js
+++ b/yaksh/static/yaksh/js/add_quiz.js
@@ -21,15 +21,5 @@ String.prototype.beginsWith = function (string) {
function usermode(location)
{
- var select = document.getElementById("id_prerequisite");
- var select_text = select.options[select.selectedIndex].text;
- if (select_text.beginsWith("----")){
- window.alert("No prerequisite for this course.\n \
- You can attempt the quiz.");
- window.location.replace(location);
- } else {
- window.alert(select_text + " is a prerequisite for this course.\n \
- You are still allowed to attempt this quiz.")
- window.location.replace(location);
- }
- }
+ window.location.replace(location);
+}
diff --git a/yaksh/static/yaksh/js/course.js b/yaksh/static/yaksh/js/course.js
index 6807cf4..f0d03e2 100644
--- a/yaksh/static/yaksh/js/course.js
+++ b/yaksh/static/yaksh/js/course.js
@@ -46,13 +46,12 @@ $(function() {
$("#send_mail").click(function(){
var subject = $("#subject").val();
- var body = $('#email_body').val();
+ var body = tinymce.get("email_body").getContent();
var status = false;
var selected = [];
$('#reject input:checked').each(function() {
selected.push($(this).attr('value'));
});
-
if (subject == '' || body == ''){
$("#error_msg").html("Please enter mail details");
$("#dialog").dialog();
diff --git a/yaksh/static/yaksh/js/design_course.js b/yaksh/static/yaksh/js/design_course.js
new file mode 100644
index 0000000..7b01491
--- /dev/null
+++ b/yaksh/static/yaksh/js/design_course.js
@@ -0,0 +1,26 @@
+$(document).ready(function(){
+ var checked_vals = [];
+ $('input:checkbox[name="quiz_lesson"]').click(function() {
+ if($(this).prop("checked") == true){
+ checked_vals.push($(this).val());
+ }
+ else{
+ checked_vals.pop($(this).val());
+ }
+ });
+ $('#design_course_form').submit(function(eventObj) {
+ var input_order = $("input[name*='order']");
+ var order_list = []
+ if (input_order){
+ $(input_order).each(function(index) {
+ order_list.push($(this).data('item-id')+":"+$(this).val());
+ });
+ }
+ $(this).append('<input type="hidden" name="choosen_list" value='+checked_vals+'>');
+ $(this).append('<input type="hidden" name="ordered_list" value='+order_list+'>');
+ return true;
+ });
+ var msg = "Check Prerequisite is set to Yes by default \n" +
+ "To change, select the Change checkbox and Click Change Prerequisite button \n";
+ $("#prereq_msg").attr("title", msg);
+}); \ No newline at end of file
diff --git a/yaksh/static/yaksh/js/edit_question.js b/yaksh/static/yaksh/js/edit_question.js
index 7a0f56d..4eb25d0 100644
--- a/yaksh/static/yaksh/js/edit_question.js
+++ b/yaksh/static/yaksh/js/edit_question.js
@@ -35,15 +35,7 @@ function decrease(frm,n)
function grade_data(showHideDiv)
{
- var ele=document.getElementById(showHideDiv);
- if (ele.style.display=="block")
- {
- ele.style.display = "none";
- }
- else
- {
- ele.style.display = "block";
- }
+ $("#"+showHideDiv).toggle();
}
function setSelectionRange(input, selectionStart, selectionEnd)
diff --git a/yaksh/static/yaksh/js/lesson.js b/yaksh/static/yaksh/js/lesson.js
new file mode 100644
index 0000000..6f873b9
--- /dev/null
+++ b/yaksh/static/yaksh/js/lesson.js
@@ -0,0 +1,78 @@
+$(document).ready(function(){
+ var csrftoken = jQuery("[name=csrfmiddlewaretoken]").val();
+
+ function csrfSafeMethod(method) {
+ // These HTTP methods do not require CSRF protection
+ return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
+ }
+ $.ajaxSetup({
+ beforeSend: function(xhr, settings) {
+ if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
+ xhr.setRequestHeader("X-CSRFToken", csrftoken);
+ }
+ }
+ });
+ $("#preview").click(function(){
+ var description = $("#id_description").val();
+ var preview_url = window.location.protocol + "//" +
+ window.location.host + "/exam/manage/courses/lesson/preview/";
+ $.ajax({
+ url: preview_url,
+ timeout: 15000,
+ type: 'POST',
+ data: JSON.stringify({'description': description}),
+ dataType: 'json',
+ contentType: 'application/json; charset=utf-8',
+ success: function(msg) {
+ preview_text(msg['data']);
+ },
+ error: function(jqXHR, textStatus) {
+
+ }
+ });
+ });
+
+ function preview_text(data){
+ var preview_div = $("#preview_text_div");
+ if (!preview_div.is(":visible")){
+ $("#preview_text_div").toggle();
+ }
+ $("#description_body").empty();
+ $("#description_body").append(data);
+ }
+
+ $("#embed").click(function() {
+ $("#dialog_iframe").toggle();
+ $("#dialog_iframe").dialog({
+ resizable: false,
+ height: '300',
+ width: '450'
+ });
+ });
+
+ $("#submit_info").click(function(){
+ var url = $("#url").val();
+ if (url == "") {
+ if (!$("#error_div").is(":visible")){
+ $("#error_div").toggle();
+ }
+ }
+ else{
+ if ($("#error_div").is(":visible")){
+ $("#error_div").toggle();
+ }
+ $("#video_frame").attr("src", url);
+ $("#html_text").text($("#iframe_div").html().trim());
+ }
+ });
+
+ $("#copy").click(function(){
+ try{
+ var text = $("#html_text");
+ text.select();
+ document.execCommand("Copy");
+ } catch (err) {
+ alert("Unable to copy. Press Ctrl+C or Cmd+C to copy")
+ }
+ });
+});
diff --git a/yaksh/static/yaksh/js/requesthandler.js b/yaksh/static/yaksh/js/requesthandler.js
index 3a7cdba..639dc81 100644
--- a/yaksh/static/yaksh/js/requesthandler.js
+++ b/yaksh/static/yaksh/js/requesthandler.js
@@ -37,7 +37,7 @@ function unlock_screen() {
}
function get_result(uid){
- var url = "/exam/get_result/" + uid + "/";
+ var url = "/exam/get_result/" + uid + "/" + course_id + "/" + module_id + "/";
ajax_check_code(url, "GET", "html", null, uid)
}