Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
155 changes: 155 additions & 0 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,161 @@
"verified_result": null
}
],
"apps/web/app/Helpers/__tests__/actual-api-format.test.ts": [
{
"hashed_secret": "1eb9369bcdb20f6c88138c9427f009b6afe19c7c",
"is_verified": false,
"line_number": 22,
"type": "Base64 High Entropy String",
"verified_result": null
},
{
"hashed_secret": "655dc5abb6b0ee511e4676b0739bb2077937014a",
"is_verified": false,
"line_number": 22,
"type": "Base64 High Entropy String",
"verified_result": null
},
{
"hashed_secret": "6eff76dbb551ea7769517f3a7188862f85a7354e",
"is_verified": false,
"line_number": 79,
"type": "Base64 High Entropy String",
"verified_result": null
},
{
"hashed_secret": "4f043b03a11e8b760986f07490ee76f48c6c7342",
"is_verified": false,
"line_number": 81,
"type": "Base64 High Entropy String",
"verified_result": null
},
{
"hashed_secret": "618eb19f52dfe817f292f54554346cad3e3a88b3",
"is_verified": false,
"line_number": 81,
"type": "Base64 High Entropy String",
"verified_result": null
}
],
"apps/web/app/Helpers/__tests__/choice-feedback-decoding.test.ts": [
{
"hashed_secret": "6eff76dbb551ea7769517f3a7188862f85a7354e",
"is_verified": false,
"line_number": 234,
"type": "Base64 High Entropy String",
"verified_result": null
}
],
"apps/web/app/Helpers/data-transformer.edge-cases.test.ts": [
{
"hashed_secret": "9716c4510d038dc8f853fc40dc96f8a2a87bb51c",
"is_verified": false,
"line_number": 162,
"type": "Base64 High Entropy String",
"verified_result": null
},
{
"hashed_secret": "4f043b03a11e8b760986f07490ee76f48c6c7342",
"is_verified": false,
"line_number": 165,
"type": "Base64 High Entropy String",
"verified_result": null
},
{
"hashed_secret": "9aa7cde469abc42954177388692fa3c14663338d",
"is_verified": false,
"line_number": 166,
"type": "Base64 High Entropy String",
"verified_result": null
}
],
"apps/web/app/Helpers/data-transformer.realworld.test.ts": [
{
"hashed_secret": "c5b49f145071d1dfaa7b852fbac2cc2d452c033d",
"is_verified": false,
"line_number": 15,
"type": "Base64 High Entropy String",
"verified_result": null
},
{
"hashed_secret": "565d3a24396607e26491162b13a69050b37c7be7",
"is_verified": false,
"line_number": 17,
"type": "Base64 High Entropy String",
"verified_result": null
},
{
"hashed_secret": "9690ab4554c9150bb66f9019049b7ed18998d6ab",
"is_verified": false,
"line_number": 22,
"type": "Base64 High Entropy String",
"verified_result": null
},
{
"hashed_secret": "4f043b03a11e8b760986f07490ee76f48c6c7342",
"is_verified": false,
"line_number": 25,
"type": "Base64 High Entropy String",
"verified_result": null
},
{
"hashed_secret": "9aa7cde469abc42954177388692fa3c14663338d",
"is_verified": false,
"line_number": 26,
"type": "Base64 High Entropy String",
"verified_result": null
},
{
"hashed_secret": "b7e41a1408b0de53b6a18b0383983df52151bffd",
"is_verified": false,
"line_number": 60,
"type": "Base64 High Entropy String",
"verified_result": null
},
{
"hashed_secret": "7f8a4c8efb7a9d741a4131e6382406d04920a55c",
"is_verified": false,
"line_number": 75,
"type": "Base64 High Entropy String",
"verified_result": null
},
{
"hashed_secret": "ef584f952dbcdb807b1f2a5b688a6b2ac7beaf76",
"is_verified": false,
"line_number": 158,
"type": "Base64 High Entropy String",
"verified_result": null
},
{
"hashed_secret": "fca9f0a000cc0d99a6b89eff22b280d43b3dc23a",
"is_verified": false,
"line_number": 168,
"type": "Base64 High Entropy String",
"verified_result": null
},
{
"hashed_secret": "ad5a4eb98aace66b683002aa7038bb800f8b0a65",
"is_verified": false,
"line_number": 174,
"type": "Base64 High Entropy String",
"verified_result": null
},
{
"hashed_secret": "28681ff8a70bc722645c0ebe5c21fbd8a2ee904a",
"is_verified": false,
"line_number": 183,
"type": "Base64 High Entropy String",
"verified_result": null
},
{
"hashed_secret": "dd65cdacb216bbeca512abfb1ecd15d1c53ac7bd",
"is_verified": false,
"line_number": 431,
"type": "Base64 High Entropy String",
"verified_result": null
}
],
"apps/web/app/api/markChat/route.ts": [
{
"hashed_secret": "3f70a0183ead614880b70bff64fd39c0d9155d62",
Expand Down
14 changes: 12 additions & 2 deletions apps/api/src/api/assignment/attempt/attempt.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
} from "@nestjs/common";
import {
Assignment,
CorrectAnswerVisibility,

Check warning on line 13 in apps/api/src/api/assignment/attempt/attempt.service.ts

View workflow job for this annotation

GitHub Actions / Lint & Test - api

'CorrectAnswerVisibility' is defined but never used
Question,
QuestionType,
QuestionVariant,
Expand All @@ -21,8 +21,8 @@
import { JsonValue } from "@prisma/client/runtime/library";
import { LearnerFileUpload } from "src/api/attempt/common/interfaces/attempt.interface";
import {
SuccessPageDataDto,

Check warning on line 24 in apps/api/src/api/assignment/attempt/attempt.service.ts

View workflow job for this annotation

GitHub Actions / Lint & Test - api

'SuccessPageDataDto' is defined but never used
SuccessPageQuestionDto,

Check warning on line 25 in apps/api/src/api/assignment/attempt/attempt.service.ts

View workflow job for this annotation

GitHub Actions / Lint & Test - api

'SuccessPageQuestionDto' is defined but never used
} from "src/api/attempt/dto/success-page-data.dto";
import { LlmFacadeService } from "src/api/llm/llm-facade.service";
import { PresentationQuestionEvaluateModel } from "src/api/llm/model/presentation.question.evaluate.model";
Expand Down Expand Up @@ -2342,15 +2342,25 @@
learnerResponse: string;
} {
const choices = this.parseChoices(question.choices);
console.log(
`Handling single correct question response for question ID: ${question.id}`,
);
const learnerChoice =
createQuestionResponseAttemptRequestDto.learnerChoices[0];

console.log(
`Learner choice: ${learnerChoice}, Choices: ${JSON.stringify(choices)}`,
);
const normalizedLearnerChoice = this.normalizeText(learnerChoice);
const correctChoice = choices.find((choice) => choice.isCorrect);

console.log(
`Correct choice: ${correctChoice ? correctChoice.choice : "None"}`,
);
const selectedChoice = choices.find(
(choice) => this.normalizeText(choice.choice) === normalizedLearnerChoice,
);
console.log(
`Selected choice: ${selectedChoice ? selectedChoice.choice : "None"}`,
);

const data = {
learnerChoice,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ export class ChoiceGradingStrategy extends AbstractGradingStrategy<string[]> {
}> {
await this.validateResponse(question, requestDto);

console.log("request dto:", requestDto);

const learnerResponse = await this.extractLearnerResponse(requestDto);

return this.gradeSingleChoice(question, learnerResponse, context);
Expand All @@ -170,6 +172,7 @@ export class ChoiceGradingStrategy extends AbstractGradingStrategy<string[]> {
responseDto: CreateQuestionResponseAttemptResponseDto;
learnerResponse: string[];
}> {
console.log("learner response:", learnerResponse);
const choices = this.parseChoices(question.choices);

if (!learnerResponse || learnerResponse.length === 0) {
Expand All @@ -187,12 +190,25 @@ export class ChoiceGradingStrategy extends AbstractGradingStrategy<string[]> {
}

const learnerChoice = learnerResponse[0];
console.log("learner response:", learnerResponse);
const normalizedLearnerChoice = this.normalizeText(learnerChoice);
const correctChoice = choices.find((choice) => choice.isCorrect);

console.log("learner choice:", normalizedLearnerChoice);
console.log(
"all choices:",
choices.map((c) => c.choice),
);

console.log(
"correct answer:",
correctChoice ? correctChoice.choice : "none",
);

const selectedChoice = choices.find(
(choice) => this.normalizeText(choice.choice) === normalizedLearnerChoice,
);
console.log("selected choice:", selectedChoice);

const data = {
learnerChoice,
Expand Down
5 changes: 3 additions & 2 deletions apps/api/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@ import { AppService } from "./app.service";
import { AdminAuthModule } from "./auth/admin-auth.module";
import { AuthModule } from "./auth/auth.module";
import { UserSessionMiddleware } from "./auth/middleware/user.session.middleware";
import { CommonModule } from "./common/common.module";
import { DatabaseModule } from "./database/database.module";
import { HealthModule } from "./health/health.module";
import { winstonOptions } from "./logger/config";
import { LoggerMiddleware } from "./logger/logger.middleware";
import { MessagingModule } from "./messaging/messaging.module";
import { DataTransformMiddleware } from "./middleware/data-transform.middleware";
import { routes } from "./routes";

@Module({
imports: [
ConfigModule.forRoot(),
WinstonModule.forRoot(winstonOptions),
HealthModule,
CommonModule,
ApiModule,
ScheduledTasksModule,
RouterModule.register(routes),
Expand All @@ -39,7 +40,7 @@ import { routes } from "./routes";
export class AppModule implements NestModule {
configure(consumer: MiddlewareConsumer) {
consumer
.apply(DataTransformMiddleware, LoggerMiddleware)
.apply(LoggerMiddleware)
.forRoutes({ path: "*", method: RequestMethod.ALL })
.apply(UserSessionMiddleware)
.forRoutes(
Expand Down
4 changes: 3 additions & 1 deletion apps/api/src/common/common.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Module, Global } from "@nestjs/common";
import { APP_INTERCEPTOR } from "@nestjs/core";
import { APP_INTERCEPTOR, Reflector } from "@nestjs/core";
import { DataTransformInterceptor } from "./interceptors/data-transform.interceptor";

/**
Expand All @@ -8,6 +8,8 @@ import { DataTransformInterceptor } from "./interceptors/data-transform.intercep
@Global()
@Module({
providers: [
Reflector,
DataTransformInterceptor,
{
provide: APP_INTERCEPTOR,
useClass: DataTransformInterceptor,
Expand Down
Loading
Loading