Ejemplo n.º 1
0
function determineResponse($inp, $type)
{
    switch ($type) {
        case "question":
            $res = renderAnswer($inp['sentence']);
            return $res;
            break;
        case "command":
            $res = renderTask($inp['sentence']);
            return $res;
            break;
        case "exclamation":
            $res = renderExcl($inp['sentence']);
            return $res;
            break;
        case "declaration":
            $res = renderConvo($inp['sentence']);
            return $res;
            break;
        default:
            $res = renderConvo($inp['sentence']);
            return $res;
            break;
    }
}
Ejemplo n.º 2
0
        <div class='modal-header'>
            <h4 class='modal-title'><?php 
echo $op['name'];
?>
</h4>
            <!-- todo: show op details here -->
        </div>
        <div class='modal-body'>
            <p class='modalmsg success'></p>
            <span class='data-taskid'><?php 
echo $task['id'];
?>
</span>
            <ul class='fa-ul task-container' id='task-container'>
                <?php 
echo renderTask($task);
?>
            </ul>
        </div>
        <!-- todo if you can't complete coz you don't have sign, just click here. -->
    </div>

    </div></div></div>
    
    <?php 
$scripts = array('main.js', 'task-problem.js');
include 'common/footer.php';
?>
 

function renderOpWithTasks($op)
{
    $rendered = '';
    $opid = $op['id'];
    $opname = $op['name'];
    $opdesc = $op['description'];
    $rendered = <<<OPERATION_START
                    <div class="card">
                        <div class='operation' data-opid='{$opid}'>
                            <h3 class='operation-title'>{$opname}</h3>
                            <p class="operation-description">{$opdesc}</p>
OPERATION_START;
    if (!is_null($op['data'])) {
        $part_data = $op['participant_data'];
        foreach ($op['data'] as $opfield) {
            $opfieldid = $opfield->id;
            $opfieldtype = $opfield->type;
            $opfieldmsg = $opfield->message;
            $fieldval = $part_data->{$opfieldid};
            switch ($opfieldtype) {
                case 'text':
                    $rendered .= <<<PART_DATA
                            <div class='participant-data'>
                                <span class='participant-data-field'>{$opfieldmsg}</span>
                                <span class='participant-data-value'>{$fieldval}</span>
                            </div>
PART_DATA;
                    break;
                case 'list':
                    $rendered .= <<<PART_DATA1
                            <div class='participant-data'>
                                <span class='participant-data-field'>{$opfieldmsg}</span>
                                <ul class='participant-data-value-list'>
PART_DATA1;
                    foreach ($fieldval as $val) {
                        if (!is_string($val)) {
                            $val = $val->val;
                        }
                        $rendered .= "<li>{$val}</li>";
                    }
                    $rendered .= <<<PART_DATA2
                                </ul>
                            </div>
PART_DATA2;
                    break;
            }
        }
    }
    if (count($op['tasks']) == 0) {
        $rendered .= "<span class='tasks-title notasks'>No tasks in this operation yet.</span>";
    } else {
        $rendered .= " <ul class='fa-ul'>";
        foreach ($op['tasks'] as $task) {
            $rendered .= renderTask($task);
        }
        $rendered .= " </ul>";
    }
    $rendered .= <<<OPERATION_END
                        </div>
                    </div>
OPERATION_END;
    return $rendered;
}