MCPcopy Create free account
hub / github.com/PrairieLearn/PrairieLearn / processIssue

Function processIssue

pages/instructorQuestion/instructorQuestion.js:66–92  ·  view source on GitHub ↗
(req, res, callback)

Source from the content-addressed store, hash-verified

64}
65
66function processIssue(req, res, callback) {
67 const description = req.body.description;
68 if (!_.isString(description) || description.length == 0) {
69 return callback(new Error('A description of the issue must be provided'));
70 }
71
72 const variant_id = req.body.__variant_id;
73 sqldb.callOneRow('variants_ensure_question', [variant_id, res.locals.question.id], (err, _result) => {
74 if (ERR(err, callback)) return;
75
76 const course_data = _.pick(res.locals, ['variant', 'question', 'course_instance', 'course']);
77 const params = [
78 variant_id,
79 description, // student message
80 'instructor-reported issue', // instructor message
81 true, // manually_reported
82 true, // course_caused
83 course_data,
84 {}, // system_data
85 res.locals.authn_user.user_id,
86 ];
87 sqldb.call('issues_insert_for_variant', params, (err) => {
88 if (ERR(err, callback)) return;
89 callback(null, variant_id);
90 });
91 });
92}
93
94router.post('/', function(req, res, next) {
95 if (req.body.__action == 'grade' || req.body.__action == 'save') {

Callers 1

Calls 2

callbackFunction · 0.85
callMethod · 0.80

Tested by

no test coverage detected