Skip to content

Commit

Permalink
Merge pull request #154 from turnitin/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
jmcgettrick committed Apr 11, 2016
2 parents f3c5cce + 7afde7b commit 24f3e95
Show file tree
Hide file tree
Showing 23 changed files with 518 additions and 81 deletions.
26 changes: 20 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
### Date: 2016-April-11
### Release: v2016011105

- Datatables styling now specific to Turnitin tables to avoid conflict. #137
- Activity logs for submissions are now more informative.
- Created warning on config page for the customer to check whether translated matching and ETS are configured at account level
- Fixes:
- Fixed issue with postdate in anonymous marking mode - the page now warns the user the impact on anonymity of moving the post-date.
- Enrolls user if necessary when performing a course restoration.
- Fixed cron logic to prevent multiple assignment creation upon cron event failure.


---

### Date: 2016-February-23
### Release: v2016011104

Expand Down Expand Up @@ -380,7 +394,7 @@ Releases before version 2015040106 will refer to changes made to the Turnitin's
- Error indicators and rollover messages now displayed in inbox.
- Error messages saved and displayed in settings area.
- EULA moved to submission declaration and submission form hidden.
- Turnitin Paper Id now shown next to submission to show that paper has been submitted.
- Turnitin Paper Id now shown next to submission to show that paper has been submitted.
- Fixes:
- Long assignment titles are now truncated.
- Link to a file in Assignment Summary now renders correctly.
Expand Down Expand Up @@ -414,7 +428,7 @@ Releases before version 2015040106 will refer to changes made to the Turnitin's
- User creation removed from restore procedure.
- Additonal indexes added to database tables
- Extra permission checks added for migration tool
- Error message now shown if ajax request to get submissions times out
- Error message now shown if ajax request to get submissions times out
- Improved CSS to scope only to plugins and files added to jQuery plugin organisation
- Forum posts are now submitted to Turnitin when posted
- Database dump added to PP settings page
Expand Down Expand Up @@ -456,10 +470,10 @@ Releases before version 2015040106 will refer to changes made to the Turnitin's
- Submissions in Plagiarism plugin stopped if there has been 5 unsuccessful attempts.
- Link removed for Originality Report if there is no score.
- Fixes:
- Incorrect links to GradeMark and Originality Report for students have been hidden.
- Incorrect links to GradeMark and Originality Report for students have been hidden.
- Conflicts with Bootstrap theme for tooltips and fixed grademark link position.
- Incorrect settings link in the Plagiarism plugin.
- Timestamp was being incorrectly set preventing more than 1 batch of submissions updating from Turnitin.
- Timestamp was being incorrectly set preventing more than 1 batch of submissions updating from Turnitin.
- Student is now enrolled on the class when checking EULA acceptance to ensure they are on account.

---
Expand Down Expand Up @@ -492,10 +506,10 @@ Releases before version 2015040106 will refer to changes made to the Turnitin's
###Release: v2014012401

- File type limit removed.
- Ability to accept no file added so that marks / grades can be allocated to non file submissions
- Ability to accept no file added so that marks / grades can be allocated to non file submissions
- Dependencies added to plagiarism plugin and blocks
- Fixes:
- Error occurring in course reset
- Error occurring in course reset

---

Expand Down
9 changes: 9 additions & 0 deletions ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,15 @@
$turnitincomms = new turnitintooltwo_comms($account_id, $account_shared, $url);

$testingconnection = true; // Provided by Androgogic to override offline mode for testing connection.

// We only want an API log entry for this if diagnostic mode is set to Debugging
if (empty($config)) {
$config = turnitintooltwo_admin_config();
}
if ($config->enablediagnostic != 2) {
$turnitincomms->setDiagnostic(0);
}

$tiiapi = $turnitincomms->initialise_api($testingconnection);

$class = new TiiClass();
Expand Down
171 changes: 171 additions & 0 deletions classes/helpdeskwizard/helpdeskwizard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
<?php

class helpdeskwizard {

/**
* Read the remote xml file containg helpdesk solutions.
*
* @return string - xml containing helpdesk solutions.
*/
public function read_xml_solutions_file() {
global $CFG;
$xml = '';

try {

// Check if solutions exist in the user's language.
$solutionsurl = "https://www.turnitin.com/static/resources/files/moodle_helpdesk/moodle-helpdesk-".current_language().".xml";
$ch = curl_init($solutionsurl);
curl_setopt($ch, CURLOPT_NOBODY, true);
$result = curl_exec($ch);

// If there is no solutions file then use English.
if ($result !== false) {
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

if ($statusCode != 200) {
$solutionsurl = "https://www.turnitin.com/static/resources/files/moodle_helpdesk/moodle-helpdesk-en.xml";
}
}

// Get correct language file.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $solutionsurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if (isset($CFG->proxyhost) AND !empty($CFG->proxyhost)) {
curl_setopt($ch, CURLOPT_PROXY, $CFG->proxyhost.':'.$CFG->proxyport);
}
if (isset($CFG->proxyuser) AND !empty($CFG->proxyuser)) {
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_PROXYUSERPWD, sprintf('%s:%s', $CFG->proxyuser, $CFG->proxypassword));
}

// Execute post.
$result = curl_exec($ch);

// Close connection.
curl_close($ch);

// Read XML into an array.
$xml = simplexml_load_string($result);

} catch (Exception $e) {
turnitintooltwo_comms::handle_exceptions($e, 'gethelpdeskxmlerror', true);
}

return $xml;
}

/**
* Output HTML helpdesk wizard.
*
* @param int - $id module id, 0 by default to indicate that it's not been accessed from a module.
* @return mixed - html containing helpdesk solutions.
*/
public function output_wizard($id = 0) {
global $CFG;

$xml = $this->read_xml_solutions_file();
$categories = array();
$output = "";

foreach ( $xml as $category => $solutions ) {
$categoryname = substr($category, 0, strrpos($category, '_'));

$categories[ucfirst($categoryname)] = ucfirst(str_replace("_", " ", $categoryname));
$selectoptions = "";

// Read all issues into the array by category
$i = 0;
foreach ($solutions as $k => $v) {
$solution = array();
$i++;
foreach ($v as $k2 => $v2) {
$solution[$k2] = (string)$v2;
}

$solutionarray[$categoryname][] = $solution;
$selectoptions .= html_writer::tag('option', $solution['issue'], array('value' => $i));

// Output a hidden div containing each solution.
$issue = html_writer::tag('div', $solution['issue'], array('class' => 'issue'));
$answer = html_writer::tag('div', $solution['answer'], array('class' => 'answer'));
$link = "";
if (!empty($solution['link'])) {
$linktext = 'Need further information?';
$linktag = html_writer::link($solution['link'], 'Read More...', array('target' => '_blank'));
$link = html_writer::tag('div', $linktext.' '.$linktag, array('class' => 'link'));
} else {
$link = html_writer::tag('div', "", array('class' => 'link'));
}
$output .= html_writer::tag('div', $issue.$answer.$link,
array('id' => 'tii_'.$categoryname.'_'.$i, 'class' => 'tii_solutions'));
}

// Output a hidden div with options for each category.
$output .= html_writer::tag('div', $selectoptions, array('id' => 'tii_'.$categoryname.'_options', 'class' => 'tii_wizard_options'));
}

// Header
$output .= html_writer::tag('h2', 'Turnitin Support Wizard');
$output .= html_writer::tag('p', 'Use the wizard below to help solve your problem');

// Category.
$wizardform = html_writer::tag('p', 'I need help with...');
$wizardform .= html_writer::select($categories, 'category', '', array('' => 'choosedots'),
array('class' => 'tii_helpdesk_category'));

// Sub Category.
$wizardform .= html_writer::tag('p', 'Just a little more information');
$wizardform .= html_writer::select(array(), 'sub_category', '', array('' => 'choosedots'),
array('class' => 'tii_helpdesk_sub_category'));

$output .= html_writer::tag('div', $wizardform, array('id' => 'tii_wizard_container'));

// Blank solution template
$issue = html_writer::tag('h4', '', array('id' => 'solution_issue'));
$answer = html_writer::tag('div', '', array('id' => 'solution_answer'));
$link = html_writer::tag('div', '', array('id' => 'solution_link'));
$output .= html_writer::tag('div', $issue.$answer.$link, array('id' => 'tii_solution_template'));

// Show link to support form.
$formlink = html_writer::tag('h2', 'Did you find your answer?');
$formlink .= html_writer::tag('button', 'No, I Need More Help', array('id' => 'btn_supportform', 'class' => 'btn'));
$formlink .= html_writer::tag('div', $id, array('id' => 'tii_helpdesk_mod_id'));
$output .= html_writer::tag('div', $formlink, array('id' => 'btn_tiisupportform_link'));

return $output;
}

/**
* Output HTML helpdesk wizard.
*
* @param array - $params from helpdesk wizard to pass to Turnitin.
* @return html - iframe linking to Turnitin support form.
*/
public function output_form( $params = array() ) {
global $USER;

// Add standard parameters.
$params['user'] = 'Instructor';
$params['name'] = $USER->firstname.' '.$USER->lastname;
$params['email'] = $USER->email;
$params['integration'] = 'Moodle';
$params['auth'] = 'ok';

// Build URL to open Helpdesk form.
$supportformurl = TURNITIN_SUPPORT_FORM.'?';
foreach ($params as $k => $v) {
$supportformurl .= $k.'='.urlencode($v).'&';
}
$supportformurl = substr($supportformurl, 0 , -1);

// Output HTML iframe containing Turnitin Helpdesk form.
return html_writer::tag('iframe', '',
array(
'src' => $supportformurl,
'width' => '100%',
'height' => '1048'
));
}
}
92 changes: 85 additions & 7 deletions extras.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,96 @@
$jsrequired = false;
$hidebg = ($cmd == 'rubricmanager' || $cmd == 'quickmarkmanager') ? true : false;

$PAGE->set_context(context_system::instance());
require_login();
// Module id needed for support form.
$id = optional_param('id', 0, PARAM_INT);

