-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
97 changed files
with
1,873 additions
and
5,811 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,28 +19,34 @@ | |
* | ||
* @package mod_capquiz | ||
* @author Aleksander Skrede <[email protected]> | ||
* @copyright 2018 NTNU | ||
* @copyright 2018 Norwegian University of Science and Technology (NTNU) | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace mod_capquiz; | ||
use mod_capquiz\capquiz; | ||
use mod_capquiz\capquiz_action_performer; | ||
|
||
require_once ("../../config.php"); | ||
global $CFG; | ||
|
||
require_once("../../config.php"); | ||
require_once($CFG->libdir . '/formslib.php'); | ||
require_once($CFG->dirroot . '/mod/capquiz/lib.php'); | ||
require_once($CFG->dirroot . '/mod/capquiz/classes/capquiz_action_performer.php'); | ||
|
||
$cmid = capquiz_urls::require_course_module_id_param(); | ||
global $PAGE; | ||
|
||
$cmid = required_param('id', PARAM_INT); | ||
$cm = get_coursemodule_from_id('capquiz', $cmid, 0, false, MUST_EXIST); | ||
require_login($cm->course, false, $cm); | ||
|
||
$context = \context_module::instance($cmid); | ||
$context = context_module::instance($cmid); | ||
require_capability('mod/capquiz:instructor', $context); | ||
|
||
$action = required_param('action', PARAM_TEXT); | ||
|
||
$capquiz = new capquiz($cmid); | ||
capquiz_urls::set_page_url($capquiz, capquiz_urls::$urlasync); | ||
capquiz_action_performer::perform($action, $capquiz); | ||
$PAGE->set_context($context); | ||
$PAGE->set_cm($cm); | ||
$PAGE->set_url(new moodle_url('/mod/capquiz/async.php')); | ||
|
||
capquiz_action_performer::perform($action, new capquiz($cmid)); | ||
|
||
capquiz_urls::redirect_to_dashboard(); | ||
redirect(new moodle_url('/mod/capquiz/view.php', ['id' => $cmid])); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,36 +19,42 @@ | |
* | ||
* @package mod_capquiz | ||
* @author Aleksander Skrede <[email protected]> | ||
* @copyright 2018 NTNU | ||
* @copyright 2018 Norwegian University of Science and Technology (NTNU) | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace mod_capquiz; | ||
use mod_capquiz\capquiz; | ||
use mod_capquiz\capquiz_question_attempt; | ||
use mod_capquiz\capquiz_question_engine; | ||
|
||
require_once('../../config.php'); | ||
require_once(__DIR__ . '/../../config.php'); | ||
|
||
$cmid = capquiz_urls::require_course_module_id_param(); | ||
global $PAGE; | ||
|
||
$cmid = required_param('id', PARAM_INT); | ||
$cm = get_coursemodule_from_id('capquiz', $cmid, 0, false, MUST_EXIST); | ||
require_login($cm->course, false, $cm); | ||
$context = \context_module::instance($cmid); | ||
|
||
$context = context_module::instance($cmid); | ||
require_capability('mod/capquiz:student', $context); | ||
|
||
$action = required_param('action', PARAM_TEXT); | ||
$attemptid = optional_param('attempt', null, PARAM_INT); | ||
$cmid = capquiz_urls::require_course_module_id_param(); | ||
$capquiz = new capquiz($cmid); | ||
$action = required_param('action', PARAM_TEXT); | ||
|
||
capquiz_urls::set_page_url($capquiz, capquiz_urls::$urlasync); | ||
$PAGE->set_context($context); | ||
$PAGE->set_cm($cm); | ||
$PAGE->set_url(new moodle_url('/mod/capquiz/async.php')); | ||
|
||
if ($attemptid !== null) { | ||
$capquiz = new capquiz($cmid); | ||
$user = $capquiz->user(); | ||
$attempt = capquiz_question_attempt::load_attempt($user, $attemptid); | ||
if ($action === 'answered') { | ||
$capquiz->question_engine($user)->attempt_answered($user, $attempt); | ||
(new capquiz_question_engine($capquiz))->attempt_answered($user, $attempt); | ||
} else if ($action === 'reviewed') { | ||
$capquiz->question_engine($user)->attempt_reviewed($attempt); | ||
(new capquiz_question_engine($capquiz))->attempt_reviewed($attempt); | ||
} | ||
capquiz_urls::redirect_to_dashboard(); | ||
redirect(new moodle_url('/mod/capquiz/view.php', ['id' => $cmid])); | ||
} | ||
|
||
capquiz_urls::redirect_to_front_page(); | ||
redirect(new moodle_url('/')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,15 +16,15 @@ | |
|
||
namespace mod_capquiz\bank; | ||
|
||
use mod_capquiz\capquiz_urls; | ||
use moodle_url; | ||
use stdClass; | ||
|
||
/** | ||
* Question bank action to add question to quiz. | ||
* | ||
* @package mod_capquiz | ||
* @copyright 2024 NTNU | ||
* @author 2024 Sebastian Gundersen | ||
* @author 2024 Sebastian Gundersen <[email protected]> | ||
* @copyright 2024 Norwegian University of Science and Technology (NTNU) | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class add_to_quiz_action extends \core_question\local\bank\question_action_base { | ||
|
@@ -38,9 +38,15 @@ class add_to_quiz_action extends \core_question\local\bank\question_action_base | |
* $label - text label to display in the UI (either in the menu, or as a tool-tip on the icon) | ||
*/ | ||
protected function get_url_icon_and_label(stdClass $question): array { | ||
global $PAGE; | ||
if (!question_has_capability_on($question, 'use')) { | ||
return [null, null, null]; | ||
} | ||
return [capquiz_urls::add_question_to_list_url($question->id), 't/add', get_string('addtoquiz', 'quiz')]; | ||
$url = new moodle_url('/mod/capquiz/action.php', [ | ||
'id' => $PAGE->cm->id, | ||
'action' => 'add-question', | ||
'question-id' => $question->id, | ||
]); | ||
return [$url, 't/add', get_string('addtoquiz', 'quiz')]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,33 +14,51 @@ | |
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* This file defines a class represeting a question bank view. | ||
* | ||
* It is based on similar implementations from the Core Quiz, | ||
* but intended to run in a pane rather than a modal overlay, | ||
* some differences are needed. It includes legacy code from | ||
* different versions of moodle, and should have been refactored. | ||
* | ||
* @package mod_capquiz | ||
* @author Hans Georg Schaathun <[email protected]> | ||
* @copyright 2018/2022 NTNU | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace mod_capquiz\bank; | ||
|
||
use context; | ||
|
||
/** | ||
* Class question_bank_view | ||
* Question bank view for CAPQuiz. | ||
* | ||
* @package mod_capquiz | ||
* @author Sebastian Gundersen <[email protected]> | ||
* @author Aleksander Skrede <[email protected]> | ||
* @copyright 2018 NTNU | ||
* @copyright 2024 NTNU | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class question_bank_view extends \core_question\local\bank\view { | ||
/** | ||
* Constructor. | ||
*/ | ||
public function __construct() { | ||
global $PAGE; | ||
$PAGE->set_pagelayout('admin'); | ||
$params = [ | ||
'cmid' => $PAGE->cm->id, | ||
'qpage' => optional_param('qpage', null, PARAM_INT), | ||
'cat' => optional_param('cat', null, PARAM_SEQUENCE), | ||
'category' => optional_param('category', null, PARAM_SEQUENCE), | ||
'qperpage' => optional_param('qperpage', null, PARAM_INT), | ||
'recurse' => optional_param('recurse', null, PARAM_BOOL), | ||
'showhidden' => optional_param('showhidden', null, PARAM_BOOL), | ||
'qbshowtext' => optional_param('qbshowtext', null, PARAM_BOOL), | ||
'cpage' => optional_param('cpage', null, PARAM_INT), | ||
'qtagids' => optional_param_array('qtagids', null, PARAM_INT), | ||
'page' => 'questions', | ||
]; | ||
for ($i = 1; $i <= \core_question\local\bank\view::MAX_SORTS; $i++) { | ||
$sort = optional_param("qbs$i", '', PARAM_TEXT); | ||
if ($sort) { | ||
$params["qbs$i"] = $sort; | ||
} else { | ||
break; | ||
} | ||
} | ||
list($url, $contexts, $cmid, $cm, $capquiz, $pagevars) = | ||
question_build_edit_resources('editq', $PAGE->url->out_as_local_url(false, []), $params); | ||
parent::__construct($contexts, $url, $cm->course, $cm, $pagevars); | ||
} | ||
|
||
/** | ||
* Specify the column heading | ||
|
Oops, something went wrong.