Router code.
r := gin.Default()
r.LoadHTMLGlob("views/*")
Teacher := r.Group("/teacher", SessionHandler)
{
Teacher.GET("/teacherpanel", controllers.TeacherPanelController)
Teacher.GET("/createquizz", controllers.CreateQuizController)
Teacher.POST("/createquizz", controllers.PostQuizController)
Teacher.GET("/addstudent", controllers.AddStudentController)
Teacher.POST("/addstudent", controllers.PostStudentController)
Teacher.GET("/listofquiz", controllers.GetListOfQuizController)
Teacher.GET("/quiz",controllers.GetQuizController)
}
Controller code GetQuizController
type or paste code here
func GetQuizController(c *gin.Context) {
fmt.Println("get quiz controller called")
quizname := c.Query("quizname")
var questions []models.Questions
dbconnection.DB.Debug().Model(&models.Quiz{}).Select("quizzes.quiz_name,questions.question,questions.option_a,questions.option_b,questions.option_c,questions.option_d,questions.answer,questions.difficulty").Joins("inner join questions on questions.quiz_id=quizzes.id").Where("quizzes.quiz_name=?", quizname).Scan(&questions)
fmt.Println(questions)
c.HTML(200,"showquiz.html",gin.H{
"data":questions,
})
}
Here in this GetQuizController c.HTML is not working.Please help me.
here is the link of github repo:-github link
#golang #gin[quote=“shashwat, post:1, topic:31748, full:true”]
Router code.
r := gin.Default()
r.LoadHTMLGlob("views/*")
Teacher := r.Group("/teacher", SessionHandler)
{
Teacher.GET("/teacherpanel", controllers.TeacherPanelController)
Teacher.GET("/createquizz", controllers.CreateQuizController)
Teacher.POST("/createquizz", controllers.PostQuizController)
Teacher.GET("/addstudent", controllers.AddStudentController)
Teacher.POST("/addstudent", controllers.PostStudentController)
Teacher.GET("/listofquiz", controllers.GetListOfQuizController)
Teacher.GET("/quiz",controllers.GetQuizController)
}
Controller code GetQuizController
type or paste code here
func GetQuizController(c *gin.Context) {
fmt.Println("get quiz controller called")
quizname := c.Query("quizname")
var questions []models.Questions
dbconnection.DB.Debug().Model(&models.Quiz{}).Select("quizzes.quiz_name,questions.question,questions.option_a,questions.option_b,questions.option_c,questions.option_d,questions.answer,questions.difficulty").Joins("inner join questions on questions.quiz_id=quizzes.id").Where("quizzes.quiz_name=?", quizname).Scan(&questions)
fmt.Println(questions)
c.HTML(200,"showquiz.html",gin.H{
"data":questions,
})
}
Here in this GetQuizController c.HTML is not working.Please help me.
here is the link of github repo:-github link