我已经开发了自定义块来提取scorm交互,元素,如x.start。时间,core.cmi.lesson_status我的问题是是否只显示登录用户的结果。这是我的代码。
类block_scormtest扩展block_base {
function init() {
$this->title = get_string('pluginname', 'block_scormtest');
}
function get_content() {
global $DB;
if ($this->content !== NULL) {
return $this->content;
}
$content = '';
$courses = $DB->get_records('scorm_scoes_track', ['element' => 'cmi.core.lesson_status']);
foreach ($courses as $course) {
$content = $course->attempt. ' '.userdate($course->timemodified, get_string('strftimerecentfull')). ' '. $course->value. '<br>';
}
$this->content = new stdClass;
$this->content->text = $content;
}
}
如果需要一个特定的用户,则需要指定用户id
在顶部添加全局$USER
对象,例如:
global $DB, $USER;
然后使用类似这样的SQL -这是包含cmi.core.lesson_status
或x.start.time
的元素
[$elemsql, $elemparams] = $DB->get_in_or_equal(['cmi.core.lesson_status', 'x.start.time'], SQL_PARAMS_NAMED);
$sql = "SELECT sst.id, c.id AS courseid, c.fullname AS coursename, s.id AS scormid, s.name AS scormname, sst.attempt, sst.element, sst.value
FROM {scorm_scoes_track} sst
JOIN {scorm} s ON s.id = sst.scormid
JOIN {course} c ON c.id = s.course
WHERE sst.userid = :userid
AND sst.element {$elemsql}";
$params = array_merge(['userid' => $USER->id], $elemparams);
$scoes = $DB->get_records_sql($sql, $params);
谢谢你,Russell。
我希望编辑逻辑,以便登录的用户只能看到他们自己为scorm交互(x.m start)创建的记录。时间,cmi.interactions_0.student_response, cmi.interactions_1.student_response, cmi.core.lesson_status)
再次感谢您的调查。
我是这个LMS开发的新手,所以我试图找出一些自定义块。我的问题还是和scorm互动有关。我已经添加了这个sql查询
选择鳞状细胞癌。userid AS用户名,scc. Name AS名称,scc. Name。scid AS SCORM_ID, sct。模块AS模块,sccvalue AS Sale_amount, sct。value AS Loan_amount
从
(SELECT uid AS userid, st.scoid, st.value)
FROM prefix_course AS c
LEFT JOIN prefix_scorm AS sc ON sc.course= c.d
LEFT JOIN prefix_scorm_scoes_track AS st ON st.scormid=sc.id
LEFT JOIN prefix_user AS u ON uid =st.userid
WHERE st.element='cmi.interactions_0.student_response') AS scc
左连接
(SELECT c.fullname Course, c.name AS module, st.scoid AS scoid, u.id AS userid, u.firstname name, st.attempt AS Attempt, st.value AS value
)FROM prefix_course AS c
LEFT JOIN prefix_scorm AS sc ON sc.course= c.d
LEFT JOIN prefix_scorm_scoes_track AS st ON st.scormid=sc.id
LEFT JOIN prefix_user AS u ON uid =st.userid
WHERE st.element='cmi.interactions_1.student_response') AS sct
在sct.scoid = scc.scoid
和sct.userid = scc.userid
ORDER BY scc.userid
生成贷款金额和销售金额的报告。现在我想以自定义块的形式显示它,只显示用户的总贷款金额和销售金额。这有点棘手。例如:在这个截图中,对于admin用户,总贷款金额应该是17800,销售金额应该是116000
输入图片描述
是否可以使用SELECT sum(value) WHERE element='cmi.interactions_0.student_response' sale amount=学生响应的总和