@universis/evaluations 1.0.19 → 1.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -46,23 +46,32 @@ class EvaluationEvent extends DataObject {
46
46
  // get evaluation key
47
47
  const token = await EvaluationAccessToken.inspect(context, context.user && context.user.authenticationToken);
48
48
  if (token.active === false) {
49
- throw new HttpTokenExpiredError('Evaluation access token has been expired or is invalid.');
49
+ throw new HttpTokenExpiredError(context.__('Evaluation access token has been expired or is invalid.'));
50
50
  }
51
51
  // get evaluation event
52
52
  // get current date
53
53
  let evaluationEvent = await context.model('EvaluationEvent')
54
54
  .where('id').equal(token.sub)
55
- .and('eventStatus/alternateName').equal('EventOpened')
55
+ .expand('eventStatus')
56
56
  .silent().getTypedItem();
57
57
  if (evaluationEvent == null) {
58
58
  throw new HttpNotFoundError('The specified evaluation cannot be found');
59
59
  }
60
+ if (evaluationEvent.eventStatus )
61
+ {
62
+ if (evaluationEvent.eventStatus.alternateName!=='EventOpened') {
63
+ throw new DataError('E_CLOSED_EVENT',context.__('The course evaluation has been closed and is no longer available') );
64
+ }
65
+ }
60
66
  // check dates
61
67
  const currentDate = new Date().setHours(0,0,0,0);
62
68
  const startDate = evaluationEvent.startDate.setHours(0,0,0,0);
63
69
  const endDate = evaluationEvent.endDate.setHours(0,0,0,0);
64
- if (startDate>currentDate || endDate<currentDate) {
65
- throw new HttpNotFoundError('The specified evaluation cannot be found, it is expired or not started.');
70
+ if (currentDate < startDate) {
71
+ throw new DataError('E_NOT_STARTED',context.__('Evaluation period for this course has not been started yet'));
72
+ }
73
+ if (currentDate > endDate) {
74
+ throw new DataError('E_EXPIRED',context.__('Evaluation period for this course has been expired'));
66
75
  }
67
76
  if (evaluationEvent.additionalType !== 'EvaluationEvent') {
68
77
  if (evaluationEvent.additionalType === 'ClassInstructorEvaluationEvent') {