(function () {
	'use strict';

	Meteor.methods(
		{
			saveExecution(execution){
				check(execution, Match.ObjectIncluding(
					{
						examination_id: String,
						names: [Match.ObjectIncluding({ language: String, name: String })],
						descriptions: [Match.ObjectIncluding({ language: String, description: String })],
						durationMinutes: Match.Integer,
						exercises: [Match.ObjectIncluding({ base_id: String, weight: Number })]
					}));

				const _examination = execution._id ? Progressor.examinations.findOne({ _id: execution._id }) : execution;

				if (!this.userId)
					throw new Meteor.Error('not-authenticated', i18n.forUser('error.notAuthenticated.message', this.userId));
				else if (_examination._id && _examination.author_id !== this.userId && !Roles.userIsInRole(this.userId, Progressor.ROLE_ADMIN))
					throw new Meteor.Error('not-owner', i18n.forUser('error.notAuthor.message', this.userId));
				else if (_examination._id && _examination.released && _examination.released.requested && !Roles.userIsInRole(this.userId, Progressor.ROLE_ADMIN))
					throw new Meteor.Error('not-admin', i18n.forUser('error.notAdmin.message', this.userId));

				if (!execution.author_id)
					execution.author_id = this.userId;
				execution.lastEditor_id = this.userId;
				execution.lastEdited = new Date();

				return Progressor.examinations.upsert(execution._id, execution).insertedId || execution._id;
			},
			deleteExecution(execution) {
				check(execution, Match.ObjectIncluding({ _id: String }));

				if (execution._id)
					execution = Progressor.examinations.findOne({ _id: execution._id });

				if (!this.userId)
					throw new Meteor.Error('not-authenticated', i18n.forUser('error.notAuthenticated.message', this.userId));
				else if (execution._id && execution.author_id !== this.userId && !Roles.userIsInRole(this.userId, Progressor.ROLE_ADMIN))
					throw new Meteor.Error('not-owner', i18n.forUser('error.notAuthor.message', this.userId));

				return Progressor.examinations.remove(execution._id).rowsAffected;
			},
			startExecution(execution) {
				check(execution, Match.ObjectIncluding({ _id: String }));

				if (execution._id)
					execution = Progressor.examinations.findOne({ _id: execution._id });

				if (!this.userId)
					throw new Meteor.Error('not-authenticated', i18n.forUser('error.notAuthenticated.message', this.userId));
				else if (execution._id && execution.author_id !== this.userId && !Roles.userIsInRole(this.userId, Progressor.ROLE_ADMIN))
					throw new Meteor.Error('not-owner', i18n.forUser('error.notAuthor.message', this.userId));

				return Progressor.examinations.update(execution._id, {
					$set: {
						startTime: new Date(),
						exercises: _.match(execution.exercises, exercise => _.extend(exercise, {
							exercise_id: Progressor.exercises.insert(_.omit(exercise, '_id', 'category_id', 'difficulty')).insertedId
						}))
					}
				}).rowsAffected;
			}
		});

})();

@@ -457,25 +457,24 @@
 onst _ex
-amina
+ecu
 tion
+s
  = execu
@@ -489,37 +489,35 @@
  ? Progressor.ex
-amina
+ecu
 tions.findOne(%7B 
@@ -697,33 +697,32 @@
 else if (_ex
-amina
+ecu
 tion
+s
 ._id && _exa
@@ -720,25 +720,24 @@
 d && _ex
-amina
+ecu
 tion
+s
 .author_
@@ -927,25 +927,24 @@
  if (_ex
-amina
+ecu
 tion
+s
 ._id && 
@@ -942,33 +942,32 @@
 s._id && _ex
-amina
+ecu
 tion
+s
 .released &&
@@ -970,25 +970,24 @@
 d && _ex
-amina
+ecu
 tion
+s
 .release
@@ -1323,37 +1323,35 @@
 rn Progressor.ex
-amina
+ecu
 tions.upsert(exe
@@ -1548,37 +1548,35 @@
  = Progressor.ex
-amina
+ecu
 tions.findOne(%7B 
@@ -1975,29 +1975,27 @@
 rogressor.ex
-amina
+ecu
 tions.remove
@@ -2173,29 +2173,27 @@
 rogressor.ex
-amina
+ecu
 tions.findOn
@@ -2600,21 +2600,19 @@
 essor.ex
-amina
+ecu
 tions.up
@@ -2696,19 +2696,17 @@
 es: _.ma
-tch
+p
 (executi
@@ -2806,57 +2806,155 @@
 t(_.
-omit(exercise, '_id', 'category_id', 'difficulty'
+extend(_.omit(Progressor.exercises.find(%7B _id: exercise._id %7D), '_id', 'category_id', 'difficulty'), %7B%0A%09%09%09%09%09%09%09%09execution_id: execution._id%0A%09%09%09%09%09%09%09%7D
 )).i

fix execution methods