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.221.240.14


Current Path : /var/www/oasis/js/
Upload File :
Current File : /var/www/oasis/js/identifyCoMarks.js

function callEnableCoMarks() {
  $("#page_main_div").load(
    "../html_modules/identifyCoMarks.html?v=1122",
    function () {
      document.getElementById("display_module_name").innerHTML =
        "Identify CO Marks";
      document.getElementById("module_name_for_save").value =
        "Identify CO Marks";
      getDefaultHeadFooterLinks("Identify CO Marks");
      loadTeacherData();
    }
  );
}

function loadTeacherData() {
  $.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>`;
      }
      $("#teachname").html(teachnameoptions);
      $.unblockUI();
    },
  });
}

function marksentrytwoloadclassnamesnew() {
  var techcode = document.getElementById("teachname").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>`;
      }
      $("#classnameoptions").html(classnameoption);
      $.unblockUI();
    },
  });
}

function getSubjectElementnew() {
  var teachcode = document.getElementById("teachname").value;
  var classid = document.getElementById("classnameoptions").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>`;
        }
        $("#subElement").html(sub_options);
        $.unblockUI();
      } else {
        alert(response.data.msg);
        $.unblockUI();
        return;
      }
    },
  });
}

function getTestMaxQnnew() {
  var teachcode = document.getElementById("teachname").value;
  var classid = document.getElementById("classnameoptions").value;
  var subelement = document.getElementById("subElement").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);
      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>`;
        }
      }
      $("#testName").html(test_options);
      $("#txtmarks").val(response.data.sub.fvalmax);
      $("#txtmarks").attr("disabled", true);
      $.unblockUI();
    },
  });
}

let corowid = [];
let marks_data_id = [];

function saveCoMarks() {
  var classid = document.getElementById("classnameoptions").value;
  var subelement = document.getElementById("subElement").value;
  var testName = document.getElementById("testName").value;

  let splitSubElement = subelement.split("*");
  let subcode = splitSubElement[0];
  let subject = splitSubElement[1];

  let rowQnno;
  let cells;
  let rowmarks;
  let corow;
  if (subject.toLowerCase() === "cie") {
    rowQnno = document.getElementById("qnno_row_cie");
    cells = rowQnno.getElementsByTagName("td");
    rowmarks = document
      .getElementById("marks_row_cie")
      .getElementsByTagName("input");
    corow = document.getElementById("co_row_cie").getElementsByTagName("input");
  } else {
    rowQnno = document.getElementById("qnno_row_activity");
    cells = rowQnno.getElementsByTagName("td");
    rowmarks = document
      .getElementById("marks_row_activity")
      .getElementsByTagName("input");
    corow = document
      .getElementById("co_row_activity")
      .getElementsByTagName("input");
  }

  marks_data_id = [];
  for (var z = 0; z < rowmarks.length; z++) {
    marks_data_id.push(rowmarks[z].id);
  }

  corowid = [];
  for (var z = 0; z < corow.length; z++) {
    corowid.push(corow[z].id);
  }

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

  let data = [];
  for (var i = 0; i < cells.length; i++) {
    let cellVal = rowQnno.getElementsByTagName("td")[i].innerText;
    var marksVal = parseFloat(document.getElementById(marks_data_id[i]).value);
    var coVal = parseFloat(document.getElementById(corowid[i]).value);

    let values = {};
    values.qnno = cellVal;
    values.marks = marksVal;
    values.co = coVal;
    data.push(values);
  }

  $.ajax({
    type: "POST",
    url: $host_url + "saveMarksDetailsEntry",
    data:
      "testName=" +
      testName +
      "&classId=" +
      classid +
      "&subelement=" +
      subcode +
      "&data=" +
      JSON.stringify(data),
    success: function (res) {
      let response = JSON.parse(res);
      console.log(response);
      if (response.error_code === 0) {
        alert(response.data);
        $.unblockUI();
      } else {
        alert(res.data);
        $.unblockUI();
        return;
      }
    },
  });
}

