Importă un pachet de curs
Importă un curs format din lecturi, o listă de verificare și un test, apoi confirmă apariția lui în catalog.
Pregătește pachetul
Alege un ID nou pentru curs și câte un ID distinct pentru fiecare lecție. Pune textul unei lecturi în body, punctele listei de verificare în items, iar întrebările testului în questions, împreună cu passingAnswers și maxAttempts. Ordonează lecțiile în ordinea parcurgerii, cu testul la sfârșit, și trece minutele fiecăreia în minutes. Trimite documentul JSON cu revizia zero și un UUID nou pentru operație.
curl
curl -X POST "$RDC_BASE_URL/elearning/v1/course-packages" \
-H "Authorization: Bearer $RDC_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"operationId": "4e08713a-ec34-4a5a-92d3-81fd42564001",
"expectedRevision": 0,
"id": "receiving-review",
"title": "Receiving review",
"validityDays": 365,
"lessons": [
{
"id": "delivery-note",
"kind": "reading",
"minutes": 2,
"title": "Check the note",
"body": "Match the delivery note against the purchase order before accepting the delivery.\n\nKeep damaged goods in the receiving area and tell purchasing the same day."
},
{
"id": "delivery-checklist",
"kind": "checklist",
"minutes": 1,
"title": "Before you accept",
"items": [
"Match the note and the order.",
"Count and inspect the cases.",
"Record the discrepancy before put-away."
]
},
{
"id": "delivery-quiz",
"kind": "quiz",
"minutes": 2,
"title": "Delivery quiz",
"maxAttempts": 3,
"passingAnswers": 2,
"questions": [
{
"prompt": "What do you match against the purchase order?",
"choices": [
"Delivery note",
"Shelf label"
],
"correct": 0
},
{
"prompt": "Where do damaged cases stay?",
"choices": [
"On the picking shelf",
"In the receiving area"
],
"correct": 1
},
{
"prompt": "When do you put away the accepted quantity?",
"choices": [
"After recording it",
"Before counting it"
],
"correct": 0
}
]
}
]
}' JavaScript
const response = await fetch(`${process.env.RDC_BASE_URL}/elearning/v1/course-packages`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.RDC_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"operationId": "4e08713a-ec34-4a5a-92d3-81fd42564001",
"expectedRevision": 0,
"id": "receiving-review",
"title": "Receiving review",
"validityDays": 365,
"lessons": [
{
"id": "delivery-note",
"kind": "reading",
"minutes": 2,
"title": "Check the note",
"body": "Match the delivery note against the purchase order before accepting the delivery.\n\nKeep damaged goods in the receiving area and tell purchasing the same day."
},
{
"id": "delivery-checklist",
"kind": "checklist",
"minutes": 1,
"title": "Before you accept",
"items": [
"Match the note and the order.",
"Count and inspect the cases.",
"Record the discrepancy before put-away."
]
},
{
"id": "delivery-quiz",
"kind": "quiz",
"minutes": 2,
"title": "Delivery quiz",
"maxAttempts": 3,
"passingAnswers": 2,
"questions": [
{
"prompt": "What do you match against the purchase order?",
"choices": [
"Delivery note",
"Shelf label"
],
"correct": 0
},
{
"prompt": "Where do damaged cases stay?",
"choices": [
"On the picking shelf",
"In the receiving area"
],
"correct": 1
},
{
"prompt": "When do you put away the accepted quantity?",
"choices": [
"After recording it",
"Before counting it"
],
"correct": 0
}
]
}
]
}),
});
const result = await response.json(); Python
import os
import requests
response = requests.request(
'POST',
f'{os.environ["RDC_BASE_URL"]}/elearning/v1/course-packages',
headers={
'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
},
json={
'operationId': '4e08713a-ec34-4a5a-92d3-81fd42564001',
'expectedRevision': 0,
'id': 'receiving-review',
'title': 'Receiving review',
'validityDays': 365,
'lessons': [
{
'id': 'delivery-note',
'kind': 'reading',
'minutes': 2,
'title': 'Check the note',
'body': 'Match the delivery note against the purchase order before accepting the delivery.
Keep damaged goods in the receiving area and tell purchasing the same day.',
},
{
'id': 'delivery-checklist',
'kind': 'checklist',
'minutes': 1,
'title': 'Before you accept',
'items': [
'Match the note and the order.',
'Count and inspect the cases.',
'Record the discrepancy before put-away.',
],
},
{
'id': 'delivery-quiz',
'kind': 'quiz',
'minutes': 2,
'title': 'Delivery quiz',
'maxAttempts': 3,
'passingAnswers': 2,
'questions': [
{
'prompt': 'What do you match against the purchase order?',
'choices': [
'Delivery note',
'Shelf label',
],
'correct': 0,
},
{
'prompt': 'Where do damaged cases stay?',
'choices': [
'On the picking shelf',
'In the receiving area',
],
'correct': 1,
},
{
'prompt': 'When do you put away the accepted quantity?',
'choices': [
'After recording it',
'Before counting it',
],
'correct': 0,
},
],
},
],
},
)
result = response.json() PHP
<?php
$body = <<<'JSON'
{
"operationId": "4e08713a-ec34-4a5a-92d3-81fd42564001",
"expectedRevision": 0,
"id": "receiving-review",
"title": "Receiving review",
"validityDays": 365,
"lessons": [
{
"id": "delivery-note",
"kind": "reading",
"minutes": 2,
"title": "Check the note",
"body": "Match the delivery note against the purchase order before accepting the delivery.\n\nKeep damaged goods in the receiving area and tell purchasing the same day."
},
{
"id": "delivery-checklist",
"kind": "checklist",
"minutes": 1,
"title": "Before you accept",
"items": [
"Match the note and the order.",
"Count and inspect the cases.",
"Record the discrepancy before put-away."
]
},
{
"id": "delivery-quiz",
"kind": "quiz",
"minutes": 2,
"title": "Delivery quiz",
"maxAttempts": 3,
"passingAnswers": 2,
"questions": [
{
"prompt": "What do you match against the purchase order?",
"choices": [
"Delivery note",
"Shelf label"
],
"correct": 0
},
{
"prompt": "Where do damaged cases stay?",
"choices": [
"On the picking shelf",
"In the receiving area"
],
"correct": 1
},
{
"prompt": "When do you put away the accepted quantity?",
"choices": [
"After recording it",
"Before counting it"
],
"correct": 0
}
]
}
]
}
JSON;
$curl = curl_init(getenv('RDC_BASE_URL') . '/elearning/v1/course-packages');
curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('RDC_TOKEN'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => $body,
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl); C#
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/elearning/v1/course-packages");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
"operationId": "4e08713a-ec34-4a5a-92d3-81fd42564001",
"expectedRevision": 0,
"id": "receiving-review",
"title": "Receiving review",
"validityDays": 365,
"lessons": [
{
"id": "delivery-note",
"kind": "reading",
"minutes": 2,
"title": "Check the note",
"body": "Match the delivery note against the purchase order before accepting the delivery.\n\nKeep damaged goods in the receiving area and tell purchasing the same day."
},
{
"id": "delivery-checklist",
"kind": "checklist",
"minutes": 1,
"title": "Before you accept",
"items": [
"Match the note and the order.",
"Count and inspect the cases.",
"Record the discrepancy before put-away."
]
},
{
"id": "delivery-quiz",
"kind": "quiz",
"minutes": 2,
"title": "Delivery quiz",
"maxAttempts": 3,
"passingAnswers": 2,
"questions": [
{
"prompt": "What do you match against the purchase order?",
"choices": [
"Delivery note",
"Shelf label"
],
"correct": 0
},
{
"prompt": "Where do damaged cases stay?",
"choices": [
"On the picking shelf",
"In the receiving area"
],
"correct": 1
},
{
"prompt": "When do you put away the accepted quantity?",
"choices": [
"After recording it",
"Before counting it"
],
"correct": 0
}
]
}
]
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync(); {
"operationId": "4e08713a-ec34-4a5a-92d3-81fd42564001",
"status": "accepted",
"aggregateRevision": null
} Verifică rezultatul după UUID. Când importul s‑a încheiat, caută ID‑ul nou în catalog înainte de a face alocarea: cursul apare cu lecțiile lui și cu totalul minutelor. La refuz, folosește codul întors pentru a corecta pachetul și inițiază o operație nouă.
curl
curl "$RDC_BASE_URL/elearning/v1/courses" \
-H "Authorization: Bearer $RDC_TOKEN" JavaScript
const response = await fetch(`${process.env.RDC_BASE_URL}/elearning/v1/courses`, {
method: 'GET',
headers: {
Authorization: `Bearer ${process.env.RDC_TOKEN}`,
},
});
const result = await response.json(); Python
import os
import requests
response = requests.request(
'GET',
f'{os.environ["RDC_BASE_URL"]}/elearning/v1/courses',
headers={
'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
},
)
result = response.json() PHP
<?php
$curl = curl_init(getenv('RDC_BASE_URL') . '/elearning/v1/courses');
curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('RDC_TOKEN'),
],
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl); C#
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/elearning/v1/courses");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync(); {
"items": [
{
"id": "receiving-goods",
"title": "Receiving goods",
"kind": "course",
"lessonIds": [
"receiving-reading",
"receiving-checklist",
"receiving-quiz"
],
"courseIds": [],
"durationMinutes": 5,
"validityDays": 365
},
{
"id": "workplace-safety",
"title": "Workplace safety",
"kind": "course",
"lessonIds": [
"safety-reading",
"safety-quiz"
],
"courseIds": [],
"durationMinutes": 4,
"validityDays": 365
},
{
"id": "new-hire-onboarding",
"title": "New-hire onboarding",
"kind": "path",
"lessonIds": [],
"courseIds": [
"workplace-safety",
"receiving-goods"
],
"durationMinutes": 9
},
{
"id": "receiving-review",
"title": "Receiving review",
"kind": "course",
"lessonIds": [
"delivery-note",
"delivery-checklist",
"delivery-quiz"
],
"courseIds": [],
"durationMinutes": 5,
"validityDays": 365
}
],
"nextCursor": null
}