diff --git a/classes/webservice/getdata_from_db.php b/classes/webservice/getdata_from_db.php index 4013708..8a3fc30 100644 --- a/classes/webservice/getdata_from_db.php +++ b/classes/webservice/getdata_from_db.php @@ -25,27 +25,34 @@ * */ function get_arlem_list(){ - global $DB,$userid,$token; + global $DB,$userid,$token; + if(isset($userid) && isset($token)){ - //save all arete ids which user are enrolled to - $unsorted_arlems = $DB->get_records_select('arete_allarlems', 'upublic = 1 OR userid = ' . $userid , null, 'timecreated DESC'); //only public and for the user - + //the moudules that the user enrolled to their activities $USER_moduleIDs = get_user_arete_modules_ids(); - //All arlems with the ARLEMs which are assigne to the courses that user is enrolled to on top of the list - $arlems = sorted_arlemList_by_user_assigned($unsorted_arlems, $USER_moduleIDs); - - }else{ - $arlems = $DB->get_records('arete_allarlems' , array('upublic' => 1 ), 'timecreated DESC'); //only public and for the user - - //add author name to ARLEM file - foreach ($arlems as $arlem) { - $arlem->author = find_author($arlem); + //if the user is enrolled atleast to one activity which contains arete module + if(!empty($USER_moduleIDs)){ + + //save all arete ids which user are enrolled to + $unsorted_arlems = $DB->get_records_select('arete_allarlems', 'upublic = 1 OR userid = ' . $userid , null, 'timecreated DESC'); //only public and for the user + //All arlems with the ARLEMs which are assigne to the courses that user is enrolled to on top of the list + $arlems = sorted_arlemList_by_user_assigned($unsorted_arlems, $USER_moduleIDs); + + print_r(json_encode($arlems)); + return; } } + + $arlems = $DB->get_records('arete_allarlems' , array('upublic' => 1 ), 'timecreated DESC'); //only public and for the user + // + //add author name to ARLEM file + foreach ($arlems as $arlem) { + $arlem->author = find_author($arlem); + } print_r(json_encode($arlems)); } diff --git a/lang/en/arete.php b/lang/en/arete.php index db98bb5..5bb25d3 100644 --- a/lang/en/arete.php +++ b/lang/en/arete.php @@ -20,7 +20,7 @@ $string['qrtitle'] = 'QR Code'; $string['qrbutton'] = 'Generate'; $string['authortitle'] = 'Author'; -$string['downloadtitle'] = 'Lunch'; +$string['downloadtitle'] = 'Launch'; $string['downloadbutton'] = 'Play'; $string['editbutton'] = 'Edit'; $string['publictitle'] = 'Public'; diff --git a/version.php b/version.php index f19401d..a29acb3 100644 --- a/version.php +++ b/version.php @@ -2,6 +2,6 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2021040900; // The current module version (Date: YYYYMMDDXX) +$plugin->version = 2021041300; // The current module version (Date: YYYYMMDDXX) $plugin->requires = 2015111000; // Requires this Moodle version $plugin->component = 'mod_arete'; // Full name of the plugin (used for diagnostics) \ No newline at end of file