Commit 77f194b5 authored by mathieso's avatar mathieso

Making create starter content great again.

parent bc74e7bc
......@@ -2,16 +2,10 @@
Installation
- add new fields
- update stuff
X - add new fields
- test on shared host
- initial valuies of new config flags and shit.
const FIELD_BASE_PROGRESS_ON_REQUIRED_ONLY = "field_base_progress_scores_on_re";
para fields
X - initial valuies of new config flags and shit.
Starter content?
......
......@@ -180,6 +180,8 @@ views.view.history_student.yml ho
field.storage.node.body.yml co
field.storage.node.field_action.yml co
field.storage.node.field_attachments.yml co
field.storage.node.field_badge_image.yml co
field.storage.node.field_base_progress_score_on_req.yml co
field.storage.node.field_caption.yml co
field.storage.node.field_categories.yml co
field.storage.node.field_challenge.yml co
......@@ -203,6 +205,7 @@ field.storage.node.field_hidden_attachments.yml co
field.storage.node.field_image.yml co
field.storage.node.field_internal_name.yml co
field.storage.node.field_initials.yml co
field.storage.node.field_maximum_submissions_per_ex.yml co
field.storage.node.field_message.yml co
field.storage.node.field_needs.yml co
field.storage.node.field_node.yml co
......@@ -221,8 +224,8 @@ field.storage.node.field_rubric_item_responses.yml co
field.storage.node.field_rubric_items.yml co
field.storage.node.field_situation.yml co
field.storage.node.field_solution.yml co
field.storage.node.field_suggestion.yml co
field.storage.node.field_submitted_files.yml co
field.storage.node.field_suggestion.yml co
field.storage.node.field_suggestion_status.yml co
field.storage.node.field_summary.yml co
field.storage.node.field_tags.yml co
......@@ -281,6 +284,7 @@ core.entity_view_display.node.class.teaser.yml co
field.field.node.class.body.yml co
field.field.node.class.field_exercises_due.yml co
field.field.node.class.field_internal_name.yml co
field.field.node.class.field_maximum_submissions_per_ex.yml co
field.field.node.class.field_notes.yml co
field.field.node.class.field_when_starts.yml co
......@@ -301,6 +305,7 @@ core.base_field_override.node.enrollment.promote.yml co
core.entity_form_display.node.enrollment.default.yml co
core.entity_view_display.node.enrollment.default.yml co
core.entity_view_display.node.enrollment.teaser.yml co
field.field.node.enrollment.field_base_progress_score_on_req.yml co
field.field.node.enrollment.field_class.yml co
field.field.node.enrollment.field_class_roles.yml co
field.field.node.enrollment.field_completion_score.yml co
......@@ -348,7 +353,6 @@ field.field.node.lesson.field_attachments.yml co
field.field.node.lesson.field_hidden_attachments.yml co
field.field.node.lesson.field_notes.yml co
field.field.node.lesson.field_order_in_book.yml co
# field.field.node.lesson.field_show_toc.yml co
field.field.node.lesson.field_tags.yml co
# Model
......@@ -393,27 +397,16 @@ core.entity_view_display.node.pattern.default.yml co
core.entity_view_display.node.pattern.teaser.yml co
field.field.node.pattern.field_action.yml co
field.field.node.pattern.field_attachments.yml co
field.field.node.pattern.field_explanation.yml co
field.field.node.pattern.field_internal_name.yml co
field.field.node.pattern.field_needs.yml co
field.field.node.pattern.field_notes.yml co
field.field.node.pattern.field_provides.yml co
field.field.node.pattern.field_explanation.yml co
field.field.node.pattern.field_situation.yml co
field.field.node.pattern.field_summary.yml co
field.field.node.pattern.field_tags.yml co
field.field.node.pattern.field_where_referenced.yml co
# Reflect note
node.type.reflect_note.yml co
core.base_field_override.node.reflect_note.promote.yml co
core.entity_form_display.node.reflect_note.default.yml co
core.entity_view_display.node.reflect_note.default.yml co
core.entity_view_display.node.reflect_note.teaser.yml co
field.field.node.reflect_note.field_internal_name.yml co
field.field.node.reflect_note.field_node.yml co
field.field.node.reflect_note.field_note.yml co
field.field.node.reflect_note.field_notes.yml co
# Principle
node.type.principle.yml co
core.base_field_override.node.principle.promote.yml co
......@@ -427,6 +420,17 @@ field.field.node.principle.field_notes.yml co
field.field.node.principle.field_tags.yml co
field.field.node.principle.field_where_referenced.yml co
# Reflect note
node.type.reflect_note.yml co
core.base_field_override.node.reflect_note.promote.yml co
core.entity_form_display.node.reflect_note.default.yml co
core.entity_view_display.node.reflect_note.default.yml co
core.entity_view_display.node.reflect_note.teaser.yml co
field.field.node.reflect_note.field_internal_name.yml co
field.field.node.reflect_note.field_node.yml co
field.field.node.reflect_note.field_note.yml co
field.field.node.reflect_note.field_notes.yml co
# Rubric item
node.type.rubric_item.yml co
core.base_field_override.node.rubric_item.promote.yml co
......@@ -485,7 +489,9 @@ field.storage.paragraph.field_explanation.yml co
field.storage.paragraph.field_highest_number.yml co
field.storage.paragraph.field_lowest_number.yml co
field.storage.paragraph.field_matching_text_responses.yml co
field.storage.paragraph.field_maximum_submissions.yml co
field.storage.paragraph.field_notes.yml co
field.storage.paragraph.field_required.yml co
field.storage.paragraph.field_response.yml co
field.storage.paragraph.field_response_to_student.yml co
field.storage.paragraph.field_response_type.yml co
......@@ -504,7 +510,8 @@ core.entity_form_display.paragraph.exercise_due.default.yml co
core.entity_view_display.paragraph.exercise_due.default.yml co
field.field.paragraph.exercise_due.field_day.yml
field.field.paragraph.exercise_due.field_exercise.yml
field.field.paragraph.exercise_due.field_maximum_submissions.yml
field.field.paragraph.exercise_due.field_required.yml
# FiB question response
paragraphs.paragraphs_type.fill_in_the_blank_question_respo.yml co
......@@ -542,20 +549,19 @@ field.field.paragraph.rubric_item_response.field_response_to_student.yml co
# BLOCKS
# Blocks for the skillling theme.
# In order they appear on blocks layout.
block.block.badgeblock.yml so
block.block.classselector_2.yml so
block.block.sidebarhiderblock.yml so
block.block.skilling_bootstrap_branding.yml so
block.block.skilling_bootstrap_content.yml so
block.block.skilling_bootstrap_local_actions.yml so
block.block.skilling_bootstrap_local_tasks.yml so
block.block.skilling_bootstrap_main_menu.yml so
block.block.sidebarhiderblock.yml so
block.block.skilling_bootstrap_page_title.yml so
block.block.skilling_bootstrap_messages.yml so
block.block.skilling_bootstrap_local_actions.yml so
block.block.skilling_bootstrap_local_tasks.yml so
block.block.skilling_bootstrap_content.yml so
block.block.skillingfooter.yml so
block.block.timelineblock.yml so
block.block.classselector_2.yml so
block.block.suggestion.yml so
block.block.badgeblock.yml so
# IMCE SETTINGS
imce.profile.admin.yml so
......@@ -575,13 +581,9 @@ taxonomy.vocabulary.rubric_item_categories.yml co
taxonomy.vocabulary.tags.yml co
# VIEWS
#skilling.views.schema.yml so
#views.filter.filter_status.yml so
#views.settings.yml so
views.view.attachments.yml so
views.view.badges_administration.yml so
views.view.badges.yml so
views.view.badges_administration.yml so
views.view.characters_administration.yml so
views.view.characters_grid.yml so
views.view.character_grid_header_list.yml so
......@@ -599,15 +601,13 @@ views.view.exercises_administration.yml so
views.view.fib_administration.yml so
views.view.hidden_attachments.yml so
views.view.history_for_instructor.yml so
views.view.history_student.yml so
views.view.lessons.yml so
views.view.lessons_administration.yml so
# views.view.mcqs.yml so
views.view.models.yml so
views.view.models_administration.yml so
views.view.multiple_choice_questions_administration.yml so
views.view.notices.yml so
#views.view.one_student.yml so
#views.view.one_student_s_details_for_instructor.yml so
views.view.patterns.yml so
views.view.patterns_administration.yml so
views.view.principles.yml so
......@@ -633,6 +633,7 @@ pathauto.pattern.badge.yml co
pathauto.pattern.character.yml co
pathauto.pattern.classes.yml co
pathauto.pattern.design_pages.yml co
pathauto.pattern.enrollment.yml co
pathauto.pattern.exercises.yml co
pathauto.pattern.fill_in_the_blank.yml co
pathauto.pattern.lessons.yml co
......@@ -640,6 +641,10 @@ pathauto.pattern.models.yml co
pathauto.pattern.multiple_choice_question.yml co
pathauto.pattern.pattern.yml co
pathauto.pattern.principle.yml co
pathauto.pattern.reflect_note.yml co
pathauto.pattern.rubric_item.yml co
pathauto.pattern.submission.yml co
pathauto.pattern.suggestion.yml co
system.action.pathauto_update_alias_node.yml co
system.action.pathauto_update_alias_user.yml co
......@@ -652,5 +657,8 @@ search.settings.yml so
system.menu.main.yml so
core.menu.static_menu_link_overrides.yml so
# USERS
user.settings.yml uo
# ??
token_custom.type.custom.yml so
......@@ -564,13 +564,13 @@ skilling.mark_notices_read:
_role: 'authenticated'
#skilling.test_class_exercise:
# path: '/ce'
# defaults:
# _controller: '\Drupal\skilling\Controller\TestController::classExercisesText'
# _title: 'ROSIE!'
# requirements:
# _role: 'authenticated'
skilling.test_tax:
path: '/tax'
defaults:
_controller: '\Drupal\skilling\Controller\TestController::tax'
_title: 'ROSIE!'
requirements:
_role: 'authenticated'
......
......@@ -50,7 +50,7 @@ services:
arguments: ['@entity_type.manager']
skilling.starter.make_starter_content:
class: Drupal\skilling\MakeStarterContent\MakeStarterContent
arguments: ['@skilling.starter.make_nodes', '@skilling.starter.make_users', '@skilling.book_update_tracker', '@messenger']
arguments: ['@skilling.starter.make_nodes', '@skilling.starter.make_users', '@skilling.book_update_tracker', '@messenger', '@entity_type.manager']
skilling.skilling_user_factory:
class: Drupal\skilling\SkillingUserFactory
arguments: ['@entity_type.manager', '@skilling.utilities']
......
......@@ -8,6 +8,7 @@ use Drupal\Core\DependencyInjection\DependencySerializationTrait;
use Drupal\Core\Entity\EntityStorageException;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\File\FileSystem;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Site\Settings;
use Drupal\node\Entity\Node;
......@@ -31,7 +32,8 @@ use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Session\Session;
use Drupal\skilling\Notice;
use Drupal\skilling\SkillingUserFactory;
use Drupal\taxonomy\Entity\Term;
use Drupal\taxonomy\Entity\Vocabulary;
/**
* Class TestController.
......@@ -552,7 +554,69 @@ class TestController extends ControllerBase {
'#markup' => 'Rosie',
];
}
public function tax() {
$maxClassLengthDays = 50;
$r = rand(3, $maxClassLengthDays);
$terms1 = \Drupal::entityManager()->getStorage('taxonomy_term')
->loadTree("myname");
$terms2 = \Drupal::entityManager()->getStorage('taxonomy_term')
->loadTree("tags");
$r=6;
$vid = 'tags';
$termName = 'Dogs';
$term = $this->entityTypeManager->getStorage('taxonomy_term')
->loadByProperties(['name' => $termName, 'vid' => $vid]);
$termName = 'Dogsasdfasd';
$term = $this->entityTypeManager->getStorage('taxonomy_term')
->loadByProperties(['name' => $termName, 'vid' => $vid]);
$vid = 'tags';
$termName = 'ROSIE';
$termId = $this->makeTaxTerm($vid, $termName);
$r = Vocabulary::loadMultiple();
$r=6;
// $new_term = Term::create([
// 'name' => 'Rosie',
// 'vid' => 'bestdogs',
// 'parent' => [],
// ]);
//
// // Save the taxonomy term.
// $new_term->save();
//
// // Return the taxonomy term id.
// $r = $new_term->id();
return [
'#markup' => 'Rosie',
];
}
protected function makeTaxTerm($vid, $termName) {
$term = $this->entityTypeManager->getStorage('taxonomy_term')
->loadByProperties(['name' => $termName, 'vid' => $vid]);
if (count($term) > 0) {
$term = reset($term);
$termId = $term->id();
}
else {
// Create the term.
$term = Term::create([
'name' => $termName,
'vid' => $vid,
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
]);
$term->save();
$termId = $term->id();
}
return $termId;
}
}
......@@ -83,7 +83,7 @@ class ClearCachesForm extends FormBase {
'#type' => 'checkbox',
'#title' => $this->t('Book tree caches'),
'#description' => $this->t(
"Caches for book trees on the right of the screen."
"Caches for book trees, like the lessons tree."
),
);
$form['submit'] = [
......
......@@ -301,12 +301,22 @@ class MakeNodes {
* @throws \Drupal\Core\Entity\EntityStorageException
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
*/
public function makeRubricItemNode($title, User $user, array $rubricItemResponses) {
public function makeRubricItemNode(
$title,
User $user,
$termId,
array $rubricItemResponses
) {
$node = $this->makeNode(
SkillingConstants::RUBRIC_ITEM_CONTENT_TYPE,
$title,
$user,
['field_notes' => 'Dogs are good!']
[
'field_notes' => 'Dogs are good!',
'field_rubric_item_responses' => [
['target_id' => $termId]
],
]
);
$responseParagraphs = [];
foreach ($rubricItemResponses as $rubricItemResponse) {
......@@ -454,6 +464,8 @@ class MakeNodes {
/* @noinspection PhpUndefinedFieldInspection */
$node->field_class_roles[] = $classRole;
}
/* @noinspection PhpUndefinedFieldInspection */
$node->field_base_progress_score_on_req = (rand() > 0.5);
$node->save();
if ($this->interactive) {
$this->messenger()->addStatus(
......@@ -542,6 +554,31 @@ class MakeNodes {
return $node;
}
public function makeExerciseDueParagraph(
NodeInterface $exercise,
$dayDue,
$maxSubmissions,
$required
) {
$exerciseDueParagraph = Paragraph::create(['type' => 'exercise_due']);
$exerciseDueParagraph->set(
SkillingConstants::FIELD_EXERCISE,
[
'target_id' => $exercise->id(),
]
);
$exerciseDueParagraph->set(SkillingConstants::FIELD_DAY, $dayDue);
// $exerciseDueParagraph->setParentEntity(
// $parentClass,
// SkillingConstants::FIELD_EXERCISES_DUE
// );
$exerciseDueParagraph->set(SkillingConstants::FIELD_MAX_SUBMISSIONS, $maxSubmissions);
$exerciseDueParagraph->set(SkillingConstants::FIELD_REQUIRED, $required);
$exerciseDueParagraph->isNew();
$exerciseDueParagraph->save();
return $exerciseDueParagraph;
}
/**
* Make an event.
*
......@@ -567,63 +604,63 @@ class MakeNodes {
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
* @throws \Drupal\Core\Entity\EntityStorageException
*/
public function makeEvent($title, $type, $summary, $details, $exercise, $notes, User $owner) {
/** @var \Drupal\node\Entity\Node $node */
$node = NULL;
$nodes = $this->entityTypeManager
->getStorage('node')
->loadByProperties([
'type' => SkillingConstants::EVENT_CONTENT_TYPE,
'title' => (string) $title,
]);
// Does the node exist?
if (count($nodes) > 0) {
// Yes.
$node = reset($nodes);
if ($this->interactive) {
$status = t('Used existing @t',
['@t' => SkillingConstants::EVENT_CONTENT_TYPE]);
$this->messenger()->addStatus($status . $node->getTitle());
}
}
else {
// Create a node.
$node = $this->entityTypeManager
->getStorage('node')
->create(['type' => SkillingConstants::EVENT_CONTENT_TYPE]);
$node->set('title', $title);
// Owner of node is student.
$node->set('uid', $owner->id());
/* @noinspection PhpUndefinedFieldInspection */
$node->field_event_type = $type;
/* @noinspection PhpUndefinedFieldInspection */
$node->body = $details;
/* @noinspection PhpUndefinedFieldInspection */
$node->body->summary = $summary;
/* @noinspection PhpUndefinedFieldInspection */
$node->body->format = SkillingConstants::STRIPPED_TEXT_FORMAT;
/* @noinspection PhpUndefinedFieldInspection */
$node->field_notes->value = $notes;
/* @noinspection PhpUndefinedFieldInspection */
$node->field_notes->format = SkillingConstants::STRIPPED_TEXT_FORMAT;
if ($type === SkillingConstants::EVENT_TYPE_EXERCISE_DUE) {
/* @noinspection PhpUndefinedFieldInspection */
$node->field_exercise->target_id = $exercise->id();
}
$node->save();
if ($this->interactive) {
$this->messenger()->addStatus(
t('Created new @type: @title',
[
'@type' => SkillingConstants::EVENT_CONTENT_TYPE,
'@title' => $title,
]
)
);
}
}
return $node;
}
// public function makeEvent($title, $type, $summary, $details, $exercise, $notes, User $owner) {
// /** @var \Drupal\node\Entity\Node $node */
// $node = NULL;
// $nodes = $this->entityTypeManager
// ->getStorage('node')
// ->loadByProperties([
// 'type' => SkillingConstants::EVENT_CONTENT_TYPE,
// 'title' => (string) $title,
// ]);
// // Does the node exist?
// if (count($nodes) > 0) {
// // Yes.
// $node = reset($nodes);
// if ($this->interactive) {
// $status = t('Used existing @t',
// ['@t' => SkillingConstants::EVENT_CONTENT_TYPE]);
// $this->messenger()->addStatus($status . $node->getTitle());
// }
// }
// else {
// // Create a node.
// $node = $this->entityTypeManager
// ->getStorage('node')
// ->create(['type' => SkillingConstants::EVENT_CONTENT_TYPE]);
// $node->set('title', $title);
// // Owner of node is student.
// $node->set('uid', $owner->id());
// /* @noinspection PhpUndefinedFieldInspection */
// $node->field_event_type = $type;
// /* @noinspection PhpUndefinedFieldInspection */
// $node->body = $details;
// /* @noinspection PhpUndefinedFieldInspection */
// $node->body->summary = $summary;
// /* @noinspection PhpUndefinedFieldInspection */
// $node->body->format = SkillingConstants::STRIPPED_TEXT_FORMAT;
// /* @noinspection PhpUndefinedFieldInspection */
// $node->field_notes->value = $notes;
// /* @noinspection PhpUndefinedFieldInspection */
// $node->field_notes->format = SkillingConstants::STRIPPED_TEXT_FORMAT;
// if ($type === SkillingConstants::EVENT_TYPE_EXERCISE_DUE) {
// /* @noinspection PhpUndefinedFieldInspection */
// $node->field_exercise->target_id = $exercise->id();
// }
// $node->save();
// if ($this->interactive) {
// $this->messenger()->addStatus(
// t('Created new @type: @title',
// [
// '@type' => SkillingConstants::EVENT_CONTENT_TYPE,
// '@title' => $title,
// ]
// )
// );
// }
// }
// return $node;
// }
/**
* Add an event to a calendar.
......
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