0xV3NOMx
Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64



Your IP : 18.227.72.27


Current Path : /proc/thread-self/root/var/www/oasis/js/
Upload File :
Current File : //proc/thread-self/root/var/www/oasis/js/qnwisemarksentrynew.js

function callMarksEntryQnWiseNew() {
  $("#page_main_div").load(
    "../html_modules/qnwisemarksentrynew.html?v=1122",
    function () {
      document.getElementById("display_module_name").innerHTML =
        "Marks Entry Question Wise New";
      document.getElementById("module_name_for_save").value =
        "Marks Entry Question Wise New";
      getDefaultHeadFooterLinks("Marks Entry Question Wise New");
      loadMarksEntryTeacher();
    }
  );
}

function loadMarksEntryTeacher() {
  $.blockUI({
    message:
      "<h1 class='h1' style='font-size:12px'><img src='img/ajax-loader.gif' border='0'></h1>",
  });
  $.ajax({
    type: "POST",
    url: $host_url + "loadIAteachcodenew",
    success: function (response) {
      var res = JSON.parse(response);
      var teachnameoptions = "";
      teachnameoptions = "<option value=''>---Select Teacher---</option>";
      for (var i = 0; i < res.data.length; i++) {
        teachnameoptions += `<option value='${res.data[i].fteachcode}'>${res.data[i].fteachcode} - ${res.data[i].fteachname}</option>`;
      }
      $("#meTeachName").html(teachnameoptions);
      $.unblockUI();
    },
  });
}

function meGetClassName() {
  var techcode = document.getElementById("meTeachName").value;
  if (techcode == "") {
    return;
  }
  $.blockUI({
    message:
      "<h1 class='h1' style='font-size:12px'><img src='img/ajax-loader.gif' border='0'></h1>",
  });
  $.ajax({
    type: "POST",
    data: "&techcode=" + techcode,
    url: $host_url + "getIAclassnamesnew",
    success: function (response) {
      var res = JSON.parse(response);
      var classnameoption = "<option value=''>---Select Class Name---</option>";
      for (var i = 0; i < res.data.length; i++) {
        classnameoption += `<option value='${res.data[i].fclassid}'>${res.data[i].fclassname} - ${res.data[i].fclassid}</option>`;
      }
      $("#meClassName").html(classnameoption);
      $.unblockUI();
    },
  });
}

function meGetSubject() {
  var teachcode = document.getElementById("meTeachName").value;
  var classid = document.getElementById("meClassName").value;
  let parameter = "&techcode=" + teachcode + "&classid=" + classid;
  if (teachcode == "") {
    return;
  }
  $.blockUI({
    message:
      "<h1 class='h1' style='font-size:12px'><img src='img/ajax-loader.gif' border='0'></h1>",
  });
  $.ajax({
    method: "GET",
    url: $host_url + "getDegSemSubDetnew",
    data: parameter,
    success: function (res) {
      var response = JSON.parse(res);
      var sub_options = "";
      if (response.error_code == 0) {
        sub_options += `<option>---Select---</option>`;
        for (var i = 0; i < response.data.subelement.length; i++) {
          let subname_opt = response.data.subelement[i].subname;
          let subname = subname_opt.split(" ").join("_");
          sub_options += `<option value=${
            response.data.subelement[i].fsubcode + "*" + subname
          }>${response.data.subelement[i].fsubshort} - ${
            response.data.subelement[i].subname
          }</option>`;
        }
        $("#meSubElement").html(sub_options);
        $.unblockUI();
      } else {
        alert(response.data.msg);
        $.unblockUI();
        return;
      }
    },
  });
}

function meGetTestMaxQn() {
  var teachcode = document.getElementById("meTeachName").value;
  var classid = document.getElementById("meClassName").value;
  var subelement = document.getElementById("meSubElement").value;
  let splitSub = subelement.split("*");

  let parameter =
    "&teachname=" +
    teachcode +
    "&classid=" +
    classid +
    "&subelemnt=" +
    splitSub[0];

  if (teachcode == "") {
    return;
  }
  $.blockUI({
    message:
      "<h1 class='h1' style='font-size:12px'><img src='img/ajax-loader.gif' border='0'></h1>",
  });
  $.ajax({
    method: "GET",
    url: $host_url + "getTestMaxQnnew",
    data: parameter,
    success: function (res) {
      var response = JSON.parse(res);
      console.log(response);

      var test_options = "";
      if (response.error_code == 0) {
        for (let i = 1; i <= response.data.sub.ftest; i++) {
          test_options += `<option value='Test ${i}'>Test ${i}</option>`;
        }
      }
      if (splitSub[1].toLowerCase() !== "cie") {
        $("#meRowRemarks").show();
      } else {
        $("#meRowRemarks").hide();
      }
      $("#meTestName").html(test_options);
      $("#meRemarks").val(response.data.remarks.fremarks);
      $("#meTextMarks").val(response.data.sub.fvalmax);
      $("#meTextMarks").attr("disabled", true);
      $.unblockUI();
    },
  });
}

