Skip to content
Snippets Groups Projects
Commit 5534b8b0 authored by Moritz Strohm's avatar Moritz Strohm
Browse files

added requested_level to tandem profiles

parent 08e19e7e
No related branches found
No related tags found
No related merge requests found
...@@ -76,8 +76,19 @@ class TandemMatching ...@@ -76,8 +76,19 @@ class TandemMatching
AND tuml.user_id <> :user_id AND tuml.user_id <> :user_id
AND tandem_profiles.target_language_id IN ( :request_user_mother_language_ids ) '; AND tandem_profiles.target_language_id IN ( :request_user_mother_language_ids ) ';
if (Config::get()->TANDEMPLUGIN_USE_LEVEL) { if (Config::get()->TANDEMPLUGIN_USE_LEVEL) {
$sql .= "AND tuml.`level` IN ( :levels ) "; $sql .= "AND tuml.`level` IN ( :other_minimum_levels ) ";
$sql_params['levels'] = self::getEqualOrHigherLevels($tandem_request->level); //Check which level is higher: The requested one or the one of the user.
$user_and_higher_levels = self::getEqualOrHigherLevels($tandem_request->level);
if ($tandem_request->requested_level) {
$requested_and_higher_levels = self::getEqualOrHigherLevels($tandem_request->requested_level);
//Use the level array that has the least entries so that no lower levels as the requested
//ones are used.
$sql_params['other_minimum_levels'] = count($user_and_higher_levels) < count($requested_and_higher_levels)
? $user_and_higher_levels : $requested_and_higher_levels;
} else {
//Easy: Use the level of the user.
$sql_params['other_minimum_levels'] = $user_and_higher_levels;
}
} }
//We must check, if there are tandem pairs. Profiles in tandem pairs //We must check, if there are tandem pairs. Profiles in tandem pairs
......
...@@ -74,6 +74,7 @@ class ProfileController extends PluginController ...@@ -74,6 +74,7 @@ class ProfileController extends PluginController
//Read all attributes: //Read all attributes:
$this->target_language_id = Request::get('target_language_id', null); $this->target_language_id = Request::get('target_language_id', null);
$this->level = Request::get('level', null); $this->level = Request::get('level', null);
$this->requested_level = Request::get('requested_level', '');
$this->comment = Request::get('comment', ''); $this->comment = Request::get('comment', '');
$this->gender = Request::get('gender', ''); $this->gender = Request::get('gender', '');
if (Config::get()->TANDEMPLUGIN_PROOF_FIELDS_ENABLED) { if (Config::get()->TANDEMPLUGIN_PROOF_FIELDS_ENABLED) {
...@@ -150,6 +151,7 @@ class ProfileController extends PluginController ...@@ -150,6 +151,7 @@ class ProfileController extends PluginController
//the following is common for add and edit mode: //the following is common for add and edit mode:
$this->tandem_profile->target_language_id = $this->target_language_id; $this->tandem_profile->target_language_id = $this->target_language_id;
$this->tandem_profile->level = $this->level; $this->tandem_profile->level = $this->level;
$this->tandem_profile->requested_level = $this->requested_level;
$this->tandem_profile->comment = $this->comment; $this->tandem_profile->comment = $this->comment;
$this->tandem_profile->gender = $this->gender; $this->tandem_profile->gender = $this->gender;
...@@ -255,6 +257,7 @@ class ProfileController extends PluginController ...@@ -255,6 +257,7 @@ class ProfileController extends PluginController
//edit mode //edit mode
$this->target_language_id = $this->tandem_profile->target_language_id; $this->target_language_id = $this->tandem_profile->target_language_id;
$this->level = $this->tandem_profile->level; $this->level = $this->tandem_profile->level;
$this->requested_level = $this->tandem_profile->requested_level;
$this->comment = $this->tandem_profile->comment; $this->comment = $this->tandem_profile->comment;
$this->gender = $this->tandem_profile->gender; $this->gender = $this->tandem_profile->gender;
...@@ -266,6 +269,7 @@ class ProfileController extends PluginController ...@@ -266,6 +269,7 @@ class ProfileController extends PluginController
//add mode //add mode
$this->target_language_id = ''; $this->target_language_id = '';
$this->level = 'A1'; $this->level = 'A1';
$this->requested_level = '';
$this->comment = ''; $this->comment = '';
$this->gender = ''; $this->gender = '';
......
<?php
class AddRequestedLevel extends Migration
{
protected function up()
{
$db = DBManager::get();
$db->exec(
"ALTER TABLE `tandem_profiles`
ADD COLUMN requested_level VARCHAR(2) NOT NULL DEFAULT ''"
);
}
protected function down()
{
$db = DBManager::get();
$db->exec(
"ALTER TABLE `tandem_profiles` DROP COLUMN requested_level"
);
}
}
...@@ -26,6 +26,7 @@ require_once(__DIR__ . '/TandemUserMotherLanguage.class.php'); ...@@ -26,6 +26,7 @@ require_once(__DIR__ . '/TandemUserMotherLanguage.class.php');
* @property string target_language_id A reference to a language entry. * @property string target_language_id A reference to a language entry.
* @property string level The language level that represents the user's skills in the target language: * @property string level The language level that represents the user's skills in the target language:
* A1, A2, B1, B2, C1 or C2 * A1, A2, B1, B2, C1 or C2
* @property string requested_level The language level that the user requests for their tandem partner.
* @property string comment * @property string comment
* @property string gender * @property string gender
* @property string proof_of_achievement * @property string proof_of_achievement
...@@ -59,7 +60,7 @@ require_once(__DIR__ . '/TandemUserMotherLanguage.class.php'); ...@@ -59,7 +60,7 @@ require_once(__DIR__ . '/TandemUserMotherLanguage.class.php');
{ {
return $this->target_language->getLocalName() return $this->target_language->getLocalName()
. ' (' . ' ('
. $this->level . ($this->requested_level ?: $this->level)
. ')'; . ')';
} }
......
pluginname=TandemPlugin pluginname=TandemPlugin
pluginclassname=TandemPlugin pluginclassname=TandemPlugin
origin=data-quest origin=data-quest
version=1.3.0 version=1.3.1
description=Dieses Plugin ermöglicht es, Sprachtandems innerhalb der Stud.IP Platform zu bilden. description=Dieses Plugin ermöglicht es, Sprachtandems innerhalb der Stud.IP Platform zu bilden.
studipMinVersion=4.0 studipMinVersion=4.0
studipMaxVersion=5.9.99 studipMaxVersion=5.9.99
...@@ -29,6 +29,20 @@ ...@@ -29,6 +29,20 @@
<option value="C2" <?= ($level == 'C2' ? 'selected="selected"' : '' ) ?>>C2</option> <option value="C2" <?= ($level == 'C2' ? 'selected="selected"' : '' ) ?>>C2</option>
</select> </select>
</label> </label>
<label>
<?= dgettext('TandemPlugin', 'Auf welcher Niveaustufe soll die andere Person die gesuchte Sprache mindestens beherrschen?') ?>
<select name="requested_level">
<option value="" <?= !$requested_level ? 'selected' : '' ?>>
<?= dgettext('TandemPlugin', 'Keine Auswahl') ?>
</option>
<option value="A1" <?= $requested_level == 'A1' ? 'selected' : '' ?>>A1</option>
<option value="A2" <?= $requested_level == 'A2' ? 'selected' : '' ?>>A2</option>
<option value="B1" <?= $requested_level == 'B1' ? 'selected' : '' ?>>B1</option>
<option value="B2" <?= $requested_level == 'B2' ? 'selected' : '' ?>>B2</option>
<option value="C1" <?= $requested_level == 'C1' ? 'selected' : '' ?>>C1</option>
<option value="C2" <?= $requested_level == 'C2' ? 'selected' : '' ?>>C2</option>
</select>
</label>
<p><?= dgettext('TandemPlugin', 'Hinweis: Dies ist eine Selbsteinschätzung des Sprachniveaus. Es handelt sich nicht um die Einstufung des Fachsprachenzentrums!') ?></p> <p><?= dgettext('TandemPlugin', 'Hinweis: Dies ist eine Selbsteinschätzung des Sprachniveaus. Es handelt sich nicht um die Einstufung des Fachsprachenzentrums!') ?></p>
</p> </p>
<label> <label>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment