// check the output func (c *Code) Check(id int64) revel.Result { s := models.Source{} has, err := engine.Id(id).Get(&s) if err != nil { log.Println(err) } data := make(map[string]interface{}) if !has { data[STATUS] = false data[ERROR] = "not exist!" return c.RenderJson(data) } r, e := s.Check() if e != nil || s.Status != models.WrongAnswer { data[STATUS] = false if e != nil { data[ERROR] = e.Error() } else { data[ERROR] = "not wrong answer" } return c.RenderJson(data) } else { data[STATUS] = true data[REPORT] = r return c.RenderJson(data) } }