// Get course and module data that we've linked to here from and set context accordingly.
if ($id != 0) {
//Pre 2.8 does not have the function get_course_and_cm_from_cmid.
if ($CFG->branch >= 28) {
list($course, $cm) = get_course_and_cm_from_cmid($id, 'turnitintooltwo');
}
else {
$cm = get_coursemodule_from_id('turnitintooltwo', $id, 0, false, MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
}

if (!$cm) {
turnitintooltwo_print_error('coursemodidincorrect', 'turnitintooltwo');
}
if (!$course = $DB->get_record("course", array("id" => $cm->course))) {
turnitintooltwo_print_error('coursemisconfigured', 'turnitintooltwo');
}
if (!$turnitintooltwo = $DB->get_record("turnitintooltwo", array("id" => $cm->instance))) {
turnitintooltwo_print_error('coursemodincorrect', 'turnitintooltwo');
}

$PAGE->set_context(context_module::instance($cm->id));
$PAGE->set_pagelayout('base');
require_login($course->id, true, $cm);
} else {
$PAGE->set_context(context_system::instance());
require_login();
}

// Load Javascript and CSS.
$turnitintooltwoview->load_page_components($hidebg);

// Configure URL correctly.
$urlparams = array('cmd' => $cmd, 'view_context' => $viewcontext);
$url = new moodle_url('/mod/turnitintooltwo/view.php', $urlparams);
if ($id != 0) {
$urlparams['id'] = $id;
}
$url = new moodle_url('/mod/turnitintooltwo/extras.php', $urlparams);
$title = "";

switch ($cmd) {
case "supportwizard":
$PAGE->requires->jquery_plugin('turnitintooltwo-turnitin_helpdesk', 'mod_turnitintooltwo');
$title = get_string('turnitinhelpdesk', 'turnitintooltwo');

include "classes/helpdeskwizard/helpdeskwizard.php";
$helpdeskwizard = new helpdeskwizard();
$output = $helpdeskwizard->output_wizard($id);
break;

case "supportform":
include "classes/helpdeskwizard/helpdeskwizard.php";
$helpdeskwizard = new helpdeskwizard();
$title = get_string('turnitinhelpdesk', 'turnitintooltwo');

// Get the Turnitin class id if we are in a class context.
$tiiclass = 0;
if ($id != 0) {
$course = turnitintooltwo_assignment::get_course_data($course->id);
$tiiclass = (isset($course->turnitin_cid)) ? $course->turnitin_cid : 0;
}

$category = optional_param('category', "", PARAM_ALPHAEXT);
$sub_category = optional_param('sub_category', "", PARAM_ALPHAEXT);

$config = turnitintooltwo_admin_config();
$plugin_version = turnitintooltwo_get_version();

// Parameters to pass to support form.
$params = array(
'category' => $category,
'sub_category' => $sub_category,
'class_id' => $tiiclass,
'vle_version' => 'Moodle ('.$CFG->branch.') '.$CFG->version,
'integration_id' => 'MoodleDirectV2',
'integration_version' => $plugin_version,
'account_id' => $config->accountid
);

// Output Iframe containing Turnitin Helpdesk form.
$output = $helpdeskwizard->output_form( $params );
break;

case "courses":
require_capability('moodle/course:create', context_system::instance());

$title = get_string('restorationheader', 'turnitintooltwo');
$jsrequired = true;

$output .= html_writer::tag('h2', get_string('restorationheader', 'turnitintooltwo'));
Expand Down Expand Up @@ -127,6 +203,7 @@
}

$PAGE->set_pagelayout('embedded');
$title = get_string('restorationheader', 'turnitintooltwo');

require_capability('moodle/course:create', context_system::instance());

Expand Down Expand Up @@ -160,6 +237,7 @@
}

$PAGE->set_pagelayout('embedded');
$title = get_string('restorationheader', 'turnitintooltwo');

require_capability('moodle/course:create', context_system::instance());

Expand Down Expand Up @@ -209,14 +287,14 @@
break;
}

$title = ($cmd == "courses" || $cmd == "multiple_class_recreation" || $cmd == "class_recreation") ?
get_string('restorationheader', 'turnitintooltwo') : '';
$nav = ($cmd == "courses" || $cmd == "multiple_class_recreation" || $cmd == "class_recreation") ?
array(array('title' => get_string('restorationheader', 'turnitintooltwo'), 'url' => '')) : array();

// Build page.
echo $turnitintooltwoview->output_header(null,
null,
$coursemodforheader = ($id != 0) ? $cm : null;
$courseforheader = ($id != 0) ? $course : null;
echo $turnitintooltwoview->output_header($coursemodforheader,
$courseforheader,
$url,
$title,
$title,
Expand Down
5 changes: 3 additions & 2 deletions jquery/plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
'turnitintooltwo-colorbox' => array('files' => array('jquery.colorbox.js', 'colorbox.css')),
'turnitintooltwo-uieditable' => array('files' => array('jqueryui-editable.js', 'jqueryui-editable.css')),
'turnitintooltwo-moment' => array('files' => array('moment.js')),
'turnitintooltwo-tooltipster' => array('files' => array('tooltipster.js', 'tooltipster.css'))
);
'turnitintooltwo-tooltipster' => array('files' => array('tooltipster.js', 'tooltipster.css')),
'turnitintooltwo-turnitin_helpdesk' => array('files' => array('turnitin_helpdesk.js'))
);
Loading

0 comments on commit 24f3e95

Please sign in to comment.