Skip to content

Commit

Permalink
Conflicts are resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
aradjafari committed Nov 25, 2021
2 parents a820c4b + a64c01f commit 06e4221
Show file tree
Hide file tree
Showing 40 changed files with 1,499 additions and 596 deletions.
22 changes: 22 additions & 0 deletions backup/moodle2/backup_arete_activity_task.class.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
<?php
// This file is part of the Augmented Reality Experience plugin (mod_arete) for 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/>.

/**
* Prints a particular instance of Augmented Reality Experience plugin
*
* @package mod_arete
* @copyright 2021, Abbas Jafari & Fridolin Wild, Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

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

Expand Down
7 changes: 4 additions & 3 deletions backup/moodle2/backup_arete_settingslib.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
// This file is part of Moodle - http://moodle.org/
// This file is part of the Augmented Reality Experience plugin (mod_arete) for 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
Expand All @@ -15,12 +15,13 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Description of arete backup settings
* Prints a particular instance of Augmented Reality Experience plugin
*
* @package mod_arete
* @copyright 2021 OU
* @copyright 2021, Abbas Jafari & Fridolin Wild, Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/


defined('MOODLE_INTERNAL') || die;

25 changes: 24 additions & 1 deletion backup/moodle2/backup_arete_stepslib.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
<?php
// This file is part of the Augmented Reality Experience plugin (mod_arete) for 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/>.

/**
* Prints a particular instance of Augmented Reality Experience plugin
*
* @package mod_arete
* @copyright 2021, Abbas Jafari & Fridolin Wild, Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die;

Expand Down Expand Up @@ -27,7 +49,8 @@ protected function define_structure() {
$allarlems = new backup_nested_element('allarlems');

$arlem = new backup_nested_element('arlemfile', array('id'), array(
'contextid', 'fileid', 'userid', 'itemid', 'sessionid', 'filename', 'views', 'filesize', 'upublic', 'activity_json', 'workplace_json', 'timecreated', 'timemodified'));
'contextid', 'fileid', 'userid', 'itemid', 'sessionid', 'filename', 'views', 'filesize', 'upublic',
'activity_json', 'workplace_json', 'timecreated', 'timemodified'));

//rating
$ratings = new backup_nested_element('ratings');
Expand Down
22 changes: 22 additions & 0 deletions backup/moodle2/restore_arete_activity_task.class.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
<?php
// This file is part of the Augmented Reality Experience plugin (mod_arete) for 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/>.

/**
* Prints a particular instance of Augmented Reality Experience plugin
*
* @package mod_arete
* @copyright 2021, Abbas Jafari & Fridolin Wild, Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

require_once($CFG->dirroot . '/mod/arete/backup/moodle2/restore_arete_stepslib.php');
class restore_arete_activity_task extends restore_activity_task {
Expand Down
31 changes: 29 additions & 2 deletions backup/moodle2/restore_arete_stepslib.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@
<?php
// This file is part of the Augmented Reality Experience plugin (mod_arete) for 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/>.

/**
* Prints a particular instance of Augmented Reality Experience plugin
*
* @package mod_arete
* @copyright 2021, Abbas Jafari & Fridolin Wild, Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/



/**
* Structure step to restore one choice activity
*/
Expand All @@ -11,9 +36,11 @@ protected function define_structure() {

$paths[] = new restore_path_element('arete_arlem', '/activity/arete/arlem/areteinstance');

$paths[] = new restore_path_element('arete_allarlems', '/activity/arete/arlem/areteinstance/allarlems/arlemfile');
$paths[] = new restore_path_element('arete_allarlems',
'/activity/arete/arlem/areteinstance/allarlems/arlemfile');

$paths[] = new restore_path_element('arete_rating', '/activity/arete/arlem/areteinstance/allarlems/arlemfile/ratings/rating');
$paths[] = new restore_path_element('arete_rating',
'/activity/arete/arlem/areteinstance/allarlems/arlemfile/ratings/rating');

// Return the paths wrapped into standard activity structure
return $this->prepare_activity_structure($paths);
Expand Down
22 changes: 22 additions & 0 deletions classes/JSONValidatorFileManager.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
<?php
// This file is part of the Augmented Reality Experience plugin (mod_arete) for 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/>.

/**
* Prints a particular instance of Augmented Reality Experience plugin
*
* @package mod_arete
* @copyright 2021, Abbas Jafari & Fridolin Wild, Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

require_once(dirname(__FILE__). '/../../../config.php');

Expand Down
71 changes: 55 additions & 16 deletions classes/filemanager.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
<?php
// This file is part of the Augmented Reality Experience plugin (mod_arete) for 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/>.

/**
* Prints a particular instance of Augmented Reality Experience plugin
*
* @package mod_arete
* @copyright 2021, Abbas Jafari & Fridolin Wild, Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

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

Expand Down Expand Up @@ -217,7 +239,7 @@ function getAllArlems($sorting)

switch ($sortingMode){
case "author": //author on allalrems is a user id while we need sort the column by username, therefore we join the table with user table
$files = $DB->get_records_sql('SELECT a.* FROM mdl_arete_allarlems AS a JOIN mdl_user AS u ON a.userid = u.id ORDER BY u.username ' . $order); //all arlems
$files = $DB->get_records_sql('SELECT a.* FROM {arete_allarlems} AS a JOIN {user} AS u ON a.userid = u.id ORDER BY u.username ' . $order); //all arlems
break;
default:
$files = $DB->get_records('arete_allarlems' , null, $sortingMode . ' ' . $order); //all arlems
Expand All @@ -226,12 +248,13 @@ function getAllArlems($sorting)

}else //others
{
$params = [1, $USER->id];
switch ($sortingMode){
case "author"://author on allalrems is a user id while we need sort the column by username, therefore we join the table with user table
$files = $DB->get_records_sql('SELECT a.* FROM mdl_arete_allarlems AS a JOIN mdl_user AS u ON a.userid = u.id WHERE a.upublic = 1 OR a.userid = '. $USER->id . ' ORDER BY u.username ' . $order); //all arlems
$files = $DB->get_records_sql('SELECT a.* FROM {arete_allarlems} AS a JOIN {user} AS u ON a.userid = u.id WHERE a.upublic = ? OR a.userid = ? ORDER BY u.username ' . $order, $params); //all arlems
break;
default:
$files = $DB->get_records_select('arete_allarlems', 'upublic = 1 OR userid = ? ' , array($USER->id), $sortingMode . ' ' . $order); //only public and for the user
$files = $DB->get_records_select('arete_allarlems', 'upublic = ? OR userid = ? ' , $params , $sortingMode . ' ' . $order); //only public and for the user
break;
}

Expand All @@ -254,7 +277,8 @@ function getAllUserArlems($sorting)

switch ($sortingMode){
case "author"://author on allalrems is a user id while we need sort the column by username, therefore we join the table with user table
$files = $DB->get_records_sql('SELECT a.* FROM mdl_arete_allarlems AS a JOIN mdl_user AS u ON a.userid = u.id WHERE a.userid = '. $USER->id . ' ORDER BY u.username ' . $order);
$params = array($USER->id);
$files = $DB->get_records_sql('SELECT a.* FROM {arete_allarlems} AS a JOIN {user} AS u ON a.userid = u.id WHERE a.userid = ? ORDER BY u.username ' . $order, $params);
break;
default:
$files = $DB->get_records('arete_allarlems', array('userid' => $USER->id) , $sortingMode . ' ' . $order);
Expand All @@ -273,22 +297,36 @@ function getAllUserArlems($sorting)
*
*/
function search_arlems($searchWord, $userSearch, $sorting){
global $DB,$USER,$order;
global $DB,$USER,$order,$COURSE;

$sortingMode = validate_sorting($sorting);

//if it is student activityies table seach only between his/her files
$only_user_arlems = $userSearch ? " userid = " . $USER->id . " AND " : "";
$userid_if_available = $userSearch ? $USER->id : '';

switch ($sortingMode){
case "author"://author on allalrems is a user id while we need sort the column by username, therefore we join the table with user table
$results = $DB->get_records_sql('SELECT a.* FROM mdl_arete_allarlems AS a JOIN mdl_user AS u ON a.userid = u.id WHERE ' . $only_user_arlems . '(filename LIKE \'%' . $searchWord . '%\'' .
'OR activity_json LIKE \'%' . $searchWord . '%\'' . 'OR workplace_json LIKE \'%' . $searchWord. '%\')' . ' ORDER BY u.username ' . $order);
break;
default:
$results = $DB->get_records_select('arete_allarlems', $only_user_arlems . '(filename LIKE \'%' . $searchWord . '%\'' . 'OR activity_json LIKE \'%' . $searchWord . '%\'' . 'OR workplace_json LIKE \'%' . $searchWord. '%\')' , null, $sortingMode . ' ' . $order); //only public and for the user
break;
$searchQuerty = '%'. $searchWord .'%';

//course context
$context = context_course::instance($COURSE->id);

//All result for the managers
if(has_capability('mod/arete:manageall', $context)){
$params = [$searchQuerty, $searchQuerty, $searchQuerty];
$results = $DB->get_records_select('arete_allarlems', '(filename LIKE ? OR activity_json LIKE ? OR workplace_json LIKE ?)' , $params, $sortingMode . ' ' . $order); //only public and for the user
}
else{
$params = [1, $userid_if_available, $searchQuerty, $searchQuerty, $searchQuerty];
switch ($sortingMode){
case "author"://author on allalrems is a user id while we need sort the column by username, therefore we join the table with user table
$results = $DB->get_records_sql('SELECT a.* FROM {arete_allarlems} AS a JOIN {user} AS u ON a.userid = u.id WHERE (a.upublic = ? OR a.userid = ?) AND (filename LIKE ? '
. 'OR activity_json LIKE ? OR workplace_json LIKE ?) ORDER BY u.username ' . $order, $params);
break;
default:
$results = $DB->get_records_select('arete_allarlems', '(upublic = ? OR userid = ?) AND (filename LIKE ? OR activity_json LIKE ? OR workplace_json LIKE ?)' , $params, $sortingMode . ' ' . $order); //only public and for the user
break;
}
}


return $results;
}
Expand All @@ -312,7 +350,7 @@ function getArlemURL($filename, $itemid, $downloadMode = null)

$file_in_allarlem = $DB->get_record('arete_allarlems' , array('filename' => $filename, 'itemid' => $itemid));

$path = explode("/" , parse_url($url)[path] );
$path = explode("/" , parse_url($url,PHP_URL_PATH));

if($downloadMode != null){
return $url;
Expand Down Expand Up @@ -361,7 +399,8 @@ function deletePluginArlem($filename, $itemid = null )
'contextid' => $system_context,
'filepath' => '/', // any path beginning and ending in /
'filename' => $filename);



//use itemid too if it is provided
if(isset($itemid)){
$fileItemId = $itemid;
Expand Down
22 changes: 22 additions & 0 deletions classes/getRating.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
<?php
// This file is part of the Augmented Reality Experience plugin (mod_arete) for 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/>.

/**
* Prints a particular instance of Augmented Reality Experience plugin
*
* @package mod_arete
* @copyright 2021, Abbas Jafari & Fridolin Wild, Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

require_once(dirname(__FILE__). '/../../../config.php');

Expand Down
25 changes: 24 additions & 1 deletion classes/insertRating.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
<?php
// This file is part of the Augmented Reality Experience plugin (mod_arete) for 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/>.

/**
* Prints a particular instance of Augmented Reality Experience plugin
*
* @package mod_arete
* @copyright 2021, Abbas Jafari & Fridolin Wild, Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

require_once(dirname(__FILE__). '/../../../config.php');

Expand Down Expand Up @@ -54,7 +76,8 @@
//return the number of votes of the activity
function getVotes(){
global $DB, $itemid;
$votes = $DB->get_records_select('arete_rating', 'itemid = ' . $itemid . ' AND rating <> 0' , null, 'timecreated DESC');
$params = [$itemid, 0];
$votes = $DB->get_records_select('arete_rating', 'itemid = ? AND rating <> ?' , $params, 'timecreated DESC');
return strval(count($votes));
}

Expand Down
Loading

0 comments on commit 06e4221

Please sign in to comment.