function getMarksTotal(id) {
  var subelement = document.getElementById("subElement").value;
  let splitSubElement = subelement.split("*");
  let subject = splitSubElement[1];
  if (subject.toLowerCase() === "cie") {
    let A1 = $("#1A").val();
    let B1 = $("#1B").val();
    let C1 = $("#1C").val();
    let D1 = $("#1D").val();
    let A2 = $("#2A").val();
    let B2 = $("#2B").val();
    let C2 = $("#2C").val();
    let D2 = $("#2D").val();
    let A3 = $("#3A").val();
    let B3 = $("#3B").val();
    let C3 = $("#3C").val();
    let D3 = $("#3D").val();
    let A4 = $("#4A").val();
    let B4 = $("#4B").val();
    let C4 = $("#4C").val();
    let D4 = $("#4D").val();

    if (A1 === "") {
      A1 = 0;
    }
    if (B1 === "") {
      B1 = 0;
    }
    if (C1 === "") {
      C1 = 0;
    }
    if (D1 === "") {
      D1 = 0;
    }
    if (A2 === "") {
      A2 = 0;
    }
    if (B2 === "") {
      B2 = 0;
    }
    if (C2 === "") {
      C2 = 0;
    }
    if (D2 === "") {
      D2 = 0;
    }
    if (A3 === "") {
      A3 = 0;
    }
    if (B3 === "") {
      B3 = 0;
    }
    if (C3 === "") {
      C3 = 0;
    }
    if (D3 === "") {
      D3 = 0;
    }
    if (A4 === "") {
      A4 = 0;
    }
    if (B4 === "") {
      B4 = 0;
    }
    if (C4 === "") {
      C4 = 0;
    }
    if (D4 === "") {
      D4 = 0;
    }

    if (
      parseFloat(A1) + parseFloat(B1) + parseFloat(C1) + parseFloat(D1) >
      25
    ) {
      alert("Maximum marks reached");
      document.getElementById(id).value = "";
      document.getElementById(id).focus();
      return;
    }
    if (
      parseFloat(A2) + parseFloat(B2) + parseFloat(C2) + parseFloat(D2) >
      25
    ) {
      alert("Maximum marks reached");
      document.getElementById(id).value = "";
      document.getElementById(id).focus();
      return;
    }
    if (
      parseFloat(A3) + parseFloat(B3) + parseFloat(C3) + parseFloat(D3) >
      25
    ) {
      alert("Maximum marks reached");
      document.getElementById(id).value = "";
      document.getElementById(id).focus();
      return;
    }
    if (
      parseFloat(A4) + parseFloat(B4) + parseFloat(C4) + parseFloat(D4) >
      25
    ) {
      alert("Maximum marks reached");
      document.getElementById(id).value = "";
      document.getElementById(id).focus();
      return;
    }
  } else {
    let A1 = $("#A1A").val();
    if (parseFloat(A1) > 50) {
      alert("Maximum marks reached");
      document.getElementById(id).value = "";
      document.getElementById(id).focus();
      return;
    }
  }
}

function viewCoMarksData() {
  var classid = document.getElementById("classnameoptions").value;
  var subelement = document.getElementById("subElement").value;
  var testName = document.getElementById("testName").value;

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

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

  if (testName == "") {
    alert("please select test");
    return;
  }

  let splitSubElement = subelement.split("*");
  let subcode = splitSubElement[0];
  let subject = splitSubElement[1];

  if (subject.toLowerCase() === "cie") {
    $("#copotable_cie_activity").hide();
    $("#copotable_cie").show();
  } else {
    $("#copotable_cie").hide();
    $("#copotable_cie_activity").show();
  }
  document.getElementById("teachname").disabled = true;
  document.getElementById("classnameoptions").disabled = true;
  document.getElementById("subElement").disabled = true;
  document.getElementById("testName").disabled = true;

  let rowmarks;
  let corow;
  if (subject.toLowerCase() === "cie") {
    rowmarks = document
      .getElementById("marks_row_cie")
      .getElementsByTagName("input");
    corow = document.getElementById("co_row_cie").getElementsByTagName("input");
  } else {
    rowmarks = document
      .getElementById("marks_row_activity")
      .getElementsByTagName("input");
    corow = document
      .getElementById("co_row_activity")
      .getElementsByTagName("input");
  }

  marks_data_id = [];
  for (var z = 0; z < rowmarks.length; z++) {
    marks_data_id.push(rowmarks[z].id);
  }

  corowid = [];
  for (var z = 0; z < corow.length; z++) {
    corowid.push(corow[z].id);
  }

  let parameter =
    "&classid=" + classid + "&subcode=" + subcode + "&testName=" + testName;

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

  $.ajax({
    method: "GET",
    url: $host_url + "viewCOMarksData",
    data: parameter,
    success: function (res) {
      let response = JSON.parse(res);
      if (response.error_code === 0) {
        for (var i = 0; i < response.data.length; i++) {
          if (subject.toLowerCase() === "cie") {
            if (marks_data_id[i] === response.data[i].FQNNO) {
              document.getElementById(marks_data_id[i]).value =
                response.data[i].FMARKS;
              document.getElementById(corowid[i]).value = response.data[i].FCO;
            }
          } else {
            if (marks_data_id[i] === "A" + response.data[i].FQNNO) {
              document.getElementById(marks_data_id[i]).value =
                response.data[i].FMARKS;
              document.getElementById(corowid[i]).value = response.data[i].FCO;
            }
          }
        }
      }
      $.unblockUI();
    },
  });
}

function isNumber(evt) {
  console.log(evt);
  evt = evt ? evt : window.event;
  var charCode = evt.which ? evt.which : evt.keyCode;
  if (charCode > 31 && (charCode < 45 || charCode > 57)) {
    return false;
  }
  return true;
}