function meViewIaStudDet() {
  var teachcode = document.getElementById("meTeachName").value;
  var classid = document.getElementById("meClassName").value;
  var subelement = document.getElementById("meSubElement").value;
  var txtmarks = document.getElementById("meTextMarks").value;
  var testName = document.getElementById("meTestName").value;
  var fsort = document.getElementById("meSort").value;

  if (teachcode == "") {
    alert("Please select teacher");
    return;
  }

  if (classid == "") {
    alert("Please select class");
    return;
  }

  if (subelement == "") {
    alert("Please select Subject");
    return;
  }

  if (testName == "" || testName == null) {
    alert("Test can be Empty");
    return;
  }

  $.blockUI({
    message:
      "<h1 class='h1' style='font-size:12px'><img src='img/ajax-loader.gif' border='0'></h1>",
  });

  let parameter =
    "teachcode=" +
    teachcode +
    "&classid=" +
    classid +
    "&subelement=" +
    subelement +
    "&txtmarks=" +
    txtmarks +
    "&testName=" +
    testName +
    "&fsort=" +
    fsort;

  $.ajax({
    method: "GET",
    url: $host_url + "meViewIaStudDet",
    data: parameter,
    success: function (res) {
      var response = JSON.parse(res);
      if (response.error_code === 0) {
        // $("#meMarksTable").hide();
        $("#meStudDet").html(response.data.html);
        // $("#meStudDet").show();
        console.log(response);
        $.unblockUI();
      } else {
        alert(response.data.msg);
        $("#meStudDet").html("");
        $.unblockUI();
        return;
      }
    },
  });
}

function getStudentMarks(regno, ...rest) {
  // var win_width = window.screen.width;
  // $("#batch_dialog").dialog("open");
  // $("#batch_dialog").data("width.dialog", 500);
  // $("#batch_dialog").data("position.dialog", [(win_width - 500) / 2, 90]);
  // $("#ui-dialog-title-batch_dialog").html(regno + " Marks Entry");
  // var path = "../html_modules/qnmarksentrypopup.html";
  // $("#batch_dialog").load(path, function () {
  //   meGetStudentMarksData(regno, rest);
  // });
  console.log(regno, ...rest);
  meGetStudentMarksData(regno, rest);
}

let marksArr = [];
function meGetStudentMarksData(regno, rest) {
  marksArr = [];
  let fregno = regno;
  let [testname, subcode, collcode, classid, degree, sem, name] = rest;

  document.getElementById("medegree").value = degree;
  document.getElementById("mesem").value = sem;
  document.getElementById("meregno").value = fregno;

  let parameters =
    "&testname=" +
    testname +
    "&subcode=" +
    subcode +
    "&classid=" +
    classid +
    "&degree=" +
    degree +
    "&sem=" +
    sem +
    "&regno=" +
    fregno +
    "&name=" +
    name;

  $.blockUI({
    message:
      "<h1 class='h1' style='font-size:12px'><img src='img/ajax-loader.gif' border='0'></h1>",
  });

  $.ajax({
    type: "GET",
    url: $host_url + "meGetStudentMarksData",
    data: parameters,
    success: function (response) {
      let res = JSON.parse(response);
      marksArr = res.data.marksArr;
      console.log(res);
      if (res.error_code === 0) {
        // $("#meStudDet").hide();
        $("#meMarksTable").html(res.data.html);
        // $("#meMarksTable").show();
        $.unblockUI();
      } else {
        alert(res.data.msg);
        $("#meMarksTable").html("");
        $.unblockUI();
        return;
      }
    },
  });
}

let total = 0;
function addStMarks(qn, qnno, maxmarks, index, testname, subcode) {
  let marks = document.getElementById("marks_" + qnno).value;
  if (parseFloat(marks) > parseFloat(maxmarks)) {
    alert("Enter Valid Marks");
    document.getElementById("marks_" + qnno).value = "";
    document.getElementById("marks_" + qnno).focus();
    return;
  }
  marksArr[index]["marks"] = marks;
  marksArr[index]["test"] = testname;
  marksArr[index]["subcode"] = subcode;

  total = 0;
  for (let i = 0; i < marksArr.length; i++) {
    console.log(marksArr[i]["marks"], "marks");
    if (marksArr[i]["fqn"] == qn) {
      total +=
        marksArr[i]["marks"] == "" ||
        marksArr[i]["marks"] == undefined ||
        marksArr[i]["marks"] == "-1" ||
        marksArr[i]["marks"].toLowerCase() == "ab" ||
        marksArr[i]["marks"].toLowerCase() == "-2"
          ? 0
          : parseFloat(marksArr[i]["marks"]);

      document.getElementById("total_" + qn).value = total;
    } else {
      total = 0;
    }
  }
}

