AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / coding / 问题

问题[moodle](coding)

Martin Hope
Eugenio Guerrero Ruiz
Asked: 2024-12-08 13:23:56 +0800 CST

生成完形填空题:一个数字和一个单选题,其中选项为图表

  • 7

我正在用 RMarkdown(在 RStudio 中使用 knitr)编写练习,其中包括一道数字题和一道单选题。我该如何编写正确的代码,让该活动显示在 Moodle 中?

数字问题需要输入相关系数(在下面的代码中其正确答案是“corr1”),而单选题需要选择代表数据的图表(其中“grafico1”是正确答案)。

library(ggplot2)
Concentration = c(7.1,82.9)
r.sq  = 0
while (r.sq <0.85) {
x = runif(33, min(Concentration),max(Concentration))
b = runif(1,-3,3)+rnorm(33,0,0.25)
a = ifelse(max(b)<0, -min(b)*max(x),0)
data = data.frame(Concentration = round(x,2), Reaction_time = round(a+b*x,2))
z = lm(data$Reaction_time~data$Concentration)
summa = summary(z)
r.sq = summa$r.squared
}
corr = round(cor(data$Concentration,data$Reaction_time),2)

corr1 = corr
r.sq  = 0
while (r.sq <0.85 | abs(corr1)<abs(corr)) {
x = runif(33, min(Concentration),max(Concentration))
b = runif(1,-3,3)+rnorm(33,0,0.25)
a = ifelse(max(b)<0, -min(b)*max(x),0)
data1 = data.frame(Concentration = round(x,2), Reaction_time = round(a+b*x,2))
z = lm(data1$Reaction_time~data1$Concentration)
corr1 =  round(cor(data1$Concentration,data1$Reaction_time),2)
summa = summary(z)
r.sq = summa$r.squared
}

corr2 = corr
r.sq  = 0
while (r.sq <0.85 | abs(corr2)<abs(corr)) {
x = runif(33, min(Concentration),max(Concentration))
b = runif(1,-3,3)+rnorm(33,0,0.25)
a = ifelse(max(b)<0, -min(b)*max(x),0)
data2 = data.frame(Concentration = round(x,2), Reaction_time = round(a+b*x,2))
z = lm(data2$Reaction_time~data2$Concentration)
corr2 =  round(cor(data2$Concentration,data2$Reaction_time),2)
summa = summary(z)
r.sq = summa$r.squared
}

corr3 = corr
r.sq  = 0
while (r.sq <0.85 | abs(corr3)<abs(corr)) {
x = runif(33, min(Concentration),max(Concentration))
b = runif(1,-3,3)+rnorm(33,0,0.25)
a = ifelse(max(b)<0, -min(b)*max(x),0)
data3 = data.frame(Concentration = round(x,2), Reaction_time = round(a+b*x,2))
z = lm(data3$Reaction_time~data3$Concentration)
corr3 =  round(cor(data3$Concentration,data3$Reaction_time),2)
summa = summary(z)
r.sq = summa$r.squared
}

write.csv(data,'concentration_vs_rxtime_q2.csv', row.names = FALSE)

p1 = ggplot(data, aes(x=Concentration, y=Reaction_time)) + geom_point()
p2 = ggplot(data1, aes(x=Concentration, y=Reaction_time)) + geom_point()
p3 = ggplot(data2, aes(x=Concentration, y=Reaction_time)) + geom_point()
p4 = ggplot(data3, aes(x=Concentration, y=Reaction_time)) + geom_point()

png('grafico1.png', width=380, height=248, units='px', pointsize=12)
p1
dev.off()

png('grafico2.png', width=380, height=248, units='px', pointsize=12)
p2
dev.off()

png('grafico3.png', width=380, height=248, units='px', pointsize=12)
p3
dev.off()

png('grafico4.png', width=380, height=248, units='px', pointsize=12)
p4
dev.off()

该代码在 Moodle 中不起作用,因为图表选项没有可用于选择正确答案的复选框。

Determine the correlation coefficinet:
##ANSWER1##


Choose the right plot for data:
1. ![](grafico1.png)  
2. ![](grafico2.png)  
3. ![](grafico3.png)  
4. ![](grafico4.png)

