Commit 4c3d7742 authored by mathieso's avatar mathieso

Bug fixes. Getting ready for the class refactor. Blah.

parent 98a47860
......@@ -9,12 +9,12 @@ X - initial valuies of new config flags and shit.
? Trimmed date format
# user editing
? Students can't see/edit their first/last name.
# SUbmission delays - user confidence
When submit, can be slow, tell user that something is happening.
# Exercise
Same for showing the exercise in the first place.
# Subm
......@@ -94,6 +94,11 @@ Check progress score computation, and reports for instructor.
# Grading interface
When grader can't see names, what happens generate message containing names?
- Maybe turn off the names thing for now.
Override completed - set when needs work.
? During fetching data for the interface, only include classes in student data
that the grader has access to.
......
......@@ -4,13 +4,13 @@ services:
arguments: [ '@entity_type.manager', '@date.formatter', '@module_handler', '@user.data', '@path.current', '@current_route_match', '@messenger']
skilling.current_class:
class: Drupal\skilling\CurrentClass
arguments: [ '@entity_type.manager', '@user.data', '@skilling.utilities', '@skilling.skilling_current_user', '@skilling.class']
arguments: [ '@entity_type.manager', '@user.data', '@skilling.utilities', '@skilling.skilling_current_user', '@skilling.class_utilities']
skilling.skillingparser:
class: Drupal\skilling\SkillingParser\SkillingParser
arguments: ['@token', '@entity_type.manager', '@skilling.utilities', '@skilling.skilling_current_user', '@skilling.skilling_user_factory', '@skilling.ajax_security']
skilling.submissions:
class: Drupal\skilling\Submissions
arguments: ['@entity_type.manager', '@skilling.skilling_current_user', '@skilling.utilities', '@skilling.current_class', '@config.factory', '@skilling.nid_bag', '@skilling.skillingparser', '@skilling.filter_user_input', '@skilling.class']
arguments: ['@entity_type.manager', '@skilling.skilling_current_user', '@skilling.utilities', '@skilling.current_class', '@config.factory', '@skilling.nid_bag', '@skilling.skillingparser', '@skilling.filter_user_input', '@skilling.class_utilities']
plugin.manager.skilling.custom_tag:
class: Drupal\skilling\Plugin\SkillingCustomTagManager
parent: default_plugin_manager
......@@ -120,8 +120,8 @@ services:
skilling.field_access_special_case_checker:
class: Drupal\skilling\Access\FieldAccessSpecialCaseChecker
arguments: ['@path.validator', '@path.current', '@skilling.skilling_current_user', '@request_stack', '@skilling.utilities']
skilling.class:
class: Drupal\skilling\SkillingClass
skilling.class_utilities:
class: Drupal\skilling\SkillingClassUtilities
arguments: ['@entity_type.manager', '@skilling.utilities', '@skilling.skilling_current_user', '@messenger']
skilling.notice:
class: Drupal\skilling\Notice
......
......@@ -4,7 +4,7 @@ namespace Drupal\skilling\Access;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\skilling\SkillingClass;
use Drupal\skilling\SkillingClassUtilities;
use Drupal\skilling\SkillingConstants;
use Drupal\skilling\SkillingUser;
use Drupal\skilling\SkillingUserFactory;
......
......@@ -81,7 +81,7 @@ class ListsController extends ControllerBase {
$view = Views::getView('exercises');
$result['view'] = $this->t('Exercises view embed error.');
if (is_object($view)) {
$display = is_null($this->currentClass->getCurrentClass())
$display = is_null($this->currentClass->getWrappedDrupalClassNode())
? 'no_current_class' // User has no current classs.
: 'with_current_class';
$view->setDisplay($display);
......
......@@ -6,7 +6,7 @@ use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\skilling\Access\FilterUserInputInterface;
use Drupal\skilling\Access\SkillingAjaxSecurityInterface;
use Drupal\skilling\SkillingClass;
use Drupal\skilling\SkillingClassUtilities;
use Drupal\skilling\SkillingConstants;
use Drupal\skilling_history\History;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -72,9 +72,9 @@ class YourClassController extends ControllerBase {
/**
* The Skilling class service.
*
* @var \Drupal\skilling\SkillingClass
* @var \Drupal\skilling\SkillingClassUtilities
*/
protected $skillingClass;
protected $skillingClassUtilities;
/**
* Module handler service.
......@@ -99,7 +99,7 @@ class YourClassController extends ControllerBase {
* @param \Drupal\skilling\Access\SkillingAjaxSecurityInterface $ajaxSecurityService
* AJAX security checking service.
* @param \Drupal\skilling\Access\FilterUserInputInterface $filterInputService
* @param \Drupal\skilling\SkillingClass $skillingClass
* @param \Drupal\skilling\SkillingClassUtilities $skillingClassUtilities
* The current class service.
*/
public function __construct(
......@@ -110,7 +110,7 @@ class YourClassController extends ControllerBase {
History $historyService,
SkillingAjaxSecurityInterface $ajaxSecurityService,
FilterUserInputInterface $filterInputService,
SkillingClass $skillingClass,
SkillingClassUtilities $skillingClassUtilities,
ModuleHandlerInterface $moduleHandler
) {
$this->entityTypeManager = $entity_type_manager;
......@@ -120,7 +120,7 @@ class YourClassController extends ControllerBase {
$this->historyService = $historyService;
$this->ajaxSecurityService = $ajaxSecurityService;
$this->filterInputService = $filterInputService;
$this->skillingClass = $skillingClass;
$this->skillingClassUtilities = $skillingClassUtilities;
$this->moduleHandler = $moduleHandler;
}
......@@ -137,7 +137,7 @@ class YourClassController extends ControllerBase {
$container->get('skilling_history.history'),
$container->get('skilling.ajax_security'),
$container->get('skilling.filter_user_input'),
$container->get('skilling.class'),
$container->get('skilling.class_utilities'),
$container->get('module_handler')
);
}
......@@ -185,7 +185,7 @@ class YourClassController extends ControllerBase {
$instructors = [];
/** @var \Drupal\node\Entity\Node $class */
foreach ($classes as $class) {
$instructorsForClass = $this->skillingClass->getInstructorsForClass($class);
$instructorsForClass = $this->skillingClassUtilities->getInstructorsForClass($class);
foreach ($instructorsForClass as $instructor) {
if (!isset($instructors[$instructor->id()])) {
$instructors[$instructor->id()] = $instructor;
......
......@@ -73,16 +73,16 @@ class CurrentClass {
/**
* The Skilling class service.
*
* @var \Drupal\skilling\SkillingClass
* @var \Drupal\skilling\SkillingClassUtilities
*/
protected $skillingClass;
protected $skillingClassUtilities;
/**
* The current class.
*
* @var \Drupal\node\Entity\Node
*/
protected $currentClass = NULL;
protected $wrappedDrupalClassNode = NULL;
/**
* The current user's current enrollment.
......@@ -118,7 +118,7 @@ class CurrentClass {
* The Skilling utilities service.
* @param \Drupal\skilling\SkillingCurrentUser $skillingCurrentUser
* The Skilling current user service.
* @param \Drupal\skilling\SkillingClass $skillingClass
* @param \Drupal\skilling\SkillingClassUtilities $skillingClassUtilities
* The Skilling class service.
*
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
......@@ -129,14 +129,14 @@ class CurrentClass {
UserDataInterface $userData,
SkillingUtilities $skillingUtilities,
SkillingCurrentUser $skillingCurrentUser,
SkillingClass $skillingClass
SkillingClassUtilities $skillingClassUtilities
) {
// Remember services.
$this->entityTypeManager = $entityTypeManager;
$this->userData = $userData;
$this->skillingUtilities = $skillingUtilities;
$this->skillingCurrentUser = $skillingCurrentUser;
$this->skillingClass = $skillingClass;
$this->skillingClassUtilities = $skillingClassUtilities;
// Set the current class.
if (!$this->skillingCurrentUser->isAnonymous()) {
// User is logged in.
......@@ -145,7 +145,7 @@ class CurrentClass {
// Are there any?
if (count($this->currentEnrollments) === 0) {
// No enrollments for the user.
$this->currentClass = NULL;
$this->wrappedDrupalClassNode = NULL;
$this->currentClasses = [];
$this->currentEnrollments = [];
$this->currentEnrollment = NULL;
......@@ -163,13 +163,13 @@ class CurrentClass {
/** @var \Drupal\node\Entity\Node $enrollment */
$this->currentEnrollment = current($this->currentEnrollments);
/* @noinspection PhpUndefinedFieldInspection */
$this->currentClass = $this->currentEnrollment->field_class->entity;
$this->currentClasses = [$this->currentClass];
$this->wrappedDrupalClassNode = $this->currentEnrollment->field_class->entity;
$this->currentClasses = [$this->wrappedDrupalClassNode];
$this->userData->set(
SkillingConstants::MODULE_NAME,
$this->skillingCurrentUser->id(),
self::CURRENT_CLASS_KEY,
$this->currentClass->id()
$this->wrappedDrupalClassNode->id()
);
}
else {
......@@ -187,8 +187,8 @@ class CurrentClass {
/** @var \Drupal\node\Entity\Node $currentEnrollment */
$this->currentEnrollment = current($this->currentEnrollments);
/* @noinspection PhpUndefinedFieldInspection */
$this->currentClass = $this->currentEnrollment->field_class->entity;
$this->currentClasses = [$this->currentClass];
$this->wrappedDrupalClassNode = $this->currentEnrollment->field_class->entity;
$this->currentClasses = [$this->wrappedDrupalClassNode];
}
else {
// There are multiple enrollments, and there is a class
......@@ -203,7 +203,7 @@ class CurrentClass {
if ($class->id() === $currentClassIdSetting) {
// Found the current class setting in the
// enrolled classes. The setting is good.
$this->currentClass = $class;
$this->wrappedDrupalClassNode = $class;
$this->currentEnrollment = $currentEnrollment;
$settingIsValid = TRUE;
}
......@@ -213,7 +213,7 @@ class CurrentClass {
// class list. Use the first class instead.
reset($this->currentEnrollments);
$this->currentEnrollment = current($this->currentEnrollments);
$this->currentClass = $this->currentEnrollment->field_class->entity;
$this->wrappedDrupalClassNode = $this->currentEnrollment->field_class->entity;
}
}
// Current class is set. Remember its id.
......@@ -221,7 +221,7 @@ class CurrentClass {
SkillingConstants::MODULE_NAME,
$this->skillingCurrentUser->id(),
self::CURRENT_CLASS_KEY,
$this->currentClass->id()
$this->wrappedDrupalClassNode->id()
);
} //End there is more than one enrollment.
} //End there are enrollments.
......@@ -235,7 +235,7 @@ class CurrentClass {
* True if there is a current class.
*/
public function isCurrentClass() {
return !is_null($this->currentClass);
return !is_null($this->wrappedDrupalClassNode);
}
/**
......@@ -247,8 +247,8 @@ class CurrentClass {
* @return \Drupal\node\NodeInterface
* The class.
*/
public function getCurrentClass() {
return $this->currentClass;
public function getWrappedDrupalClassNode() {
return $this->wrappedDrupalClassNode;
}
/**
......@@ -271,7 +271,7 @@ class CurrentClass {
if (!$this->isCurrentClass()) {
return 0;
}
return $this->currentClass->id();
return $this->wrappedDrupalClassNode->id();
}
/**
......@@ -370,7 +370,7 @@ class CurrentClass {
* The tags.
*/
public function getCacheTags() {
return $this->currentClass->getCacheTags();
return $this->wrappedDrupalClassNode->getCacheTags();
}
/**
......@@ -390,11 +390,11 @@ class CurrentClass {
if (!$this->skillingCurrentUser->isStudent()) {
return NULL;
}
if (is_null($this->currentClass)) {
if (is_null($this->wrappedDrupalClassNode)) {
return NULL;
}
/** @var \Drupal\user\Entity\User[] $instructors */
$instructors = $this->skillingClass->getInstructorsForClass($this->currentClass);
$instructors = $this->skillingClassUtilities->getInstructorsForClass($this->wrappedDrupalClassNode);
if (count($instructors) === 0) {
return NULL;
}
......@@ -418,13 +418,13 @@ class CurrentClass {
* @throws \Drupal\skilling\Exception\SkillingException
*/
public function getExerciseDueForExercise($exerciseId) {
if (!$this->currentClass) {
if (!$this->wrappedDrupalClassNode) {
throw new SkillingException(
Html::escape('No current class.'), __FILE__, __LINE__
);
}
return $this->skillingClass->getExerciseDueRecordForExercise(
$this->currentClass, $exerciseId
return $this->skillingClassUtilities->getExerciseDueRecordForExercise(
$this->wrappedDrupalClassNode, $exerciseId
);
}
......@@ -441,12 +441,12 @@ class CurrentClass {
* @throws \Drupal\skilling\Exception\SkillingException
*/
public function getExerciseDues() {
if (!$this->currentClass) {
if (!$this->wrappedDrupalClassNode) {
throw new SkillingException(
Html::escape('No current class.'), __FILE__, __LINE__
);
}
return $this->skillingClass->getExerciseDues($this->currentClass);
return $this->skillingClassUtilities->getExerciseDues($this->wrappedDrupalClassNode);
}
/**
......@@ -454,7 +454,7 @@ class CurrentClass {
* @return mixed
*/
public function getDefaultMaxSubmissions() {
return $this->skillingClass->getDefaultMaxSubmissions($this->currentClass);
return $this->skillingClassUtilities->getDefaultMaxSubmissions($this->wrappedDrupalClassNode);
}
/**
......@@ -464,7 +464,7 @@ class CurrentClass {
* @throws \Drupal\skilling\Exception\SkillingException
*/
public function getMaxSubmissionsAllowedForExercise($exerciseId) {
if (!$this->currentClass) {
if (!$this->wrappedDrupalClassNode) {
throw new SkillingException(
Html::escape('No current class.'), __FILE__, __LINE__
);
......@@ -478,7 +478,7 @@ class CurrentClass {
* @return mixed
*/
public function getStartDate() {
$whenStarts = $this->currentClass
$whenStarts = $this->wrappedDrupalClassNode
->get(SkillingConstants::FIELD_WHEN_STARTS)
->getValue()[0]['value'];
return $whenStarts;
......
......@@ -81,6 +81,8 @@ class Exercises {
* @return array
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
* @throws \Drupal\Core\Entity\EntityStorageException
* @throws \Drupal\skilling\Exception\SkillingException
*/
public function getCourseExerciseSummary() {
$result = [];
......@@ -90,7 +92,7 @@ class Exercises {
}
// Get the class.
/** @var \Drupal\node\Entity\Node $class */
$class = $this->currentClass->getCurrentClass();
$class = $this->currentClass->getWrappedDrupalClassNode();
if (!$class) {
$result['problem_message'] = $this->t('No current class.');
return $result;
......
......@@ -3,12 +3,6 @@
namespace Drupal\skilling\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\skilling\CurrentClass;
use Drupal\skilling\SkillingConstants;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\skilling\Utilities;
use Drupal\Core\Entity\EntityTypeManagerInterface;
/**
* Provides a Skilling footer block.
......
......@@ -8,7 +8,6 @@ use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Render\Renderer;
use Drupal\Core\Session\AccountInterface;
use Drupal\skilling\CurrentClass;
use Drupal\skilling\SkillingConstants;
use Drupal\skilling\SkillingCurrentUser;
use Drupal\skilling\SkillingUserFactory;
use Drupal\skilling\Timeline;
......@@ -77,6 +76,9 @@ class TimelineBlock extends BlockBase implements ContainerFactoryPluginInterface
* @param \Drupal\skilling\Timeline $timelineService
* Timeline service.
* @param \Drupal\skilling\Utilities $utilities
* @param \Drupal\skilling\CurrentClass $current_class
* @param \Drupal\skilling\SkillingUserFactory $userFactory
* @param \Drupal\skilling\SkillingCurrentUser $skillingCurrentUser
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition,
Renderer $renderer,
......@@ -126,7 +128,7 @@ class TimelineBlock extends BlockBase implements ContainerFactoryPluginInterface
}
// Hide block if not a current class.
$canShow = FALSE;
if (!is_null($this->currentClass->getCurrentClass())) {
if (!is_null($this->currentClass->getWrappedDrupalClassNode())) {
$canShow = TRUE;
}
if ($canShow) {
......
......@@ -2,18 +2,11 @@
namespace Drupal\skilling\Plugin\SkillingCustomTag;
use DateTime;
use Drupal\Component\Utility\Html;
use Drupal;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\file\Entity\File;
use Drupal\node\Entity\Node;
use Drupal\skilling\Exception\SkillingException;
use Drupal\skilling\Plugin\SkillingCustomTagBase;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\skilling\SkillingConstants;
use Drupal\skilling\SkillingCurrentUser;
use Drupal\skilling\Submissions;
use Drupal\skilling\Utilities as SkillingUtilities;
use Drupal\skilling\NidBag;
use DateInterval;
/**
......@@ -127,13 +120,13 @@ class ExerciseTag extends SkillingCustomTagBase {
else {
parent::__construct($configuration, $pluginId, $pluginDefinition);
}
$this->entityTypeManager = \Drupal::service('entity_type.manager');
$this->skillingUtilities = \Drupal::service('skilling.utilities');
$this->nidBag = \Drupal::service('skilling.nid_bag');
$this->currentUser = \Drupal::service('skilling.skilling_current_user');
$this->submissionsService = \Drupal::service('skilling.submissions');
$this->currentClass = \Drupal::service('skilling.current_class');
$this->dateFormatter = \Drupal::service('date.formatter');
$this->entityTypeManager = Drupal::service('entity_type.manager');
$this->skillingUtilities = Drupal::service('skilling.utilities');
$this->nidBag = Drupal::service('skilling.nid_bag');
$this->currentUser = Drupal::service('skilling.skilling_current_user');
$this->submissionsService = Drupal::service('skilling.submissions');
$this->currentClass = Drupal::service('skilling.current_class');
$this->dateFormatter = Drupal::service('date.formatter');
}
/**
......@@ -151,8 +144,11 @@ class ExerciseTag extends SkillingCustomTagBase {
*
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
* @throws \Drupal\Core\Entity\EntityStorageException
* @throws \Drupal\skilling\Exception\SkillingException
* @throws \Drupal\skilling\Exception\SkillingParserException
* @throws \Drupal\skilling\Exception\SkillingValueMissingException
* @throws \Exception
*/
public function processTag($content = '', array $options = NULL, Node $nodeWithTag = NULL) {
// Find the name of the exercise.
......@@ -221,7 +217,7 @@ class ExerciseTag extends SkillingCustomTagBase {
$task = $exercise->body->value;
// Check that the parser exists.
if (!$this->parser) {
$this->parser = \Drupal::service('skilling.skillingparser');
$this->parser = Drupal::service('skilling.skillingparser');
}
$task = $this->parser->parse($task);
$renderableSubmissionLinks = $this->submissionsService->createSubmissionLinks($exercise);
......@@ -239,11 +235,11 @@ class ExerciseTag extends SkillingCustomTagBase {
$whenDueDisplay = null;
$numberOfSubmissions = null;
$exerciseSubmissionStatus = null;
if (!is_null($this->currentClass->getCurrentClass())) {
if (!is_null($this->currentClass->getWrappedDrupalClassNode())) {
if ($this->currentUser->isStudent()) {
// Submissions from the user.
$exerciseSubmissionStatus = $this->submissionsService->getSubmissionStatusForStudentExercise(
$this->currentUser, $exerciseId, $this->currentClass
$this->currentUser, $exerciseId, $this->currentClass->getWrappedDrupalClassNode()
);
$numberOfSubmissions = count($renderableSubmissionLinks['submissions']);
}
......@@ -314,7 +310,7 @@ class ExerciseTag extends SkillingCustomTagBase {
],
],
];
$rendered = \Drupal::service('renderer')->render($renderable);
$rendered = Drupal::service('renderer')->render($renderable);
return $rendered;
}
......
......@@ -48,7 +48,7 @@ class ExerciseDueDate extends Drupal\views\Plugin\views\field\Date { //FieldPlu
if ($exercise->bundle() === SkillingConstants::EXERCISE_CONTENT_TYPE) {
/** @var Drupal\skilling\CurrentClass $currentClass */
$currentClass = Drupal::service('skilling.current_class');
if (!is_null($currentClass->getCurrentClass())) {
if (!is_null($currentClass->getWrappedDrupalClassNode())) {
$exerciseDueData
= $currentClass->getExerciseDueForExercise($exercise->id());
if (!is_null($exerciseDueData)) {
......
......@@ -266,7 +266,7 @@ class StudentSubmissionsDataSource extends QueryPluginBase {
->getSubmissionStatusForStudentExercise(
$this->skillingCurrentUser,
$exercise->id(),
$exerciseDue
$this->currentClass->getWrappedDrupalClassNode()
);
if (isset($filters['status'])) {
$valueToFilterFor = $filters['status'][0];
......
......@@ -10,9 +10,11 @@ use Drupal\skilling\Exception\SkillingWrongTypeException;
use Drupal\Core\Messenger\MessengerInterface;
/**
* Class SkillingClass.
* Class SkillingClassUtilities.
*
* Some useful functions for working with class nodes.
*/
class SkillingClass {
class SkillingClassUtilities {
/**
* The entity type manager service.
......@@ -28,13 +30,6 @@ class SkillingClass {
*/
protected $skillingUtilities;
/**
* The current class service.
*
* @var \Drupal\skilling\CurrentClass
*/
protected $skillingCurrentClass;
/**
* The Skilling current user service.
*
......@@ -50,7 +45,7 @@ class SkillingClass {
protected $messenger;
/**
* Constructs a new SkillingClass object.
* Constructs a new SkillingClassUtilities object.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
* Entity type manager service.
......@@ -276,15 +271,15 @@ class SkillingClass {
public function getMaxSubmissionsAllowedForExercise(NodeInterface $class, $exerciseId) {
if (!$class) {
throw new SkillingException(
Html::escape('No current class.'), __FILE__, __LINE__
Html::escape('No class.'), __FILE__, __LINE__
);
}
$exerciseDueRecord = $this->getExerciseDueRecordForExercise($class, $exerciseId);
if (!$exerciseDueRecord) {
$maxSubs = $this->getDefaultMaxSubmissions($class);
if ($exerciseDueRecord) {
$maxSubs = $exerciseDueRecord['maxSubs'];
}
else {
$maxSubs = $exerciseDueRecord->get(SkillingConstants::FIELD_MAX_SUBMISSIONS)->value;
$maxSubs = $this->getDefaultMaxSubmissions($class);
}
return $maxSubs;
}
......
......@@ -4,6 +4,7 @@ namespace Drupal\skilling;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\node\NodeInterface;
use Drupal\skilling\Access\FilterUserInputInterface;
use Drupal\skilling\Exception\SkillingClassRoleException;
use Drupal\skilling\Exception\SkillingException;
......@@ -88,9 +89,9 @@ class Submissions {
/**
* The Skilling class service.
*
* @var \Drupal\skilling\SkillingClass
* @var \Drupal\skilling\SkillingClassUtilities
*/
protected $skillingClass;
protected $skillingClassUtilities;
/**
* Constructor.
......@@ -111,7 +112,7 @@ class Submissions {
* The Skilling parser.
* @param \Drupal\skilling\Access\FilterUserInputInterface $filterInputService
* Input filter service.
* @param \Drupal\skilling\SkillingClass $skillingClass
* @param \Drupal\skilling\SkillingClassUtilities $skillingClassUtilities
* The Skilling class service.
*/
public function __construct(
......@@ -123,7 +124,7 @@ class Submissions {
NidBag $nidBag,
SkillingParser $parser,
FilterUserInputInterface $filterInputService,
SkillingClass $skillingClass
SkillingClassUtilities $skillingClassUtilities
) {
$this->entityTypeManager = $entity_type_manager;
$this->currentUser = $currentUser;
......@@ -133,7 +134,7 @@ class Submissions {
$this->nidBag = $nidBag;
$this->parser = $parser;
$this->filterInputService = $filterInputService;
$this->skillingClass = $skillingClass;
$this->skillingClassUtilities = $skillingClassUtilities;
}
/**
......@@ -531,8 +532,10 @@ class Submissions {
*
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
* @throws \Drupal\Core\Entity\EntityStorageException
* @throws \Drupal\skilling\Exception\SkillingException
* @throws \Drupal\skilling\Exception\SkillingParserException
* @throws \Drupal\skilling\Exception\SkillingValueMissingException
*/
protected function computeSubmissionLinkData(Node $exercise) {
// Is a student?
......@@ -634,10 +637,10 @@ class Submissions {
}
}
$submissionStatus = $this->getSubmissionStatusForStudentExercise(
$this->currentUser,
(int)$exercise->id(),
$exerciseDue
);
$this->currentUser,
(int)$exercise->id(),
$this->currentClass->getWrappedDrupalClassNode()
);
$submissionSummaries['submission_status'] = $submissionStatus;
// Create submission data for each submission.
$submissionSummaries['submissions'] = [];
......@@ -795,6 +798,7 @@ class Submissions {
*
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
* @throws \Drupal\Core\Entity\EntityStorageException
* @throws \Drupal\skilling\Exception\SkillingException
* @throws \Drupal\skilling\Exception\SkillingValueMissingException
* @throws \Drupal\skilling\Exception\SkillingWrongTypeException
......@@ -831,6 +835,7 @@ class Submissions {
*
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
* @throws \Drupal\Core\Entity\EntityStorageException
* @throws \Drupal\skilling\Exception\SkillingException
* @throws \Drupal\skilling\Exception\SkillingValueMissingException
*/
......@@ -879,7 +884,7 @@ class Submissions {
public function getSubmissionStatusForStudentExercise(
SkillingUser $student,
$exerciseNid,
$class
NodeInterface $class
) {
// Is the user a student?
if (!$student->isStudent()) {
......@@ -949,7 +954,7 @@ class Submissions {
}
else {
// Get max submissions allowed for the exercise for the class.
$maxAllowed = $this->skillingClass->getMaxSubmissionsAllowedForExercise(
$maxAllowed = $this->skillingClassUtilities->getMaxSubmissionsAllowedForExercise(
$class, $exerciseNid
);
if ($submissionCountForExercise >= $maxAllowed) {
......
......@@ -87,7 +87,7 @@ class Timeline {
}
// Get the class.
/** @var \Drupal\node\Entity\Node $class */
$class = $this->currentClass->getCurrentClass();
$class = $this->currentClass->getWrappedDrupalClassNode();
if (!$class) {
$problemMessage = $this->t('No current class.');
return [$problemMessage, $eventsForTemplate];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment