-
Notifications
You must be signed in to change notification settings - Fork 0
/
StudiGPT.php
executable file
·75 lines (65 loc) · 2.74 KB
/
StudiGPT.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
require_once 'lib/gpt_common.inc.php';
StudipAutoloader::addClassLookups([
'CoursewareGPTBlock\GPTBlock' => __DIR__ . '/lib/GPTBlock.php',
'CoursewareGPTBlock\GPTClient' => __DIR__ . '/lib/clients/GPTClient.php',
'CoursewareGPTBlock\OpenaiClient' => __DIR__ . '/lib/clients/OpenaiClient.php',
'CoursewareGPTBlock\GPTFeedback' => __DIR__ . '/models/GPTFeedback.php',
'CoursewareGPTBlock\GPTQuestion' => __DIR__ . '/models/GPTQuestion.php',
'CoursewareGPTBlock\GPTUserAnswer' => __DIR__ . '/models/GPTUserAnswer.php',
'CoursewareGPTBlock\GPTUserFeedback' => __DIR__ . '/models/GPTUserFeedback.php',
]);
use Courseware\CoursewarePlugin;
class StudiGPT extends StudIPPlugin implements SystemPlugin, CoursewarePlugin
{
public function __construct()
{
parent::__construct();
if (match_route('dispatch.php/*/courseware')) {
PageLayout::addHeadElement('script', [], 'var COURSEWARE_GPT_BLOCK_BASE_URL = "' . dirname($this->url_for('api')) . '";');
\PageLayout::addScript($this->getPluginUrl() . '/js/courseware-gpt-block.js', ['type' => 'module']);
\PageLayout::addStylesheet($this->getPluginURL() . '/css/courseware-gpt-block.css');
// Set block adder icon
\PageLayout::addStyle('.cw-blockadder-item.cw-blockadder-item-gpt { background-image:url('.\Icon::create('chat')->asImagePath().')}');
}
// set up translation domain
bindtextdomain('CoursewareGPTBlock', __DIR__ . '/locale');
}
/**
* Implement this method to register more block types.
*
* You get the current list of block types and must return an updated list
* containing your own block types.
*
* @param array $otherBlockTypes the current list of block types
*
* @return array the updated list of block types
*/
public function registerBlockTypes(array $otherBlockTypes): array
{
$otherBlockTypes[] = CoursewareGPTBlock\GPTBlock::class;
return $otherBlockTypes;
}
/**
* Implement this method to register more container types.
*
* You get the current list of container types and must return an updated list
* containing your own container types.
*
* @param array $otherContainerTypes the current list of container types
*
* @return array the updated list of container types
*/
public function registerContainerTypes(array $otherContainerTypes): array
{
return $otherContainerTypes;
}
/**
* Return a URL to a specified route in this plugin.
* $params can contain optional additional parameters
*/
public function url_for($path, $params = []): string
{
return PluginEngine::getURL($this, $params, $path);
}
}