Skip to content

Commit

Permalink
New Feature: right check
Browse files Browse the repository at this point in the history
  • Loading branch information
WunderJacob committed Mar 20, 2024
1 parent 9c5256e commit e1ac083
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 45 deletions.
4 changes: 2 additions & 2 deletions classes/observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ public static function enroll_all_participants($adelelp, $data) {
$coursecontext = context_course::instance($data->courseid);
$enrolledusers = get_enrolled_users($coursecontext, '', 0, 'u.id, u.username, u.firstname, u.lastname, u.email');
$userparams = new stdClass();
$userparams->relateduserid = $data->userid;
$userparams->userid = $data->userid;
foreach ($enrolledusers as $user) {
$userparams->userid = $user->id;
$userparams->relateduserid = $user->id;
enrollment::subscribe_user_to_learning_path($learningpath, $userparams);
}
}
Expand Down
4 changes: 4 additions & 0 deletions lang/en/adele.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,7 @@
$string['mform_options_userlist_only'] = 'Jeder sieht nur seine eigenen Ergebnisse';
$string['mform_options_participantslist_this_course'] = 'Jeder, der für diesen Kurs eingeschrieben ist';
$string['mform_options_participantslist_starting_courses'] = 'Jeder ist eingeschrieben, der in einem Startknoten ist';
$string['mform_options_create_learningpath'] = 'Create learning path';
$string['mform_options_link_create_learningpath'] = 'Link to learning path creation';


40 changes: 20 additions & 20 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function adele_delete_instance($id) {
* @param cm_info $cm The course module information object.
*/
function mod_adele_cm_info_view(cm_info $cm) {
global $DB, $PAGE, $USER;
global $DB, $PAGE, $USER, $OUTPUT;
$learningpathmod = $DB->get_record(
'adele',
[
Expand All @@ -125,17 +125,17 @@ function mod_adele_cm_info_view(cm_info $cm) {
) {

$alisecompatible = local_adele::get_internalquuiz_id($learningpathmod->learningpathid, $PAGE->course->id);

if (has_capability('mod/adele:addinstance', context_system::instance())) {
$modulecontext = context_module::instance($cm->id);
if (has_capability('mod/adele:addinstance', $modulecontext)) {
if ($alisecompatible['alisecompatible']) {
$PAGE->requires->js_call_amd('local_adele/app-lazy', 'init');
$html = '
<div id="local-adele-app" name="local-adele-app" view="teacher" learningpath="' .
$learningpathmod->learningpathid . '" user="' . $USER->id . '" userlist="' .
$learningpathmod->userlist . '">
<router-view></router-view>
</div>
';
$html = $OUTPUT->render_from_template('local_adele/initview',
[
'userid' => $USER->id,
'contextid' => $modulecontext->id,
'learningpath' => $learningpathmod->learningpathid,
'userlist' => $learningpathmod->userlist,
'view' => "teacher"
]);
} else {
$html = '<div style="background-color: #f8d7da; border: 1px solid #f5c6cb; border-radius: 5px;
padding: 15px; margin-bottom: 20px; color: #721c24;">
Expand All @@ -144,16 +144,16 @@ function mod_adele_cm_info_view(cm_info $cm) {
</div>';
}
$cm->set_content($html);
} else if (has_capability('mod/adele:readinstance', context_system::instance())) {
} else if (has_capability('mod/adele:readinstance', $modulecontext)) {
if ($alisecompatible['alisecompatible']) {
$PAGE->requires->js_call_amd('local_adele/app-lazy', 'init');
$html = '
<div id="local-adele-app" name="local-adele-app" view="student" learningpath="' .
$learningpathmod->learningpathid . '" user="' . $USER->id . '" userlist="' .
$learningpathmod->userlist . '">
<router-view></router-view>
</div>
';
$html = $OUTPUT->render_from_template('local_adele/initview',
[
'userid' => $USER->id,
'contextid' => $modulecontext->id,
'learningpath' => $learningpathmod->learningpathid,
'userlist' => $learningpathmod->userlist,
'view' => "student"
]);
} else {
$html = '<div style="background-color: #f8d7da; border: 1px solid #f5c6cb; border-radius: 5px;
padding: 15px; margin-bottom: 20px; color: #721c24;">
Expand Down
11 changes: 7 additions & 4 deletions mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,13 @@ public function definition() {
} else {
$this->add_intro_editor();
}

// Adding the rest of mod_adele settings, spreading all them into this fieldset
// ... or adding more fieldsets ('header' elements) if needed for better logic.
$mform->addElement('static', 'label1', 'adelesettings', get_string('adelesettings', 'mod_adele'));
// Adding a link after the header.
$mform->addElement('static', 'link',
get_string('mform_options_create_learningpath', 'mod_adele'),
'<a href="/local/adele/index.php#/learningpaths/edit" target="blank">' .
get_string('mform_options_link_create_learningpath', 'mod_adele') .
'</a>'
);
$mform->addElement('header', 'adelefieldset', get_string('adelefieldset', 'mod_adele'));

$select = [];
Expand Down
37 changes: 18 additions & 19 deletions view.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,16 @@
$learningpath->learningpathid
) {
$alisecompatible = local_adele::get_internalquuiz_id($learningpath->learningpathid, $PAGE->course->id);

if (has_capability('mod/adele:addinstance', context_system::instance())) {
if (has_capability('mod/adele:addinstance', $modulecontext)) {
if ($alisecompatible['alisecompatible']) {
$PAGE->requires->js_call_amd('local_adele/app-lazy', 'init');
echo <<<EOT
<div id="local-adele-app" name="local-adele-app"
view="teacher" learningpath="{$learningpath->learningpathid}"
user="{$USER->id}" userlist="{$learningpath->userlist}">
<router-view></router-view>
</div>
EOT;
echo $OUTPUT->render_from_template('local_adele/initview',
[
'userid' => $USER->id,
'contextid' => $modulecontext->id,
'learningpath' => $learningpath->learningpathid,
'userlist' => $learningpath->userlist,
'view' => "teacher"
]);
} else {
echo <<<EOT
<div style="background-color: #f8d7da; border: 1px solid #f5c6cb; border-radius: 5px;
Expand All @@ -98,16 +97,16 @@
</div>
EOT;
}
} else if (has_capability('mod/adele:readinstance', context_system::instance())) {
} else if (has_capability('mod/adele:readinstance', $modulecontext)) {
if ($alisecompatible['alisecompatible']) {
$PAGE->requires->js_call_amd('local_adele/app-lazy', 'init');
echo <<<EOT
<div id="local-adele-app"name="local-adele-app"
view="student" learningpath="{$learningpath->learningpathid}"
user="{$USER->id}" userlist="{$learningpath->userlist}">
<router-view></router-view>
</div>
EOT;
echo $OUTPUT->render_from_template('local_adele/initview',
[
'userid' => $USER->id,
'contextid' => $modulecontext->id,
'learningpath' => $learningpath->learningpathid,
'userlist' => $learningpath->userlist,
'view' => "student"
]);
} else {
echo <<<EOT
<div style="background-color: #f8d7da; border: 1px solid #f5c6cb; border-radius: 5px;
Expand Down

0 comments on commit e1ac083

Please sign in to comment.