I've been working on a derivative of the Content Translation Manager and Content Translation filter for use with DeepL. I'm stuck at creating a unique hash with moodle_text_filter.
This is my hashing code at the moment, but I don't trust it's always going to be unique plus the $text dependency needs stripped out.
list($context, $course, $cm) = get_context_info_array($this->context->id);
$hashkey = sha1(trim('/' . $cm->added . '/' . $format . $this->context->path . '/' . substr($text, 0, 12)));
I've tried creating unique hashes using context and text format to no avail. I need the ability to inject a unique identifier into the filter that's not based on creating a sha1 hash of the text itself, because if you change the source text you lose the db connection to the translation. If I can find a way to create the a unique hash not based on the text itself then this derivative based on DeepL and a different UI will be done. What I would like to do is inject the table and column name from where the text was originally derived from but I can't figure a universal way to do that without going accounting for activities, section types, and other strings in a course.
I looked all the way back to Moodle 2.5 to see what hashing functions existed for text previously and couldn't find anything.
I'm open to ideas here...