Both check_ntp_time and check_ntp return just first measured offset, instead of wanted average of four measurements. There is used bad index j (equeal to 0) instead of correct index i in avg_offset loop:
So avg_offset counts num_responses times the same first measured offset, then it is divided by num_responses, and first measured offset is back in avg_offset, instead of wanted average.
Also, I think that counting just an arithmetic average is not very good thing. For example, when there are measured values 0.001, 1.000, 0.001 and 0.001, the result will be 0.25075, whereas I think that there should be some logic, which skips obviously bad value 1.000, and result should be 0.001.