Skip to content

Commit

Permalink
solrrag_coreai: SolrRag but with AI coding moving to a core subsystem
Browse files Browse the repository at this point in the history
  • Loading branch information
mhughes2k committed Mar 20, 2024
1 parent 8a6ce11 commit c9f18ec
Show file tree
Hide file tree
Showing 30 changed files with 673 additions and 23 deletions.
105 changes: 105 additions & 0 deletions .phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="MoodleCore">
<rule ref="./.phpcs.xml.dist"/>
<exclude-pattern>node_modules/</exclude-pattern>
<exclude-pattern>vendor/</exclude-pattern>
<exclude-pattern>admin/tool/componentlibrary/amd/src/lunr.js</exclude-pattern>
<exclude-pattern>admin/tool/pluginskel/vendor/autoload.php</exclude-pattern>
<exclude-pattern>admin/tool/pluginskel/vendor/composer/</exclude-pattern>
<exclude-pattern>admin/tool/pluginskel/vendor/symfony/</exclude-pattern>
<exclude-pattern>admin/tool/pluginskel/vendor/monolog/monolog/</exclude-pattern>
<exclude-pattern>admin/tool/pluginskel/vendor/psr/log/</exclude-pattern>
<exclude-pattern>admin/tool/policy/amd/src/jquery-eu-cookie-law-popup.js</exclude-pattern>
<exclude-pattern>auth/cas/CAS/</exclude-pattern>
<exclude-pattern>cache/stores/mongodb/MongoDB/</exclude-pattern>
<exclude-pattern>enrol/lti/ims-blti/</exclude-pattern>
<exclude-pattern>filter/algebra/AlgParser.pm</exclude-pattern>
<exclude-pattern>filter/tex/mimetex.*</exclude-pattern>
<exclude-pattern>h5p/h5plib/v124/joubel/core/</exclude-pattern>
<exclude-pattern>h5p/h5plib/v124/joubel/editor/</exclude-pattern>
<exclude-pattern>lib/editor/atto/plugins/html/yui/src/codemirror/</exclude-pattern>
<exclude-pattern>lib/editor/atto/plugins/html/yui/src/beautify/</exclude-pattern>
<exclude-pattern>lib/editor/atto/yui/src/rangy/js/*.*</exclude-pattern>
<exclude-pattern>lib/editor/tiny/js/tinymce/</exclude-pattern>
<exclude-pattern>lib/editor/tinymce/plugins/pdw/tinymce/</exclude-pattern>
<exclude-pattern>lib/editor/tinymce/plugins/spellchecker/rpc.php</exclude-pattern>
<exclude-pattern>lib/editor/tinymce/tiny_mce/</exclude-pattern>
<exclude-pattern>lib/mlbackend/php/phpml/</exclude-pattern>
<exclude-pattern>lib/adodb/</exclude-pattern>
<exclude-pattern>lib/behat/axe/</exclude-pattern>
<exclude-pattern>lib/bennu/</exclude-pattern>
<exclude-pattern>lib/evalmath/</exclude-pattern>
<exclude-pattern>lib/phpspreadsheet/</exclude-pattern>
<exclude-pattern>lib/google/</exclude-pattern>
<exclude-pattern>lib/htmlpurifier/</exclude-pattern>
<exclude-pattern>lib/minify/matthiasmullie-minify/</exclude-pattern>
<exclude-pattern>lib/minify/matthiasmullie-pathconverter/</exclude-pattern>
<exclude-pattern>lib/pear/HTML/Common.php</exclude-pattern>
<exclude-pattern>lib/pear/HTML/QuickForm.php</exclude-pattern>
<exclude-pattern>lib/pear/HTML/QuickForm/</exclude-pattern>
<exclude-pattern>lib/pear/PEAR.php</exclude-pattern>
<exclude-pattern>lib/phpmailer/</exclude-pattern>
<exclude-pattern>lib/simplepie/</exclude-pattern>
<exclude-pattern>lib/tcpdf/</exclude-pattern>
<exclude-pattern>lib/yuilib/</exclude-pattern>
<exclude-pattern>lib/yuilib/gallery/</exclude-pattern>
<exclude-pattern>lib/jquery/</exclude-pattern>
<exclude-pattern>lib/html2text/</exclude-pattern>
<exclude-pattern>lib/markdown/</exclude-pattern>
<exclude-pattern>lib/xhprof/</exclude-pattern>
<exclude-pattern>lib/horde/</exclude-pattern>
<exclude-pattern>lib/requirejs/</exclude-pattern>
<exclude-pattern>lib/amd/src/loglevel.js</exclude-pattern>
<exclude-pattern>lib/mustache/</exclude-pattern>
<exclude-pattern>lib/amd/src/mustache.js</exclude-pattern>
<exclude-pattern>lib/graphlib.php</exclude-pattern>
<exclude-pattern>lib/php-css-parser/</exclude-pattern>
<exclude-pattern>lib/rtlcss/</exclude-pattern>
<exclude-pattern>lib/scssphp/</exclude-pattern>
<exclude-pattern>lib/spout/</exclude-pattern>
<exclude-pattern>lib/amd/src/chartjs-lazy.js</exclude-pattern>
<exclude-pattern>lib/maxmind/GeoIp2/</exclude-pattern>
<exclude-pattern>lib/maxmind/MaxMind/</exclude-pattern>
<exclude-pattern>lib/ltiprovider/</exclude-pattern>
<exclude-pattern>lib/lti1p3/</exclude-pattern>
<exclude-pattern>lib/amd/src/truncate.js</exclude-pattern>
<exclude-pattern>lib/fonts/</exclude-pattern>
<exclude-pattern>lib/amd/src/adapter.js</exclude-pattern>
<exclude-pattern>lib/validateurlsyntax.php</exclude-pattern>
<exclude-pattern>lib/amd/src/popper.js</exclude-pattern>
<exclude-pattern>lib/geopattern-php/</exclude-pattern>
<exclude-pattern>lib/php-jwt/</exclude-pattern>
<exclude-pattern>lib/polyfills/</exclude-pattern>
<exclude-pattern>lib/emoji-data/</exclude-pattern>
<exclude-pattern>lib/plist/</exclude-pattern>
<exclude-pattern>lib/zipstream/</exclude-pattern>
<exclude-pattern>lib/php-enum/</exclude-pattern>
<exclude-pattern>lib/http-message/</exclude-pattern>
<exclude-pattern>lib/phpxmlrpc/</exclude-pattern>
<exclude-pattern>local/codechecker/phpcs/</exclude-pattern>
<exclude-pattern>local/codechecker/PHPCompatibility/</exclude-pattern>
<exclude-pattern>media/player/videojs/amd/src/video-lazy.js</exclude-pattern>
<exclude-pattern>media/player/videojs/amd/src/Youtube-lazy.js</exclude-pattern>
<exclude-pattern>media/player/videojs/videojs/</exclude-pattern>
<exclude-pattern>media/player/videojs/amd/src/local/ogv/ogv.js</exclude-pattern>
<exclude-pattern>media/player/videojs/ogvjs/</exclude-pattern>
<exclude-pattern>media/player/videojs/amd/src/videojs-ogvjs-lazy.js</exclude-pattern>
<exclude-pattern>mod/assign/feedback/editpdf/fpdi/</exclude-pattern>
<exclude-pattern>repository/s3/S3.php</exclude-pattern>
<exclude-pattern>theme/boost/scss/bootstrap/</exclude-pattern>
<exclude-pattern>theme/boost/amd/src/bootstrap/alert.js</exclude-pattern>
<exclude-pattern>theme/boost/amd/src/bootstrap/button.js</exclude-pattern>
<exclude-pattern>theme/boost/amd/src/bootstrap/carousel.js</exclude-pattern>
<exclude-pattern>theme/boost/amd/src/bootstrap/collapse.js</exclude-pattern>
<exclude-pattern>theme/boost/amd/src/bootstrap/dropdown.js</exclude-pattern>
<exclude-pattern>theme/boost/amd/src/bootstrap/modal.js</exclude-pattern>
<exclude-pattern>theme/boost/amd/src/bootstrap/popover.js</exclude-pattern>
<exclude-pattern>theme/boost/amd/src/bootstrap/tools/sanitizer.js</exclude-pattern>
<exclude-pattern>theme/boost/amd/src/bootstrap/scrollspy.js</exclude-pattern>
<exclude-pattern>theme/boost/amd/src/bootstrap/tab.js</exclude-pattern>
<exclude-pattern>theme/boost/amd/src/bootstrap/toast.js</exclude-pattern>
<exclude-pattern>theme/boost/amd/src/bootstrap/tooltip.js</exclude-pattern>
<exclude-pattern>theme/boost/amd/src/bootstrap/util.js</exclude-pattern>
<exclude-pattern>theme/boost/amd/src/index.js</exclude-pattern>
<exclude-pattern>theme/boost/scss/fontawesome/</exclude-pattern>
</ruleset>
21 changes: 21 additions & 0 deletions course/moodleform_mod.php
Original file line number Diff line number Diff line change
Expand Up @@ -1195,4 +1195,25 @@ public function get_data() {
}
return $data;
}

public function standard_aiprovider_coursemodule_elements() {

if (!$this->_features->ai) {
return;
}
$mform = $this->_form;
// Adding the rest of mod_xaichat settings, spreading all them into this fieldset
// ... or adding more fieldsets ('header' elements) if needed for better logic.
$mform->addElement('header', 'aiprovider', get_string('aiprovider'));

$providers = \core\ai\api::get_all_providers();
$optproviders = [];
foreach($providers as $provider) {
$optproviders[$provider->get('id')] = $provider->get('name');
}
$mform->addElement('select', 'aiproviderid',
'Choose Provider',
$optproviders
);
}
}
48 changes: 48 additions & 0 deletions customfield/field/plusteams/classes/data_controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
namespace customfield_plusteams;

defined('MOODLE_INTERNAL') || die;

class data_controller extends \core_customfield\data_controller {
public function datafield(): string {
return 'stringvalue';
}

public function get_default_value() {
$defaultvalue = $this->get_field()->get_configdata_property('defaultvalue');
if ('' . $defaultvalue !== '') {
$key = array_search($defaultvalue, $this->get_field()->get_options());
if ($key !== false) {
return $key;
}
}
return 0;
}

public function instance_form_definition(\MoodleQuickForm $mform) {
// $field = $this->get_field();
// $config = $field->get('configdata');
// $options = $field->get_options();
// $formattedoptions = array();
// $context = $this->get_field()->get_handler()->get_configuration_context();
// local_plusteams_linkform($mform);
}
public function instance_form_validation(array $data, array $files) : array {

}
public function export_value() {
$value = $this->get_value();

if ($this->is_empty($value)) {
return null;
}

$options = $this->get_field()->get_options();
if (array_key_exists($value, $options)) {
return format_string($options[$value], true,
['context' => $this->get_field()->get_handler()->get_configuration_context()]);
}

return null;
}
}
Empty file.
Empty file.
6 changes: 6 additions & 0 deletions customfield/field/plusteams/version.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
defined('MOODLE_INTERNAL') || die();

$plugin->component = 'customfield_plusteams';
$plugin->version = 2022041900;
$plugin->requires = 2022041200;
1 change: 1 addition & 0 deletions grade/grading/form/multigraders
Submodule multigraders added at aec0ab
1 change: 1 addition & 0 deletions grade/grading/form/workflow
Submodule workflow added at eb0a4b
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
43 changes: 43 additions & 0 deletions lib/classes/event/grade_item_hidden.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Grade item updated event.
*
* @package core
* @copyright 2019 Dmitrii Metelkin <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace core\event;

defined('MOODLE_INTERNAL') || die();

class grade_item_hidden extends grade_item_updated {
protected function init() {
$this->data['objecttable'] = 'grade_items';
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
}
public static function get_name() {
return get_string('eventgradeitemhidden', 'core_grades');
}
public function get_description() {
return "The user with id '" . $this->userid . "' hid a grade item with id '" . $this->objectid . "'" .
" of type '" . $this->other['itemtype'] . "' and name '" . $this->other['itemname'] . "'" .
" in the course with the id '" . $this->courseid . "'.";
}
}
43 changes: 43 additions & 0 deletions lib/classes/event/grade_item_revealed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Grade item updated event.
*
* @package core
* @copyright 2019 Dmitrii Metelkin <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace core\event;

defined('MOODLE_INTERNAL') || die();

class grade_item_revealed extends grade_item_updated {
protected function init() {
$this->data['objecttable'] = 'grade_items';
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
}
public static function get_name() {
return get_string('eventgradeitemrevealed', 'core_grades');
}
public function get_description() {
return "The user with id '" . $this->userid . "' revealed a grade item with id '" . $this->objectid . "'" .
" of type '" . $this->other['itemtype'] . "' and name '" . $this->other['itemname'] . "'" .
" in the course with the id '" . $this->courseid . "'.";
}
}
2 changes: 2 additions & 0 deletions lib/moodlelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,8 @@
define('FEATURE_CONTROLS_GRADE_VISIBILITY', 'controlsgradevisbility');
/** True if module supports plagiarism plugins */
define('FEATURE_PLAGIARISM', 'plagiarism');
/** True if module uses ai provider. */
define('FEATURE_AI', 'ai');

/** True if module has code to track whether somebody viewed it */
define('FEATURE_COMPLETION_TRACKS_VIEWS', 'completion_tracks_views');
Expand Down
2 changes: 1 addition & 1 deletion lib/phpunit/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,10 @@
$CFG->profilingenabled = true;
$CFG->profilingincluded = '*';
}

require("$CFG->dirroot/lib/setup.php");

raise_memory_limit(MEMORY_HUGE);

if (PHPUNIT_UTIL) {
// We are not going to do testing, this is 'true' in utility scripts that only init database.
return;
Expand Down
3 changes: 3 additions & 0 deletions lib/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,7 @@
setup_DB();

if (PHPUNIT_TEST and !PHPUNIT_UTIL) {

// Make sure tests do not run in parallel.
$suffix = '';
if (phpunit_util::is_in_isolated_process()) {
Expand All @@ -663,7 +664,9 @@
try {
if ($dbhash = $DB->get_field('config', 'value', array('name'=>'phpunittest'))) {
// reset DB tables
echo('1');
phpunit_util::reset_database();
echo('2');
}
} catch (Exception $e) {
if ($dbhash) {
Expand Down
1 change: 1 addition & 0 deletions local/ai
Submodule ai added at a41b82
1 change: 1 addition & 0 deletions local/clientevents
Submodule clientevents added at 24ed0b
1 change: 1 addition & 0 deletions local/codechecker
Submodule codechecker added at 9708c2
1 change: 1 addition & 0 deletions local/plusteams
Submodule plusteams added at 3e0a10
1 change: 1 addition & 0 deletions local/recompletion
Submodule recompletion added at 2ed9fc
10 changes: 6 additions & 4 deletions mod/xaichat/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
*/

defined('MOODLE_INTERNAL') || die();

require_once($CFG->dirroot ."/search/engine/solrrag/classes/ai/api.php");
require_once($CFG->dirroot ."/search/engine/solrrag/classes/ai/aiprovider.php");
require_once($CFG->dirroot ."/search/engine/solrrag/classes/ai/aiclient.php");
//
//require_once($CFG->dirroot ."/search/engine/solrrag/classes/ai/api.php");
//require_once($CFG->dirroot ."/search/engine/solrrag/classes/ai/aiprovider.php");
//require_once($CFG->dirroot ."/search/engine/solrrag/classes/ai/aiclient.php");

/**
* Return if the plugin supports $feature.
Expand All @@ -36,6 +36,8 @@
*/
function xaichat_supports($feature) {
switch ($feature) {
case FEATURE_AI:
return true;
case FEATURE_GRADE_HAS_GRADE:
return true;
case FEATURE_MOD_INTRO:
Expand Down
14 changes: 1 addition & 13 deletions mod/xaichat/mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,7 @@ public function definition() {
$this->add_intro_editor();
}

// Adding the rest of mod_xaichat settings, spreading all them into this fieldset
// ... or adding more fieldsets ('header' elements) if needed for better logic.
$mform->addElement('header', 'xaichatfieldset', get_string('xaichatfieldset', 'mod_xaichat'));

$providers = \core\ai\api::get_all_providers();
$optproviders = [];
foreach($providers as $provider) {
$optproviders[$provider->get('id')] = $provider->get('name');
}
$mform->addElement('select', 'aiproviderid',
'Choose Provider',
$optproviders
);
$this->standard_aiprovider_coursemodule_elements();
// Add standard grading elements.
$this->standard_grading_coursemodule_elements();

Expand Down
Loading

0 comments on commit c9f18ec

Please sign in to comment.