Changes in / [dd264cb:91bfcf4]


Ignore:
Location:
src
Files:
11 deleted
16 edited

Legend:

Unmodified
Added
Removed
  • src/Clients/Angular/finki-chattery/src/app/core/state/question-facade.service.ts

    rdd264cb r91bfcf4  
    1919  GetQuestionState,
    2020  GetSearchQuestions,
    21   RespondToAnswer,
    2221  SetCorrectAnswer,
    2322  VoteAnswer
     
    8685  }
    8786
    88   public respondToAnswer(answerUid: string, questionUid: string, text: string): void {
    89     this.dispatchEffect(new RespondToAnswer(questionUid, answerUid, text));
    90   }
    91 
    9287  public fetchQuestion(questionUid: string): void {
    9388    this.dispatchEffect(new GetQuestionState(questionUid));
  • src/Clients/Angular/finki-chattery/src/app/core/state/question-state/question-state-request.models.ts

    rdd264cb r91bfcf4  
    44  constructor(public voteType: VoteType) {}
    55}
    6 
    7 export class RespondToAnswerRequest {
    8   constructor(public text: string) {}
    9 }
  • src/Clients/Angular/finki-chattery/src/app/core/state/question-state/question.actions.ts

    rdd264cb r91bfcf4  
    33
    44import {
    5   AnswerResponseQuestionStateViewModel,
    65  PreviewQuestionViewModel,
    76  QuestionStateViewModel,
     
    1413  GetQuestionState = '[Question] Get state',
    1514  GetQuestionStateSuccess = '[Question] Get state success',
    16   RespondToAnswer = '[Question] RespondToAnswer',
    17   RespondToAnswerSuccess = '[Question] RespondToAnswer success',
    1815  SetCorrectAnswer = '[Question] Set Correct Answer',
    1916  SetCorrectAnswerSuccess = '[Question] Set Correct Answer success',
     
    103100}
    104101
    105 export class RespondToAnswer implements Action {
    106   readonly type = QuestionActionTypes.RespondToAnswer;
    107 
    108   constructor(public questionUid: string, public answerUid: string, public text: string) {}
    109 }
    110 
    111 export class RespondToAnswerSuccess implements Action {
    112   readonly type = QuestionActionTypes.RespondToAnswerSuccess;
    113 
    114   constructor(public payload: AnswerResponseQuestionStateViewModel, public answerUid: string) {}
    115 }
    116 
    117102export class EffectStartedWorking implements Action {
    118103  readonly type = QuestionActionTypes.EffectStartedWorking;
     
    140125  | VoteAnswerSuccess
    141126  | SetCorrectAnswerSuccess
    142   | RespondToAnswerSuccess
    143127  | EffectStartedWorking
    144128  | EffectFinishedWorking
  • src/Clients/Angular/finki-chattery/src/app/core/state/question-state/question.effects.ts

    rdd264cb r91bfcf4  
    88import { NotificationService } from '../../services/notification.service';
    99import { QuestionFacadeService } from '../question-facade.service';
    10 import { RespondToAnswerRequest, VoteAnswerRequest } from './question-state-request.models';
    11 import {
    12   AnswerResponseQuestionStateResponse,
    13   PreviewQuestionResponse,
    14   QuestionStateResponse,
    15   VoteAnswerResponse
    16 } from './question-state-response.models';
     10import { VoteAnswerRequest } from './question-state-request.models';
     11import { PreviewQuestionResponse, QuestionStateResponse, VoteAnswerResponse } from './question-state-response.models';
    1712import {
    1813  EffectFinishedWorking,
     
    2722  GetSearchQuestionsSuccess,
    2823  QuestionActionTypes,
    29   RespondToAnswer,
    30   RespondToAnswerSuccess,
    3124  SetCorrectAnswer,
    3225  SetCorrectAnswerSuccess,
     
    144137    );
    145138  });
    146 
    147   respondToAnswer$ = createEffect(() => {
    148     return this.actions$.pipe(
    149       ofType<RespondToAnswer>(QuestionActionTypes.RespondToAnswer),
    150       mergeMap((action) => {
    151         return this.api
    152           .post<AnswerResponseQuestionStateResponse>(
    153             `v1/questions/${action.questionUid}/answers/${action.answerUid}/answerresponses`,
    154             new RespondToAnswerRequest(action.text)
    155           )
    156           .pipe(
    157             tap((state) => this.notification.successNotification('success-answer-response')),
    158             switchMap((state) => [
    159               new RespondToAnswerSuccess(QuestionMapper.ToAnswerResponseQuestionStateViewModel(state), action.answerUid),
    160               new EffectFinishedWorking()
    161             ]),
    162             catchError((err) => [new EffectFinishedWorkingError(err)])
    163           );
    164       })
    165     );
    166   });
    167139}
  • src/Clients/Angular/finki-chattery/src/app/core/state/question-state/question.mapper.ts

    rdd264cb r91bfcf4  
    1414} from 'src/app/shared-app/models';
    1515import { TranslateFromJsonService } from 'src/app/shared-app/services';
    16 import {
    17   AnswerResponseQuestionStateResponse,
    18   PreviewQuestionResponse,
    19   QuestionStateResponse,
    20   VoteAnswerResponse
    21 } from './question-state-response.models';
     16import { PreviewQuestionResponse, QuestionStateResponse, VoteAnswerResponse } from './question-state-response.models';
    2217
    2318export class QuestionMapper {
     
    123118    return new VoteAnswerViewModel(response.answerUid, response.voteUid, response.voteType);
    124119  }
    125 
    126   public static ToAnswerResponseQuestionStateViewModel(
    127     response: AnswerResponseQuestionStateResponse
    128   ): AnswerResponseQuestionStateViewModel {
    129     const answerResponseStudent = new AnswerResponseStudentQuestionStateViewModel(
    130       response.studentResponse.uid,
    131       response.studentResponse.index,
    132       response.studentResponse.imageUrl,
    133       response.studentResponse.reputation
    134     );
    135 
    136     return new AnswerResponseQuestionStateViewModel(response.uid, response.text, moment(response.createdOn), answerResponseStudent);
    137   }
    138120}
  • src/Clients/Angular/finki-chattery/src/app/core/state/question-state/question.reducers.ts

    rdd264cb r91bfcf4  
    9090      };
    9191    }
    92     case QuestionActionTypes.RespondToAnswerSuccess: {
    93       if (state.question) {
    94         return {
    95           ...state,
    96           question: {
    97             ...state.question,
    98             answers: state.question.answers.map((x) => {
    99               if (x.uid === action.answerUid) {
    100                 return {
    101                   ...x,
    102                   answerResponses: [...x.answerResponses, action.payload]
    103                 };
    104               }
    105 
    106               return x;
    107             })
    108           }
    109         };
    110       }
    111 
    112       return {
    113         ...state
    114       };
    115     }
    11692    case QuestionActionTypes.EffectStartedWorking: {
    11793      return {
  • src/Clients/Angular/finki-chattery/src/app/shared-app/components/components.ts

    rdd264cb r91bfcf4  
    99import { PreviewQuestionFullComponent } from './question/preview-question-full/preview-question-full.component';
    1010import { QuestionPreviewComponent } from './question/question-preview/question-preview.component';
    11 import { RespondToAnswerDialogComponent } from './question/respond-to-answer-dialog/respond-to-answer-dialog.component';
    1211import { SearchQuestionComponent } from './question/search-question/search-question.component';
    1312import { StudentCardComponent } from './question/student-card/student-card.component';
     
    2524  AskQuestionSharedComponent,
    2625  PreviewQuestionFullComponent,
    27   TextEditorComponent,
    28   RespondToAnswerDialogComponent
     26  TextEditorComponent
    2927];
  • src/Clients/Angular/finki-chattery/src/app/shared-app/components/question/question-preview/question-preview.component.html

    rdd264cb r91bfcf4  
    4545            <div *ngFor="let answerResponse of answer.answerResponses">
    4646              {{ answerResponse.text }}
    47               <mat-chip class="cursor">{{ answerResponse.student.index }}</mat-chip> -
     47              <mat-chip class="cursor" selected>{{ answerResponse.student.index }}</mat-chip> -
    4848              {{ answerResponse.createdOn | momentDate: 'LL' }}
    4949              <hr />
     
    5252        </div>
    5353      </mat-card-content>
    54       <mat-card-actions>
    55         <app-button (action)="openRespondToAnswerDialog(answer.uid)" [buttonType]="ButtonType.Basic">{{
    56           'question-preview-respond-to-answer-button' | translate
    57         }}</app-button>
    58       </mat-card-actions>
     54      <mat-card-actions> </mat-card-actions>
    5955    </mat-card>
    6056  </ng-container>
  • src/Clients/Angular/finki-chattery/src/app/shared-app/components/question/question-preview/question-preview.component.ts

    rdd264cb r91bfcf4  
    55
    66import { QuestionStateViewModel, VoteType } from 'src/app/shared-app/models';
    7 import { SharedDialogService } from 'src/app/shared-app/services/shared-dialog.service';
    87import { ButtonType } from '../../generic/button/button.models';
    98
     
    1817  working = true;
    1918  ButtonType = ButtonType;
    20   constructor(
    21     private questionFacade: QuestionFacadeService,
    22     private notification: NotificationService,
    23     private dialog: SharedDialogService
    24   ) {}
     19  constructor(private questionFacade: QuestionFacadeService, private notification: NotificationService) {}
    2520
    2621  ngOnInit(): void {
     
    4439    this.questionFacade.setCorrectAnswer(questionUid, answerUid);
    4540  }
    46 
    47   openRespondToAnswerDialog(answerUid: string): void {
    48     this.dialog.respondToAnswer(this.question.uid, answerUid);
    49   }
    5041}
  • src/Clients/Angular/finki-chattery/src/assets/translations/en.json

    rdd264cb r91bfcf4  
    5555  "sucess-vote": "Successfully voted answer",
    5656  "success-correct-answer": "Successfully set correct answer",
    57   "success-answer-response": "Successfully responded to answer",
    5857  "ask-question-ask-button": "Ask question",
    59   "question-preview-respond-to-answer-button": "Respond to answer",
    60   "respond-to-answer-title": "Respond to answer",
    61   "respond-to-answer-title-text-placeholder": "Response text",
    62   "close-button": "Close",
    63   "submit-button": "Submit",
    6458  "AnswerAlreadyUpvoted": "You have already upvoted this answer",
    6559  "AnswerAlreadyDownvoted": "You have already downvoted this answer",
  • src/FinkiChattery/FinkiChattery.Api/ApplicationServices/Questioning/Mapper/QuestionMapper.cs

    rdd264cb r91bfcf4  
    4848                            var answerResponseStudent = new AnswerResponseStudentQuestionStateResponse(y.StudentDto.Id, y.StudentDto.Uid, y.StudentDto.Index, y.StudentDto.ImageUrl, y.StudentDto.Reputation);
    4949
    50                             return ToAnswerResponseQuestionStateResponse(y);
     50                            return new AnswerResponseQuestionStateResponse(y.Id, y.Uid, y.Text, y.CreatedOn, answerResponseStudent);
    5151                        });
    5252                    }
     
    7676            return new QuestionStateResponse(questionState.Id, questionState.Uid, questionState.Title, questionState.Text, questionState.CreatedOn, questionState.Views, questionState.LastActiveOn, student, answers, questionCategories, team);
    7777        }
    78 
    79         public static AnswerResponseQuestionStateResponse ToAnswerResponseQuestionStateResponse(this AnswerResponseQuestionStateDto dto)
    80         {
    81             var answerResponseStudent = new AnswerResponseStudentQuestionStateResponse(dto.StudentDto.Id, dto.StudentDto.Uid, dto.StudentDto.Index, dto.StudentDto.ImageUrl, dto.StudentDto.Reputation);
    82 
    83             return new AnswerResponseQuestionStateResponse(dto.Id, dto.Uid, dto.Text, dto.CreatedOn, answerResponseStudent);
    84         }
    8578    }
    8679}
  • src/FinkiChattery/FinkiChattery.Commands/Questioning/QuestioningErrorCodes.cs

    rdd264cb r91bfcf4  
    77        public const string QuestionTitleLengthInvalid = "QuestionTitleLengthInvalid";
    88        public const string QuestionTextLengthInvalid = "QuestionTextLengthInvalid";
    9         public const string AnswerResponseTextLengthInvalid = "AnswerResponseTextLengthInvalid";
    109        public const string CategoriesDontExist = "CategoriesDontExist";
    1110        public const string TeamDontExist = "TeamDontExist";
  • src/FinkiChattery/FinkiChattery.Commands/Questioning/Validators/QuestioningFluentValidationRules.cs

    rdd264cb r91bfcf4  
    1616        }
    1717
    18         public static IRuleBuilderOptions<T, string> AnswerResponseTextValidate<T>(this IRuleBuilder<T, string> ruleBuilder)
    19         {
    20             return ruleBuilder.NotNull().WithMessage(QuestioningErrorCodes.CantBeNull).MaximumLength(4000).WithMessage(QuestioningErrorCodes.AnswerResponseTextLengthInvalid);
    21         }
    22 
    2318        public static IRuleBuilderOptions<T, string> AnswerTextValidate<T>(this IRuleBuilder<T, string> ruleBuilder)
    2419        {
  • src/FinkiChattery/FinkiChattery.Persistence/Models/AnswerResponse.cs

    rdd264cb r91bfcf4  
    11using System;
     2using System.Collections.Generic;
     3using System.Linq;
     4using System.Text;
     5using System.Threading.Tasks;
    26
    37namespace FinkiChattery.Persistence.Models
     
    59    public class AnswerResponse : BaseEntity
    610    {
    7         public AnswerResponse() : base()
    8         {
    9             CreatedOn = DateTime.UtcNow;
    10         }
    11 
    1211        public string Text { get; set; }
    1312
  • src/FinkiChattery/FinkiChattery.Persistence/UnitOfWork/Contracts/IUnitOfWork.cs

    rdd264cb r91bfcf4  
    1515        ITeacherRepo Teachers { get; }
    1616        IModeratorRepo Moderators { get; }
    17         IAnswerResponseRepo AnswerResponses { get; }
    1817        Task<int> SaveAsync();
    1918    }
  • src/FinkiChattery/FinkiChattery.Persistence/UnitOfWork/Implementations/UnitOfWork.cs

    rdd264cb r91bfcf4  
    1616        private ModeratorRepo _moderators;
    1717        private TeacherRepo _teachers;
    18         private AnswerResponseRepo _answerResponses;
    1918
    2019        public UnitOfWork(ApplicationDbContext dbContext)
    2120        {
    2221            DbContext = dbContext;
    23         }
    24 
    25         public IAnswerResponseRepo AnswerResponses
    26         {
    27             get
    28             {
    29                 if (_answerResponses == null)
    30                 {
    31                     _answerResponses = new AnswerResponseRepo(DbContext);
    32                 }
    33 
    34                 return _answerResponses;
    35             }
    3622        }
    3723
Note: See TracChangeset for help on using the changeset viewer.