package com.ruoyi.applet.contoller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.model.service.IExaminationService;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.model.service.IAppExaminationInstructionsService;
import com.ruoyi.model.service.IShortAnswerQuestionsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(description = "考核")
@RestController
@RequestMapping("/applet/examination")
public class AppletExaminationController extends BaseController {

    @Autowired
    private IAppExaminationInstructionsService appExaminationInstructionsService;

    @ApiOperation("考核说明")
    @GetMapping("/instructions/{id}")
    public AjaxResult getInstructionsById(@PathVariable Long id){
        return AjaxResult.success(appExaminationInstructionsService.selectAppExaminationInstructionsByExaminationInstructionsId(id));
    }
    @Autowired
    private IExaminationService examinationService;

    /**
     * 接收前端传递过来的问题类型，根据问题类型查找问题
     * @param examinationTypeId 1为选择题，2为主观题
     * @return 查询到的问题列表
     */
    @ApiOperation("查询考核题目及其答案")
    @GetMapping("/getExaminationType")
    public TableDataInfo getExaminationType(@RequestParam Long examinationTypeId){
        return getDataTable(examinationService.getExaminationType(examinationTypeId));
    }

    @Autowired
    private IShortAnswerQuestionsService shortAnswerQuestionsService;

    @ApiOperation("查询简答题列表")
    @GetMapping("getShortAnswerQuestionsList")
    public TableDataInfo getShortAnswerQuestionsList(){
        return getDataTable(shortAnswerQuestionsService.getShortAnswerQuestionsList());
    }
}
