-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chore/mcq variants api #290
Open
sukanyamohanty143
wants to merge
4
commits into
beta-1
Choose a base branch
from
chore/mcq-variants-api
base: beta-1
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
817f7d9
Add the MCQ variants functionality in MCQ
sukanyamohanty143 ae8fb06
Merge branch 'beta-1' of https://github.com/navgurukul/zuvy-server in…
sukanyamohanty143 6a839cb
Fixed the search assignment by assignment title in admin submission tab
sukanyamohanty143 e00b0a4
The appropriate message has been added in the response
sukanyamohanty143 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -187,12 +187,20 @@ export class ContentController { | |
@ApiBearerAuth() | ||
@UseGuards(RolesGuard) | ||
async createQuizForModule( | ||
@Body() quizQuestions: quizBatchDto | ||
) { | ||
const res = await this.contentService.createQuizForModule( | ||
quizQuestions | ||
); | ||
return res; | ||
@Body() quizQuestions: quizBatchDto, | ||
@Res() res | ||
): Promise<object> { | ||
try { | ||
let [err, success] = await this.contentService.createQuizForModule( | ||
quizQuestions | ||
); | ||
if (err) { | ||
return ErrorResponse.BadRequestException(err.message).send(res); | ||
} | ||
return new SuccessResponse( success.message, success.statusCode, []).send(res); | ||
} catch (error) { | ||
return ErrorResponse.BadRequestException(error.message).send(res); | ||
} | ||
} | ||
|
||
@Put('/editAssessment/:assessmentOutsourseId/:chapterId') | ||
|
@@ -232,7 +240,7 @@ export class ContentController { | |
@Get('/chapterDetailsById/:chapterId') | ||
@ApiOperation({ summary: 'Get chapter details by id' }) | ||
@ApiBearerAuth() | ||
async getChapterDetailsById(@Param('chapterId') chapterId: number, @Query('bootcampId') bootcampId: number, @Query('moduleId') moduleId: number, @Query('topicId') topicId: number){ | ||
async getChapterDetailsById(@Param('chapterId') chapterId: number, @Query('bootcampId') bootcampId: number, @Query('moduleId') moduleId: number, @Query('topicId') topicId: number) { | ||
return this.contentService.getChapterDetailsById(chapterId, bootcampId, moduleId, topicId); | ||
} | ||
|
||
|
@@ -343,13 +351,19 @@ export class ContentController { | |
@Query('tagId') tagId: number[], | ||
@Query('difficulty') difficulty: ('Easy' | 'Medium' | 'Hard') | ('Easy' | 'Medium' | 'Hard')[], | ||
@Query('searchTerm') searchTerm: string, | ||
@Res() res | ||
): Promise<object> { | ||
const res = await this.contentService.getAllQuizQuestions( | ||
tagId, | ||
difficulty, | ||
searchTerm, | ||
); | ||
return res; | ||
try { | ||
let [err, success] = await this.contentService.getAllQuizQuestions(tagId, difficulty, searchTerm); | ||
|
||
if (err) { | ||
return ErrorResponse.BadRequestException(success.message).send(res); | ||
} | ||
|
||
return new SuccessResponse(success.message || 'Quizzes retrieved successfully', success.statusCode, success['data']).send(res); | ||
} catch (error) { | ||
return ErrorResponse.BadRequestException(error.message).send(res); | ||
} | ||
} | ||
|
||
@Patch('/updateCodingQuestion/:questionId') | ||
|
@@ -411,12 +425,23 @@ export class ContentController { | |
} | ||
|
||
@Post('/editquiz') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please change it to use the PUT API. |
||
@ApiOperation({ summary: 'Create a quiz' }) | ||
@ApiOperation({ summary: 'Edit quiz or its variants' }) | ||
@ApiBearerAuth() | ||
@UseGuards(RolesGuard) | ||
async editQuizForModule(@Body() quizQuestions: editQuizBatchDto) { | ||
const res = await this.contentService.editQuizQuestions(quizQuestions); | ||
return res; | ||
async editQuizForModule(@Body() quizQuestions: editQuizBatchDto, @Res() res | ||
): Promise<object> { | ||
|
||
try { | ||
let [err, success] = await this.contentService.editQuizQuestions( | ||
quizQuestions | ||
); | ||
if (err) { | ||
return ErrorResponse.BadRequestException(err.message).send(res); | ||
} | ||
return new SuccessResponse(success.message, success.statusCode, []).send(res); | ||
} catch (error) { | ||
return ErrorResponse.BadRequestException(error.message).send(res); | ||
} | ||
} | ||
|
||
|
||
|
@@ -534,15 +559,15 @@ export class ContentController { | |
@Get('/students/assessmentId=:assessmentId') | ||
@ApiOperation({ summary: 'Get the student of a particular assessment' }) | ||
@ApiBearerAuth() | ||
async getStudentsOfAssessment(@Param('assessmentId') assessmentId: number , @Query('moduleId') moduleId:number , @Query('bootcampId') bootcampId:number, @Query('chapterId') chapterId:number, @Req() req) { | ||
async getStudentsOfAssessment(@Param('assessmentId') assessmentId: number, @Query('moduleId') moduleId: number, @Query('bootcampId') bootcampId: number, @Query('chapterId') chapterId: number, @Req() req) { | ||
return this.contentService.getStudentsOfAssessment(assessmentId, chapterId, moduleId, bootcampId, req); | ||
} | ||
|
||
@Get('/startAssessmentForStudent/assessmentOutsourseId=:assessmentOutsourseId') | ||
@ApiOperation({ summary: 'Start the assessment for a student' }) | ||
@ApiBearerAuth() | ||
async startAssessmentForStudent(@Req() req, @Param('assessmentOutsourseId') assessmentOutsourseId: number){ | ||
return this.contentService.startAssessmentForStudent(assessmentOutsourseId,req); | ||
async startAssessmentForStudent(@Req() req, @Param('assessmentOutsourseId') assessmentOutsourseId: number) { | ||
return this.contentService.startAssessmentForStudent(assessmentOutsourseId, req); | ||
} | ||
|
||
@Get('/assessmentDetailsOfQuiz/:assessmentOutsourseId') | ||
|
@@ -554,7 +579,7 @@ export class ContentController { | |
description: 'studentId of the assessment', | ||
}) | ||
@ApiBearerAuth() | ||
async getAssessmentDetailsOfQuiz(@Param('assessmentOutsourseId') assessmentOutsourseId: number, @Req() req, @Query('studentId') userId:number ){ | ||
async getAssessmentDetailsOfQuiz(@Param('assessmentOutsourseId') assessmentOutsourseId: number, @Req() req, @Query('studentId') userId: number) { | ||
if (!userId) { | ||
userId = req.user[0].id; | ||
} | ||
|
@@ -570,14 +595,14 @@ export class ContentController { | |
type: Number, | ||
description: 'studentId of the assessment', | ||
}) | ||
async getAssessmentDetailsOfOpenEnded(@Param('assessmentOutsourseId') assessmentOutsourseId: number, @Req() req, @Query('studentId') userId:number){ | ||
async getAssessmentDetailsOfOpenEnded(@Param('assessmentOutsourseId') assessmentOutsourseId: number, @Req() req, @Query('studentId') userId: number) { | ||
if (!userId) { | ||
userId = req.user[0].id; | ||
} | ||
return this.contentService.getAssessmentDetailsOfOpenEnded(assessmentOutsourseId, userId); | ||
} | ||
|
||
|
||
@Post('/createQuestionType') | ||
@ApiOperation({ summary: 'Create a Question Type for the form' }) | ||
@ApiBearerAuth() | ||
|
@@ -593,15 +618,15 @@ export class ContentController { | |
const res = await this.contentService.getAllQuestionTypes(); | ||
return res; | ||
} | ||
|
||
@Post('/form') | ||
@ApiOperation({ summary: 'Create a form' }) | ||
@ApiBearerAuth() | ||
@UseGuards(RolesGuard) | ||
async createFormForModule ( | ||
async createFormForModule( | ||
@Query('chapterId') chapterId: number, | ||
@Body() formQuestion: formBatchDto | ||
){ | ||
) { | ||
const res = await this.contentService.createFormForModule( | ||
chapterId, | ||
formQuestion | ||
|
@@ -625,14 +650,14 @@ export class ContentController { | |
}) | ||
@ApiBearerAuth() | ||
async getAllFormQuestions( | ||
@Param('chapterId') chapterId: number, | ||
@Query('typeId') typeId: number, | ||
@Query('searchTerm') searchTerm: string, | ||
@Param('chapterId') chapterId: number, | ||
@Query('typeId') typeId: number, | ||
@Query('searchTerm') searchTerm: string, | ||
): Promise<object> { | ||
const res = await this.contentService.getAllFormQuestions( | ||
chapterId, | ||
typeId, | ||
searchTerm, | ||
chapterId, | ||
typeId, | ||
searchTerm, | ||
); | ||
return res; | ||
} | ||
|
@@ -651,7 +676,7 @@ export class ContentController { | |
return res; | ||
} | ||
|
||
|
||
@Post('/createAndEditForm/:chapterId') | ||
@ApiOperation({ summary: 'Create a form' }) | ||
@ApiBearerAuth() | ||
|
@@ -719,4 +744,55 @@ export class ContentController { | |
return ErrorResponse.BadRequestException(error.message).send(res); | ||
} | ||
} | ||
|
||
@Get('/quiz/:id') | ||
@ApiOperation({ summary: 'Get a single quiz with all its variants by mcqId' }) | ||
@ApiBearerAuth() | ||
@UseGuards(RolesGuard) | ||
async getQuizWithVariants(@Param('id') id: number, @Res() res): Promise<object> { | ||
try { | ||
let [err, success] = await this.contentService.getQuizWithVariants(id); | ||
if (err) { | ||
return ErrorResponse.BadRequestException(err.message).send(res); | ||
} | ||
return new SuccessResponse(success.message, success.statusCode, success.data).send(res); | ||
} catch (error) { | ||
return ErrorResponse.BadRequestException(error.message).send(res); | ||
} | ||
} | ||
|
||
@Delete('/deleteQuiz') | ||
@ApiOperation({ summary: 'Delete a quiz or a specific variant' }) | ||
@ApiQuery({ | ||
name: 'quizId', | ||
required: true, | ||
type: Number, | ||
description: 'delete quiz by id', | ||
}) | ||
@ApiQuery({ | ||
name: 'variantNumber', | ||
required: false, | ||
type: Number, | ||
description: 'delete specific variant of the quiz', | ||
}) | ||
@ApiBearerAuth() | ||
@UseGuards(RolesGuard) | ||
async deleteQuizOrVariant( | ||
@Query('quizId') quizId: number, | ||
@Query('variantNumber') variantNumber: number, | ||
@Res() res | ||
) { | ||
// Call the service method to delete quiz or variant | ||
|
||
try { | ||
let [err, success] = await this.contentService.deleteQuizOrVariant(quizId, variantNumber); | ||
if (err) { | ||
return ErrorResponse.BadRequestException(err.message).send(res); | ||
} | ||
return new SuccessResponse(success.message, success.statusCode, []).send(res); | ||
} catch (error) { | ||
return ErrorResponse.BadRequestException(error.message).send(res); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we storing the question in both tables if it is a variant? @Arunesh700