Meta-information
================
extype: cloze
exclozetype: num|schoice
exsolution: `r corr1`|1000
exname: mod10_q1
moodle
  • 1 个回答
  • 18 Views
Martin Hope
Raptor
Asked: 2024-10-23 11:47:37 +0800 CST

Moodle API 获取 Wiki 内容

  • 5

我安装了 Moodle 4.4.3。系统中添加了多个课程。我可以访问 Moodle API。我正在使用 API 调用core_course_get_contents我的其中一门课程的内容。以下是响应:

[
  {
    "id": 38,
    "name": "Section Title",
    "visible": 1,
    "summary": "",
    "summaryformat": 1,
    "section": 1,
    "hiddenbynumsections": 0,
    "uservisible": true,
    "modules": [
      {
        "id": 21,
        "url": "https://example.com/mod/wiki/view.php?id=21",
        "name": "Reading materials",
        "instance": 5,
        "contextid": 44,
        "visible": 1,
        "uservisible": true,
        "visibleoncoursepage": 1,
        "modicon": "https://example.com/theme/image.php/boost/wiki/1727859606/monologo?filtericon=1",
        "modname": "wiki",
        "purpose": "collaboration",
        "branded": false,
        "modplural": "Wikis",
        "availability": null,
        "indent": 0,
        "onclick": "",
        "afterlink": null,
        "customdata": "\"\"",
        "noviewlink": false,
        "completion": 0,
        "downloadcontent": 1,
        "dates": [],
        "groupmode": 0
      }
    ]
  }
]

课程页面包含 1 个添加了 Wiki 活动的条目。我了解到 ID=38 是课程页面上的条目“章节标题”,而 ID=21 是 Wiki ID。然后我使用 Moodle API 调用mod_wiki_get_page_contents尝试pageid=21获取 Wiki 活动的内容。但是响应并未显示 Wikipedia 的内容,而是显示其他页面的内容:

{
  "page": {
    "id": 21,
    "wikiid": 19,
    "subwikiid": 18,
    "groupid": 0,
    "userid": 0,
    "title": "Home",
    "cachedcontent": "(Wrong content here)",
    "contentformat": 1,
    "caneditpage": true,
    "version": 106,
    "tags": []
  },
  "warnings": []
}

在正确的 Wiki 页面的网页中,从编辑按钮的链接,我可以猜出 Wiki 的 ID 是7而不是21,但 ID=7 没有出现在任何响应中。当我使用mod_wiki_get_page_contents和 时pageid=7,它会显示正确的内容。

我的问题是:如何利用 Moodle API 获取 ID=7?

谢谢。

moodle
  • 1 个回答
  • 13 Views
Martin Hope
thebaby
Asked: 2023-12-31 08:29:07 +0800 CST

基于下拉自定义字段的 Moodle 过滤课程

  • 5

我已经创建了一些课程自定义字段,我想创建一些来显示一些过滤器,这些过滤器将根据用户的偏好过滤课程,例如过滤器语言有 ENG、SP、IT

如果用户选择 ENG,则应仅显示语言中包含 ENG 的课程(自定义字段)

我的代码:

require_once(__DIR__ . '/../config.php');

$PAGE->set_context(context_system::instance());
$PAGE->set_pagelayout('standard');
$PAGE->set_title("Custom Fields");
$PAGE->set_heading("All Custom Fields for Courses");

echo $OUTPUT->header();

$ftopics = $DB->get_records('customfield_field', array('shortname' => 'topic'));
$flevels = $DB->get_records('customfield_field', array('shortname' => 'level'));
$flanguages = $DB->get_records('customfield_field', array('shortname' => 'language'));

echo '<form method="get" action="#">'; // Start a form

// ----- TOPIC OPTIONS -----
echo '<select name="topic_filter" id="topic_filter">'; // Start a dropdown/select element
echo '<option value="">All Topics</option>'; // Include an option for all topics

foreach ($ftopics as $topic) {
    $configdata = json_decode($topic->configdata, true);

    // Check if 'options' key exists in the decoded configdata
    if (isset($configdata['options'])) {
        // Split the options string into an array using "\r\n" as the delimiter
        $options = explode("\r\n", $configdata['options']);

        // Remove empty values
        $options = array_filter($options);

        // Display options as dropdown options
        foreach ($options as $option) {
            echo '<option value="' . $option . '">' . $option . '</option>';
        }
    }
}