function saveMarksEntryQnWiseNew() {
  let degree = document.getElementById("medegree").value;
  let sem = document.getElementById("mesem").value;
  let regno = document.getElementById("meregno").value;

  let arr = [];
  marksArr.map((el, i) => {
    let obj = {};
    obj.fclassid = el.fclassid;
    obj.fco = el.fco;
    obj.fmaxmarks = el.fmarks;
    obj.fqn = el.fqn;
    obj.fqnno = el.fqnno;
    obj.fsubcode = el.subcode;
    obj.ftest = el.test;
    obj.fmarks =
      el.marks == null || el.marks == ""
        ? "0"
        : el.marks == "-2"
        ? "ab"
        : el.marks;
    arr.push(obj);
  });

  $.blockUI({
    message:
      "<h1 class='h1' style='font-size:12px'><img src='img/ajax-loader.gif' border='0'></h1>",
  });

  $.ajax({
    type: "POST",
    url: $host_url + "saveMeStudenMarks",
    data:
      "degree=" +
      degree +
      "&sem=" +
      sem +
      "&regno=" +
      regno +
      "&data=" +
      JSON.stringify(arr),
    success: function (res) {
      let response = JSON.parse(res);
      console.log(response);
      if (response.error_code === 0) {
        alert(response.data.msg);
        $.unblockUI();
        meViewIaStudDet();
      } else {
        alert(response.data.msg);
        $.unblockUI();
        return;
      }
    },
  });
}

function searchRegCode() {
  var input, filter, table, tr, td, i, txtValue;
  input = document.getElementById("myInput");
  filter = input.value.toUpperCase();
  table = document.getElementById("tabledata");
  tr = table.getElementsByTagName("tr");
  for (i = 0; i < tr.length; i++) {
    // td1 = tr[i].getElementsByTagName("td")[3];
    td2 = tr[i].getElementsByTagName("td")[2];
    if (td2) {
      txtValue =
        // (td1.textContent || td1.innerText) &&
        td2.textContent || td2.innerText;
      if (txtValue.toUpperCase().indexOf(filter) > -1) {
        tr[i].style.display = "";
      } else {
        tr[i].style.display = "none";
      }
    }
  }
}

function absentHandler(regno, ...rest) {
  console.log(regno, rest);
  let fregno = regno;
  let ftestname = rest[0];
  let fsubcode = rest[1];
  let fclassid = rest[3];
  let fdegree = rest[4];
  let fexamno = rest[5];

  let parameters =
    "regno=" +
    fregno +
    "&fdegree=" +
    fdegree +
    "&fexamno=" +
    fexamno +
    "&fclassid=" +
    fclassid +
    "&fsubcode=" +
    fsubcode +
    "&ftestname=" +
    ftestname;

  if (window.confirm("Are you sure ? Do you want make Absent ?")) {
    $.blockUI({
      message:
        "<h1 class='h1' style='font-size:12px'><img src='img/ajax-loader.gif' border='0'></h1>",
    });
    $.ajax({
      type: "POST",
      url: $host_url + "iaMarksStudentAbsnet",
      data: parameters,
      success: function (params) {
        let res = JSON.parse(params);
        if (res.error_code === 0) {
          alert(res.data.msg);
          meViewIaStudDet();
          $.unblockUI();
        } else {
          alert(res.data.msg);
          $.unblockUI();
          return;
        }
      },
    });
  } else {
    console.log("cancelled");
  }
}

function marksEntryQnWiseNewReport() {
  var classid = document.getElementById("meClassName").value;
  var subelement = document.getElementById("meSubElement").value;
  var testName = document.getElementById("meTestName").value;
  var teachcode = document.getElementById("meTeachName").value;
  var txtmarks = document.getElementById("meTextMarks").value;
  console.log(txtmarks, "subelement");
  window.open(
    $host_url +
      "marksEntryQnWiseNewReport" +
      "&classid=" +
      classid +
      "&subcode=" +
      subelement +
      "&testName=" +
      testName +
      "&teachcode=" +
      teachcode +
      "&txtmarks=" +
      txtmarks
  );
}

function backHandler() {
  // $("#meMarksTable").hide();
  // $("#meStudDet").show();
}



function removeAbsentHandler(regno, ...rest) {
  console.log(regno, rest);
  let fregno = regno;
  let ftestname = rest[0];
  let fsubcode = rest[1];
  let fclassid = rest[3];
  let fdegree = rest[4];
  let fexamno = rest[5];

  let parameters =
    "regno=" +
    fregno +
    "&fdegree=" +
    fdegree +
    "&fexamno=" +
    fexamno +
    "&fclassid=" +
    fclassid +
    "&fsubcode=" +
    fsubcode +
    "&ftestname=" +
    ftestname;

  if (window.confirm("Are you sure ? Do you want remove Absent ?")) {
    $.blockUI({
      message:
        "<h1 class='h1' style='font-size:12px'><img src='img/ajax-loader.gif' border='0'></h1>",
    });
    $.ajax({
      type: "POST",
      url: $host_url + "removeAbsentHandler",
      data: parameters,
      success: function (params) {
        let res = JSON.parse(params);
        if (res.error_code === 0) {
          alert(res.data.msg);
          meViewIaStudDet();
          $.unblockUI();
        } else {
          alert(res.data.msg);
          $.unblockUI();
          return;
        }
      },
    });
  } else {
    console.log("cancelled");
  }
}