var UpdateKeyInformationData = function(providerCode , qualCode) { console.log("Running UpdateKeyInformationData"); var qualifications = []; try { //Set up the client to connect to the KIS Data Service url var oDataUrl = `https://info4learners.tec.govt.nz/KeyInformation?$filter=ProviderCode eq '${providerCode}' and QualificationCode eq '${qualCode}'`; $.support.cors = true; $.getJSON(oDataUrl, function(data) { console.log("Total Count : " + data.value.length); data.value.forEach(function(qual) { var kis = { "QualificationName": qual.QualificationName, "QualificationCode": qual.QualificationCode, "CourseCompletion": qual.CourseCompletion, "Duration": qual.Duration, "MinimumEntryRequirements": qual.MinimumEntryRequirements, "GovernmentSubsidy": qual.GovernmentSubsidy, "GraduatesInEmployment": qual.GraduatesInEmployment, "GraduatesInStudy": qual.GraduatesInStudy, "GraduatesOnBenefit": qual.GraduatesOnBenefit, "AnnualStudentFees": qual.AnnualStudentFees, "AnnualGovernmentTuitionSubsidy": qual.AnnualGovernmentTuitionSubsidy, "Total_Annual": qual.Total_Annual, "Total_TotalQualification": qual.Total_TotalQualification, "GraduatesOnBenefit": qual.GraduatesOnBenefit, "MedianEarnings": qual.MedianEarnings, "UpperQuartileEarnings": qual.UpperQuartileEarnings, "LowerQuartileEarnings": qual.LowerQuartileEarnings, "Total_Annual": qual.Total_Annual, "Total_TotalQualification": qual.Total_TotalQualification, "StudentFees": qual.StudentFees }; qualifications.push(kis); }); console.log(qualifications.length); outputData(qualifications); }) .fail(function(data, args) { console.error(`Error => ${data}`); $("#OutputData").text("Sorry, this information is not available right now. Please check back later.") }); } catch (ex) { console.error("Error trying to get Data : " + ex); } } var outputData = function(quals) { var outputText = ""; $("#OutputData").append(`
#Qualificaion Code - ${quals[i].QualificationCode}
`; outputText = outputText + `#QualificationName - ${quals[i].QualificationName}
`; outputText = outputText + `#CourseCompletion - ${quals[i].CourseCompletion}
`; outputText = outputText + `#MinimumEntryRequirements - ${quals[i].MinimumEntryRequirements}
`; outputText = outputText + `#Duration - ${quals[i].Duration}
`; outputText = outputText + `#GovernmentSubsidy - ${quals[i].GovernmentSubsidy}
`; outputText = outputText + `#GraduatesInEmployment - ${quals[i].GraduatesInEmployment}
`; outputText = outputText + `#GraduatesInStudy - ${quals[i].GraduatesInStudy}
`; outputText = outputText + `#GraduatesOnBenefit - ${quals[i].GraduatesOnBenefit}
`; outputText = outputText + `#LowerQuartileEarnings - ${quals[i].LowerQuartileEarnings}
`; outputText = outputText + `#MedianEarnings - ${quals[i].MedianEarnings}
`; outputText = outputText + `#StudentFees - ${quals[i].StudentFees}
`; outputText = outputText + `#Total Annual - ${quals[i].Total_Annual}
`; outputText = outputText + `#Total TotalQualification - ${quals[i].Total_TotalQualification}
`; outputText = outputText + `#AnnualGovernmentTuitionSubsidy - ${quals[i].AnnualGovernmentTuitionSubsidy}
`; outputText = outputText + `#AnnualStudentFees - ${quals[i].AnnualStudentFees}
`; outputText = outputText + `#UpperQuartileEarnings - ${quals[i].UpperQuartileEarnings}
`; $("#OutputData").append(`${outputText}
`); } } $(document).ready(function() { UpdateKeyInformationData(6006 , 'NC0951'); })