echo '</select>'; // End the dropdown/select element

// ----- LEVEL OPTIONS -----
echo '<select name="level_filter" id="level_filter">';
echo '<option value="">All Levels</option>'; // Include an option for all levels

foreach ($flevels as $level) {
    $configdata = json_decode($level->configdata, true);

    // Check if 'options' key exists in the decoded configdata
    if (isset($configdata['options'])) {
        // Split the options string into an array using "\r\n" as the delimiter
        $options = explode("\r\n", $configdata['options']);

        // Remove empty values
        $options = array_filter($options);

        // Display options as dropdown options
        foreach ($options as $option) {
            echo '<option value="' . $option . '">' . $option . '</option>';
        }
    }
}

echo '</select>'; // End the dropdown/select element

// ----- LANGUAGE OPTIONS -----
echo '<select name="language_filter" id="language_filter">';
echo '<option value="">All Languages</option>'; // Include an option for all languages

foreach ($flanguages as $language) {
    $configdata = json_decode($language->configdata, true);

    // Check if 'options' key exists in the decoded configdata
    if (isset($configdata['options'])) {
        // Split the options string into an array using "\r\n" as the delimiter
        $options = explode("\r\n", $configdata['options']);

        // Remove empty values
        $options = array_filter($options);

        // Display options as dropdown options
        foreach ($options as $option) {
            echo '<option value="' . $option . '">' . $option . '</option>';
        }
    }
}

echo '</select>'; // End the dropdown/select element

echo '<input type="submit" value="Filter">';
echo '</form>'; // End the form

// Fetch filter values
$topicFilter = optional_param('topic_filter', null, PARAM_TEXT);
$levelFilter = optional_param('level_filter', null, PARAM_TEXT);
$languageFilter = optional_param('language_filter', null, PARAM_TEXT);

// Construct SQL query based on the selected filters
$sql = "SELECT c.id, c.fullname, c.summary
        FROM {course} c";

// Add WHERE clause based on selected filters
$whereClause = array();
if (!empty($topicFilter)) {
    $whereClause[] = "c.id IN (SELECT cd.instanceid FROM {customfield_data} cd WHERE cd.shortname = 'topic' AND cd.value = :topic_filter AND cd.instanceid = c.id)";
}
if (!empty($levelFilter)) {
    $whereClause[] = "c.id IN (SELECT cd.instanceid FROM {customfield_data} cd WHERE cd.shortname = 'level' AND cd.value = :level_filter AND cd.instanceid = c.id)";
}
if (!empty($languageFilter)) {
    $whereClause[] = "c.id IN (SELECT cd.instanceid FROM {customfield_data} cd WHERE cd.shortname = 'language' AND cd.value = :language_filter AND cd.instanceid = c.id)";
}

// Combine WHERE clauses with AND
if (!empty($whereClause)) {
    $sql .= ' WHERE ' . implode(' AND ', $whereClause);
}

// Execute the query
$params = array(
    'topic_filter' => $topicFilter,
    'level_filter' => $levelFilter,
    'language_filter' => $languageFilter
);

$courses = $DB->get_records_sql($sql, $params);

// Display the titles of the filtered courses
foreach ($courses as $course) {
    echo '<div>';
    echo '<h2>' . html_writer::link(new moodle_url('/course/view.php', array('id' => $course->id)), $course->fullname) . '</h2>';
    echo '<p>' . $course->summary . '</p>';
    echo '</div>';
}

echo $OUTPUT->footer();
?>

错误:

从数据库读取时出错

有关此错误的更多信息

调试信息:“where 子句”中的未知列“cd.shortname”

SELECT c.id, c.fullname, c.summary
FROM mdl_course c WHERE c.id IN (SELECT cd.instanceid FROM mdl_customfield_data cd WHERE cd.shortname = 'level' AND cd.value = ? AND cd.instanceid = c.id)
[array (
0 => 'HEI',
)]

错误代码:dmlreadException

注意: 我做错了一些事情,我在查询中使用了选项的结果。例如,语言选项有 ENG、SP、IT,我在查询中使用字符串 ENG 来过滤这些课程。选项 ID 的使用错误。任何其他提示或建议,非常欢迎

moodle
  • 1 个回答
  • 21 Views
Martin Hope
kardelen kamsız
Asked: 2023-08-17 20:41:12 +0800 CST

BBB 录音未显示在我的 Moodle 网站中

  • 5

我有个问题。我的问题与bigbluebutton相关。当我开始录制课程时,课程会被录制,但不会上传到系统。例如;

在此输入图像描述

当我查看日志页面时,出现此错误:

我,[2023-08-13T12:51:53.608989 #330293]信息--:发送请求到http://www.dehaonline.com/mod/bigbluebuttonbn/bbb_broker.php?action=recording_ready&bigbluebuttonbn=16

我,[2023-08-13T12:51:53.932772 #330293]信息--:回调HTTP请求失败:400错误请求。捕获异常:“kid”为空,无法查找正确的密钥(代码 400)

问题是bbb_broker.php吗?我该如何解决这个问题?

我尝试重建录音,但并不能解决问题。我联系了 bigbluebutton 服务器管理员,他告诉我问题是由 Moodle 引起的

moodle
  • 1 个回答
  • 12 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    重新格式化数字,在固定位置插入分隔符

    • 6 个回答
  • Marko Smith

    为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会?

    • 2 个回答
  • Marko Smith

    VScode 自动卸载扩展的问题(Material 主题)

    • 2 个回答
  • Marko Smith

    Vue 3:创建时出错“预期标识符但发现‘导入’”[重复]

    • 1 个回答
  • Marko Smith

    具有指定基础类型但没有枚举器的“枚举类”的用途是什么?

    • 1 个回答
  • Marko Smith

    如何修复未手动导入的模块的 MODULE_NOT_FOUND 错误?

    • 6 个回答
  • Marko Smith

    `(表达式,左值) = 右值` 在 C 或 C++ 中是有效的赋值吗?为什么有些编译器会接受/拒绝它?

    • 3 个回答
  • Marko Smith

    在 C++ 中,一个不执行任何操作的空程序需要 204KB 的堆,但在 C 中则不需要

    • 1 个回答
  • Marko Smith

    PowerBI 目前与 BigQuery 不兼容:Simba 驱动程序与 Windows 更新有关

    • 2 个回答
  • Marko Smith

    AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String”

    • 1 个回答
  • Martin Hope
    Fantastic Mr Fox msvc std::vector 实现中仅不接受可复制类型 2025-04-23 06:40:49 +0800 CST
  • Martin Hope
    Howard Hinnant 使用 chrono 查找下一个工作日 2025-04-21 08:30:25 +0800 CST
  • Martin Hope
    Fedor 构造函数的成员初始化程序可以包含另一个成员的初始化吗? 2025-04-15 01:01:44 +0800 CST
  • Martin Hope
    Petr Filipský 为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会? 2025-03-23 21:39:40 +0800 CST
  • Martin Hope
    Catskul C++20 是否进行了更改,允许从已知绑定数组“type(&)[N]”转换为未知绑定数组“type(&)[]”? 2025-03-04 06:57:53 +0800 CST
  • Martin Hope
    Stefan Pochmann 为什么 {2,3,10} 和 {x,3,10} (x=2) 的顺序不同? 2025-01-13 23:24:07 +0800 CST
  • Martin Hope
    Chad Feller 在 5.2 版中,bash 条件语句中的 [[ .. ]] 中的分号现在是可选的吗? 2024-10-21 05:50:33 +0800 CST
  • Martin Hope
    Wrench 为什么双破折号 (--) 会导致此 MariaDB 子句评估为 true? 2024-05-05 13:37:20 +0800 CST
  • Martin Hope
    Waket Zheng 为什么 `dict(id=1, **{'id': 2})` 有时会引发 `KeyError: 'id'` 而不是 TypeError? 2024-05-04 14:19:19 +0800 CST
  • Martin Hope
    user924 AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String” 2024-03-20 03:12:31 +0800 CST

热门标签

python javascript c++ c# java typescript sql reactjs html

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve